mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-09 06:32:06 +00:00
Fix for nodeInfo change to inform phone
This commit is contained in:
parent
320bf57687
commit
f0c4c18a79
@ -689,11 +689,11 @@ void NodeDB::updateTelemetry(uint32_t nodeId, const meshtastic_Telemetry &t, RxS
|
|||||||
|
|
||||||
/** Update user info for this node based on received user data
|
/** Update user info for this node based on received user data
|
||||||
*/
|
*/
|
||||||
void NodeDB::updateUser(uint32_t nodeId, const meshtastic_User &p)
|
bool NodeDB::updateUser(uint32_t nodeId, const meshtastic_User &p)
|
||||||
{
|
{
|
||||||
meshtastic_NodeInfo *info = getOrCreateNode(nodeId);
|
meshtastic_NodeInfo *info = getOrCreateNode(nodeId);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_DEBUG("old user %s/%s/%s\n", info->user.id, info->user.long_name, info->user.short_name);
|
LOG_DEBUG("old user %s/%s/%s\n", info->user.id, info->user.long_name, info->user.short_name);
|
||||||
@ -713,6 +713,8 @@ void NodeDB::updateUser(uint32_t nodeId, const meshtastic_User &p)
|
|||||||
// We just changed something important about the user, store our DB
|
// We just changed something important about the user, store our DB
|
||||||
saveToDisk(SEGMENT_DEVICESTATE);
|
saveToDisk(SEGMENT_DEVICESTATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// given a subpacket sniffed from the network, update our DB state
|
/// given a subpacket sniffed from the network, update our DB state
|
||||||
|
@ -86,7 +86,7 @@ class NodeDB
|
|||||||
|
|
||||||
/** Update user info for this node based on received user data
|
/** Update user info for this node based on received user data
|
||||||
*/
|
*/
|
||||||
void updateUser(uint32_t nodeId, const meshtastic_User &p);
|
bool updateUser(uint32_t nodeId, const meshtastic_User &p);
|
||||||
|
|
||||||
/// @return our node number
|
/// @return our node number
|
||||||
NodeNum getNodeNum() { return myNodeInfo.my_node_num; }
|
NodeNum getNodeNum() { return myNodeInfo.my_node_num; }
|
||||||
|
@ -12,7 +12,7 @@ bool NodeInfoModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes
|
|||||||
{
|
{
|
||||||
auto p = *pptr;
|
auto p = *pptr;
|
||||||
|
|
||||||
nodeDB.updateUser(getFrom(&mp), p);
|
bool hasChanged = nodeDB.updateUser(getFrom(&mp), p);
|
||||||
|
|
||||||
bool wasBroadcast = mp.to == NODENUM_BROADCAST;
|
bool wasBroadcast = mp.to == NODENUM_BROADCAST;
|
||||||
|
|
||||||
@ -23,6 +23,10 @@ bool NodeInfoModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes
|
|||||||
screen->print(lcd.c_str());
|
screen->print(lcd.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if user has changed while packet was not for us, inform phone
|
||||||
|
if (hasChanged && !wasBroadcast && mp.to != nodeDB.getNodeNum())
|
||||||
|
service.sendToPhone(packetPool.allocCopy(mp));
|
||||||
|
|
||||||
// LOG_DEBUG("did handleReceived\n");
|
// LOG_DEBUG("did handleReceived\n");
|
||||||
return false; // Let others look at this message also if they want
|
return false; // Let others look at this message also if they want
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user