Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion docs/cli_commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,28 @@ This document provides an overview of CLI commands that can be sent to MeshCore
---

### Packet stats - Packet counters: Received, Sent
**Usage:** `stats-packets`
**Usage:** `stats-packets <mode>`

**Serial Only:** Yes

### View or change guest telemetry access
**Usage:**
- `get guest.enviroment`
- `set guest.enviroment <mode>`

**Parameters:**
- `mode`: `normal`, `gps` or `all`
- `normal`: guests can see battery level and CPU temperature
- `gps`: guests can also see the node's GPS position
- `all`: guests can see all available telemetry

**Default:** `normal`

**Notes:**
- The setting applies only to telemetry returned to guest clients.
- It does not change the node's position in advertisements.
- The spelling `enviroment` is part of the CLI command for compatibility.

---

## Logging
Expand Down
8 changes: 7 additions & 1 deletion examples/simple_repeater/MyMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,13 @@ int MyMesh::handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t

// query other sensors -- target specific
if ((sender->permissions & PERM_ACL_ROLE_MASK) == PERM_ACL_GUEST) {
perm_mask = 0x00; // just base telemetry allowed
if (_prefs.guest_environment == GUEST_ENVIRONMENT_GPS) {
perm_mask &= TELEM_PERM_LOCATION;
} else if (_prefs.guest_environment == GUEST_ENVIRONMENT_ALL) {
perm_mask &= TELEM_PERM_LOCATION | TELEM_PERM_ENVIRONMENT;
} else {
perm_mask &= 0x00; // just base telemetry allowed
}
}
sensors.querySensors(perm_mask, telemetry);

Expand Down
8 changes: 7 additions & 1 deletion examples/simple_room_server/MyMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,13 @@ int MyMesh::handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t
telemetry.addVoltage(TELEM_CHANNEL_SELF, (float)board.getBattMilliVolts() / 1000.0f);
// query other sensors -- target specific
if ((sender->permissions & PERM_ACL_ROLE_MASK) == PERM_ACL_GUEST) {
perm_mask = 0x00; // just base telemetry allowed
if (_prefs.guest_environment == GUEST_ENVIRONMENT_GPS) {
perm_mask &= TELEM_PERM_LOCATION;
} else if (_prefs.guest_environment == GUEST_ENVIRONMENT_ALL) {
perm_mask &= TELEM_PERM_LOCATION | TELEM_PERM_ENVIRONMENT;
} else {
perm_mask &= 0x00; // just base telemetry allowed
}
}
sensors.querySensors(perm_mask, telemetry);

Expand Down
23 changes: 23 additions & 0 deletions src/helpers/CommonCLI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,21 @@ void CommonCLI::handleSetCmd(uint32_t sender_timestamp, char* command, char* rep
StrHelper::strncpy(_prefs->guest_password, &config[15], sizeof(_prefs->guest_password));
savePrefs();
strcpy(reply, "OK");
} else if (memcmp(config, "guest.enviroment ", 17) == 0) {
const char* value = &config[17];
uint8_t mode;
if (strcmp(value, "normal") == 0) {
_prefs->guest_environment = GUEST_ENVIRONMENT_NORMAL;
} else if (strcmp(value, "gps") == 0) {
_prefs->guest_environment = GUEST_ENVIRONMENT_GPS;
} else if (strcmp(value, "all") == 0) {
_prefs->guest_environment = GUEST_ENVIRONMENT_ALL;
} else {
strcpy(reply, "Error: expected normal, gps or all");
return;
}
savePrefs();
strcpy(reply, "OK");
} else if (memcmp(config, "prv.key ", 8) == 0) {
uint8_t prv_key[PRV_KEY_SIZE];
bool success = mesh::Utils::fromHex(prv_key, PRV_KEY_SIZE, &config[8]);
Expand Down Expand Up @@ -829,6 +844,14 @@ void CommonCLI::handleGetCmd(uint32_t sender_timestamp, char* command, char* rep
sprintf(reply, "> %d", ((uint32_t) _prefs->advert_interval) * 2);
} else if (memcmp(config, "guest.password", 14) == 0) {
sprintf(reply, "> %s", _prefs->guest_password);
} else if (memcmp(config, "guest.enviroment", 16) == 0) {
const char* mode = "normal";
if (_prefs->guest_environment == GUEST_ENVIRONMENT_GPS) {
mode = "gps";
} else if (_prefs->guest_environment == GUEST_ENVIRONMENT_ALL) {
mode = "all";
}
sprintf(reply, "> %s", mode);
} else if (sender_timestamp == 0 && memcmp(config, "prv.key", 7) == 0) { // from serial command line only
uint8_t prv_key[PRV_KEY_SIZE];
int len = _callbacks->getSelfId().writeTo(prv_key, PRV_KEY_SIZE);
Expand Down
6 changes: 6 additions & 0 deletions src/helpers/CommonCLI.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#define LOOP_DETECT_MODERATE 2
#define LOOP_DETECT_STRICT 3

#define GUEST_ENVIRONMENT_NORMAL 0
#define GUEST_ENVIRONMENT_GPS 1
#define GUEST_ENVIRONMENT_ALL 2

class NodePrefs : public ConfigSerializer {
public:
// in-memory backing data
Expand All @@ -40,6 +44,7 @@ class NodePrefs : public ConfigSerializer {
uint8_t sf = 0;
uint8_t cr = 0;
uint8_t allow_read_only = 0;
uint8_t guest_environment = GUEST_ENVIRONMENT_NORMAL;
uint8_t multi_acks = 0;
float bw = 0;
uint8_t flood_max = 0;
Expand Down Expand Up @@ -171,6 +176,7 @@ class NodePrefs : public ConfigSerializer {
def("name", node_name, sizeof(node_name));
def("pass", password, sizeof(password));
def("guest", guest_password, sizeof(guest_password));
def("guest_env", guest_environment);
def("owner", owner_info, sizeof(owner_info));
def("adv_int", advert_interval);
def("f_adv_int", flood_advert_interval);
Expand Down