* more MyMesh::Listener interface hooks

This commit is contained in:
Scott Powell
2026-09-17 17:33:36 +10:00
parent 30dd723c26
commit b3b17025e3
8 changed files with 37 additions and 18 deletions
+19 -1
View File
@@ -415,6 +415,11 @@ void MyMesh::onContactPathUpdated(const ContactInfo &contact) {
}
ContactInfo* MyMesh::processAck(const uint8_t *data) {
if (_listener) {
uint32_t ack_crc;
memcpy(&ack_crc, data, 4);
_listener->onACKRecv(ack_crc);
}
// see if matches any in a table
for (int i = 0; i < EXPECTED_ACK_TABLE_SIZE; i++) {
if (memcmp(data, &expected_ack_table[i].ack, 4) == 0) { // got an ACK from recipient
@@ -588,7 +593,7 @@ void MyMesh::onChannelMessageRecv(const mesh::GroupChannel &channel, mesh::Packe
if (!getChannel(channel_idx, channel_details)) {
strcpy(channel_details.name, "Unknown");
}
_listener->onChannelMsgRecv(channel_details, path_len, text);
_listener->onChannelMessageRecv(channel_details, path_len, text);
_listener->onQueueSizeChanged(offline_queue_len);
}
}
@@ -626,6 +631,9 @@ void MyMesh::onChannelDataRecv(const mesh::GroupChannel &channel, mesh::Packet *
frame[0] = PUSH_CODE_MSG_WAITING; // send push 'tickle'
_serial->writeFrame(frame, 1);
}
if (_listener) {
_listener->onChannelDataRecv(channel, pkt, data_type, data, data_len);
}
}
uint8_t MyMesh::onContactRequest(const ContactInfo &contact, uint32_t sender_timestamp, const uint8_t *data,
@@ -673,6 +681,8 @@ uint8_t MyMesh::onContactRequest(const ContactInfo &contact, uint32_t sender_tim
memcpy(&reply[4], telemetry.getBuffer(), tlen);
return 4 + tlen;
}
} else if (_listener) {
return _listener->onUnhandledRequest(contact, sender_timestamp, data, len, reply);
}
return 0; // unknown
}
@@ -748,6 +758,8 @@ 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);
}
}
@@ -822,6 +834,9 @@ void MyMesh::onRawDataRecv(mesh::Packet *packet) {
} else {
MESH_DEBUG_PRINTLN("onRawDataRecv(), data received while app offline");
}
if (_listener) {
_listener->onRawDataRecv(packet);
}
}
void MyMesh::onTraceRecv(mesh::Packet *packet, uint32_t tag, uint32_t auth_code, uint8_t flags,
@@ -852,6 +867,9 @@ void MyMesh::onTraceRecv(mesh::Packet *packet, uint32_t tag, uint32_t auth_code,
} else {
MESH_DEBUG_PRINTLN("onTraceRecv(), data received while app offline");
}
if (_listener) {
_listener->onTraceRecv(packet, tag, auth_code, flags, path_snrs, path_hashes, path_len);
}
}
uint32_t MyMesh::calcFloodTimeoutMillisFor(uint32_t pkt_airtime_millis) const {
+12 -3
View File
@@ -92,10 +92,19 @@ public:
class Listener {
public:
virtual void onMessageRecv(const ContactInfo &from, uint8_t txt_type, uint32_t sender_timestamp, uint8_t path_len, const char* text) = 0;
virtual void onChannelMsgRecv(ChannelDetails& channel_details, uint8_t path_len, const char* text) = 0;
virtual void onChannelMessageRecv(ChannelDetails& channel_details, uint8_t path_len, const char* text) = 0;
virtual void onQueueSizeChanged(int msgcount) = 0;
virtual void onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path_len, const uint8_t* path) = 0;
virtual void onControlDataRecv(const mesh::Packet* packet) = 0;
virtual void onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path_len, const uint8_t* path) { }
virtual void onControlDataRecv(const mesh::Packet* packet) { }
virtual void onChannelDataRecv(const mesh::GroupChannel &channel, mesh::Packet *pkt, uint16_t data_type,
const uint8_t *data, size_t data_len) { }
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 void onTraceRecv(mesh::Packet *packet, 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 *packet) { }
};
MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMeshTables &tables, DataStore& store);
+1 -1
View File
@@ -808,7 +808,7 @@ void UITask::onMessageRecv(const ContactInfo &from, uint8_t txt_type, uint32_t s
}
}
void UITask::onChannelMsgRecv(ChannelDetails& channel_details, uint8_t path_len, const char* text) {
void UITask::onChannelMessageRecv(ChannelDetails& channel_details, uint8_t path_len, const char* text) {
((MsgPreviewScreen *) msg_preview)->addPreview(path_len, channel_details.name, text);
setCurrScreen(msg_preview);
+1 -1
View File
@@ -112,7 +112,7 @@ public:
// MyMesh::Listener
void onMessageRecv(const ContactInfo &from, uint8_t txt_type, uint32_t sender_timestamp, uint8_t path_len, const char* text) override;
void onChannelMsgRecv(ChannelDetails& channel_details, uint8_t path_len, const char* text) override;
void onChannelMessageRecv(ChannelDetails& channel_details, uint8_t path_len, const char* text) override;
void onQueueSizeChanged(int offline_queue_size) override;
void onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path_len, const uint8_t* path) override;
void onControlDataRecv(const mesh::Packet* packet) override;
+1 -4
View File
@@ -168,7 +168,7 @@ void UITask::onMessageRecv(const ContactInfo &from, uint8_t txt_type, uint32_t s
}
}
void UITask::onChannelMsgRecv(ChannelDetails& channel_details, uint8_t path_len, const char* text) {
void UITask::onChannelMessageRecv(ChannelDetails& channel_details, uint8_t path_len, const char* text) {
#ifdef HAS_DRV2605
vibration.trigger(); // vibrate even while the app is connected (honors quiet + cooldown)
#endif
@@ -200,9 +200,6 @@ void UITask::onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path
}
}
void UITask::onControlDataRecv(const mesh::Packet* packet) {
}
void UITask::renderBatteryIndicator(uint16_t batteryMilliVolts) {
// Convert millivolts to percentage
#ifndef BATT_MIN_MILLIVOLTS
+1 -2
View File
@@ -72,10 +72,9 @@ public:
// MyMesh::Listener
void onMessageRecv(const ContactInfo &from, uint8_t txt_type, uint32_t sender_timestamp, uint8_t path_len, const char* text) override;
void onChannelMsgRecv(ChannelDetails& channel_details, uint8_t path_len, const char* text) override;
void onChannelMessageRecv(ChannelDetails& channel_details, uint8_t path_len, const char* text) override;
void onQueueSizeChanged(int offline_queue_size) override;
void onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path_len, const uint8_t* path) override;
void onControlDataRecv(const mesh::Packet* packet) override;
// from AbstractUITask
void notify(UIEventType t = UIEventType::none) override;
+1 -4
View File
@@ -528,7 +528,7 @@ void UITask::onMessageRecv(const ContactInfo &from, uint8_t txt_type, uint32_t s
}
}
void UITask::onChannelMsgRecv(ChannelDetails& channel_details, uint8_t path_len, const char* text) {
void UITask::onChannelMessageRecv(ChannelDetails& channel_details, uint8_t path_len, const char* text) {
if (_display != NULL) {
if (!_display->isOn() && !hasConnection()) {
_display->turnOn();
@@ -549,9 +549,6 @@ void UITask::onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path
}
}
void UITask::onControlDataRecv(const mesh::Packet* packet) {
}
void UITask::userLedHandler() {
#ifdef PIN_STATUS_LED
int cur_time = millis();
+1 -2
View File
@@ -100,10 +100,9 @@ public:
// MyMesh::Listener
void onMessageRecv(const ContactInfo &from, uint8_t txt_type, uint32_t sender_timestamp, uint8_t path_len, const char* text) override;
void onChannelMsgRecv(ChannelDetails& channel_details, uint8_t path_len, const char* text) override;
void onChannelMessageRecv(ChannelDetails& channel_details, uint8_t path_len, const char* text) override;
void onQueueSizeChanged(int offline_queue_size) override;
void onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path_len, const uint8_t* path) override;
void onControlDataRecv(const mesh::Packet* packet) override;
// from AbstractUITask
void notify(UIEventType t = UIEventType::none) override;