mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-20 17:52:35 +00:00
Update last_sent_by_id in FloodingRouter
This commit is contained in:
@@ -174,11 +174,29 @@ bool NeighborInfoModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp,
|
||||
{
|
||||
printNeighborInfo("RECIEVED", np);
|
||||
updateNeighbors(mp, np);
|
||||
np->last_sent_by_id = nodeDB.getNodeNum();
|
||||
// Allow others to handle this packet
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
Copy the content of a current NeighborInfo packet into a new one and update the last_sent_by_id to our NodeNum
|
||||
*/
|
||||
void NeighborInfoModule::updateLastSentById(meshtastic_MeshPacket *p)
|
||||
{
|
||||
auto &incoming = p->decoded;
|
||||
meshtastic_NeighborInfo scratch;
|
||||
meshtastic_NeighborInfo *updated = NULL;
|
||||
memset(&scratch, 0, sizeof(scratch));
|
||||
pb_decode_from_bytes(incoming.payload.bytes, incoming.payload.size, &meshtastic_NeighborInfo_msg, &scratch);
|
||||
updated = &scratch;
|
||||
|
||||
updated->last_sent_by_id = nodeDB.getNodeNum();
|
||||
|
||||
// Set updated last_sent_by_id to the payload of the to be flooded packet
|
||||
p->decoded.payload.size =
|
||||
pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes), &meshtastic_NeighborInfo_msg, updated);
|
||||
}
|
||||
|
||||
void NeighborInfoModule::resetNeighbors()
|
||||
{
|
||||
neighborState.neighbors_count = 0;
|
||||
|
||||
Reference in New Issue
Block a user