mirror of
https://github.com/meshtastic/firmware.git
synced 2025-07-30 02:15:41 +00:00

Some checks are pending
CI / setup (check) (push) Waiting to run
CI / setup (esp32) (push) Waiting to run
CI / setup (esp32c3) (push) Waiting to run
CI / setup (esp32c6) (push) Waiting to run
CI / setup (esp32s3) (push) Waiting to run
CI / setup (nrf52840) (push) Waiting to run
CI / setup (rp2040) (push) Waiting to run
CI / setup (stm32) (push) Waiting to run
CI / version (push) Waiting to run
CI / check (push) Blocked by required conditions
CI / build-esp32 (push) Blocked by required conditions
CI / build-esp32s3 (push) Blocked by required conditions
CI / build-esp32c3 (push) Blocked by required conditions
CI / build-esp32c6 (push) Blocked by required conditions
CI / build-nrf52840 (push) Blocked by required conditions
CI / build-rpi2040 (push) Blocked by required conditions
CI / build-stm32 (push) Blocked by required conditions
CI / build-debian-src (push) Waiting to run
CI / package-pio-deps-native-tft (push) Waiting to run
CI / test-native (push) Waiting to run
CI / docker-deb-amd64 (push) Waiting to run
CI / docker-deb-amd64-tft (push) Waiting to run
CI / docker-alp-amd64 (push) Waiting to run
CI / docker-alp-amd64-tft (push) Waiting to run
CI / docker-deb-arm64 (push) Waiting to run
CI / docker-deb-armv7 (push) Waiting to run
CI / gather-artifacts (esp32) (push) Blocked by required conditions
CI / gather-artifacts (esp32c3) (push) Blocked by required conditions
CI / gather-artifacts (esp32c6) (push) Blocked by required conditions
CI / gather-artifacts (esp32s3) (push) Blocked by required conditions
CI / gather-artifacts (nrf52840) (push) Blocked by required conditions
CI / gather-artifacts (rp2040) (push) Blocked by required conditions
CI / gather-artifacts (stm32) (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
CI / release-firmware (esp32) (push) Blocked by required conditions
CI / release-firmware (esp32c3) (push) Blocked by required conditions
CI / release-firmware (esp32c6) (push) Blocked by required conditions
CI / release-firmware (esp32s3) (push) Blocked by required conditions
CI / release-firmware (nrf52840) (push) Blocked by required conditions
CI / release-firmware (rp2040) (push) Blocked by required conditions
CI / release-firmware (stm32) (push) Blocked by required conditions
CI / publish-firmware (push) Blocked by required conditions
* Add TraceRoute function to menus and modules to support node path tracing * Adjust text spacing and line wrapping logic in trace route result result. * Add HAS_SCREEN for TraceRouteModule drawFrame. --------- Co-authored-by: Tom Fifield <tom@tomfifield.net> Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
73 lines
2.8 KiB
C++
73 lines
2.8 KiB
C++
#pragma once
|
|
#include "ProtobufModule.h"
|
|
#include "concurrency/OSThread.h"
|
|
#include "graphics/Screen.h"
|
|
#include "graphics/SharedUIDisplay.h"
|
|
#include "input/InputBroker.h"
|
|
#if HAS_SCREEN
|
|
#include "OLEDDisplayUi.h"
|
|
#endif
|
|
|
|
#define ROUTE_SIZE sizeof(((meshtastic_RouteDiscovery *)0)->route) / sizeof(((meshtastic_RouteDiscovery *)0)->route[0])
|
|
|
|
/**
|
|
* A module that traces the route to a certain destination node
|
|
*/
|
|
enum TraceRouteRunState { TRACEROUTE_STATE_IDLE, TRACEROUTE_STATE_TRACKING, TRACEROUTE_STATE_RESULT, TRACEROUTE_STATE_COOLDOWN };
|
|
|
|
class TraceRouteModule : public ProtobufModule<meshtastic_RouteDiscovery>,
|
|
public Observable<const UIFrameEvent *>,
|
|
private concurrency::OSThread
|
|
{
|
|
public:
|
|
TraceRouteModule();
|
|
|
|
bool startTraceRoute(NodeNum node);
|
|
void launch(NodeNum node);
|
|
void handleTraceRouteResult(const String &result);
|
|
bool shouldDraw();
|
|
#if HAS_SCREEN
|
|
virtual void drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) override;
|
|
#endif
|
|
|
|
const char *getNodeName(NodeNum node);
|
|
|
|
virtual bool wantUIFrame() override { return shouldDraw(); }
|
|
virtual Observable<const UIFrameEvent *> *getUIFrameObservable() override { return this; }
|
|
|
|
protected:
|
|
bool handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_RouteDiscovery *r) override;
|
|
|
|
virtual meshtastic_MeshPacket *allocReply() override;
|
|
|
|
/* Called before rebroadcasting a RouteDiscovery payload in order to update
|
|
the route array containing the IDs of nodes this packet went through */
|
|
void alterReceivedProtobuf(meshtastic_MeshPacket &p, meshtastic_RouteDiscovery *r) override;
|
|
|
|
virtual int32_t runOnce() override;
|
|
|
|
private:
|
|
// Call to add unknown hops (e.g. when a node couldn't decrypt it) to the route based on hopStart and current hopLimit
|
|
void insertUnknownHops(meshtastic_MeshPacket &p, meshtastic_RouteDiscovery *r, bool isTowardsDestination);
|
|
|
|
// Call to add your ID to the route array of a RouteDiscovery message
|
|
void appendMyIDandSNR(meshtastic_RouteDiscovery *r, float snr, bool isTowardsDestination, bool SNRonly);
|
|
|
|
/* Call to print the route array of a RouteDiscovery message.
|
|
Set origin to where the request came from.
|
|
Set dest to the ID of its destination, or NODENUM_BROADCAST if it has not yet arrived there. */
|
|
void printRoute(meshtastic_RouteDiscovery *r, uint32_t origin, uint32_t dest, bool isTowardsDestination);
|
|
|
|
TraceRouteRunState runState = TRACEROUTE_STATE_IDLE;
|
|
unsigned long lastTraceRouteTime = 0;
|
|
unsigned long resultShowTime = 0;
|
|
unsigned long cooldownMs = 30000;
|
|
unsigned long resultDisplayMs = 10000;
|
|
unsigned long trackingTimeoutMs = 10000;
|
|
String bannerText;
|
|
String resultText;
|
|
NodeNum tracingNode = 0;
|
|
bool initialized = false;
|
|
};
|
|
|
|
extern TraceRouteModule *traceRouteModule; |