Skip to content

Commit 0ea7fb7

Browse files
authored
Create desired.ino
WIP
0 parents  commit 0ea7fb7

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

desired.ino

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Bridge.begin(); <- statica nel loader di zephyr / core
2+
// -> rpc.call("$/reset", res);
3+
4+
void setup() {
5+
pinMode(LED_BUILTIN, OUTPUT);
6+
7+
if (!Bridge.provide("set_led", set_led)) { // -> rpc.call("$/register", res, "set_led");
8+
// ERRORE!
9+
};
10+
Bridge.provide("add", add); // -> rpc.call("$/register", res, "add");
11+
// ERRORE ignorato
12+
Bridge.provide("greet", greet); // -> rpc.call("$/register", res, "greet");
13+
14+
// metodi forniti con provide possono ricevere anche notifiche (semplicemente il risultato non viene restituito)
15+
}
16+
17+
bool set_led(bool state) {
18+
digitalWrite(LED_BUILTIN, state);
19+
return state;
20+
}
21+
22+
int add(int a, int b) {
23+
return a + b;
24+
}
25+
26+
String greet() {
27+
return String("Hello Friend");
28+
}
29+
30+
void loop() {
31+
float res;
32+
if (!Bridge.call("multiply", res, 1.0, 2.0)) {
33+
// ERRORE!
34+
};
35+
36+
Bridge.notify("signal", 200);
37+
38+
// update viene chiamato automaticamente in un thread separato
39+
// Bridge.update(); -> server.run();
40+
}

0 commit comments

Comments
 (0)