ping_neighbor endpoint: support multi-byte path hashes #52

Closed
opened 2026-10-27 09:30:23 +01:00 by adam · 2 comments
Owner

Summary

The /api/ping_neighbor endpoint currently hardcodes 1-byte addressing for target_id, but path_hash_mode (on feat/companion) now supports 2-byte and 3-byte path hashes.

Current behavior

api_endpoints.py line ~2103:

target_hash = int(target_id, 16)
if target_hash < 0 or target_hash > 255:
    return self._error("target_id must be a valid byte (0x00-0xFF)")

Three places are locked to 1 byte:

  1. Input validation — rejects anything > 0xFF
  2. Trace packet — path=[target_hash] passes a single byte
  3. Response formatting — f"0x{target_hash:02x}" and f"0x{h:02x}" for path hops

Requested change

When config.mesh.path_hash_mode is 1 (2-byte) or 2 (3-byte):

  • Accept wider target_id values (up to 0xFFFF / 0xFFFFFF)
  • Pass the appropriately-sized hash to PacketBuilder.create_trace()
  • Format response target_id and path hops with the matching width (04x / 06x)

This would let the console (and upstream UI) ping using the full hash precision the user has configured.

## Summary The `/api/ping_neighbor` endpoint currently hardcodes 1-byte addressing for `target_id`, but `path_hash_mode` (on `feat/companion`) now supports 2-byte and 3-byte path hashes. ## Current behavior `api_endpoints.py` line ~2103: ```python target_hash = int(target_id, 16) if target_hash < 0 or target_hash > 255: return self._error("target_id must be a valid byte (0x00-0xFF)") ``` Three places are locked to 1 byte: 1. **Input validation** — rejects anything > `0xFF` 2. **Trace packet** — `path=[target_hash]` passes a single byte 3. **Response formatting** — `f"0x{target_hash:02x}"` and `f"0x{h:02x}"` for path hops ## Requested change When `config.mesh.path_hash_mode` is `1` (2-byte) or `2` (3-byte): - Accept wider `target_id` values (up to `0xFFFF` / `0xFFFFFF`) - Pass the appropriately-sized hash to `PacketBuilder.create_trace()` - Format response `target_id` and `path` hops with the matching width (`04x` / `06x`) This would let the console (and upstream UI) ping using the full hash precision the user has configured. <!-- github-sync-id:4050357371 -->
adam closed this issue 2026-10-27 09:30:23 +01:00
Author
Owner

Have committed 155575865a can you please test.

Have committed 155575865af14108a5b53d0d27d7ed24c53a058f can you please test. <!-- github-comment-id:4038585514 -->
Author
Owner

{"success": true, "data": {"target_id": "0xb8c1", "rtt_ms": 1427.48, "snr_db": 0, "rssi": 0, "path": ["0xb8c1"], "tag": 1855790637, "path_hash_mode": 1}, "message": "Ping successful"}%

confirmed ping works as designed!

{"success": true, "data": {"target_id": "0xb8c1", "rtt_ms": 1427.48, "snr_db": 0, "rssi": 0, "path": ["0xb8c1"], "tag": 1855790637, "path_hash_mode": 1}, "message": "Ping successful"}% confirmed ping works as designed! <!-- github-comment-id:4040800917 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/pyMC_Repeater#52