CommonCLI: get/set loc to replace gps advert command
This commit is contained in:
1 parent
f349ead541
commit
798b719caf
2 files changed
+35
-1
No files matched your search
@@ -1101,6 +1101,8 @@ Covers serial NMEA receivers (`MicroNMEALocationProvider`).
|
|||||||
|
|
||||||
#### View or change the GPS advert policy
|
#### View or change the GPS advert policy
|
||||||
**Usage:**
|
**Usage:**
|
||||||
|
- `get advert.loc`
|
||||||
|
- `set advert.loc <policy>`
|
||||||
- `gps advert`
|
- `gps advert`
|
||||||
- `gps advert <policy>`
|
- `gps advert <policy>`
|
||||||
|
|
||||||
@@ -1108,10 +1110,12 @@ Covers serial NMEA receivers (`MicroNMEALocationProvider`).
|
|||||||
- `policy`: `none`|`share`|`prefs`
|
- `policy`: `none`|`share`|`prefs`
|
||||||
- `none`: don't include location in adverts
|
- `none`: don't include location in adverts
|
||||||
- `share`: share gps location (from SensorManager)
|
- `share`: share gps location (from SensorManager)
|
||||||
- `prefs`: location stored in node's lat and lon settings
|
- `prefs`: location stored in node's lat and lon settings (can be different from gps value)
|
||||||
|
|
||||||
**Default:** `prefs`
|
**Default:** `prefs`
|
||||||
|
|
||||||
|
**Note:** `gps advert` command is the old format but is only accessible when a gps is attached to the unit. It has been kept for compatibility but one should prefer using `get/set` commands instead.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Sensors (When sensor support is compiled in)
|
### Sensors (When sensor support is compiled in)
|
||||||
|
|||||||
@@ -467,6 +467,22 @@ void CommonCLI::handleSetCmd(uint32_t sender_timestamp, char* command, char* rep
|
|||||||
savePrefs();
|
savePrefs();
|
||||||
strcpy(reply, "OK");
|
strcpy(reply, "OK");
|
||||||
}
|
}
|
||||||
|
} else if (memcmp(config, "advert.loc ", 11) == 0) {
|
||||||
|
if (memcmp(config+11, "none", 4) == 0) {
|
||||||
|
_prefs->advert_loc_policy = ADVERT_LOC_NONE;
|
||||||
|
savePrefs();
|
||||||
|
strcpy(reply, "OK");
|
||||||
|
} else if (memcmp(config+11, "share", 5) == 0) {
|
||||||
|
_prefs->advert_loc_policy = ADVERT_LOC_SHARE;
|
||||||
|
savePrefs();
|
||||||
|
strcpy(reply, "OK");
|
||||||
|
} else if (memcmp(config+11, "prefs", 5) == 0) {
|
||||||
|
_prefs->advert_loc_policy = ADVERT_LOC_PREFS;
|
||||||
|
savePrefs();
|
||||||
|
strcpy(reply, "OK");
|
||||||
|
} else {
|
||||||
|
strcpy(reply, "Error, invalid policy");
|
||||||
|
}
|
||||||
} else if (memcmp(config, "guest.password ", 15) == 0) {
|
} else if (memcmp(config, "guest.password ", 15) == 0) {
|
||||||
StrHelper::strncpy(_prefs->guest_password, &config[15], sizeof(_prefs->guest_password));
|
StrHelper::strncpy(_prefs->guest_password, &config[15], sizeof(_prefs->guest_password));
|
||||||
savePrefs();
|
savePrefs();
|
||||||
@@ -665,6 +681,20 @@ void CommonCLI::handleGetCmd(uint32_t sender_timestamp, char* command, char* rep
|
|||||||
sprintf(reply, "> %d", ((uint32_t) _prefs->flood_advert_interval));
|
sprintf(reply, "> %d", ((uint32_t) _prefs->flood_advert_interval));
|
||||||
} else if (memcmp(config, "advert.interval", 15) == 0) {
|
} else if (memcmp(config, "advert.interval", 15) == 0) {
|
||||||
sprintf(reply, "> %d", ((uint32_t) _prefs->advert_interval) * 2);
|
sprintf(reply, "> %d", ((uint32_t) _prefs->advert_interval) * 2);
|
||||||
|
} else if (memcmp(config, "advert.loc", 10) == 0) {
|
||||||
|
switch (_prefs->advert_loc_policy) {
|
||||||
|
case ADVERT_LOC_NONE:
|
||||||
|
strcpy(reply, "> none");
|
||||||
|
break;
|
||||||
|
case ADVERT_LOC_PREFS:
|
||||||
|
strcpy(reply, "> prefs");
|
||||||
|
break;
|
||||||
|
case ADVERT_LOC_SHARE:
|
||||||
|
strcpy(reply, "> share");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
strcpy(reply, "Error, invalid policy");
|
||||||
|
}
|
||||||
} else if (memcmp(config, "guest.password", 14) == 0) {
|
} else if (memcmp(config, "guest.password", 14) == 0) {
|
||||||
sprintf(reply, "> %s", _prefs->guest_password);
|
sprintf(reply, "> %s", _prefs->guest_password);
|
||||||
} else if (sender_timestamp == 0 && memcmp(config, "prv.key", 7) == 0) { // from serial command line only
|
} else if (sender_timestamp == 0 && memcmp(config, "prv.key", 7) == 0) { // from serial command line only
|
||||||
|
|||||||
Reference in new issue
Block a user