Skip to content

Commit 1520f4d

Browse files
author
Scott Powell
committed
* repeater, DISCOVER_REQ, flags lowest bit now for 'prefix_only' responses
1 parent 62d7ce1 commit 1520f4d

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

docs/payloads.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,12 @@ The plaintext contained in the ciphertext matches the format described in [plain
199199

200200
## DISCOVER_REQ (sub_type)
201201

202-
| Field | Size (bytes) | Description |
203-
|--------------|-----------------|--------------------------------------------|
204-
| flags | 1 | 0x8 (upper 4 bits) |
205-
| type_filter | 1 | bit for each ADV_TYPE_* |
206-
| tag | 4 | randomly generate by sender |
207-
| since | 4 | (optional) epoch timestamp (0 by default) |
202+
| Field | Size (bytes) | Description |
203+
|--------------|-----------------|----------------------------------------------|
204+
| flags | 1 | 0x8 (upper 4 bits), prefix_only (lowest bit) |
205+
| type_filter | 1 | bit for each ADV_TYPE_* |
206+
| tag | 4 | randomly generate by sender |
207+
| since | 4 | (optional) epoch timestamp (0 by default) |
208208

209209
## DISCOVER_RESP (sub_type)
210210

@@ -213,7 +213,7 @@ The plaintext contained in the ciphertext matches the format described in [plain
213213
| flags | 1 | 0x9 (upper 4 bits), node_type (lower 4) |
214214
| snr | 1 | signed, SNR*4 |
215215
| tag | 4 | reflected back from DISCOVER_REQ |
216-
| pubkey | 32 | node's ID |
216+
| pubkey | 8 or 32 | node's ID (or prefix) |
217217

218218

219219
# Custom packet

examples/simple_repeater/MyMesh.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,12 +636,13 @@ void MyMesh::onControlDataRecv(mesh::Packet* packet) {
636636
}
637637

638638
if ((filter & (1 << ADV_TYPE_REPEATER)) != 0 && _prefs.discovery_mod_timestamp >= since) {
639+
bool prefix_only = packet->payload[0] & 1;
639640
uint8_t data[6 + PUB_KEY_SIZE];
640641
data[0] = CTL_TYPE_NODE_DISCOVER_RESP | ADV_TYPE_REPEATER; // low 4-bits for node type
641642
data[1] = packet->_snr; // let sender know the inbound SNR ( x 4)
642643
memcpy(&data[2], &tag, 4); // include tag from request, for client to match to
643644
memcpy(&data[6], self_id.pub_key, PUB_KEY_SIZE);
644-
auto resp = createControlData(data, sizeof(data));
645+
auto resp = createControlData(data, prefix_only ? 6 + 8 : 6 + PUB_KEY_SIZE);
645646
if (resp) {
646647
sendZeroHop(resp, getRetransmitDelay(resp)*4); // apply random delay (widened x4), as multiple nodes can respond to this
647648
}

0 commit comments

Comments
 (0)