fix(d1l): add keep-alive handler and improve password handling #44

Merged
okapteinis merged 1 commit from fix/d1l-auth-ping into nightly 2025-12-27 10:02:56 +02:00
okapteinis commented 2025-12-27 10:02:38 +02:00 (Migrated from github.com)
  • Add REQ_TYPE_KEEP_ALIVE handler in simple_repeater to respond to ping requests from the MeshCore Companion App (was returning 0/unknown)
  • Improve authentication debug logging to show both received and expected password with lengths for easier debugging
  • Add defensive null-termination and whitespace trimming for password storage to prevent issues with trailing CR/LF from serial input
  • Fix syntax error in CMD_SET_DEVICE_TIME handler (corrupted code block)

This fixes the "Ping" failure issue where the D1L repeater was not responding to keep-alive requests from connected clients.

🤖 Generated with Claude Code

Description

Type of Change

  • Bug fix (non-breaking change fixing an issue)
  • New feature (non-breaking change adding functionality)
  • Breaking change (fix or feature causing existing functionality to change)
  • Documentation update
  • Hardware support addition
  • Performance improvement

Testing Performed

  • Builds successfully on affected platforms
  • Tested on physical hardware
  • Verified no new compiler warnings
  • Checked memory usage
  • Example applications still work
  • Documentation updated

Hardware Tested

  • Device:
  • Firmware variant:
  • Test results:

Code Quality Checklist

  • Follows existing code style
  • No dynamic memory allocation in inappropriate places
  • No reformatting of existing code
  • Added comments for non-obvious logic
  • Updated documentation
  • CHANGELOG.md updated if applicable

Breaking Changes

Screenshots/Logs

Additional Notes

