Address PR review: subtract-1 encoding and clamp max_hops

- Change > to >= so stored value 1 means direct/0-hop only (liamcottle)
- Clamp max_hops to 63 on write since getPathHashCount() caps at 63 (robekl)
- Update comments to reflect encoding: 0=no limit, 1=direct only, N=up to N-1 hops

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Wouter Bijen 2026-03-03 08:37:22 +01:00
parent 00566741f6
commit c016db86d5
4 changed files with 5 additions and 5 deletions

View file

@ -1790,7 +1790,7 @@ void MyMesh::handleCmdFrame(size_t len) {
} else if (cmd_frame[0] == CMD_SET_AUTOADD_CONFIG) {
_prefs.autoadd_config = cmd_frame[1];
if (len >= 3) {
_prefs.autoadd_max_hops = cmd_frame[2];
_prefs.autoadd_max_hops = min(cmd_frame[2], (uint8_t)63);
}
savePrefs();
writeOKFrame();

View file

@ -30,5 +30,5 @@ struct NodePrefs { // persisted to file
uint8_t autoadd_config; // bitmask for auto-add contacts config
uint8_t client_repeat;
uint8_t path_hash_mode; // which path mode to use when sending
uint8_t autoadd_max_hops; // 0 = no limit, 1-63 = max hops for auto-add
uint8_t autoadd_max_hops; // 0 = no limit, 1 = direct only, N = up to N-1 hops (max 63)
};