2025-09-04 23:43:05 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <Mesh.h>
|
|
|
|
|
|
|
|
|
|
class AbstractBridge {
|
|
|
|
|
public:
|
|
|
|
|
virtual ~AbstractBridge() {}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Initializes the bridge.
|
|
|
|
|
*/
|
|
|
|
|
virtual void begin() = 0;
|
|
|
|
|
|
2025-09-24 16:30:00 +01:00
|
|
|
/**
|
|
|
|
|
* @brief Stops the bridge.
|
|
|
|
|
*/
|
|
|
|
|
virtual void end() = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Gets the current state of the bridge.
|
|
|
|
|
*
|
|
|
|
|
* @return true if the bridge is initialized and running, false otherwise.
|
|
|
|
|
*/
|
|
|
|
|
virtual bool getState() const = 0;
|
|
|
|
|
|
2025-09-04 23:43:05 +01:00
|
|
|
/**
|
|
|
|
|
* @brief A method to be called on every main loop iteration.
|
|
|
|
|
* Used for tasks like checking for incoming data.
|
|
|
|
|
*/
|
|
|
|
|
virtual void loop() = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief A callback that is triggered when the mesh transmits a packet.
|
|
|
|
|
* The bridge can use this to forward the packet.
|
2025-09-24 16:30:00 +01:00
|
|
|
*
|
2025-09-04 23:43:05 +01:00
|
|
|
* @param packet The packet that was transmitted.
|
|
|
|
|
*/
|
2025-10-03 00:20:09 +01:00
|
|
|
virtual void sendPacket(mesh::Packet* packet) = 0;
|
2025-09-04 23:43:05 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Processes a received packet from the bridge's medium.
|
2025-09-24 16:30:00 +01:00
|
|
|
*
|
2025-09-05 01:50:50 +01:00
|
|
|
* @param packet The packet that was received.
|
2025-09-04 23:43:05 +01:00
|
|
|
*/
|
2025-09-05 01:50:50 +01:00
|
|
|
virtual void onPacketReceived(mesh::Packet* packet) = 0;
|
2025-09-04 23:43:05 +01:00
|
|
|
};
|