AbstractBridge.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #include <Mesh.h>
  3. class AbstractBridge {
  4. public:
  5. virtual ~AbstractBridge() {}
  6. /**
  7. * @brief Initializes the bridge.
  8. */
  9. virtual void begin() = 0;
  10. /**
  11. * @brief Stops the bridge.
  12. */
  13. virtual void end() = 0;
  14. /**
  15. * @brief Gets the current state of the bridge.
  16. *
  17. * @return true if the bridge is initialized and running, false otherwise.
  18. */
  19. virtual bool isRunning() const = 0;
  20. /**
  21. * @brief A method to be called on every main loop iteration.
  22. * Used for tasks like checking for incoming data.
  23. */
  24. virtual void loop() = 0;
  25. /**
  26. * @brief A callback that is triggered when the mesh transmits a packet.
  27. * The bridge can use this to forward the packet.
  28. *
  29. * @param packet The packet that was transmitted.
  30. */
  31. virtual void sendPacket(mesh::Packet* packet) = 0;
  32. /**
  33. * @brief Processes a received packet from the bridge's medium.
  34. *
  35. * @param packet The packet that was received.
  36. */
  37. virtual void onPacketReceived(mesh::Packet* packet) = 0;
  38. };