Skip to content

Commit 54b4b43

Browse files
committed
Updated TheThingsNetwork documentation
1 parent aab3944 commit 54b4b43

File tree

1 file changed

+42
-19
lines changed

1 file changed

+42
-19
lines changed

docs/TheThingsNetwork.md

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# API Reference
2+
23
The `TheThingsNetwork` class enables Arduino devices with supported LoRa modules to communicate via The Things Network.
34

4-
## Class: TheThingsNetwork
5+
## Class: `TheThingsNetwork`
6+
57
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.
68

79
```c
@@ -16,7 +18,32 @@ TheThingsNetwork ttn(Stream& modemStream, Stream& debugStream, fp_ttn_t fp, uint
1618
- `uint8_t sf = 7`: Optional custom spreading factor. Can be `7` to `12` for `TTN_FP_EU868` and `7` to `12` for `TTN_FP_US915`. Defaults to `7`.
1719
- `uint8_t fsb = 2`: Optional custom front-side bus. Can be `1` to `8`. Defaults to `2`.
1820
19-
## Method: showStatus
21+
## Method: `reset`
22+
23+
Performs a software reset of the RN module. This does not clear saved state, e.g. provisioned keys.
24+
25+
```c
26+
void showStatus();
27+
```
28+
29+
## Method: `getHardwareEui`
30+
31+
Gets the unique hardware EUI, often used as the DevEUI.
32+
33+
```c
34+
size_t getHardwareEui(char *buffer, size_t size);
35+
```
36+
37+
## Method: `getAppEui`
38+
39+
Gets the provisioned AppEUI. The AppEUI is set using `provision()` or `join()`.
40+
41+
```c
42+
size_t getAppEui(char *buffer, size_t size);
43+
```
44+
45+
## Method: `showStatus`
46+
2047
Writes information about the device and LoRa module to `debugStream`.
2148

2249
```c
@@ -39,7 +66,8 @@ Total airtime: 0.00 s
3966

4067
See the [DeviceInfo](https://github.com/TheThingsNetwork/arduino-device-lib/blob/master/examples/DeviceInfo/DeviceInfo.ino) example.
4168

42-
## Method: onMessage
69+
## Method: `onMessage`
70+
4371
Sets a function which will be called to process incoming messages. You'll want to do this in your `setup()` function and then define a `void (*cb)(const byte* payload, size_t length, port_t port)` function somewhere else in your sketch.
4472

4573
```c
@@ -52,7 +80,8 @@ void onMessage(void (*cb)(const byte* payload, size_t length, port_t port));
5280
5381
See the [Receive](https://github.com/TheThingsNetwork/arduino-device-lib/blob/master/examples/Receive/Receive.ino) example.
5482
55-
## Method: join
83+
## Method: `join`
84+
5685
Activate the device via OTAA (default).
5786
5887
```c
@@ -69,7 +98,8 @@ Returns `true` or `false` depending on whether it received confirmation that the
6998

7099
Call the method without the first two arguments if the device's LoRa module comes with pre-flashed values.
71100

72-
## Method: personalize
101+
## Method: `personalize`
102+
73103
Activate the device via ABP.
74104

75105
```c
@@ -87,7 +117,8 @@ Call the method with no arguments if the device's LoRa module comes with pre-fla
87117
88118
See the [ABP](https://github.com/TheThingsNetwork/arduino-device-lib/blob/master/examples/ABP/ABP.ino) example.
89119
90-
## Method: sendBytes
120+
## Method: `sendBytes`
121+
91122
Send a message to the application using raw bytes.
92123
93124
```c
@@ -110,7 +141,8 @@ See the [Send](https://github.com/TheThingsNetwork/arduino-device-lib/blob/maste
110141

111142
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).
112143

113-
## Method: poll
144+
## Method: `poll`
145+
114146
Calls `sendBytes()` with `{ 0x00 }` as payload to poll for incoming messages.
115147

116148
```c
@@ -124,7 +156,8 @@ Returns the result of `sendBytes()`.
124156
125157
See the [Receive](https://github.com/TheThingsNetwork/arduino-device-lib/blob/master/examples/Receive/Receive.ino) example.
126158
127-
## Method: provision
159+
## Method: `provision`
160+
128161
Sets the information needed to activate the device via OTAA, without actually activating. Call join() without the first 2 arguments to activate.
129162
130163
```c
@@ -134,18 +167,8 @@ bool provision(const char *appEui, const char *appKey);
134167
- `const char *appEui`: Application Identifier for the device.
135168
- `const char *appKey`: Application Key assigned to the device.
136169

137-
## Method: calculateAirtime
138-
Calculate the uplink time of a message.
139-
140-
```c
141-
float calculateAirtime(size_t payloadSize);
142-
```
143-
144-
- `size_t payloadSize`: number of bytes you want to send.
145-
146-
Returns the uplink time of the message in seconds.
170+
## Method: `sleep`
147171

148-
## Method: sleep
149172
Sleep the LoRa module for a specified number of milliseconds.
150173

151174
```c

0 commit comments

Comments
 (0)