|
|
@@ -495,19 +495,27 @@ void MyMesh::sendFloodScoped(const TransportKey& scope, mesh::Packet* pkt, uint3
|
|
|
|
|
|
void MyMesh::sendFloodScoped(const ContactInfo& recipient, mesh::Packet* pkt, uint32_t delay_millis) {
|
|
|
// TODO: dynamic send_scope, depending on recipient and current 'home' Region
|
|
|
- TransportKey default_scope;
|
|
|
- memcpy(&default_scope.key, _prefs.default_scope_key, sizeof(default_scope.key));
|
|
|
+ if (send_unscoped) {
|
|
|
+ sendFlood(pkt, delay_millis, _prefs.path_hash_mode + 1); // app has explicitly requested un-scoped
|
|
|
+ } else {
|
|
|
+ TransportKey default_scope;
|
|
|
+ memcpy(&default_scope.key, _prefs.default_scope_key, sizeof(default_scope.key));
|
|
|
|
|
|
- auto scope = send_scope.isNull() ? &default_scope : &send_scope;
|
|
|
- sendFloodScoped(*scope, pkt, delay_millis);
|
|
|
+ auto scope = send_scope.isNull() ? &default_scope : &send_scope;
|
|
|
+ sendFloodScoped(*scope, pkt, delay_millis);
|
|
|
+ }
|
|
|
}
|
|
|
void MyMesh::sendFloodScoped(const mesh::GroupChannel& channel, mesh::Packet* pkt, uint32_t delay_millis) {
|
|
|
// TODO: have per-channel send_scope
|
|
|
- TransportKey default_scope;
|
|
|
- memcpy(&default_scope.key, _prefs.default_scope_key, sizeof(default_scope.key));
|
|
|
+ if (send_unscoped) {
|
|
|
+ sendFlood(pkt, delay_millis, _prefs.path_hash_mode + 1); // app has explicitly requested un-scoped
|
|
|
+ } else {
|
|
|
+ TransportKey default_scope;
|
|
|
+ memcpy(&default_scope.key, _prefs.default_scope_key, sizeof(default_scope.key));
|
|
|
|
|
|
- auto scope = send_scope.isNull() ? &default_scope : &send_scope;
|
|
|
- sendFloodScoped(*scope, pkt, delay_millis);
|
|
|
+ auto scope = send_scope.isNull() ? &default_scope : &send_scope;
|
|
|
+ sendFloodScoped(*scope, pkt, delay_millis);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void MyMesh::onMessageRecv(const ContactInfo &from, mesh::Packet *pkt, uint32_t sender_timestamp,
|
|
|
@@ -856,6 +864,7 @@ MyMesh::MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMe
|
|
|
dirty_contacts_expiry = 0;
|
|
|
memset(advert_paths, 0, sizeof(advert_paths));
|
|
|
memset(send_scope.key, 0, sizeof(send_scope.key));
|
|
|
+ send_unscoped = false;
|
|
|
|
|
|
// defaults
|
|
|
memset(&_prefs, 0, sizeof(_prefs));
|
|
|
@@ -1885,10 +1894,14 @@ void MyMesh::handleCmdFrame(size_t len) {
|
|
|
}
|
|
|
} else if (cmd_frame[0] == CMD_SET_FLOOD_SCOPE_KEY && len >= 2 && cmd_frame[1] == 0) {
|
|
|
if (len >= 2 + 16) {
|
|
|
- memcpy(send_scope.key, &cmd_frame[2], sizeof(send_scope.key)); // set curr scope TransportKey
|
|
|
+ memcpy(send_scope.key, &cmd_frame[2], sizeof(send_scope.key)); // set scope override TransportKey
|
|
|
} else {
|
|
|
- memset(send_scope.key, 0, sizeof(send_scope.key)); // set scope to null
|
|
|
+ memset(send_scope.key, 0, sizeof(send_scope.key)); // reset scope override
|
|
|
}
|
|
|
+ send_unscoped = false;
|
|
|
+ writeOKFrame();
|
|
|
+ } else if (cmd_frame[0] == CMD_SET_FLOOD_SCOPE_KEY && len >= 2 && cmd_frame[1] == 1) { // ver 12+
|
|
|
+ send_unscoped = true;
|
|
|
writeOKFrame();
|
|
|
} else if (cmd_frame[0] == CMD_SET_DEFAULT_FLOOD_SCOPE && len >= 1) {
|
|
|
if (len >= 1+31+16) {
|