only display messages destined to us

This commit is contained in:
geeksville 2020-02-17 16:32:51 -08:00
parent c0fdf227b7
commit 47d278b3b9
3 changed files with 17 additions and 9 deletions

View File

@ -49,7 +49,7 @@ void NodeDB::init()
devicestate.node_db_count = 0; devicestate.node_db_count = 0;
devicestate.receive_queue_count = 0; devicestate.receive_queue_count = 0;
radioConfig.preferences.send_owner_secs = 60 * 60; // default to once an hour radioConfig.preferences.send_owner_secs = 60 * 60; // default to once an hour
radioConfig.preferences.position_broadcast_secs = 15 * 60; // default to once every 15 mins radioConfig.preferences.position_broadcast_secs = 15 * 60; // default to once every 15 mins
#ifdef GPS_RX_PIN #ifdef GPS_RX_PIN
@ -236,8 +236,8 @@ void NodeDB::updateFrom(const MeshPacket &mp)
if (oldNumNodes != *numNodes) if (oldNumNodes != *numNodes)
updateGUI = true; // we just created a nodeinfo updateGUI = true; // we just created a nodeinfo
if(mp.rx_time) // if the packet has a valid timestamp use it if (mp.rx_time) // if the packet has a valid timestamp use it
info->last_seen = mp.rx_time; info->last_seen = mp.rx_time;
switch (p.which_variant) switch (p.which_variant)
{ {
@ -247,13 +247,19 @@ void NodeDB::updateFrom(const MeshPacket &mp)
updateGUIforNode = info; updateGUIforNode = info;
break; break;
case SubPacket_data_tag: { case SubPacket_data_tag:
{
// Keep a copy of the most recent text message. // Keep a copy of the most recent text message.
if(p.variant.data.typ == Data_Type_CLEAR_TEXT) { if (p.variant.data.typ == Data_Type_CLEAR_TEXT)
{
DEBUG_MSG("Received text msg from=0%0x, msg=%.*s\n", mp.from, p.variant.data.payload.size, p.variant.data.payload.bytes); DEBUG_MSG("Received text msg from=0%0x, msg=%.*s\n", mp.from, p.variant.data.payload.size, p.variant.data.payload.bytes);
devicestate.rx_text_message = mp; if (mp.to == NODENUM_BROADCAST || mp.to == nodeDB.getNodeNum())
devicestate.has_rx_text_message = true; {
updateTextMessage = true; // We only store/display messages destined for us.
devicestate.rx_text_message = mp;
devicestate.has_rx_text_message = true;
updateTextMessage = true;
}
} }
break; break;
} }

View File

@ -47,6 +47,7 @@ public:
/// we updateGUI and updateGUIforNode if we think our this change is big enough for a redraw /// we updateGUI and updateGUIforNode if we think our this change is big enough for a redraw
void updateFrom(const MeshPacket &p); void updateFrom(const MeshPacket &p);
/// @return our node number
NodeNum getNodeNum() { return myNodeInfo.my_node_num; } NodeNum getNodeNum() { return myNodeInfo.my_node_num; }
size_t getNumNodes() { return *numNodes; } size_t getNumNodes() { return *numNodes; }

View File

@ -544,7 +544,8 @@ uint32_t screen_loop()
if (wakeScreen || nodeDB.updateTextMessage) // If a new text message arrived, turn the screen on immedately if (wakeScreen || nodeDB.updateTextMessage) // If a new text message arrived, turn the screen on immedately
{ {
screen_on(); // make sure the screen is not asleep lastPressMs = millis(); // if we were told to wake the screen, reset the press timeout
screen_on(); // make sure the screen is not asleep
wakeScreen = false; wakeScreen = false;
} }