-
Notifications
You must be signed in to change notification settings - Fork 0
/
arduino_lora_boilerplate.ino
50 lines (39 loc) · 1.01 KB
/
arduino_lora_boilerplate.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
50
/************** lora_boilerplate ***************
* Simple skeleton to interface with a
* Reyax RYLR896 Serial LoRa module
* Jon Wallace 2020
*/
#include "secrets.h"
#include "lora.h"
void setup() {
Serial.begin(115200);
lora_reset();
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
char next = Serial.read();
process_character(next);
}
void process_response() {
switch (parse_response()) {
case RES_READY:
Serial.print("AT+CPIN=" SECRET "\r\n");
lora_initialized = true;
break;
case RES_ERR: print_error(); break;
case RES_OK: Serial.println("RES_OK"); break;
case RES_RCV:
process_rcv();
Serial.print("Incoming: ");
Serial.print(res_buff);
Serial.print("\r\n");
send("AT+SEND=0,4,PONG\r\n");
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
break;
case UNKNOWN_RESPONSE:
Serial.print("UNKNOWN_RESPONSE: ");
Serial.print(res_buff);
break;
default: break;
}
}