Skip to content

Commit e4319bf

Browse files
committed
feat: global Bridge hardcoded Serial1 dependency
1 parent 17b41e3 commit e4319bf

File tree

3 files changed

+8
-21
lines changed

3 files changed

+8
-21
lines changed

README.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This is WIP. Expects changes soon.
88

99
Including Arduino_BridgeImola.h gives the user access to a Bridge object that can be used both as a RPC client and/or server to execute and serve RPCs to/from the CPU Host running a GOLANG router.
1010

11-
- The Bridge object is defined on Serial1
11+
- The Bridge object is pre-defined on Serial1 and automatically initialized inside the main setup()
1212
- The Bridge.call method is blocking and works the same as in RPClite
1313
- The Bridge can provide callbacks to incoming RPC requests both in a thread-unsafe and thread-safe fashion (provide & provide_safe)
1414
- Thread-safe methods execution is granted in the main loop thread where update_safe is called. By design users cannot access .update_safe() freely
@@ -28,19 +28,9 @@ String greet() {
2828
void setup() {
2929
Serial.begin(115200);
3030
while (!Serial);
31-
32-
Serial1.begin(115200);
33-
while (!Serial1);
3431

3532
pinMode(LED_BUILTIN, OUTPUT);
3633

37-
if (!Bridge.begin()) {
38-
Serial.println("Error initializing Bridge");
39-
while(1);
40-
} else {
41-
Serial.println("Bridge initialized successfully");
42-
}
43-
4434
if (!Bridge.provide("set_led", set_led)) {
4535
Serial.println("Error providing method: set_led");
4636
} else {

examples/simple_bridge/simple_bridge.ino

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,9 @@ String greet() {
1717
void setup() {
1818
Serial.begin(115200);
1919
while (!Serial);
20-
21-
Serial1.begin(115200);
22-
while (!Serial1);
2320

2421
pinMode(LED_BUILTIN, OUTPUT);
2522

26-
if (!Bridge.begin()) {
27-
Serial.println("Error initializing Bridge");
28-
while(1);
29-
} else {
30-
Serial.println("Bridge initialized successfully");
31-
}
32-
3323
if (!Bridge.provide("set_led", set_led)) {
3424
Serial.println("Error providing method: set_led");
3525
} else {

src/bridge.h

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

12+
#define SERIAL1_BAUD 115200
13+
1214
#include <zephyr/kernel.h>
1315
#include <Arduino_RPClite.h>
1416

@@ -169,6 +171,11 @@ static k_thread_stack_t *upd_stack_area;
169171
static struct k_thread upd_thread_data;
170172

171173
void __setupHook(){
174+
175+
Serial1.begin(SERIAL1_BAUD);
176+
177+
Bridge.begin();
178+
172179
upd_stack_area = k_thread_stack_alloc(UPDATE_THREAD_STACK_SIZE, 0);
173180
upd_tid = k_thread_create(&upd_thread_data, upd_stack_area,
174181
UPDATE_THREAD_STACK_SIZE,

0 commit comments

Comments
 (0)