Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/simple_repeater/MyMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
#endif

#ifdef WITH_RS232_BRIDGE
#ifdef WITH_USB_SERIAL_BRIDGE
#include <Adafruit_TinyUSB.h>
extern Adafruit_USBD_CDC bridgeSerial;
#endif
#include "helpers/bridges/RS232Bridge.h"
#define WITH_BRIDGE
#endif
Expand Down
8 changes: 8 additions & 0 deletions examples/simple_repeater/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

#include "MyMesh.h"

#ifdef WITH_USB_SERIAL_BRIDGE
Adafruit_USBD_CDC bridgeSerial;
#endif

#ifdef DISPLAY_CLASS
#include "UITask.h"
static UITask ui_task(display);
Expand Down Expand Up @@ -36,6 +40,10 @@ static unsigned long userBtnDownAt = 0;
#endif

void setup() {
#ifdef WITH_USB_SERIAL_BRIDGE
// Register the second CDC interface before Serial mounts the USB device.
bridgeSerial.begin(115200);
#endif
Serial.begin(115200);
delay(1000);

Expand Down
12 changes: 12 additions & 0 deletions src/helpers/bridges/RS232Bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@

#include <HardwareSerial.h>

#ifdef WITH_USB_SERIAL_BRIDGE
#include <Adafruit_TinyUSB.h>
#endif

#ifdef WITH_RS232_BRIDGE

RS232Bridge::RS232Bridge(NodePrefs *prefs, Stream &serial, mesh::PacketManager *mgr, mesh::RTCClock *rtc)
: BridgeBase(prefs, mgr, rtc), _serial(&serial) {}

void RS232Bridge::begin() {
BRIDGE_DEBUG_PRINTLN("Initializing at %d baud...\n", _prefs->bridge_baud);
#ifdef WITH_USB_SERIAL_BRIDGE
static_cast<Adafruit_USBD_CDC*>(_serial)->begin(_prefs->bridge_baud);
#else
#if !defined(WITH_RS232_BRIDGE_RX) || !defined(WITH_RS232_BRIDGE_TX)
#error "WITH_RS232_BRIDGE_RX and WITH_RS232_BRIDGE_TX must be defined"
#endif
Expand All @@ -28,14 +35,19 @@ void RS232Bridge::begin() {
#error RS232Bridge was not tested on the current platform
#endif
((HardwareSerial *)_serial)->begin(_prefs->bridge_baud);
#endif

// Update bridge state
_initialized = true;
}

void RS232Bridge::end() {
BRIDGE_DEBUG_PRINTLN("Stopping...\n");
#ifdef WITH_USB_SERIAL_BRIDGE
static_cast<Adafruit_USBD_CDC*>(_serial)->end();
#else
((HardwareSerial *)_serial)->end();
#endif

// Update bridge state
_initialized = false;
Expand Down
19 changes: 19 additions & 0 deletions variants/rak4631/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,25 @@ build_src_filter = ${rak4631.build_src_filter}
+<helpers/bridges/RS232Bridge.cpp>
+<../examples/simple_repeater>

[env:RAK_4631_repeater_bridge_usbserial]
extends = rak4631
build_flags =
${rak4631.build_flags}
-D DISPLAY_CLASS=SSD1306Display
-D ADVERT_NAME='"USB Bridge"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=50
-D WITH_RS232_BRIDGE=bridgeSerial
-D WITH_USB_SERIAL_BRIDGE
-D CFG_TUD_CDC=2
-UENV_INCLUDE_GPS
build_src_filter = ${rak4631.build_src_filter}
+<helpers/ui/SSD1306Display.cpp>
+<helpers/bridges/RS232Bridge.cpp>
+<../examples/simple_repeater>

[env:RAK_4631_repeater_bridge_rs232_serial2]
extends = rak4631
build_flags =
Expand Down
16 changes: 16 additions & 0 deletions variants/sensecap_solar/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ build_flags =
build_src_filter = ${SenseCap_Solar.build_src_filter}
+<../examples/simple_repeater/*.cpp>

[env:SenseCap_Solar_repeater_bridge_usbserial]
extends = SenseCap_Solar
build_flags =
${SenseCap_Solar.build_flags}
-D ADVERT_NAME='"SenseCap Solar USB Bridge"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=50
-D WITH_RS232_BRIDGE=bridgeSerial
-D WITH_USB_SERIAL_BRIDGE
-D CFG_TUD_CDC=2
build_src_filter = ${SenseCap_Solar.build_src_filter}
+<helpers/bridges/RS232Bridge.cpp>
+<../examples/simple_repeater/*.cpp>

[env:SenseCap_Solar_room_server]
extends = SenseCap_Solar
build_flags =
Expand Down