2022-12-06 14:08:04 +01:00
|
|
|
#pragma once
|
|
|
|
|
#include "ProtobufModule.h"
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A module that traces the route to a certain destination node
|
|
|
|
|
*/
|
2023-01-21 18:22:19 +01:00
|
|
|
class TraceRouteModule : public ProtobufModule<meshtastic_RouteDiscovery>
|
2022-12-06 14:08:04 +01:00
|
|
|
{
|
2023-01-21 14:34:29 +01:00
|
|
|
public:
|
|
|
|
|
TraceRouteModule();
|
2022-12-06 14:08:04 +01:00
|
|
|
|
2023-01-21 14:34:29 +01:00
|
|
|
protected:
|
2023-01-21 18:22:19 +01:00
|
|
|
bool handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_RouteDiscovery *r) override;
|
2022-12-06 14:08:04 +01:00
|
|
|
|
2023-01-21 18:22:19 +01:00
|
|
|
virtual meshtastic_MeshPacket *allocReply() override;
|
2022-12-06 14:08:04 +01:00
|
|
|
|
2024-03-23 13:31:58 +01:00
|
|
|
/* Called before rebroadcasting a RouteDiscovery payload in order to update
|
2023-01-21 14:34:29 +01:00
|
|
|
the route array containing the IDs of nodes this packet went through */
|
2024-03-23 13:31:58 +01:00
|
|
|
void alterReceivedProtobuf(meshtastic_MeshPacket &p, meshtastic_RouteDiscovery *r) override;
|
2022-12-06 14:08:04 +01:00
|
|
|
|
2023-01-21 14:34:29 +01:00
|
|
|
private:
|
2024-06-09 23:03:53 +02:00
|
|
|
// Call to add unknown hops (e.g. when a node couldn't decrypt it) to the route based on hopStart and current hopLimit
|
2024-08-18 00:34:32 +02:00
|
|
|
void insertUnknownHops(meshtastic_MeshPacket &p, meshtastic_RouteDiscovery *r, bool isTowardsDestination);
|
2024-06-09 23:03:53 +02:00
|
|
|
|
2023-01-21 14:34:29 +01:00
|
|
|
// Call to add your ID to the route array of a RouteDiscovery message
|
2024-08-18 00:34:32 +02:00
|
|
|
void appendMyIDandSNR(meshtastic_RouteDiscovery *r, float snr, bool isTowardsDestination, bool SNRonly);
|
2022-12-06 14:08:04 +01:00
|
|
|
|
2023-01-21 14:34:29 +01:00
|
|
|
/* 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. */
|
2024-08-18 00:34:32 +02:00
|
|
|
void printRoute(meshtastic_RouteDiscovery *r, uint32_t origin, uint32_t dest, bool isTowardsDestination);
|
2022-12-06 14:08:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern TraceRouteModule *traceRouteModule;
|