* various changes for CLI support via companion radio

This commit is contained in:
Scott Powell
2025-02-27 12:51:00 +11:00
parent 189ed79d46
commit 1209d54d2e
6 changed files with 79 additions and 11 deletions

View File

@@ -423,6 +423,7 @@ protected:
if (flags == TXT_TYPE_CLI_DATA) {
if (client->is_admin) {
handleAdminCommand(sender_timestamp, (const char *) &data[5], (char *) &temp[5]);
temp[4] = (TXT_TYPE_CLI_DATA << 2); // attempt and flags, (NOTE: legacy was: TXT_TYPE_PLAIN)
send_ack = true;
} else {
temp[5] = 0; // no reply
@@ -452,7 +453,6 @@ protected:
now++;
}
memcpy(temp, &now, 4); // mostly an extra blob to help make packet_hash unique
temp[4] = (TXT_TYPE_PLAIN << 2); // attempt and flags
// calc expected ACK reply
//mesh::Utils::sha256((uint8_t *)&expected_ack_crc, 4, temp, 5 + text_len, self_id.pub_key, PUB_KEY_SIZE);
@@ -604,9 +604,15 @@ public:
}
}
void handleAdminCommand(uint32_t sender_timestamp, const char* command, char reply[]) {
void handleAdminCommand(uint32_t sender_timestamp, const char* command, char* reply) {
while (*command == ' ') command++; // skip leading spaces
if (strlen(command) > 4 && command[2] == '|') { // optional prefix (for companion radio CLI)
memcpy(reply, command, 3); // reflect the prefix back
reply += 3;
command += 3;
}
if (memcmp(command, "reboot", 6) == 0) {
board.reboot(); // doesn't return
} else if (memcmp(command, "advert", 6) == 0) {