mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-11-02 10:51:57 +00:00
* refactor: removed UITask dependency from MyMesh. New MyMesh::Listener interface
* UITask's are now a MyMesh task Listener
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "NodePrefs.h"
|
#include "NodePrefs.h"
|
||||||
|
#include "MyMesh.h"
|
||||||
|
|
||||||
enum class UIEventType {
|
enum class UIEventType {
|
||||||
none,
|
none,
|
||||||
@@ -22,25 +23,21 @@ enum class UIEventType {
|
|||||||
ack
|
ack
|
||||||
};
|
};
|
||||||
|
|
||||||
class AbstractUITask {
|
class AbstractUITask : public MyMesh::Listener {
|
||||||
protected:
|
protected:
|
||||||
mesh::MainBoard* _board;
|
mesh::MainBoard* _board;
|
||||||
MultiSerialInterface* _interfaceManager;
|
MultiSerialInterface* _interfaceManager;
|
||||||
bool _connected;
|
|
||||||
|
|
||||||
AbstractUITask(mesh::MainBoard* board, MultiSerialInterface* interfaceManager) : _board(board), _interfaceManager(interfaceManager) {
|
AbstractUITask(mesh::MainBoard* board, MultiSerialInterface* interfaceManager) : _board(board), _interfaceManager(interfaceManager) {
|
||||||
_connected = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void setHasConnection(bool connected) { _connected = connected; }
|
bool hasConnection() const { return _interfaceManager->isConnected(); }
|
||||||
bool hasConnection() const { return _connected; }
|
|
||||||
uint16_t getBattMilliVolts() const { return _board->getBattMilliVolts(); }
|
uint16_t getBattMilliVolts() const { return _board->getBattMilliVolts(); }
|
||||||
bool isBluetoothEnabled() const { return _interfaceManager->isBluetoothEnabled(); }
|
bool isBluetoothEnabled() const { return _interfaceManager->isBluetoothEnabled(); }
|
||||||
void enableBluetooth() { _interfaceManager->enableBluetooth(); }
|
void enableBluetooth() { _interfaceManager->enableBluetooth(); }
|
||||||
void disableBluetooth() { _interfaceManager->disableBluetooth(); }
|
void disableBluetooth() { _interfaceManager->disableBluetooth(); }
|
||||||
virtual void msgRead(int msgcount) = 0;
|
|
||||||
virtual void newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount) = 0;
|
|
||||||
virtual void notify(UIEventType t = UIEventType::none) = 0;
|
virtual void notify(UIEventType t = UIEventType::none) = 0;
|
||||||
virtual void loop() = 0;
|
virtual void loop() = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -368,10 +368,6 @@ void MyMesh::onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path
|
|||||||
memcpy(&out_frame[1], contact.id.pub_key, PUB_KEY_SIZE);
|
memcpy(&out_frame[1], contact.id.pub_key, PUB_KEY_SIZE);
|
||||||
_serial->writeFrame(out_frame, 1 + PUB_KEY_SIZE);
|
_serial->writeFrame(out_frame, 1 + PUB_KEY_SIZE);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
#ifdef DISPLAY_CLASS
|
|
||||||
if (_ui) _ui->notify(UIEventType::newContactMessage);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// add inbound-path to mem cache
|
// add inbound-path to mem cache
|
||||||
@@ -395,6 +391,8 @@ void MyMesh::onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path
|
|||||||
p->path_len = mesh::Packet::copyPath(p->path, path, path_len);
|
p->path_len = mesh::Packet::copyPath(p->path, path, path_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_listener) _listener->onDiscoveredContact(contact, is_new, path_len, path);
|
||||||
|
|
||||||
if (!is_new) dirty_contacts_expiry = futureMillis(LAZY_CONTACTS_WRITE_DELAY); // only schedule lazy write for contacts that are in contacts[]
|
if (!is_new) dirty_contacts_expiry = futureMillis(LAZY_CONTACTS_WRITE_DELAY); // only schedule lazy write for contacts that are in contacts[]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -520,17 +518,13 @@ void MyMesh::queueMessage(const ContactInfo &from, uint8_t txt_type, mesh::Packe
|
|||||||
_serial->writeFrame(frame, 1);
|
_serial->writeFrame(frame, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DISPLAY_CLASS
|
|
||||||
// we only want to show text messages on display, not cli data
|
// we only want to show text messages on display, not cli data
|
||||||
bool should_display = txt_type == TXT_TYPE_PLAIN || txt_type == TXT_TYPE_SIGNED_PLAIN;
|
bool should_display = txt_type == TXT_TYPE_PLAIN || txt_type == TXT_TYPE_SIGNED_PLAIN;
|
||||||
if (should_display && _ui) {
|
if (should_display && _listener) {
|
||||||
_ui->newMsg(path_len, from.name, text, offline_queue_len);
|
_listener->onMessageRecv(path_len, from.name, text);
|
||||||
if (!_serial->isConnected()) {
|
_listener->onQueueSizeChanged(offline_queue_len);
|
||||||
_ui->notify(UIEventType::contactMessage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MyMesh::filterRecvFloodPacket(mesh::Packet* packet) {
|
bool MyMesh::filterRecvFloodPacket(mesh::Packet* packet) {
|
||||||
// REVISIT: try to determine which Region (from transport_codes[1]) that Sender is indicating for replies/responses
|
// REVISIT: try to determine which Region (from transport_codes[1]) that Sender is indicating for replies/responses
|
||||||
@@ -640,20 +634,16 @@ void MyMesh::onChannelMessageRecv(const mesh::GroupChannel &channel, mesh::Packe
|
|||||||
uint8_t frame[1];
|
uint8_t frame[1];
|
||||||
frame[0] = PUSH_CODE_MSG_WAITING; // send push 'tickle'
|
frame[0] = PUSH_CODE_MSG_WAITING; // send push 'tickle'
|
||||||
_serial->writeFrame(frame, 1);
|
_serial->writeFrame(frame, 1);
|
||||||
} else {
|
|
||||||
#ifdef DISPLAY_CLASS
|
|
||||||
if (_ui) _ui->notify(UIEventType::channelMessage);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#ifdef DISPLAY_CLASS
|
if (_listener) {
|
||||||
// Get the channel name from the channel index
|
// Get the channel name from the channel index
|
||||||
const char *channel_name = "Unknown";
|
|
||||||
ChannelDetails channel_details;
|
ChannelDetails channel_details;
|
||||||
if (getChannel(channel_idx, channel_details)) {
|
if (!getChannel(channel_idx, channel_details)) {
|
||||||
channel_name = channel_details.name;
|
strcpy(channel_details.name, "Unknown");
|
||||||
|
}
|
||||||
|
_listener->onChannelMsgRecv(channel_details, path_len, text);
|
||||||
|
_listener->onQueueSizeChanged(offline_queue_len);
|
||||||
}
|
}
|
||||||
if (_ui) _ui->newMsg(path_len, channel_name, text, offline_queue_len);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyMesh::onChannelDataRecv(const mesh::GroupChannel &channel, mesh::Packet *pkt, uint16_t data_type,
|
void MyMesh::onChannelDataRecv(const mesh::GroupChannel &channel, mesh::Packet *pkt, uint16_t data_type,
|
||||||
@@ -930,9 +920,9 @@ uint32_t MyMesh::calcDirectTimeoutMillisFor(uint32_t pkt_airtime_millis, uint8_t
|
|||||||
|
|
||||||
void MyMesh::onSendTimeout() {}
|
void MyMesh::onSendTimeout() {}
|
||||||
|
|
||||||
MyMesh::MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMeshTables &tables, DataStore& store, AbstractUITask* ui)
|
MyMesh::MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMeshTables &tables, DataStore& store)
|
||||||
: BaseChatMesh(radio, *new ArduinoMillis(), rng, rtc, *new StaticPoolPacketManager(16), tables),
|
: BaseChatMesh(radio, *new ArduinoMillis(), rng, rtc, *new StaticPoolPacketManager(16), tables),
|
||||||
_serial(NULL), telemetry(MAX_PACKET_PAYLOAD - 4), _store(&store), _ui(ui), _iter(0) {
|
_serial(NULL), telemetry(MAX_PACKET_PAYLOAD - 4), _store(&store), _listener(NULL), _iter(0) {
|
||||||
_iter_started = false;
|
_iter_started = false;
|
||||||
_cli_rescue = false;
|
_cli_rescue = false;
|
||||||
cli_command[0] = 0;
|
cli_command[0] = 0;
|
||||||
@@ -1463,9 +1453,7 @@ void MyMesh::handleCmdFrame(size_t len) {
|
|||||||
int out_len;
|
int out_len;
|
||||||
if ((out_len = getFromOfflineQueue(out_frame)) > 0) {
|
if ((out_len = getFromOfflineQueue(out_frame)) > 0) {
|
||||||
_serial->writeFrame(out_frame, out_len);
|
_serial->writeFrame(out_frame, out_len);
|
||||||
#ifdef DISPLAY_CLASS
|
if (_listener) _listener->onQueueSizeChanged(offline_queue_len);
|
||||||
if (_ui) _ui->msgRead(offline_queue_len);
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
out_frame[0] = RESP_CODE_NO_MORE_MESSAGES;
|
out_frame[0] = RESP_CODE_NO_MORE_MESSAGES;
|
||||||
_serial->writeFrame(out_frame, 1);
|
_serial->writeFrame(out_frame, 1);
|
||||||
@@ -2466,10 +2454,6 @@ void MyMesh::loop() {
|
|||||||
saveContacts();
|
saveContacts();
|
||||||
dirty_contacts_expiry = 0;
|
dirty_contacts_expiry = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DISPLAY_CLASS
|
|
||||||
if (_ui) _ui->setHasConnection(_serial->isConnected());
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MyMesh::advert() {
|
bool MyMesh::advert() {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <Mesh.h>
|
#include <Mesh.h>
|
||||||
#include "AbstractUITask.h"
|
|
||||||
|
|
||||||
/*------------ Frame Protocol --------------*/
|
/*------------ Frame Protocol --------------*/
|
||||||
#define FIRMWARE_VER_CODE 14
|
#define FIRMWARE_VER_CODE 14
|
||||||
@@ -96,10 +95,19 @@ struct DiscoveredNode {
|
|||||||
|
|
||||||
class MyMesh : public BaseChatMesh, public DataStoreHost {
|
class MyMesh : public BaseChatMesh, public DataStoreHost {
|
||||||
public:
|
public:
|
||||||
MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMeshTables &tables, DataStore& store, AbstractUITask* ui=NULL);
|
class Listener {
|
||||||
|
public:
|
||||||
|
virtual void onMessageRecv(uint8_t path_len, const char* from_name, const char* text) = 0;
|
||||||
|
virtual void onChannelMsgRecv(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;
|
||||||
|
};
|
||||||
|
|
||||||
|
MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMeshTables &tables, DataStore& store);
|
||||||
|
|
||||||
void begin(bool has_display);
|
void begin(bool has_display);
|
||||||
void startInterface(BaseSerialInterface &serial);
|
void startInterface(BaseSerialInterface &serial);
|
||||||
|
void setListener(Listener* listener) { _listener = listener; }
|
||||||
|
|
||||||
const char *getNodeName();
|
const char *getNodeName();
|
||||||
NodePrefs *getNodePrefs();
|
NodePrefs *getNodePrefs();
|
||||||
@@ -237,7 +245,7 @@ private:
|
|||||||
uint32_t pending_telemetry, pending_discovery; // pending _TELEMETRY_REQ
|
uint32_t pending_telemetry, pending_discovery; // pending _TELEMETRY_REQ
|
||||||
uint32_t pending_req; // pending _BINARY_REQ
|
uint32_t pending_req; // pending _BINARY_REQ
|
||||||
BaseSerialInterface *_serial;
|
BaseSerialInterface *_serial;
|
||||||
AbstractUITask* _ui;
|
Listener* _listener;
|
||||||
|
|
||||||
ContactsIterator _iter;
|
ContactsIterator _iter;
|
||||||
uint32_t _iter_filter_since;
|
uint32_t _iter_filter_since;
|
||||||
|
|||||||
@@ -114,11 +114,7 @@ MultiSerialInterface interface_manager;
|
|||||||
|
|
||||||
StdRNG fast_rng;
|
StdRNG fast_rng;
|
||||||
SimpleMeshTables tables;
|
SimpleMeshTables tables;
|
||||||
MyMesh the_mesh(radio_driver, fast_rng, rtc_clock, tables, store
|
MyMesh the_mesh(radio_driver, fast_rng, rtc_clock, tables, store);
|
||||||
#ifdef DISPLAY_CLASS
|
|
||||||
, &ui_task
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
/* END GLOBAL OBJECTS */
|
/* END GLOBAL OBJECTS */
|
||||||
|
|
||||||
@@ -285,6 +281,7 @@ void setup() {
|
|||||||
|
|
||||||
#ifdef DISPLAY_CLASS
|
#ifdef DISPLAY_CLASS
|
||||||
ui_task.begin(disp, &sensors, the_mesh.getNodePrefs()); // still want to pass this in as dependency, as prefs might be moved
|
ui_task.begin(disp, &sensors, the_mesh.getNodePrefs()); // still want to pass this in as dependency, as prefs might be moved
|
||||||
|
the_mesh.setListener(&ui_task);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
board.onBootComplete();
|
board.onBootComplete();
|
||||||
|
|||||||
@@ -751,17 +751,7 @@ switch(t){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UITask::onMessageRecv(uint8_t path_len, const char* from_name, const char* text) {
|
||||||
void UITask::msgRead(int msgcount) {
|
|
||||||
_msgcount = msgcount;
|
|
||||||
if (msgcount == 0) {
|
|
||||||
gotoHomeScreen();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount) {
|
|
||||||
_msgcount = msgcount;
|
|
||||||
|
|
||||||
((MsgPreviewScreen *) msg_preview)->addPreview(path_len, from_name, text);
|
((MsgPreviewScreen *) msg_preview)->addPreview(path_len, from_name, text);
|
||||||
setCurrScreen(msg_preview);
|
setCurrScreen(msg_preview);
|
||||||
|
|
||||||
@@ -774,6 +764,42 @@ void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, i
|
|||||||
_next_refresh = 100; // trigger refresh
|
_next_refresh = 100; // trigger refresh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!hasConnection()) {
|
||||||
|
notify(UIEventType::contactMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UITask::onChannelMsgRecv(ChannelDetails& channel_details, uint8_t path_len, const char* text) {
|
||||||
|
((MsgPreviewScreen *) msg_preview)->addPreview(path_len, channel_details.name, text);
|
||||||
|
setCurrScreen(msg_preview);
|
||||||
|
|
||||||
|
if (_display != NULL) {
|
||||||
|
if (!_display->isOn() && !hasConnection()) {
|
||||||
|
_display->turnOn();
|
||||||
|
}
|
||||||
|
if (_display->isOn()) {
|
||||||
|
_auto_off = millis() + AUTO_OFF_MILLIS; // extend the auto-off timer
|
||||||
|
_next_refresh = 100; // trigger refresh
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasConnection()) {
|
||||||
|
notify(UIEventType::channelMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UITask::onQueueSizeChanged(int msgcount) {
|
||||||
|
_msgcount = msgcount;
|
||||||
|
if (msgcount == 0) {
|
||||||
|
gotoHomeScreen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UITask::onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path_len, const uint8_t* path) {
|
||||||
|
if (!hasConnection()) {
|
||||||
|
notify(UIEventType::newContactMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UITask::userLedHandler() {
|
void UITask::userLedHandler() {
|
||||||
|
|||||||
@@ -90,10 +90,13 @@ public:
|
|||||||
bool getGPSState();
|
bool getGPSState();
|
||||||
void toggleGPS();
|
void toggleGPS();
|
||||||
|
|
||||||
|
// MyMesh::Listener
|
||||||
|
void onMessageRecv(uint8_t path_len, const char* from_name, const char* text) override;
|
||||||
|
void onChannelMsgRecv(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;
|
||||||
|
|
||||||
// from AbstractUITask
|
// from AbstractUITask
|
||||||
void msgRead(int msgcount) override;
|
|
||||||
void newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount) override;
|
|
||||||
void notify(UIEventType t = UIEventType::none) override;
|
void notify(UIEventType t = UIEventType::none) override;
|
||||||
void loop() override;
|
void loop() override;
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ switch(t){
|
|||||||
// Serial.println((int) t);
|
// Serial.println((int) t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UITask::msgRead(int msgcount) {
|
void UITask::onQueueSizeChanged(int msgcount) {
|
||||||
_msgcount = msgcount;
|
_msgcount = msgcount;
|
||||||
if (msgcount == 0) {
|
if (msgcount == 0) {
|
||||||
clearMsgPreview();
|
clearMsgPreview();
|
||||||
@@ -139,9 +139,7 @@ void UITask::clearMsgPreview() {
|
|||||||
_need_refresh = true;
|
_need_refresh = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount) {
|
void UITask::onMessageRecv(uint8_t path_len, const char* from_name, const char* text) {
|
||||||
_msgcount = msgcount;
|
|
||||||
|
|
||||||
#ifdef HAS_DRV2605
|
#ifdef HAS_DRV2605
|
||||||
vibration.trigger(); // vibrate even while the app is connected (honors quiet + cooldown)
|
vibration.trigger(); // vibrate even while the app is connected (honors quiet + cooldown)
|
||||||
#endif
|
#endif
|
||||||
@@ -162,6 +160,41 @@ void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, i
|
|||||||
_need_refresh = true;
|
_need_refresh = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!hasConnection()) {
|
||||||
|
notify(UIEventType::contactMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UITask::onChannelMsgRecv(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
|
||||||
|
|
||||||
|
if (path_len == 0xFF) {
|
||||||
|
sprintf(_origin, "(F) %s", channel_details.name);
|
||||||
|
} else {
|
||||||
|
sprintf(_origin, "(%d) %s", (uint32_t) path_len, channel_details.name);
|
||||||
|
}
|
||||||
|
StrHelper::strncpy(_msg, text, sizeof(_msg));
|
||||||
|
|
||||||
|
if (_display != NULL) {
|
||||||
|
if (!_display->isOn() && !hasConnection()) {
|
||||||
|
_display->turnOn();
|
||||||
|
}
|
||||||
|
if (_display->isOn()) {
|
||||||
|
_auto_off = millis() + AUTO_OFF_MILLIS; // extend the auto-off timer
|
||||||
|
_need_refresh = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasConnection()) {
|
||||||
|
notify(UIEventType::channelMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UITask::onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path_len, const uint8_t* path) {
|
||||||
|
if (!hasConnection()) {
|
||||||
|
notify(UIEventType::newContactMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UITask::renderBatteryIndicator(uint16_t batteryMilliVolts) {
|
void UITask::renderBatteryIndicator(uint16_t batteryMilliVolts) {
|
||||||
@@ -262,7 +295,7 @@ void UITask::renderCurrScreen() {
|
|||||||
_display->print(tmp);
|
_display->print(tmp);
|
||||||
|
|
||||||
// BT pin
|
// BT pin
|
||||||
if (!_connected && the_mesh.getBLEPin() != 0) {
|
if (!hasConnection() && the_mesh.getBLEPin() != 0) {
|
||||||
_display->setColor(UIColor::warning_txt);
|
_display->setColor(UIColor::warning_txt);
|
||||||
_display->setTextSize(2);
|
_display->setTextSize(2);
|
||||||
_display->setCursor(0, 43);
|
_display->setCursor(0, 43);
|
||||||
|
|||||||
@@ -70,9 +70,13 @@ public:
|
|||||||
bool hasDisplay() const { return _display != NULL; }
|
bool hasDisplay() const { return _display != NULL; }
|
||||||
void clearMsgPreview();
|
void clearMsgPreview();
|
||||||
|
|
||||||
|
// MyMesh::Listener
|
||||||
|
void onMessageRecv(uint8_t path_len, const char* from_name, const char* text) override;
|
||||||
|
void onChannelMsgRecv(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;
|
||||||
|
|
||||||
// from AbstractUITask
|
// from AbstractUITask
|
||||||
void msgRead(int msgcount) override;
|
|
||||||
void newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount) override;
|
|
||||||
void notify(UIEventType t = UIEventType::none) override;
|
void notify(UIEventType t = UIEventType::none) override;
|
||||||
void loop() override;
|
void loop() override;
|
||||||
|
|
||||||
|
|||||||
@@ -503,16 +503,14 @@ switch(t){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UITask::msgRead(int msgcount) {
|
void UITask::onQueueSizeChanged(int msgcount) {
|
||||||
_msgcount = msgcount;
|
_msgcount = msgcount;
|
||||||
if (msgcount == 0) {
|
if (msgcount == 0) {
|
||||||
gotoHomeScreen();
|
gotoHomeScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount) {
|
void UITask::onMessageRecv(uint8_t path_len, const char* from_name, const char* text) {
|
||||||
_msgcount = msgcount;
|
|
||||||
|
|
||||||
if (_display != NULL) {
|
if (_display != NULL) {
|
||||||
if (!_display->isOn() && !hasConnection()) {
|
if (!_display->isOn() && !hasConnection()) {
|
||||||
_display->turnOn();
|
_display->turnOn();
|
||||||
@@ -522,6 +520,30 @@ void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, i
|
|||||||
_next_refresh = 100; // trigger refresh
|
_next_refresh = 100; // trigger refresh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!hasConnection()) {
|
||||||
|
notify(UIEventType::contactMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UITask::onChannelMsgRecv(ChannelDetails& channel_details, uint8_t path_len, const char* text) {
|
||||||
|
if (_display != NULL) {
|
||||||
|
if (!_display->isOn() && !hasConnection()) {
|
||||||
|
_display->turnOn();
|
||||||
|
}
|
||||||
|
if (_display->isOn()) {
|
||||||
|
_auto_off = millis() + AUTO_OFF_MILLIS; // extend the auto-off timer
|
||||||
|
_next_refresh = 100; // trigger refresh
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasConnection()) {
|
||||||
|
notify(UIEventType::channelMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UITask::onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path_len, const uint8_t* path) {
|
||||||
|
if (!hasConnection()) {
|
||||||
|
notify(UIEventType::newContactMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UITask::userLedHandler() {
|
void UITask::userLedHandler() {
|
||||||
|
|||||||
@@ -98,10 +98,13 @@ public:
|
|||||||
bool getGPSState();
|
bool getGPSState();
|
||||||
void toggleGPS();
|
void toggleGPS();
|
||||||
|
|
||||||
|
// MyMesh::Listener
|
||||||
|
void onMessageRecv(uint8_t path_len, const char* from_name, const char* text) override;
|
||||||
|
void onChannelMsgRecv(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;
|
||||||
|
|
||||||
// from AbstractUITask
|
// from AbstractUITask
|
||||||
void msgRead(int msgcount) override;
|
|
||||||
void newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount) override;
|
|
||||||
void notify(UIEventType t = UIEventType::none) override;
|
void notify(UIEventType t = UIEventType::none) override;
|
||||||
void loop() override;
|
void loop() override;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user