diff --git a/src/modules/NeighborInfoModule.cpp b/src/modules/NeighborInfoModule.cpp index 97dc170019..d204e5be95 100644 --- a/src/modules/NeighborInfoModule.cpp +++ b/src/modules/NeighborInfoModule.cpp @@ -101,12 +101,12 @@ void NeighborInfoModule::cleanUpNeighbors() } /* Send neighbor info to the mesh */ -void NeighborInfoModule::sendNeighborInfo(NodeNum dest, bool wantReplies) +void NeighborInfoModule::sendNeighborInfo(NodeNum dest, bool wantReplies, bool sendEmpty) { meshtastic_NeighborInfo neighborInfo = meshtastic_NeighborInfo_init_zero; collectNeighborInfo(&neighborInfo); // only send neighbours if we have some to send - if (neighborInfo.neighbors_count > 0) { + if (neighborInfo.neighbors_count > 0 or sendEmpty) { meshtastic_MeshPacket *p = allocDataProtobuf(neighborInfo); p->to = dest; p->decoded.want_response = wantReplies; @@ -138,6 +138,7 @@ Pass it to an upper client; do not persist this data on the mesh */ bool NeighborInfoModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_NeighborInfo *np) { + LOG_DEBUG("NeighborInfo: handleRecievedProtobuf"); if (np) { printNeighborInfo("RECEIVED", np); updateNeighbors(mp, np); @@ -145,6 +146,11 @@ bool NeighborInfoModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, // If the hopLimit is the same as hopStart, then it is a neighbor getOrCreateNeighbor(mp.from, mp.from, 0, mp.rx_snr); // Set the broadcast interval to 0, as we don't know it } + if (mp.decoded.want_response && np->neighbors_count == 0) { // want response, and is otherwise empty. + LOG_INFO("NeighborInfoRequested."); + sendNeighborInfo(mp.from, false, true); // do we want this to be dm, or broadcast? + // sendNeighborInfo(NODENUM_BROADCAST, false); // do we want this to be dm, or broadcast? + } // Allow others to handle this packet return false; } @@ -168,6 +174,7 @@ void NeighborInfoModule::resetNeighbors() void NeighborInfoModule::updateNeighbors(const meshtastic_MeshPacket &mp, const meshtastic_NeighborInfo *np) { + LOG_DEBUG("updateNeighbors"); // The last sent ID will be 0 if the packet is from the phone, which we don't count as // an edge. So we assume that if it's zero, then this packet is from our node. if (mp.which_payload_variant == meshtastic_MeshPacket_decoded_tag && mp.from) { diff --git a/src/modules/NeighborInfoModule.h b/src/modules/NeighborInfoModule.h index aa76a21871..6d23b4f224 100644 --- a/src/modules/NeighborInfoModule.h +++ b/src/modules/NeighborInfoModule.h @@ -48,7 +48,7 @@ class NeighborInfoModule : public ProtobufModule, priva /* * Send info on our node's neighbors into the mesh */ - void sendNeighborInfo(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false); + void sendNeighborInfo(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false, bool sendEmpty = false); /* update neighbors with subpacket sniffed from network */ void updateNeighbors(const meshtastic_MeshPacket &mp, const meshtastic_NeighborInfo *np);