Skip to content

Commit e35183a

Browse files
author
Scott Powell
committed
Merge branch 'dev' into rep-room-acl
# Conflicts: # examples/simple_repeater/main.cpp
2 parents 08f91f8 + 5344f04 commit e35183a

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

examples/simple_repeater/MyMesh.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ void MyMesh::logRx(mesh::Packet *pkt, int len, float score) {
208208

209209
void MyMesh::logTx(mesh::Packet *pkt, int len) {
210210
#ifdef WITH_BRIDGE
211-
bridge->onPacketTransmitted(pkt);
211+
bridge.onPacketTransmitted(pkt);
212212
#endif
213213
if (_logging) {
214214
File f = openAppend(PACKET_LOG_FILE);
@@ -473,16 +473,13 @@ bool MyMesh::onPeerPathRecv(mesh::Packet *packet, int sender_idx, const uint8_t
473473
MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondClock &ms, mesh::RNG &rng,
474474
mesh::RTCClock &rtc, mesh::MeshTables &tables)
475475
: mesh::Mesh(radio, ms, rng, rtc, *new StaticPoolPacketManager(32), tables),
476-
_cli(board, rtc, &_prefs, this), telemetry(MAX_PACKET_PAYLOAD - 4) {
477-
#ifdef WITH_BRIDGE
476+
_cli(board, rtc, &_prefs, this), telemetry(MAX_PACKET_PAYLOAD - 4)
478477
#if defined(WITH_RS232_BRIDGE)
479-
bridge = new RS232Bridge(WITH_RS232_BRIDGE, _mgr, &rtc);
478+
, bridge(WITH_RS232_BRIDGE, _mgr, &rtc)
480479
#elif defined(WITH_ESPNOW_BRIDGE)
481-
bridge = new ESPNowBridge(_mgr, &rtc);
482-
#else
483-
#error "You must choose either RS232 or ESPNow bridge"
484-
#endif
480+
, bridge(_mgr, &rtc)
485481
#endif
482+
{
486483
memset(known_clients, 0, sizeof(known_clients));
487484
next_local_advert = next_flood_advert = 0;
488485
set_radio_at = revert_radio_at = 0;
@@ -518,6 +515,10 @@ void MyMesh::begin(FILESYSTEM *fs) {
518515
// load persisted prefs
519516
_cli.loadPrefs(_fs);
520517

518+
#ifdef WITH_BRIDGE
519+
bridge.begin();
520+
#endif
521+
521522
radio_set_params(_prefs.freq, _prefs.bw, _prefs.sf, _prefs.cr);
522523
radio_set_tx_power(_prefs.tx_power_dbm);
523524

@@ -668,7 +669,7 @@ void MyMesh::handleCommand(uint32_t sender_timestamp, char *command, char *reply
668669

669670
void MyMesh::loop() {
670671
#ifdef WITH_BRIDGE
671-
bridge->loop();
672+
bridge.loop();
672673
#endif
673674

674675
mesh::Mesh::loop();

examples/simple_repeater/MyMesh.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
102102
uint8_t pending_sf;
103103
uint8_t pending_cr;
104104
int matching_peer_indexes[MAX_CLIENTS];
105+
#if defined(WITH_RS232_BRIDGE)
106+
RS232Bridge bridge;
107+
#elif defined(WITH_ESPNOW_BRIDGE)
108+
ESPNowBridge bridge;
109+
#endif
105110

106111
ClientInfo* putClient(const mesh::Identity& id);
107112
void putNeighbour(const mesh::Identity& id, uint32_t timestamp, float snr);

examples/simple_repeater/main.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
static UITask ui_task(display);
99
#endif
1010

11-
#ifdef WITH_BRIDGE
12-
AbstractBridge* bridge;
13-
#endif
14-
1511
StdRNG fast_rng;
1612
SimpleMeshTables tables;
1713

@@ -27,10 +23,6 @@ void setup() {
2723
Serial.begin(115200);
2824
delay(1000);
2925

30-
#ifdef WITH_BRIDGE
31-
bridge->begin();
32-
#endif
33-
3426
board.begin();
3527

3628
#ifdef DISPLAY_CLASS

0 commit comments

Comments
 (0)