mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Merge pull request #1476 from mattzzw/region_via_LoRa
Add cli command `region list {allowed|denied}`, enable output of region cmd via remote cli
This commit is contained in:
commit
d81616ec68
3 changed files with 86 additions and 11 deletions
|
|
@ -1072,8 +1072,8 @@ void MyMesh::handleCommand(uint32_t sender_timestamp, char *command, char *reply
|
|||
|
||||
const char* parts[4];
|
||||
int n = mesh::Utils::parseTextParts(command, parts, 4, ' ');
|
||||
if (n == 1 && sender_timestamp == 0) {
|
||||
region_map.exportTo(Serial);
|
||||
if (n == 1) {
|
||||
region_map.exportTo(reply, 160);
|
||||
} else if (n >= 2 && strcmp(parts[1], "load") == 0) {
|
||||
temp_map.resetFrom(region_map); // rebuild regions in a temp instance
|
||||
memset(load_stack, 0, sizeof(load_stack));
|
||||
|
|
@ -1146,6 +1146,25 @@ void MyMesh::handleCommand(uint32_t sender_timestamp, char *command, char *reply
|
|||
} else {
|
||||
strcpy(reply, "Err - not found");
|
||||
}
|
||||
} else if (n >= 3 && strcmp(parts[1], "list") == 0) {
|
||||
uint8_t mask = 0;
|
||||
bool invert = false;
|
||||
|
||||
if (strcmp(parts[2], "allowed") == 0) {
|
||||
mask = REGION_DENY_FLOOD;
|
||||
invert = false; // list regions that DON'T have DENY flag
|
||||
} else if (strcmp(parts[2], "denied") == 0) {
|
||||
mask = REGION_DENY_FLOOD;
|
||||
invert = true; // list regions that DO have DENY flag
|
||||
} else {
|
||||
strcpy(reply, "Err - use 'allowed' or 'denied'");
|
||||
return;
|
||||
}
|
||||
|
||||
int len = region_map.exportNamesTo(reply, 160, mask, invert);
|
||||
if (len == 0) {
|
||||
strcpy(reply, "-none-");
|
||||
}
|
||||
} else {
|
||||
strcpy(reply, "Err - ??");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue