-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathLoRa.ino
45 lines (38 loc) · 781 Bytes
/
LoRa.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
#include <stdint.h>
#include "Arduino.h"
#include "CaLoRa.h"
#define SERIAL_BAUDRATE 9600
CaLoRa *caLoRa;
void recv_callback(uint8_t* message, int length){
Serial.println((char*)message);
}
void setup()
{
// Wait for serial port to be available
Serial.begin(SERIAL_BAUDRATE);
while (!Serial) ;
Serial.println("Serial started");
// initialize CaLoRa
caLoRa = new CaLoRa(recv_callback);
if(!caLoRa->init()) {
Serial.println("LoRa init failed");
exit(0);
}
}
/*
* application loop
* -
*/
void loop()
{
/* application codes
* - delay() function should not be used in main loop
*
* ex)
* haveSomethingToSend = getSensorData();
* if (haveSomethingToSend)
* caLoRa->send((uint8_t*)"test", sizeof("test"));
*/
// LoRa loop
caLoRa->oneLoop();
}