Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4094c20

Browse files
First: Add initial example
This is just minimal and incomplete example.
1 parent 86e81e0 commit 4094c20

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

examples/First/First.ino

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include <STM32LoRaWAN.h>
2+
#include <BSP/mw_log_conf.h>
3+
4+
STM32LoRaWAN modem;
5+
6+
static const unsigned long TX_INTERVAL = 60000; /* ms */
7+
unsigned long last_tx = 0;
8+
9+
void setup() {
10+
Serial.begin(115200);
11+
Serial.println("Start");
12+
modem.begin();
13+
modem.dataRate(0); // 0 == slowest == most range
14+
15+
modem.joinOTAA(/* AppEui */ "0000000000000000", /* AppKey */ "00000000000000000000000000000000", /* DevEui */ "0000000000000000");
16+
//modem.joinABP(/* DevAddr */ "00000000", /* NwkSKey */ "00000000000000000000000000000000", /* AppSKey */ "00000000000000000000000000000000");
17+
18+
while(!modem.connected())
19+
modem.poll();
20+
21+
Serial.println("Joined");
22+
}
23+
24+
void send_packet() {
25+
uint8_t payload[] = {0xde, 0xad, 0xbe, 0xef};
26+
modem.send(payload, sizeof(payload), /* port */ 10, /* confirmed */ false);
27+
}
28+
29+
void loop() {
30+
modem.poll();
31+
32+
if (!last_tx || millis() - last_tx > TX_INTERVAL) {
33+
send_packet();
34+
last_tx = millis();
35+
}
36+
}

0 commit comments

Comments
 (0)