9494#define PUSH_CODE_LOG_RX_DATA 0x88
9595#define PUSH_CODE_TRACE_DATA 0x89
9696#define PUSH_CODE_NEW_ADVERT 0x8A
97- #define PUSH_CODE_BINARY_RESPONSE 0x8B // was 'PUSH_CODE_TELEMETRY_RESPONSE'
97+ #define PUSH_CODE_TELEMETRY_RESPONSE 0x8B
98+ #define PUSH_CODE_BINARY_RESPONSE 0x8C
9899
99100#define ERR_CODE_UNSUPPORTED_CMD 1
100101#define ERR_CODE_NOT_FOUND 2
@@ -492,14 +493,25 @@ void MyMesh::onContactResponse(const ContactInfo &contact, const uint8_t *data,
492493 memcpy (&out_frame[i], &data[4 ], len - 4 );
493494 i += (len - 4 );
494495 _serial->writeFrame (out_frame, i);
496+ } else if (len > 4 && tag == pending_telemetry) { // check for matching response tag
497+ pending_telemetry = 0 ;
498+
499+ int i = 0 ;
500+ out_frame[i++] = PUSH_CODE_TELEMETRY_RESPONSE;
501+ out_frame[i++] = 0 ; // reserved
502+ memcpy (&out_frame[i], contact.id .pub_key , 6 );
503+ i += 6 ; // pub_key_prefix
504+ memcpy (&out_frame[i], &data[4 ], len - 4 );
505+ i += (len - 4 );
506+ _serial->writeFrame (out_frame, i);
495507 } else if (len > 4 && tag == pending_req) { // check for matching response tag
496508 pending_req = 0 ;
497509
498510 int i = 0 ;
499511 out_frame[i++] = PUSH_CODE_BINARY_RESPONSE;
500512 out_frame[i++] = 0 ; // reserved
501- memcpy (&out_frame[i], contact. id . pub_key , 6 );
502- i += 6 ; // pub_key_prefix
513+ memcpy (&out_frame[i], &tag, 4 ); // app needs to match this to RESP_CODE_SENT.tag
514+ i += 4 ;
503515 memcpy (&out_frame[i], &data[4 ], len - 4 );
504516 i += (len - 4 );
505517 _serial->writeFrame (out_frame, i);
@@ -568,7 +580,7 @@ MyMesh::MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMe
568580 _cli_rescue = false ;
569581 offline_queue_len = 0 ;
570582 app_target_ver = 0 ;
571- pending_login = pending_status = pending_req = 0 ;
583+ pending_login = pending_status = pending_telemetry = pending_req = 0 ;
572584 next_ack_idx = 0 ;
573585 sign_data = NULL ;
574586 dirty_contacts_expiry = 0 ;
@@ -1105,7 +1117,7 @@ void MyMesh::handleCmdFrame(size_t len) {
11051117 if (result == MSG_SEND_FAILED) {
11061118 writeErrFrame (ERR_CODE_TABLE_FULL);
11071119 } else {
1108- pending_req = pending_status = 0 ;
1120+ pending_req = pending_telemetry = pending_status = 0 ;
11091121 memcpy (&pending_login, recipient->id .pub_key , 4 ); // match this to onContactResponse()
11101122 out_frame[0 ] = RESP_CODE_SENT;
11111123 out_frame[1 ] = (result == MSG_SEND_SENT_FLOOD) ? 1 : 0 ;
@@ -1125,7 +1137,7 @@ void MyMesh::handleCmdFrame(size_t len) {
11251137 if (result == MSG_SEND_FAILED) {
11261138 writeErrFrame (ERR_CODE_TABLE_FULL);
11271139 } else {
1128- pending_req = pending_login = 0 ;
1140+ pending_req = pending_telemetry = pending_login = 0 ;
11291141 // FUTURE: pending_status = tag; // match this in onContactResponse()
11301142 memcpy (&pending_status, recipient->id .pub_key , 4 ); // legacy matching scheme
11311143 out_frame[0 ] = RESP_CODE_SENT;
@@ -1146,8 +1158,8 @@ void MyMesh::handleCmdFrame(size_t len) {
11461158 if (result == MSG_SEND_FAILED) {
11471159 writeErrFrame (ERR_CODE_TABLE_FULL);
11481160 } else {
1149- pending_status = pending_login = 0 ;
1150- pending_req = tag; // match this in onContactResponse()
1161+ pending_status = pending_login = pending_req = 0 ;
1162+ pending_telemetry = tag; // match this in onContactResponse()
11511163 out_frame[0 ] = RESP_CODE_SENT;
11521164 out_frame[1 ] = (result == MSG_SEND_SENT_FLOOD) ? 1 : 0 ;
11531165 memcpy (&out_frame[2 ], &tag, 4 );
@@ -1164,7 +1176,7 @@ void MyMesh::handleCmdFrame(size_t len) {
11641176 sensors.querySensors (0xFF , telemetry);
11651177
11661178 int i = 0 ;
1167- out_frame[i++] = PUSH_CODE_BINARY_RESPONSE ;
1179+ out_frame[i++] = PUSH_CODE_TELEMETRY_RESPONSE ;
11681180 out_frame[i++] = 0 ; // reserved
11691181 memcpy (&out_frame[i], self_id.pub_key , 6 );
11701182 i += 6 ; // pub_key_prefix
@@ -1182,7 +1194,7 @@ void MyMesh::handleCmdFrame(size_t len) {
11821194 if (result == MSG_SEND_FAILED) {
11831195 writeErrFrame (ERR_CODE_TABLE_FULL);
11841196 } else {
1185- pending_status = pending_login = 0 ;
1197+ pending_status = pending_login = pending_telemetry = 0 ;
11861198 pending_req = tag; // match this in onContactResponse()
11871199 out_frame[0 ] = RESP_CODE_SENT;
11881200 out_frame[1 ] = (result == MSG_SEND_SENT_FLOOD) ? 1 : 0 ;
0 commit comments