diff --git a/docs/software/TODO.md b/docs/software/TODO.md index 50796ef1b..ac5c2d337 100644 --- a/docs/software/TODO.md +++ b/docs/software/TODO.md @@ -9,10 +9,9 @@ For app cleanup: * DONE check build guide * DONE write devapi user guide * DONE update android code: https://developer.android.com/topic/libraries/view-binding/migration -* only do wantReplies once per packet type, if we change network settings force it again * test GPIO watch * writeup docs on gpio -* make python ping command +* DONE make python ping command * DONE make hello world example service * DONE have python tool check max packet size before sending to device * DONE if request was sent reliably, send reply reliably @@ -32,6 +31,7 @@ For app cleanup: * DONE test that position, text messages and user info work properly with new android app and old device code * do UDP tunnel * fix the RTC drift bug +* only do wantReplies once per packet type, if we change network settings force it again * move python ping functionality into device, reply with rxsnr info * use channels for gpio security https://github.com/meshtastic/Meshtastic-device/issues/104 * generate autodocs diff --git a/src/mesh/DSRRouter.cpp b/src/mesh/DSRRouter.cpp index f1ec32e32..d8ca542d7 100644 --- a/src/mesh/DSRRouter.cpp +++ b/src/mesh/DSRRouter.cpp @@ -170,7 +170,7 @@ bool DSRRouter::weAreInRoute(const RouteDiscovery &route) **/ void DSRRouter::updateRoutes(const RouteDiscovery &route, bool isRequest) { - DEBUG_MSG("FIXME not implemented"); + DEBUG_MSG("FIXME not implemented updateRoutes\n"); } /** @@ -178,7 +178,7 @@ void DSRRouter::updateRoutes(const RouteDiscovery &route, bool isRequest) */ void DSRRouter::sendRouteReply(const RouteDiscovery &route, NodeNum toAppend) { - DEBUG_MSG("FIXME not implemented"); + DEBUG_MSG("FIXME not implemented sendRoute\n"); } /** @@ -188,7 +188,7 @@ void DSRRouter::sendRouteReply(const RouteDiscovery &route, NodeNum toAppend) */ NodeNum DSRRouter::getNextHop(NodeNum dest) { - DEBUG_MSG("FIXME not implemented"); + DEBUG_MSG("FIXME not implemented getNextHop\n"); return 0; } @@ -198,7 +198,7 @@ NodeNum DSRRouter::getNextHop(NodeNum dest) */ void DSRRouter::resendRouteRequest(const MeshPacket *p) { - DEBUG_MSG("FIXME not implemented"); + DEBUG_MSG("FIXME not implemented resendRoute\n"); } /** @@ -208,7 +208,7 @@ void DSRRouter::resendRouteRequest(const MeshPacket *p) */ void DSRRouter::addRoute(NodeNum dest, NodeNum forwarder, uint8_t numHops) { - DEBUG_MSG("FIXME not implemented"); + DEBUG_MSG("FIXME not implemented addRoute\n"); } /** @@ -216,7 +216,7 @@ void DSRRouter::addRoute(NodeNum dest, NodeNum forwarder, uint8_t numHops) */ void DSRRouter::removeRoute(NodeNum dest) { - DEBUG_MSG("FIXME not implemented"); + DEBUG_MSG("FIXME not implemented removeRoute\n"); } /** @@ -224,7 +224,7 @@ void DSRRouter::removeRoute(NodeNum dest) */ void DSRRouter::sendNextHop(NodeNum n, const MeshPacket *p) { - DEBUG_MSG("FIXME not implemented"); + DEBUG_MSG("FIXME not implemented sendNextHop\n"); } /** @@ -232,7 +232,7 @@ void DSRRouter::sendNextHop(NodeNum n, const MeshPacket *p) */ void DSRRouter::sendRouteError(const MeshPacket *p, RouteError err) { - DEBUG_MSG("FIXME not implemented"); + DEBUG_MSG("FIXME not implemented sendRouteError\n"); } /** make a copy of p, start discovery, but only if we don't @@ -241,5 +241,5 @@ void DSRRouter::sendRouteError(const MeshPacket *p, RouteError err) */ void DSRRouter::startDiscovery(NodeNum dest) { - DEBUG_MSG("FIXME not implemented"); + DEBUG_MSG("FIXME not implemented startDiscovery\n"); } \ No newline at end of file diff --git a/src/mesh/FloodingRouter.cpp b/src/mesh/FloodingRouter.cpp index ffd652bf8..db3355582 100644 --- a/src/mesh/FloodingRouter.cpp +++ b/src/mesh/FloodingRouter.cpp @@ -38,8 +38,7 @@ void FloodingRouter::sniffReceived(const MeshPacket *p) tosend->hop_limit--; // bump down the hop count - DEBUG_MSG("Rebroadcasting received floodmsg to neighbors, fr=0x%x,to=0x%x,id=%d,hop_limit=%d\n", p->from, p->to, - p->id, tosend->hop_limit); + printPacket("Rebroadcasting received floodmsg to neighbors", p); // Note: we are careful to resend using the original senders node id // We are careful not to call our hooked version of send() - because we don't want to check this again Router::send(tosend); diff --git a/src/mesh/MeshPlugin.cpp b/src/mesh/MeshPlugin.cpp index e2a6bf289..ebaee49a6 100644 --- a/src/mesh/MeshPlugin.cpp +++ b/src/mesh/MeshPlugin.cpp @@ -27,11 +27,14 @@ MeshPlugin::~MeshPlugin() void MeshPlugin::callPlugins(const MeshPacket &mp) { // DEBUG_MSG("In call plugins\n"); + bool pluginFound = false; for (auto i = plugins->begin(); i != plugins->end(); ++i) { auto &pi = **i; pi.currentRequest = ∓ if (pi.wantPortnum(mp.decoded.data.portnum)) { + pluginFound = true; + bool handled = pi.handleReceived(mp); // Possibly send replies @@ -42,11 +45,12 @@ void MeshPlugin::callPlugins(const MeshPacket &mp) if (handled) break; } - else { - DEBUG_MSG("Plugin %s not interested\n", pi.name); - } + pi.currentRequest = NULL; } + + if(!pluginFound) + DEBUG_MSG("No plugins interested in portnum=%d\n", mp.decoded.data.portnum); } /** Messages can be received that have the want_response bit set. If set, this callback will be invoked diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index c3ae6930f..999526de2 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -96,9 +96,9 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) if (!available()) { // DEBUG_MSG("getFromRadio, !available\n"); return false; - } else { - DEBUG_MSG("getFromRadio, state=%d\n", state); - } + } + + DEBUG_MSG("getFromRadio, state=%d\n", state); // In case we send a FromRadio packet memset(&fromRadioScratch, 0, sizeof(fromRadioScratch)); @@ -162,6 +162,9 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) case STATE_SEND_PACKETS: // Do we have a message from the mesh? if (packetForPhone) { + + printPacket("phone downloaded packet", packetForPhone); + // Encapsulate as a FromRadio packet fromRadioScratch.which_variant = FromRadio_packet_tag; fromRadioScratch.variant.packet = *packetForPhone; diff --git a/src/mesh/ProtobufPlugin.h b/src/mesh/ProtobufPlugin.h index cda4ed8bf..a5c0aea15 100644 --- a/src/mesh/ProtobufPlugin.h +++ b/src/mesh/ProtobufPlugin.h @@ -55,11 +55,11 @@ template class ProtobufPlugin : private SinglePortPlugin // it would be better to update even if the message was destined to others. auto &p = mp.decoded.data; - DEBUG_MSG("Received %s from=0x%0x, id=%d, payloadlen=%d\n", name, mp.from, mp.id, p.payload.size); + DEBUG_MSG("Received %s from=0x%0x, id=0x%x, payloadlen=%d\n", name, mp.from, mp.id, p.payload.size); T scratch; if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, fields, &scratch)) - handleReceivedProtobuf(mp, scratch); + return handleReceivedProtobuf(mp, scratch); return false; // Let others look at this message also if they want } diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index a1bbc5c4d..f52fd7c2d 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -123,7 +123,7 @@ void printPacket(const char *prefix, const MeshPacket *p) auto &s = p->decoded; switch (s.which_payload) { case SubPacket_data_tag: - DEBUG_MSG(" Payload:Data"); + DEBUG_MSG(" Portnum=%d", s.data.portnum); break; case SubPacket_position_tag: DEBUG_MSG(" Payload:Position"); diff --git a/src/mesh/ReliableRouter.cpp b/src/mesh/ReliableRouter.cpp index bbbb52386..93402c127 100644 --- a/src/mesh/ReliableRouter.cpp +++ b/src/mesh/ReliableRouter.cpp @@ -92,7 +92,7 @@ void ReliableRouter::sendAckNak(bool isAck, NodeNum to, PacketId idFrom) auto p = allocForSending(); p->hop_limit = 0; // Assume just immediate neighbors for now p->to = to; - DEBUG_MSG("Sending an ack=0x%x,to=0x%x,idFrom=%d,id=%d\n", isAck, to, idFrom, p->id); + DEBUG_MSG("Sending an ack=0x%x,to=0x%x,idFrom=0x%x,id=0x%x\n", isAck, to, idFrom, p->id); if (isAck) { p->decoded.ack.success_id = idFrom; diff --git a/src/plugins/RemoteHardwarePlugin.cpp b/src/plugins/RemoteHardwarePlugin.cpp index dee93363f..e9f25e51a 100644 --- a/src/plugins/RemoteHardwarePlugin.cpp +++ b/src/plugins/RemoteHardwarePlugin.cpp @@ -51,6 +51,8 @@ RemoteHardwarePlugin::RemoteHardwarePlugin() bool RemoteHardwarePlugin::handleReceivedProtobuf(const MeshPacket &req, const HardwareMessage &p) { + DEBUG_MSG("Received RemoteHardware typ=%d\n", p.typ); + switch (p.typ) { case HardwareMessage_Type_WRITE_GPIOS: // Print notification to LCD screen @@ -87,6 +89,7 @@ bool RemoteHardwarePlugin::handleReceivedProtobuf(const MeshPacket &req, const H lastWatchMsec = 0; // Force a new publish soon previousWatch = ~watchGpios; // generate a 'previous' value which is guaranteed to not match (to force an initial publish) enabled = true; // Let our thread run at least once + DEBUG_MSG("Now watching GPIOs 0x%x\n", watchGpios); break; } @@ -98,6 +101,7 @@ bool RemoteHardwarePlugin::handleReceivedProtobuf(const MeshPacket &req, const H DEBUG_MSG("Hardware operation %d not yet implemented! FIXME\n", p.typ); break; } + return true; // handled } @@ -110,6 +114,7 @@ int32_t RemoteHardwarePlugin::runOnce() { if(curVal != previousWatch) { previousWatch = curVal; + DEBUG_MSG("Broadcasting GPIOS 0x%x changed!\n", curVal); // Something changed! Tell the world with a broadcast message HardwareMessage reply = HardwareMessage_init_default;