Refactor bridge implementations to inherit from BridgeBase

This commit is contained in:
João Brázio
2025-09-08 02:03:08 +01:00
parent 537449e6af
commit 0051ccef26
7 changed files with 282 additions and 155 deletions

View File

@@ -2,8 +2,7 @@
#include "MeshCore.h"
#include "esp_now.h"
#include "helpers/AbstractBridge.h"
#include "helpers/SimpleMeshTables.h"
#include "helpers/bridges/BridgeBase.h"
#ifdef WITH_ESPNOW_BRIDGE
@@ -44,21 +43,12 @@
* WITH_ESPNOW_BRIDGE_SECRET values. Packets encrypted with a different key will
* fail the checksum validation and be discarded.
*/
class ESPNowBridge : public AbstractBridge {
class ESPNowBridge : public BridgeBase {
private:
static ESPNowBridge *_instance;
static void recv_cb(const uint8_t *mac, const uint8_t *data, int32_t len);
static void send_cb(const uint8_t *mac, esp_now_send_status_t status);
/** Packet manager for allocating and queuing mesh packets */
mesh::PacketManager *_mgr;
/** RTC clock for timestamping debug messages */
mesh::RTCClock *_rtc;
/** Tracks seen packets to prevent loops in broadcast communications */
SimpleMeshTables _seen_packets;
/**
* ESP-NOW Protocol Structure:
* - ESP-NOW header: 20 bytes (handled by ESP-NOW protocol)
@@ -168,14 +158,6 @@ public:
* @param packet The mesh packet to transmit
*/
void onPacketTransmitted(mesh::Packet *packet) override;
/**
* Gets formatted date/time string for logging
* Format: "HH:MM:SS - DD/MM/YYYY U"
*
* @return Formatted date/time string
*/
const char *getLogDateTime();
};
#endif