From 0cdc1fc959ebcbda8b08b0534dc118e34e284329 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Sun, 13 Dec 2020 16:11:38 +0800 Subject: [PATCH] make gpiowatch work correctly --- src/mesh/Router.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 9ea3cceb..458a338f 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -93,19 +93,28 @@ MeshPacket *Router::allocForSending() p->to = NODENUM_BROADCAST; p->hop_limit = HOP_RELIABLE; p->id = generatePacketId(); - p->rx_time = getValidTime(RTCQualityFromNet); // Just in case we process the packet locally - make sure it has a valid timestamp + p->rx_time = + getValidTime(RTCQualityFromNet); // Just in case we process the packet locally - make sure it has a valid timestamp return p; } ErrorCode Router::sendLocal(MeshPacket *p) { + // No need to deliver externally if the destination is the local node if (p->to == nodeDB.getNodeNum()) { - DEBUG_MSG("Enqueuing internal message for the receive queue\n"); + printPacket("Enqueuing local", p); fromRadioQueue.enqueue(p); return ERRNO_OK; - } else - return send(p); + } + + // If we are sending a broadcast, we also treat it as if we just received it ourself + // this allows local apps (and PCs) to see broadcasts sourced locally + if (p->to == NODENUM_BROADCAST) { + handleReceived(p); + } + + return send(p); } /**