Skip to content

Commit a923a97

Browse files
committed
feat: Bridge obj with configurable/default baud
1 parent 6fec689 commit a923a97

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/bridge.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#define UPDATE_THREAD_STACK_SIZE 500
1010
#define UPDATE_THREAD_PRIORITY 5
1111

12-
#define SERIAL1_BAUD 115200
12+
#define DEFAULT_SERIAL_BAUD 115200
1313

1414
#include <zephyr/kernel.h>
1515
#include <Arduino_RPClite.h>
@@ -19,20 +19,22 @@ class BridgeClass {
1919

2020
RPCClient* client = nullptr;
2121
RPCServer* server = nullptr;
22+
HardwareSerial* serial_ptr = nullptr;
2223
ITransport* transport;
2324

2425
struct k_mutex read_mutex;
2526
struct k_mutex write_mutex;
2627

2728
public:
28-
BridgeClass(ITransport& t) : transport(&t) {}
2929

30-
BridgeClass(Stream& stream) {
31-
transport = new SerialTransport(stream);
30+
BridgeClass(HardwareSerial& serial) {
31+
serial_ptr = &serial;
32+
transport = new SerialTransport(serial);
3233
}
3334

3435
// Initialize the bridge
35-
bool begin() {
36+
bool begin(unsigned long baud=DEFAULT_SERIAL_BAUD) {
37+
serial_ptr->begin(baud);
3638

3739
k_mutex_init(&read_mutex);
3840
k_mutex_init(&write_mutex);
@@ -174,8 +176,6 @@ static struct k_thread upd_thread_data;
174176

175177
void __setupHook(){
176178

177-
Serial1.begin(SERIAL1_BAUD);
178-
179179
Bridge.begin();
180180

181181
upd_stack_area = k_thread_stack_alloc(UPDATE_THREAD_STACK_SIZE, 0);

0 commit comments

Comments
 (0)