Skip to content

Commit 5029b1c

Browse files
committed
Update smooth-scroll, move Arduino v2 guide to current, update Uno current guide, Catch pull status errors, closes TheThingsNetwork#101
1 parent 34d6985 commit 5029b1c

30 files changed

+428
-661
lines changed

Gemfile.lock

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,39 @@ GEM
1111
coffee-script (2.4.1)
1212
coffee-script-source
1313
execjs
14-
coffee-script-source (1.10.0)
15-
colorator (0.1)
14+
coffee-script-source (1.11.1)
15+
colorator (1.1.0)
1616
colored (1.2)
1717
ethon (0.9.0)
1818
ffi (>= 1.3.0)
1919
execjs (2.7.0)
20-
faraday (0.9.2)
20+
faraday (0.10.0)
2121
multipart-post (>= 1.2, < 3)
2222
ffi (1.9.14)
23+
forwardable-extended (2.6.0)
2324
gemoji (2.1.0)
24-
github-pages (91)
25+
github-pages (104)
2526
activesupport (= 4.2.7)
2627
github-pages-health-check (= 1.2.0)
27-
jekyll (= 3.1.6)
28+
jekyll (= 3.3.0)
29+
jekyll-avatar (= 0.4.2)
2830
jekyll-coffeescript (= 1.0.1)
29-
jekyll-feed (= 0.5.1)
31+
jekyll-feed (= 0.8.0)
3032
jekyll-gist (= 1.4.0)
31-
jekyll-github-metadata (= 2.0.2)
32-
jekyll-mentions (= 1.1.3)
33+
jekyll-github-metadata (= 2.2.0)
34+
jekyll-mentions (= 1.2.0)
3335
jekyll-paginate (= 1.1.0)
3436
jekyll-redirect-from (= 0.11.0)
3537
jekyll-sass-converter (= 1.3.0)
36-
jekyll-seo-tag (= 2.0.0)
37-
jekyll-sitemap (= 0.10.0)
38+
jekyll-seo-tag (= 2.1.0)
39+
jekyll-sitemap (= 0.12.0)
40+
jekyll-swiss (= 0.4.0)
3841
jemoji (= 0.7.0)
3942
kramdown (= 1.11.1)
4043
liquid (= 3.0.6)
4144
listen (= 3.0.6)
4245
mercenary (~> 0.3)
46+
minima (= 2.0.0)
4347
rouge (= 1.11.1)
4448
terminal-table (~> 1.4)
4549
github-pages-health-check (1.2.0)
@@ -61,34 +65,42 @@ GEM
6165
typhoeus (~> 0.7)
6266
yell (~> 2.0)
6367
i18n (0.7.0)
64-
jekyll (3.1.6)
65-
colorator (~> 0.1)
68+
jekyll (3.3.0)
69+
addressable (~> 2.4)
70+
colorator (~> 1.0)
6671
jekyll-sass-converter (~> 1.0)
6772
jekyll-watch (~> 1.1)
6873
kramdown (~> 1.3)
6974
liquid (~> 3.0)
7075
mercenary (~> 0.3.3)
76+
pathutil (~> 0.9)
7177
rouge (~> 1.7)
7278
safe_yaml (~> 1.0)
79+
jekyll-avatar (0.4.2)
80+
jekyll (~> 3.0)
7381
jekyll-coffeescript (1.0.1)
7482
coffee-script (~> 2.2)
75-
jekyll-feed (0.5.1)
83+
jekyll-feed (0.8.0)
84+
jekyll (~> 3.3)
7685
jekyll-gist (1.4.0)
7786
octokit (~> 4.2)
78-
jekyll-github-metadata (2.0.2)
87+
jekyll-github-metadata (2.2.0)
7988
jekyll (~> 3.1)
80-
octokit (~> 4.0)
81-
jekyll-mentions (1.1.3)
89+
octokit (~> 4.0, != 4.4.0)
90+
jekyll-mentions (1.2.0)
91+
activesupport (~> 4.0)
8292
html-pipeline (~> 2.3)
8393
jekyll (~> 3.0)
8494
jekyll-paginate (1.1.0)
8595
jekyll-redirect-from (0.11.0)
8696
jekyll (>= 2.0)
8797
jekyll-sass-converter (1.3.0)
8898
sass (~> 3.2)
89-
jekyll-seo-tag (2.0.0)
90-
jekyll (~> 3.1)
91-
jekyll-sitemap (0.10.0)
99+
jekyll-seo-tag (2.1.0)
100+
jekyll (~> 3.3)
101+
jekyll-sitemap (0.12.0)
102+
jekyll (~> 3.3)
103+
jekyll-swiss (0.4.0)
92104
jekyll-watch (1.5.0)
93105
listen (~> 3.0, < 3.1)
94106
jemoji (0.7.0)
@@ -104,40 +116,50 @@ GEM
104116
rb-inotify (>= 0.9.7)
105117
mercenary (0.3.6)
106118
mini_portile2 (2.1.0)
119+
minima (2.0.0)
107120
minitest (5.9.0)
108121
multipart-post (2.0.0)
109122
net-dns (0.8.0)
110123
nokogiri (1.6.8)
111124
mini_portile2 (~> 2.1.0)
112125
pkg-config (~> 1.1.7)
113-
octokit (4.3.0)
114-
sawyer (~> 0.7.0, >= 0.5.3)
126+
octokit (4.6.2)
127+
sawyer (~> 0.8.0, >= 0.5.3)
115128
parallel (1.9.0)
129+
pathutil (0.14.0)
130+
forwardable-extended (~> 2.6)
116131
pkg-config (1.1.7)
117132
public_suffix (1.5.3)
118-
rb-fsevent (0.9.7)
133+
rake (10.5.0)
134+
rake-jekyll (1.1.0)
135+
rake (~> 10.0)
136+
rb-fsevent (0.9.8)
119137
rb-inotify (0.9.7)
120138
ffi (>= 0.5.0)
121139
rouge (1.11.1)
122140
safe_yaml (1.0.4)
123141
sass (3.4.22)
124-
sawyer (0.7.0)
125-
addressable (>= 2.3.5, < 2.5)
126-
faraday (~> 0.8, < 0.10)
127-
terminal-table (1.6.0)
142+
sawyer (0.8.1)
143+
addressable (>= 2.3.5, < 2.6)
144+
faraday (~> 0.8, < 1.0)
145+
terminal-table (1.7.3)
146+
unicode-display_width (~> 1.1.1)
128147
thread_safe (0.3.5)
129148
typhoeus (0.8.0)
130149
ethon (>= 0.8.0)
131150
tzinfo (1.2.2)
132151
thread_safe (~> 0.1)
152+
unicode-display_width (1.1.1)
133153
yell (2.0.6)
134154

