2022-12-06 13:08:04 +00:00
|
|
|
#pragma once
|
|
|
|
#include "ProtobufModule.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A module that traces the route to a certain destination node
|
|
|
|
*/
|
2023-01-21 17:22:19 +00:00
|
|
|
class TraceRouteModule : public ProtobufModule<meshtastic_RouteDiscovery>
|
2022-12-06 13:08:04 +00:00
|
|
|
{
|
2023-01-21 13:34:29 +00:00
|
|
|
public:
|
|
|
|
TraceRouteModule();
|
2022-12-06 13:08:04 +00:00
|
|
|
|
2023-01-21 13:34:29 +00:00
|
|
|
// Let FloodingRouter call updateRoute upon rebroadcasting a TraceRoute request
|
|
|
|
friend class FloodingRouter;
|
2022-12-06 13:08:04 +00:00
|
|
|
|
2023-01-21 13:34:29 +00:00
|
|
|
protected:
|
2023-01-21 17:22:19 +00:00
|
|
|
bool handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_RouteDiscovery *r) override;
|
2022-12-06 13:08:04 +00:00
|
|
|
|
2023-01-21 17:22:19 +00:00
|
|
|
virtual meshtastic_MeshPacket *allocReply() override;
|
2022-12-06 13:08:04 +00:00
|
|
|
|
2023-01-21 13:34:29 +00:00
|
|
|
/* Call before rebroadcasting a RouteDiscovery payload in order to update
|
|
|
|
the route array containing the IDs of nodes this packet went through */
|
2023-01-21 17:22:19 +00:00
|
|
|
void updateRoute(meshtastic_MeshPacket *p);
|
2022-12-06 13:08:04 +00:00
|
|
|
|
2023-01-21 13:34:29 +00:00
|
|
|
private:
|
|
|
|
// Call to add your ID to the route array of a RouteDiscovery message
|
2023-01-21 17:22:19 +00:00
|
|
|
void appendMyID(meshtastic_RouteDiscovery *r);
|
2022-12-06 13:08:04 +00:00
|
|
|
|
2023-01-21 13:34:29 +00: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. */
|
2023-01-21 17:22:19 +00:00
|
|
|
void printRoute(meshtastic_RouteDiscovery *r, uint32_t origin, uint32_t dest);
|
2022-12-06 13:08:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern TraceRouteModule *traceRouteModule;
|