@@ -124,10 +124,6 @@ struct ClientInfo {
124
124
#define MAX_CLIENTS 32
125
125
#endif
126
126
127
- #ifdef WITH_BRIDGE
128
- AbstractBridge* bridge;
129
- #endif
130
-
131
127
struct NeighbourInfo {
132
128
mesh::Identity id;
133
129
uint32_t advert_timestamp;
@@ -154,6 +150,11 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
154
150
float pending_bw;
155
151
uint8_t pending_sf;
156
152
uint8_t pending_cr;
153
+ #if defined(WITH_RS232_BRIDGE)
154
+ RS232Bridge bridge;
155
+ #elif defined(WITH_ESPNOW_BRIDGE)
156
+ ESPNowBridge bridge;
157
+ #endif
157
158
158
159
ClientInfo* putClient (const mesh::Identity& id) {
159
160
uint32_t min_time = 0xFFFFFFFF ;
@@ -315,7 +316,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
315
316
}
316
317
void logTx (mesh::Packet* pkt, int len) override {
317
318
#ifdef WITH_BRIDGE
318
- bridge-> onPacketTransmitted (pkt);
319
+ bridge. onPacketTransmitted (pkt);
319
320
#endif
320
321
if (_logging) {
321
322
File f = openAppend (PACKET_LOG_FILE);
@@ -581,16 +582,12 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
581
582
MyMesh (mesh::MainBoard& board, mesh::Radio& radio, mesh::MillisecondClock& ms, mesh::RNG& rng, mesh::RTCClock& rtc, mesh::MeshTables& tables)
582
583
: mesh::Mesh(radio, ms, rng, rtc, *new StaticPoolPacketManager(32 ), tables),
583
584
_cli (board, rtc, &_prefs, this ), telemetry(MAX_PACKET_PAYLOAD - 4 )
584
- {
585
- #ifdef WITH_BRIDGE
586
585
#if defined(WITH_RS232_BRIDGE)
587
- bridge = new RS232Bridge (WITH_RS232_BRIDGE, _mgr, &rtc);
586
+ , bridge (WITH_RS232_BRIDGE, _mgr, &rtc)
588
587
#elif defined(WITH_ESPNOW_BRIDGE)
589
- bridge = new ESPNowBridge (_mgr, &rtc);
590
- #else
591
- #error "You must choose either RS232 or ESPNow bridge"
592
- #endif
588
+ , bridge(_mgr, &rtc)
593
589
#endif
590
+ {
594
591
memset (known_clients, 0 , sizeof (known_clients));
595
592
next_local_advert = next_flood_advert = 0 ;
596
593
set_radio_at = revert_radio_at = 0 ;
@@ -626,6 +623,10 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
626
623
// load persisted prefs
627
624
_cli.loadPrefs (_fs);
628
625
626
+ #ifdef WITH_BRIDGE
627
+ bridge.begin ();
628
+ #endif
629
+
629
630
radio_set_params (_prefs.freq , _prefs.bw , _prefs.sf , _prefs.cr );
630
631
radio_set_tx_power (_prefs.tx_power_dbm );
631
632
@@ -792,7 +793,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
792
793
793
794
void loop () {
794
795
#ifdef WITH_BRIDGE
795
- bridge-> loop ();
796
+ bridge. loop ();
796
797
#endif
797
798
798
799
mesh::Mesh::loop ();
@@ -843,10 +844,6 @@ void setup() {
843
844
Serial.begin (115200 );
844
845
delay (1000 );
845
846
846
- #ifdef WITH_BRIDGE
847
- bridge->begin ();
848
- #endif
849
-
850
847
board.begin ();
851
848
852
849
#ifdef DISPLAY_CLASS
0 commit comments