Skip to content

Commit 1c17713

Browse files
authored
Merge branch 'master' into asian-frequency-plans
2 parents 5ec6bf4 + c3d8a2a commit 1c17713

File tree

5 files changed

+11
-14
lines changed

5 files changed

+11
-14
lines changed

docs/TheThingsNetwork.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# API Reference
22

3-
The `TheThingsNetwork` class enables Arduino devices with supported LoRa modules to communicate via The Things Network.
3+
The `TheThingsNetwork` class enables Arduino devices with supported LoRaWAN modules to communicate via The Things Network. Currently supported LoRaWAN modules are the Microchip RN2483 and the RN2903.
44

55
## Class: `TheThingsNetwork`
66

7-
Include and instantiate the TheThingsNetwork class. The constructor initialize the library with the Streams it should communicate with. It also sets the value of the spreading factor, the front-side Bus and the frequency plan.
7+
Include and instantiate the TheThingsNetwork class. The constructor initialize the library with the Streams it should communicate with. It also sets the value of the spreading factor, the frequency plan and the frequency sub-band.
88

99
```c
1010
#include <TheThingsNetwork.h>
1111

1212
TheThingsNetwork ttn(Stream& modemStream, Stream& debugStream, fp_ttn_t fp, uint8_t sf = 7, uint8_t fsb = 2);
1313
```
1414
15-
- `Stream& modemStream`: Stream for the LoRa modem (for The Things Node/Uno use `Serial1` and data rate `57600`).
16-
- `Stream& debugStream`: Stream to write debug logs to (for The Things Node/Uno use `Serial` and data rate `9600`).
15+
- `Stream& modemStream`: Stream for the LoRa modem ([see notes](https://www.thethingsnetwork.org/docs/devices/arduino/usage.html)).
16+
- `Stream& debugStream`: Stream to write debug logs to ([see notes](https://www.thethingsnetwork.org/docs/devices/arduino/usage.html)).
1717
- `fp_ttn_fp fp`: The frequency plan: `TTN_FP_EU868`, `TTN_FP_US915`, `TTN_FP_AS920_923`, `TTN_FP_AS923_925` or `TTN_FP_KR920_923` depending on the region you deploy in. See [the wiki](https://www.thethingsnetwork.org/wiki/LoRaWAN/Frequencies/Frequency-Plans).
1818
- `uint8_t sf = 7`: Optional custom spreading factor. Can be `7` to `10` for `TTN_FP_US915` and `7` to `12` for other frequency plans. Defaults to `7`.
1919
- `uint8_t fsb = 2`: Optional custom frequency subband. Can be `1` to `8`. Defaults to `2` (for US915).
@@ -61,7 +61,6 @@ Band: 868
6161
Data Rate: 5
6262
RX Delay 1: 1000
6363
RX Delay 2: 2000
64-
Total airtime: 0.00 s
6564
```
6665

6766
See the [DeviceInfo](https://github.com/TheThingsNetwork/arduino-device-lib/blob/master/examples/DeviceInfo/DeviceInfo.ino) example.
@@ -140,8 +139,6 @@ Returns a success or error code and logs the related error message:
140139

141140
See the [Send](https://github.com/TheThingsNetwork/arduino-device-lib/blob/master/examples/Send/Send.ino) example.
142141

143-
Also in sendBytes, due to TTN's 30 second fair access policy, we update the airtime each time we uplink a message. This airtime is based on a lot of variables but the most important ones are the spreading factor and the size of the message, the higher it is the less messages you can send in 30 seconds (SF7 around 500 messages of 8 bytes, SF12 around 20 messages of 8 bytes).
144-
145142
## Method: `poll`
146143

147144
Calls `sendBytes()` with `{ 0x00 }` as payload to poll for incoming messages.

examples/TheThingsMessage/Receive/Receive.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ devicedata_t data = api_DeviceData_init_default;
1717

1818
void setup()
1919
{
20-
pinMode(TTN_PIN_LED, INPUT);
20+
pinMode(LED_BUILTIN, INPUT);
2121

2222
loraSerial.begin(57600);
2323
debugSerial.begin(9600);
@@ -41,7 +41,7 @@ void setup()
4141
void loop()
4242
{
4343
// Read sensors
44-
data.motion = digitalRead(TTN_PIN_LED) == HIGH;
44+
data.motion = digitalRead(LED_BUILTIN) == HIGH;
4545
data.water = 682;
4646

4747
// Encode data
@@ -63,4 +63,4 @@ void message(const uint8_t *payload, size_t length, port_t port)
6363
appdata_t appData = api_AppData_init_default;
6464
TheThingsMessage::decodeAppData(&appData, payload, length);
6565
}
66-
}
66+
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=TheThingsNetwork
2-
version=2.5.1
2+
version=2.5.2
33
author=The Things Network
44
maintainer=Johan Stokking <[email protected]>
55
sentence=The Things Network Arduino Library.

src/TheThingsMessage.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ bool TheThingsMessage::decodeAppData(appdata_t *receiveData, const byte *payload
1010
{
1111
return false;
1212
}
13-
receiveData->light ? digitalWrite(TTN_PIN_LED, HIGH) : digitalWrite(TTN_PIN_LED, LOW);
13+
#ifdef LED_BUILTIN
14+
receiveData->light ? digitalWrite(LED_BUILTIN, HIGH) : digitalWrite(LED_BUILTIN, LOW);
15+
#endif
1416
return true;
1517
}
1618

src/TheThingsMessage.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
#include "deviceData.pb.h"
1212
#include "appData.pb.h"
1313

14-
#define TTN_PIN_LED LED_BUILTIN
15-
1614
typedef api_DeviceData devicedata_t;
1715
typedef api_AppData appdata_t;
1816

0 commit comments

Comments
 (0)