Files
Meck/src/helpers/AbstractBridge.h
João Brázio 1948d284a0 Extract serial bridge into dedicated classes
This commit refactors the serial bridge functionality out of the `simple_repeater` example and into a more reusable, object-oriented structure.

An `AbstractBridge` interface has been introduced, along with a concrete `SerialBridge` implementation. This encapsulates all the logic for packet framing, checksum calculation, and serial communication, cleaning up the main example file significantly.

The `simple_repeater` example now instantiates and uses the `SerialBridge` class, resulting in better separation of concerns and improved code organization.
2025-09-04 23:43:05 +01:00

33 lines
724 B
C++

#pragma once
#include <Mesh.h>
class AbstractBridge {
public:
virtual ~AbstractBridge() {}
/**
* @brief Initializes the bridge.
*/
virtual void begin() = 0;
/**
* @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.
*
* @param packet The packet that was transmitted.
*/
virtual void onPacketTransmitted(mesh::Packet* packet) = 0;
/**
* @brief Processes a received packet from the bridge's medium.
*/
virtual void onPacketReceived() = 0;
};