You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/TheThingsNetwork.md
+42-19Lines changed: 42 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,9 @@
1
1
# API Reference
2
+
2
3
The `TheThingsNetwork` class enables Arduino devices with supported LoRa modules to communicate via The Things Network.
3
4
4
-
## Class: TheThingsNetwork
5
+
## Class: `TheThingsNetwork`
6
+
5
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.
- `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`.
17
19
- `uint8_t fsb = 2`: Optional custom front-side bus. Can be `1` to `8`. Defaults to `2`.
18
20
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_tgetHardwareEui(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
+
20
47
Writes information about the device and LoRa module to `debugStream`.
21
48
22
49
```c
@@ -39,7 +66,8 @@ Total airtime: 0.00 s
39
66
40
67
See the [DeviceInfo](https://github.com/TheThingsNetwork/arduino-device-lib/blob/master/examples/DeviceInfo/DeviceInfo.ino) example.
41
68
42
-
## Method: onMessage
69
+
## Method: `onMessage`
70
+
43
71
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.
See the [Receive](https://github.com/TheThingsNetwork/arduino-device-lib/blob/master/examples/Receive/Receive.ino) example.
54
82
55
-
## Method: join
83
+
## Method: `join`
84
+
56
85
Activate the device via OTAA (default).
57
86
58
87
```c
@@ -69,7 +98,8 @@ Returns `true` or `false` depending on whether it received confirmation that the
69
98
70
99
Call the method without the first two arguments if the device's LoRa module comes with pre-flashed values.
71
100
72
-
## Method: personalize
101
+
## Method: `personalize`
102
+
73
103
Activate the device via ABP.
74
104
75
105
```c
@@ -87,7 +117,8 @@ Call the method with no arguments if the device's LoRa module comes with pre-fla
87
117
88
118
See the [ABP](https://github.com/TheThingsNetwork/arduino-device-lib/blob/master/examples/ABP/ABP.ino) example.
89
119
90
-
## Method: sendBytes
120
+
## Method: `sendBytes`
121
+
91
122
Send a message to the application using raw bytes.
92
123
93
124
```c
@@ -110,7 +141,8 @@ See the [Send](https://github.com/TheThingsNetwork/arduino-device-lib/blob/maste
110
141
111
142
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).
112
143
113
-
## Method: poll
144
+
## Method: `poll`
145
+
114
146
Calls `sendBytes()` with `{ 0x00 }` as payload to poll for incoming messages.
115
147
116
148
```c
@@ -124,7 +156,8 @@ Returns the result of `sendBytes()`.
124
156
125
157
See the [Receive](https://github.com/TheThingsNetwork/arduino-device-lib/blob/master/examples/Receive/Receive.ino) example.
126
158
127
-
## Method: provision
159
+
## Method: `provision`
160
+
128
161
Sets the information needed to activate the device via OTAA, without actually activating. Call join() without the first 2 arguments to activate.
0 commit comments