-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.ino
50 lines (37 loc) · 818 Bytes
/
client.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "globals.h"
#include <TaskScheduler.h>
#ifdef useServo
#include "servo.h"
#endif
Scheduler scheduler;
void setup() {
Serial.begin(9600);
loRa_setup(freq, sf, cs, rst, irq, key);
#ifdef useServo
servo_setup(&scheduler);
#endif
}
void loop() {
String loRaMessage = loRa_receiveMessage();
if (loRaMessage != "") {
Serial.print(loRaMessage);
if (loRaMessage != "1") {
String message = "";
#ifdef useServo
servo_interact(loRaMessage);
message = "1";
#endif
if (message != "") {
loRa_sendMessage(message);
}
}
}
String serialMessage = "";
if (Serial.available()) {
serialMessage = Serial.readString();
if (serialMessage) {
loRa_sendMessage(serialMessage);
}
}
scheduler.execute();
}