* changed onUnhandledResponse() to return true if handled/consumed

* unhandled responses (eg. push telemetry) now sent to app as PUSH_CODE_BINARY_RESPONSE frames
This commit is contained in:
Scott Powell
2026-09-24 13:49:57 +10:00
parent c423dece36
commit b204f9a114
2 changed files with 16 additions and 3 deletions
+15 -2
View File
@@ -758,8 +758,21 @@ void MyMesh::onContactResponse(const ContactInfo &contact, const uint8_t *data,
memcpy(&out_frame[i], &data[4], len - 4);
i += (len - 4);
_serial->writeFrame(out_frame, i);
} else if (_listener && len > 4) {
_listener->onUnhandledResponse(contact, tag, &data[4], len - 4);
} else {
bool handled;
if (_listener && len > 4) {
handled = _listener->onUnhandledResponse(contact, tag, &data[4], len - 4);
} else {
handled = false;
}
if (!handled) { // let the app know about unknown/unhandled responses (eg. push telemetry packets)
int i = 0;
out_frame[i++] = PUSH_CODE_BINARY_RESPONSE;
out_frame[i++] = 0; // reserved
memcpy(&out_frame[i], data, len);
i += len;
_serial->writeFrame(out_frame, i);
}
}
}
+1 -1
View File
@@ -101,7 +101,7 @@ public:
virtual void onACKRecv(uint32_t ack_crc) { }
virtual uint8_t onUnhandledRequest(const ContactInfo &contact, uint32_t sender_timestamp, const uint8_t *data,
uint8_t len, uint8_t *reply) { return 0; /* unknown request type */ }
virtual void onUnhandledResponse(const ContactInfo &from, uint32_t tag, const uint8_t* data, uint8_t len) { }
virtual bool onUnhandledResponse(const ContactInfo &from, uint32_t tag, const uint8_t* data, uint8_t len) { return false; /* not handled */ }
virtual void onTraceRecv(mesh::Packet *pkt, uint32_t tag, uint32_t auth_code, uint8_t flags,
const uint8_t *path_snrs, const uint8_t *path_hashes, uint8_t path_len) { }
virtual void onRawDataRecv(mesh::Packet *pkt) { }