Browse Source

Merge 38b1b54cbe into db232808aa

pull/1551/merge
Saradonim 19 hours ago
committed by GitHub
parent
commit
1af1e4b70f
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 21
      examples/companion_radio/MyMesh.cpp

21
examples/companion_radio/MyMesh.cpp

@ -1082,9 +1082,8 @@ void MyMesh::handleCmdFrame(size_t len) {
int i = 1; int i = 1;
uint8_t txt_type = cmd_frame[i++]; uint8_t txt_type = cmd_frame[i++];
uint8_t attempt = cmd_frame[i++]; uint8_t attempt = cmd_frame[i++];
uint32_t msg_timestamp; uint32_t msg_timestamp = getRTCClock()->getCurrentTimeUnique(); // Use node's RTC for consistency
memcpy(&msg_timestamp, &cmd_frame[i], 4); i += 4; // skip timestamp in cmd_frame (not used)
i += 4;
uint8_t *pub_key_prefix = &cmd_frame[i]; uint8_t *pub_key_prefix = &cmd_frame[i];
i += 6; i += 6;
ContactInfo *recipient = lookupContactByPubKey(pub_key_prefix, 6); ContactInfo *recipient = lookupContactByPubKey(pub_key_prefix, 6);
@ -1096,7 +1095,6 @@ void MyMesh::handleCmdFrame(size_t len) {
int result; int result;
uint32_t expected_ack; uint32_t expected_ack;
if (txt_type == TXT_TYPE_CLI_DATA) { if (txt_type == TXT_TYPE_CLI_DATA) {
msg_timestamp = getRTCClock()->getCurrentTimeUnique(); // Use node's RTC instead of app timestamp to avoid tripping replay protection
result = sendCommandData(*recipient, msg_timestamp, attempt, text, est_timeout); result = sendCommandData(*recipient, msg_timestamp, attempt, text, est_timeout);
expected_ack = 0; // no Ack expected expected_ack = 0; // no Ack expected
} else { } else {
@ -1128,9 +1126,8 @@ void MyMesh::handleCmdFrame(size_t len) {
int i = 1; int i = 1;
uint8_t txt_type = cmd_frame[i++]; // should be TXT_TYPE_PLAIN uint8_t txt_type = cmd_frame[i++]; // should be TXT_TYPE_PLAIN
uint8_t channel_idx = cmd_frame[i++]; uint8_t channel_idx = cmd_frame[i++];
uint32_t msg_timestamp; uint32_t msg_timestamp = getRTCClock()->getCurrentTimeUnique(); // Use node's RTC for consistency
memcpy(&msg_timestamp, &cmd_frame[i], 4); i += 4; // skip timestamp in cmd_frame (not used)
i += 4;
const char *text = (char *)&cmd_frame[i]; const char *text = (char *)&cmd_frame[i];
if (txt_type != TXT_TYPE_PLAIN) { if (txt_type != TXT_TYPE_PLAIN) {
@ -1236,13 +1233,9 @@ void MyMesh::handleCmdFrame(size_t len) {
} else if (cmd_frame[0] == CMD_SET_DEVICE_TIME && len >= 5) { } else if (cmd_frame[0] == CMD_SET_DEVICE_TIME && len >= 5) {
uint32_t secs; uint32_t secs;
memcpy(&secs, &cmd_frame[1], 4); memcpy(&secs, &cmd_frame[1], 4);
uint32_t curr = getRTCClock()->getCurrentTime(); // Allow setting time to any value (removed >= check to allow correcting a clock stuck in the future)
if (secs >= curr) { getRTCClock()->setCurrentTime(secs);
getRTCClock()->setCurrentTime(secs); writeOKFrame();
writeOKFrame();
} else {
writeErrFrame(ERR_CODE_ILLEGAL_ARG);
}
} else if (cmd_frame[0] == CMD_SEND_SELF_ADVERT) { } else if (cmd_frame[0] == CMD_SEND_SELF_ADVERT) {
mesh::Packet* pkt; mesh::Packet* pkt;
if (_prefs.advert_loc_policy == ADVERT_LOC_NONE) { if (_prefs.advert_loc_policy == ADVERT_LOC_NONE) {

Loading…
Cancel
Save