Update last_sent_by_id in FloodingRouter

This commit is contained in:
GUVWAF
2023-06-08 20:02:36 +02:00
parent 5c438ae792
commit 66c71250b8
4 changed files with 34 additions and 6 deletions

View File

@@ -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;