Skip to content

Commit b59d199

Browse files
author
Scott Powell
committed
* Sensor: DISCOVER_REQ, prefix_only support
1 parent 74f136b commit b59d199

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

examples/simple_sensor/SensorMesh.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,14 +636,15 @@ void SensorMesh::onControlDataRecv(mesh::Packet* packet) {
636636
}
637637

638638
if ((filter & (1 << ADV_TYPE_SENSOR)) != 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_SENSOR; // 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) {
646-
sendZeroHop(resp, getRetransmitDelay(resp)); // apply random delay, as multiple nodes can respond to this
647+
sendZeroHop(resp, getRetransmitDelay(resp)*4); // apply random delay (widened x4), as multiple nodes can respond to this
647648
}
648649
}
649650
}

0 commit comments

Comments
 (0)