Skip to content

Commit 870b5d2

Browse files
author
Scott Powell
committed
* companion: 'self telemetry' request with CMD_SEND_TELEMETRY_REQ (with no pubkey param)
1 parent 006cd42 commit 870b5d2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

examples/companion_radio/MyMesh.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,6 +1373,28 @@ void MyMesh::handleCmdFrame(size_t len) {
13731373
} else {
13741374
writeErrFrame(ERR_CODE_NOT_FOUND); // contact not found
13751375
}
1376+
} else if (cmd_frame[0] == CMD_SEND_TELEMETRY_REQ && len == 4) { // 'self' telemetry request
1377+
out_frame[0] = RESP_CODE_SENT;
1378+
out_frame[1] = 0;
1379+
uint32_t tag = 0, est_timeout = 50;
1380+
memcpy(&out_frame[2], &tag, 4);
1381+
memcpy(&out_frame[6], &est_timeout, 4);
1382+
_serial->writeFrame(out_frame, 10);
1383+
1384+
telemetry.reset();
1385+
telemetry.addVoltage(TELEM_CHANNEL_SELF, (float)board.getBattMilliVolts() / 1000.0f);
1386+
// query other sensors -- target specific
1387+
sensors.querySensors(0xFF, telemetry);
1388+
1389+
int i = 0;
1390+
out_frame[i++] = PUSH_CODE_TELEMETRY_RESPONSE;
1391+
out_frame[i++] = 0; // reserved
1392+
memcpy(&out_frame[i], self_id.pub_key, 6);
1393+
i += 6; // pub_key_prefix
1394+
uint8_t tlen = telemetry.getSize();
1395+
memcpy(&out_frame[i], telemetry.getBuffer(), tlen);
1396+
i += tlen;
1397+
_serial->writeFrame(out_frame, i);
13761398
} else if (cmd_frame[0] == CMD_HAS_CONNECTION && len >= 1 + PUB_KEY_SIZE) {
13771399
uint8_t *pub_key = &cmd_frame[1];
13781400
if (hasConnectionTo(pub_key)) {

0 commit comments

Comments
 (0)