109109
110110#define MAX_SIGN_DATA_LEN (8 * 1024 ) // 8K
111111
112- #ifdef DISPLAY_CLASS
113- #include " UITask.h"
114- #endif
115-
116112void MyMesh::writeOKFrame () {
117113 uint8_t buf[1 ];
118114 buf[0 ] = RESP_CODE_OK;
@@ -247,7 +243,7 @@ void MyMesh::onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path
247243 }
248244 } else {
249245#ifdef DISPLAY_CLASS
250- ui_task. soundBuzzer (UIEventType::newContactMessage);
246+ if (_ui) _ui-> soundBuzzer (UIEventType::newContactMessage);
251247#endif
252248 }
253249
@@ -354,10 +350,10 @@ void MyMesh::queueMessage(const ContactInfo &from, uint8_t txt_type, mesh::Packe
354350#ifdef DISPLAY_CLASS
355351 // we only want to show text messages on display, not cli data
356352 bool should_display = txt_type == TXT_TYPE_PLAIN || txt_type == TXT_TYPE_SIGNED_PLAIN;
357- if (should_display) {
358- ui_task. newMsg (path_len, from.name , text, offline_queue_len);
353+ if (should_display && _ui ) {
354+ _ui-> newMsg (path_len, from.name , text, offline_queue_len);
359355 if (!_serial->isConnected ()) {
360- ui_task. soundBuzzer (UIEventType::contactMessage);
356+ _ui-> soundBuzzer (UIEventType::contactMessage);
361357 }
362358 }
363359#endif
@@ -416,7 +412,7 @@ void MyMesh::onChannelMessageRecv(const mesh::GroupChannel &channel, mesh::Packe
416412 _serial->writeFrame (frame, 1 );
417413 } else {
418414#ifdef DISPLAY_CLASS
419- ui_task. soundBuzzer (UIEventType::channelMessage);
415+ if (_ui) _ui-> soundBuzzer (UIEventType::channelMessage);
420416#endif
421417 }
422418#ifdef DISPLAY_CLASS
@@ -426,7 +422,7 @@ void MyMesh::onChannelMessageRecv(const mesh::GroupChannel &channel, mesh::Packe
426422 if (getChannel (channel_idx, channel_details)) {
427423 channel_name = channel_details.name ;
428424 }
429- ui_task. newMsg (path_len, channel_name, text, offline_queue_len);
425+ if (_ui) _ui-> newMsg (path_len, channel_name, text, offline_queue_len);
430426#endif
431427}
432428
@@ -635,9 +631,9 @@ uint32_t MyMesh::calcDirectTimeoutMillisFor(uint32_t pkt_airtime_millis, uint8_t
635631
636632void MyMesh::onSendTimeout () {}
637633
638- MyMesh::MyMesh (mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMeshTables &tables, DataStore& store)
634+ MyMesh::MyMesh (mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMeshTables &tables, DataStore& store, AbstractUITask* ui )
639635 : BaseChatMesh(radio, *new ArduinoMillis(), rng, rtc, *new StaticPoolPacketManager(16 ), tables),
640- _serial(NULL ), telemetry(MAX_PACKET_PAYLOAD - 4 ), _store(&store) {
636+ _serial(NULL ), telemetry(MAX_PACKET_PAYLOAD - 4 ), _store(&store), _ui(ui) {
641637 _iter_started = false ;
642638 _cli_rescue = false ;
643639 offline_queue_len = 0 ;
@@ -1041,7 +1037,7 @@ void MyMesh::handleCmdFrame(size_t len) {
10411037 if ((out_len = getFromOfflineQueue (out_frame)) > 0 ) {
10421038 _serial->writeFrame (out_frame, out_len);
10431039#ifdef DISPLAY_CLASS
1044- ui_task. msgRead (offline_queue_len);
1040+ if (_ui) _ui-> msgRead (offline_queue_len);
10451041#endif
10461042 } else {
10471043 out_frame[0 ] = RESP_CODE_NO_MORE_MESSAGES;
@@ -1643,7 +1639,7 @@ void MyMesh::loop() {
16431639 }
16441640
16451641#ifdef DISPLAY_CLASS
1646- ui_task. setHasConnection (_serial->isConnected ());
1642+ if (_ui) _ui-> setHasConnection (_serial->isConnected ());
16471643#endif
16481644}
16491645
0 commit comments