135155
PLATFORMS
136156
ruby
137157

138158
DEPENDENCIES
139-
github-pages
159+
github-pages (= 104)
140160
html-proofer
161+
rake
162+
rake-jekyll
141163

142164
BUNDLED WITH
143165
1.12.5

_includes/current/arduino.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ sections:
55
- arduino/_ide.md
66
- arduino/_usage.md
77
- arduino/_api.md
8+
- arduino/_bytes.md
89
- arduino/_examples.md
910
- arduino/_resources.md
1011
redirect_from:
11-
- /arduino/
12+
- /refactor/arduino/
13+
- /v2-preview/arduino/
1214
---
1315

1416
[Arduino](https://www.arduino.cc/en/Guide/Introduction) is an open-source electronics platform based on easy-to-use hardware and software. It's intended for anyone making interactive projects.
@@ -17,8 +19,6 @@ With [The Things Network Library](https://github.com/thethingsnetwork/arduino-de
1719

1820
## Prerequisites
1921

20-
* Access to [staging.thethingsnetwork.org](https://staging.thethingsnetwork.org/).
22+
* A staging or preview account.
2123
* Arduino board with [Microchip RN2xx3 module](http://www.microchip.com/design-centers/wireless-connectivity/embedded-wireless/lora-technology) for LoRaWAN.
22-
* Version 0.x of the [The Things Network Arduino Library](https://github.com/thethingsnetwork/arduino-device-lib).
23-
24-
> Since version 0.17, the library now has its [own repository](https://github.com/thethingsnetwork/arduino-device-lib), can be installed via the [Library Manager](https://www.arduino.cc/en/Guide/Libraries#toc3) and has been renamed from `TheThingsUno` to `TheThingsNetwork`. I guess it should have been bumped to 1.x - oops! 😝
24+
* Version 1.x of the [The Things Network Arduino Library](https://github.com/thethingsnetwork/arduino-device-lib).

_includes/current/arduino/_api.md

Lines changed: 74 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,24 @@
1+
<!-- EDIT AT https://github.com/TheThingsNetwork/arduino-device-lib/blob/master/docs/TheThingsNetwork.md -->
2+
13
# API Reference
4+
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.
25

3-
Include TheThingsNetwork library:
6+
## Class: TheThingsNetwork
47

58
```c
69
#include <TheThingsNetwork.h>
7-
```
8-
9-
## Method: reset
10-
Reset the LoRaWAN module. In most cases you'd call this with no arguments before calling `init()`.
11-
12-
```c
13-
void reset(bool adr = true, int sf = DEFAULT_SF, int fsb = DEFAULT_FSB);
14-
```
1510

16-
- `bool adr = true` **TODO**
17-
- `int sf = DEFAULT_SF` **TODO**
18-
- `int fsb = DEFAULT_FSB` **TODO**
19-
20-
## Method: init
21-
Initialize the library with the streams it should communicate with.
22-
23-
```c
24-
void init(Stream& modemStream, Stream& debugStream);
11+
TheThingsNetwork ttn(Stream& modemStream, Stream& debugStream, fp_ttn_t fp, uint8_t sf = 7, uint8_t fsb = 2);
2512
```
2613
27-
- `Stream& modemStream`: Stream to the LoRaWAN modem.
28-
- `Stream& debugStream`: Stream to write debug logs to.
29-
30-
For The Things Uno and Node use `Serial1` and `Serial`.
14+
- `Stream& modemStream`: Stream for the LoRa modem (for The Things Node/Uno use `Serial1` and data rate `57600`).
15+
- `Stream& debugStream`: Stream to write debug logs to (for The Things Node/Uno use `Serial` and data rate `9600`).
16+
- `fp_ttn_fp fp`: The frequency plan: `TTN_FP_EU868` or `TTN_FP_US915` depending on the region you deploy in.
17+
- `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`.
18+
- `uint8_t fsb = 2`: Optional custom front-side bus. Can be `1` to `8`. Defaults to `2`.
3119
3220
## Method: showStatus
33-
Writes information about the device and LoRaWAN module to `debugStream`.
21+
Writes information about the device and LoRa module to `debugStream`.
3422
3523
```c
3624
void showStatus();
@@ -39,96 +27,111 @@ void showStatus();
3927
Will write something like:
4028

4129
```bash
42-
Device Information
43-
44-
EUI: 0004A30B001B672E
45-
Battery: 3304
46-
AppEUI: 0000000000000000
47-
DevEUI: 0004A30B001B672E
48-
DevAddr: 00000000
30+
EUI: 0004A30B001B7AD2
31+
Battery: 3223
32+
AppEUI: 70B3D57EF000001C
33+
DevEUI: 0004A30B001B7AD2
34+
Band: 868
4935
Data Rate: 5
5036
RX Delay 1: 1000
5137
RX Delay 2: 2000
52-
53-
use the device `EUI` to register the device for OTAA
38+
Total airtime: 0.00 s
5439
```
5540

56-
## Method: join
57-
Activate the device via OTAA.
41+
See the [DeviceInfo](https://github.com/TheThingsNetwork/arduino-device-lib/blob/master/examples/DeviceInfo/DeviceInfo.ino) example.
42+
43+
## Method: onMessage
44+
Sets a function which will be called to process incoming messages.
5845

5946
```c
60-
bool join(const byte appEui[8], const byte appKey[16]);
47+
void onMessage(void (*cb)(const byte* payload, size_t length, port_t port));
6148
```
6249
63-
- `const byte appEui[8]`: Application EUI the device is registered to.
64-
- `const byte appKey[16]`: Application Key assigned to the device.
50+
- `const byte* payload`: Bytes received.
51+
- `size_t length`: Number of bytes.
52+
- `port_t port`: The port addressed.
53+
54+
See the [Receive](https://github.com/TheThingsNetwork/arduino-device-lib/blob/master/examples/Receive/Receive.ino) example.
6555
66-
Returns `true` or `false` depending on whether it received confirmation that the activation was successful. You'll probably call this method in a while to retry until it returns true:
56+
## Method: join
57+
Activate the device via OTAA (default).
6758
6859
```c
69-
while (!ttn.join(appEui, appKey)) {
70-
delay(10000);
71-
}
60+
bool join(const char *appEui, const char *appKey, int8_t retries = -1, uint32_t retryDelay = 10000);
61+
bool join(int8_t retries = -1, uint32_t retryDelay = 10000);
7262
```
7363

74-
See [Library Usage / Activate](#activate).
64+
- `const char *appEui`: Application EUI the device is registered to.
65+
- `const char *appKey`: Application Key assigned to the device.
66+
- `int8_t retries = -1`: Number of times to retry after failed or unconfirmed join. Defaults to `-1` which means infinite.
67+
- `uint32_t retryDelay = 10000`: Delay in ms between attempts. Defaults to 10 seconds.
68+
69+
Returns `true` or `false` depending on whether it received confirmation that the activation was successful before the maximum number of attempts.
70+
71+
Call the method without the first two arguments if the device's LoRa module comes with pre-flashed values.
7572

7673
## Method: personalize
7774
Activate the device via ABP.
7875

7976
```c
80-
bool personalize(const byte devAddr[4], const byte nwkSKey[16], const byte appSKey[16]);
77+
bool personalize(const char *devAddr, const char *nwkSKey, const char *appSKey);
78+
bool personalize();
8179
```
8280
83-
- `const byte devAddr[4]`: Dev(ice) Address assigned to the device.
84-
- `const byte nwkSKey[16]`: Network Session Key assigned to the device.
85-
- `const byte appSKey[16]`: App(lication) Session Key assigned to the device.
81+
- `const char *devAddr`: Device Address assigned to the device.
82+
- `const char *nwkSKey`: Network Session Key assigned to the device for identification.
83+
- `const char *appSKey`: Application Session Key assigned to the device for encryption.
8684
87-
See [Library Usage / Activate](#activate).
85+
Returns `true` or `false` depending on whether the activation was successful.
86+
87+
Call the method with no arguments if the device's LoRa module comes with pre-flashed values.
88+
89+
See the [ABP](https://github.com/TheThingsNetwork/arduino-device-lib/blob/master/examples/ABP/ABP.ino) example.
8890
8991
## Method: sendBytes
9092
Send a message to the application using raw bytes.
9193
9294
```c
93-
int sendBytes(const byte* buffer, int length, int port = 1, bool confirm = false);
95+
int8_t sendBytes(const byte* payload, size_t length, port_t port = 1, bool confirm = false);
9496
```
9597

96-
- `const byte* buffer`: Bytes to send.
97-
- `int length`: The number of bytes. Use `sizeof(buffer)` to get it.
98-
- `int port = 1`: The port to address. Defaults to `1`.
99-
- `bool confirm = false`: Whether to ask for confirmation.
98+
- `const byte* payload `: Bytes to send.
99+
- `size_t length`: The number of bytes. Use `sizeof(payload)` to get it.
100+
- `port_t port = 1`: The port to address. Defaults to `1`.
101+
- `bool confirm = false`: Whether to ask for confirmation. Defaults to `false`.
100102

101-
- **TODO:** How does one check the result?
103+
Returns a success or error code and logs the related error message:
102104

103-
Returns the size of the message received in response, if any. Use `downlink` for the actual bytes received.
105+
* `-1`: Send command failed.
106+
* `-2`: Time-out.
107+
* `1`: Successful transmission.
108+
* `2`: Successful transmission. Received \<N> bytes
109+
* `-10`: Unexpected response: \<Response>
104110

105-
## Method: sendString
106-
Send a message to the application using a string, which the library will encode as bytes for you.
111+
See the [Send](https://github.com/TheThingsNetwork/arduino-device-lib/blob/master/examples/Send/Send.ino) example.
107112

108-
> To minimize air time we advise not to use this method and try to use a minimal amount of bytes to communicate your message.
113+
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).
114+
115+
## Method: poll
116+
Calls `sendBytes()` with `{ 0x00 }` as payload to poll for incoming messages.
109117

110118
```c
111-
int sendString(String message, int port = 1, bool confirm = false);
119+
int8_t poll(port_t port = 1, bool confirm = false);
112120
```
113121
114-
- `String message`: String to encode and send.
115-
- `int port = 1`: The port to address. Defaults to `1`.
122+
- `port_t port = 1`: The port to address. Defaults to `1`.
116123
- `bool confirm = false`: Whether to ask for confirmation.
117124
118-
- **TODO:** How does one check the result?
125+
Returns the result of `sendBytes()`.
119126
120-
Returns the size of the message received in response, if any. Use `downlink` for the actual bytes received.
127+
See the [Receive](https://github.com/TheThingsNetwork/arduino-device-lib/blob/master/examples/Receive/Receive.ino) example.
121128
122-
## Property: downlinkPort
123-
The port the last message received was addressed to.
129+
## Method: provision
130+
Sets the information needed to activate the device via OTAA, without actually activating. Call join() without the first 2 arguments to activate.
124131
125132
```c
126-
int downlinkPort
133+
bool provision(const char *appEui, const char *appKey);
127134
```
128135

129-
## Property: downlink
130-
The last message received.
131-
132-
```c
133-
byte downlink[64];
134-
```
136+
- `const char *appEui`: Application Identifier for the device.
137+
- `const char *appKey`: Application Key assigned to the device.

0 commit comments

Comments
 (0)