- Add REQ_TYPE_KEEP_ALIVE handler in simple_repeater to respond to ping requests from the MeshCore Companion App (was returning 0/unknown) - Improve authentication debug logging to show both received and expected password with lengths for easier debugging - Add defensive null-termination and whitespace trimming for password storage to prevent issues with trailing CR/LF from serial input - Fix syntax error in CMD_SET_DEVICE_TIME handler (corrupted code block) This fixes the "Ping" failure issue where the D1L repeater was not responding to keep-alive requests from connected clients. 🤖 Generated with [Claude Code](https://claude.com/claude-code) ## Description <!-- Provide a clear description of what this PR does --> ## Type of Change <!-- Mark relevant items with [x] --> - [ ] Bug fix (non-breaking change fixing an issue) - [ ] New feature (non-breaking change adding functionality) - [ ] Breaking change (fix or feature causing existing functionality to change) - [ ] Documentation update - [ ] Hardware support addition - [ ] Performance improvement ## Related Issues <!-- Link related issues: Fixes #123, Relates to #456 --> ## Testing Performed <!-- Describe testing done --> - [ ] Builds successfully on affected platforms - [ ] Tested on physical hardware - [ ] Verified no new compiler warnings - [ ] Checked memory usage - [ ] Example applications still work - [ ] Documentation updated ## Hardware Tested <!-- List hardware tested, or write "N/A" if documentation-only --> - Device: - Firmware variant: - Test results: ## Code Quality Checklist - [ ] Follows existing code style - [ ] No dynamic memory allocation in inappropriate places - [ ] No reformatting of existing code - [ ] Added comments for non-obvious logic - [ ] Updated documentation - [ ] CHANGELOG.md updated if applicable ## Breaking Changes <!-- Describe any breaking changes and migration path, or write "None" --> ## Screenshots/Logs <!-- Add screenshots or serial logs if applicable --> ## Additional Notes <!-- Any additional information for reviewers -->
gemini-code-assist[bot] commented 2025-12-27 10:02:53 +02:00 (Migrated from github.com)

Summary of Changes

Hello @okapteinis, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses several critical issues to improve the robustness and debuggability of the D1L repeater. It introduces proper handling for keep-alive pings from the MeshCore Companion App, enhances password management with better debugging information and defensive input sanitization, and rectifies a syntax error in the device time setting command. These changes collectively aim to improve device reliability and ease of troubleshooting.

Highlights

  • Keep-Alive (Ping) Support: Implemented a REQ_TYPE_KEEP_ALIVE handler in simple_repeater to correctly respond to ping requests from the MeshCore Companion App, resolving an issue where these requests previously returned an unknown status.
  • Enhanced Password Debugging and Storage: Improved authentication debug logging to display both received and expected passwords along with their lengths, aiding in easier debugging. Additionally, defensive null-termination and whitespace trimming (including CR/LF) were added to password storage to prevent issues from serial input.
  • CMD_SET_DEVICE_TIME Syntax Correction: Corrected a syntax error within the CMD_SET_DEVICE_TIME handler in MyMesh.cpp, which previously contained a corrupted code block.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩︎

## Summary of Changes Hello @okapteinis, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses several critical issues to improve the robustness and debuggability of the D1L repeater. It introduces proper handling for keep-alive pings from the MeshCore Companion App, enhances password management with better debugging information and defensive input sanitization, and rectifies a syntax error in the device time setting command. These changes collectively aim to improve device reliability and ease of troubleshooting. ### Highlights * **Keep-Alive (Ping) Support**: Implemented a REQ_TYPE_KEEP_ALIVE handler in simple_repeater to correctly respond to ping requests from the MeshCore Companion App, resolving an issue where these requests previously returned an unknown status. * **Enhanced Password Debugging and Storage**: Improved authentication debug logging to display both received and expected passwords along with their lengths, aiding in easier debugging. Additionally, defensive null-termination and whitespace trimming (including CR/LF) were added to password storage to prevent issues from serial input. * **CMD_SET_DEVICE_TIME Syntax Correction**: Corrected a syntax error within the CMD_SET_DEVICE_TIME handler in MyMesh.cpp, which previously contained a corrupted code block. <details> <summary><b>Using Gemini Code Assist</b></summary> <br> The full guide for Gemini Code Assist can be found on our [documentation page](https://developers.google.com/gemini-code-assist/docs/review-github-code), here are some quick tips. <b>Invoking Gemini</b> You can request assistance from Gemini at any point by creating a comment using either `/gemini <command>` or `@gemini-code-assist <command>`. Below is a summary of the supported commands on the current page. Feature | Command | Description --- | --- | --- Code Review | `/gemini review` | Performs a code review for the current pull request in its current state. Pull Request Summary | `/gemini summary` | Provides a summary of the current pull request in its current state. Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. Help | `/gemini help` | Displays a list of available commands. <b>Customization</b> To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a `.gemini/` folder in the base of the repository. Detailed instructions can be found [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). <b>Limitations & Feedback</b> Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up [here](https://google.qualtrics.com/jfe/form/SV_2cyuGuTWsEw84yG). <b>You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the [Gemini Code Assist IDE Extension](https://cloud.google.com/products/gemini/code-assist).</b> </details> [^1]: Review the [Privacy Notices](https://policies.google.com/privacy), [Generative AI Prohibited Use Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of Service](https://policies.google.com/terms), and learn how to configure Gemini Code Assist in GitHub [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). Gemini can make mistakes, so double check it and [use code with caution](https://support.google.com/legal/answer/13505487).
gemini-code-assist[bot] (Migrated from github.com) reviewed 2025-12-27 10:03:53 +02:00
gemini-code-assist[bot] (Migrated from github.com) left a comment

Code Review

This pull request introduces several valuable fixes and enhancements. The addition of a keep-alive handler correctly addresses the ping failure issue. The improved debug logging for password authentication and the robust password handling (null-termination and whitespace trimming) are great for debugging and stability. The fix for the corrupted code block in the CMD_SET_DEVICE_TIME handler is also a crucial correction. I've added a few suggestions in src/helpers/CommonCLI.cpp to further refine the new password handling logic by improving efficiency and reducing code duplication.

## Code Review This pull request introduces several valuable fixes and enhancements. The addition of a keep-alive handler correctly addresses the ping failure issue. The improved debug logging for password authentication and the robust password handling (null-termination and whitespace trimming) are great for debugging and stability. The fix for the corrupted code block in the `CMD_SET_DEVICE_TIME` handler is also a crucial correction. I've added a few suggestions in `src/helpers/CommonCLI.cpp` to further refine the new password handling logic by improving efficiency and reducing code duplication.
@ -248,3 +254,3 @@
savePrefs();
sprintf(reply, "password now: %s", _prefs->password); // echo back just to let admin know for sure!!
sprintf(reply, "password now: %s (len=%d)", _prefs->password, strlen(_prefs->password)); // echo back with length
} else if (memcmp(command, "clear stats", 11) == 0) {
gemini-code-assist[bot] (Migrated from github.com) commented 2025-12-27 10:03:53 +02:00

medium

There's a small optimization possible here. The len variable, which holds the string length after trimming, is already available from the preceding lines. You can reuse it here instead of calling strlen() again. This avoids a redundant calculation.

      sprintf(reply, "password now: %s (len=%d)", _prefs->password, len);   // echo back with length
![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg) There's a small optimization possible here. The `len` variable, which holds the string length after trimming, is already available from the preceding lines. You can reuse it here instead of calling `strlen()` again. This avoids a redundant calculation. ```c sprintf(reply, "password now: %s (len=%d)", _prefs->password, len); // echo back with length ```
gemini-code-assist[bot] (Migrated from github.com) commented 2025-12-27 10:03:53 +02:00

medium

This block of code for null-termination and whitespace trimming is identical to the one for the admin password at lines 248-253. To improve maintainability and reduce code duplication, consider extracting this logic into a private helper function within the CommonCLI class. This function could take a char* and its size as arguments.

![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg) This block of code for null-termination and whitespace trimming is identical to the one for the admin password at lines 248-253. To improve maintainability and reduce code duplication, consider extracting this logic into a private helper function within the `CommonCLI` class. This function could take a `char*` and its size as arguments.
gemini-code-assist[bot] (Migrated from github.com) commented 2025-12-27 10:03:53 +02:00

medium

Similar to the admin password handling, you can optimize this by reusing the len variable calculated just before. This avoids calling strlen() again.

        sprintf(reply, "OK (len=%d)", len);
![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg) Similar to the admin password handling, you can optimize this by reusing the `len` variable calculated just before. This avoids calling `strlen()` again. ```c sprintf(reply, "OK (len=%d)", len); ```
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ojars/MeshCore!44
No description provided.