Skip to content

Commit 8a7ee08

Browse files
authored
Merge pull request #1 from TheThingsNetwork/master
Merge in from upstream
2 parents 921e603 + e3115cc commit 8a7ee08

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2293
-687
lines changed

.travis.yml

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
1-
language: python
2-
python:
3-
- "2.7"
4-
5-
# Cache PlatformIO packages using Travis CI container-based infrastructure
6-
sudo: false
7-
cache:
8-
directories:
9-
- "~/.platformio"
10-
1+
language: c
112
env:
12-
- PLATFORMIO_CI_SRC=test/TheThingsNetwork.ino
13-
- PLATFORMIO_CI_SRC=test/TheThingsMessage.ino
14-
3+
- ARDUINO_VERSION=1.6.13
4+
before_install:
5+
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16"
6+
- sleep 3
7+
- export DISPLAY=:1.0
8+
- wget http://downloads.arduino.cc/arduino-$ARDUINO_VERSION-linux64.tar.xz
9+
- tar xf arduino-$ARDUINO_VERSION-linux64.tar.xz
10+
- sudo mv arduino-$ARDUINO_VERSION /usr/local/share/arduino
11+
- sudo ln -s /usr/local/share/arduino/arduino /usr/local/bin/arduino
1512
install:
16-
- pip install -U platformio
17-
13+
- ln -s $PWD /usr/local/share/arduino/libraries/TheThingsNetwork
14+
- arduino --install-library "DHT sensor library:1.3.0,Adafruit Unified Sensor:1.0.2"
15+
before_script:
16+
# Replace placeholders with actual frequency plan (on Mac OS folow -i by '')
17+
- find $PWD/examples -type f -name "*.ino" -exec sed -i 's/REPLACE_ME/TTN_FP_EU868/g' {} +
1818
script:
19-
# - platformio ci --lib=src --board=leonardo --board=sparkfun_promicro8
20-
- "echo \"Warning: no test specified\" && exit 0"
19+
- test/verify arduino:avr:leonardo examples/SendABP/SendABP.ino
20+
- test/verify arduino:avr:leonardo examples/DeviceInfo/DeviceInfo.ino
21+
- test/verify arduino:avr:leonardo examples/TheThingsMessage/Receive/Receive.ino
22+
- test/verify arduino:avr:leonardo examples/TheThingsMessage/Send/Send.ino
23+
- test/verify arduino:avr:leonardo examples/PassThrough/PassThrough.ino
24+
- test/verify arduino:avr:leonardo examples/QuickStart/QuickStart.ino
25+
- test/verify arduino:avr:leonardo examples/Receive/Receive.ino
26+
- test/verify arduino:avr:leonardo examples/SendOTAA/SendOTAA.ino
27+
- test/verify arduino:avr:leonardo examples/Sensors/DHT/DHT.ino
28+
- test/verify arduino:avr:leonardo examples/Sensors/LightSensor/LightSensor.ino
29+
- test/verify arduino:avr:leonardo examples/Workshop/Workshop.ino
30+
- test/verify arduino:avr:leonardo test/TheThingsMessage/TheThingsMessage.ino
31+
- test/verify arduino:avr:leonardo test/TheThingsNetwork/TheThingsNetwork.ino
32+
notifications:
33+
email:
34+
on_success: change
35+
on_failure: change

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
Johan Stokking <johan@thethingsnetwork.org>
22
Fokke Zandbergen <mail@fokkezb.nl>
3+
Alessandro Blason <mrblason@gmail.com>

CONTRIBUTING.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
## Contributing
22

3-
We'd ❤️ to welcome your contribution. Please make sure you:
3+
We'd ❤️ to welcome your contribution. Please make sure your changes include:
44

5-
1. Keep [keywords.txt](../keywords.txt) up to date with your changes.
6-
2. Keep [API.md](../API.md) up to date with your changes.
5+
1. Examples: [examples](examples)
6+
2. Syntax highlighting: [keywords.txt](keywords.txt)
7+
3. Documentation: [docs](docs)
8+
4. Tests: [test](test)
9+
5. Verification of the examples and tests: [.travis.yml](.travis.yml)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# The Things Network Arduino Library
22
[![Build Status](https://travis-ci.org/TheThingsNetwork/arduino-device-lib.svg?branch=master)](https://travis-ci.org/TheThingsNetwork/arduino-device-lib)
33

4-
This is an [Arduino Library](https://www.arduino.cc/en/Guide/Libraries) for Arduino-compatible devices like [The Things Uno](https://shop.thethingsnetwork.com/index.php/product/the-things-uno/) and [Node](https://shop.thethingsnetwork.com/index.php/product/the-things-node/) to communicate via [The Things Network](https://www.thethingsnetwork.org).
4+
This is an [Arduino Library](https://www.arduino.cc/en/Guide/Libraries) for Arduino devices like [The Things Uno](https://www.thethingsnetwork.org/docs/devices/uno/) and [Node](https://www.thethingsnetwork.org/docs/devices/node/) to communicate via [The Things Network](https://www.thethingsnetwork.org).
55

66
> At the moment this library requires devices to feature a [Microchip RN2xx3 module](http://www.microchip.com/design-centers/wireless-connectivity/embedded-wireless/lora-technology).
77
@@ -12,7 +12,7 @@ This is an [Arduino Library](https://www.arduino.cc/en/Guide/Libraries) for Ardu
1212

1313
## Documentation
1414

15-
* [The Things Network Documentation / Arduino](https://www.thethingsnetwork.org/docs/arduino/)
15+
* [The Things Network Documentation](https://www.thethingsnetwork.org/docs/devices/arduino/)
1616
* API References:
1717
* [TheThingsNetwork](docs/TheThingsNetwork.md)
1818
* [TheThingsMessage](docs/TheThingsMessage.md)

docs/CayenneLPP.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# API Reference
2+
3+
The `CayenneLPP` class enables Arduino devices to encode data with the Cayenne Low Power Payload (LPP). [Read more about Cayenne LPP](https://mydevices.com/cayenne/docs/lora/#lora-cayenne-low-power-payload)
4+
5+
## Class: `CayenneLPP`
6+
7+
Include and instantiate the CayenneLPP class. The constructor takes the size of the allocated buffer. Depending on the LoRa frequency plan and data rate used, the maximum payload varies. It's safe to send up to 51 bytes of payload.
8+
9+
```c
10+
#include <CayenneLPP.h>
11+
12+
CayenneLPP lpp(uint8_t size);
13+
```
14+
15+
- `uint8_t size`: The maximum payload size to send, e.g. `51`.
16+
17+
## Example
18+
19+
```c
20+
TheThingsNetwork ttn(loraSerial, debugSerial, freqPlan);
21+
CayenneLPP lpp(51);
22+
23+
lpp.reset();
24+
lpp.addTemperature(1, 22.5);
25+
lpp.addBarometricPressure(2, 1073.21);
26+
lpp.addGPS(3, 52.37365, 4.88650, 2);
27+
28+
ttn.sendBytes(lpp.getBuffer(), lpp.getSize());
29+
```
30+
31+
See the [CayenneLPP](https://github.com/TheThingsNetwork/arduino-device-lib/blob/master/examples/CayenneLPP/CayenneLPP.ino) example.
32+
33+
## Method: `reset`
34+
35+
Resets the buffer.
36+
37+
```c
38+
void reset(void);
39+
```
40+
41+
## Method: `getSize`
42+
43+
Returns the size of the buffer.
44+
45+
```c
46+
uint8_t getSize(void);
47+
```
48+
49+
## Method: `getBuffer`
50+
51+
Returns a pointer to the buffer.
52+
53+
```c
54+
uint8_t *getBuffer(void);
55+
```
56+
57+
## Method: `copy`
58+
59+
Copies the internal buffer to a specified buffer and returns the copied size.
60+
61+
```c
62+
uint8_t copy(uint8_t *buffer);
63+
```
64+
65+
## Methods: `add...`
66+
67+
Add data to the buffer. The `channel` parameter acts as a key for the data field. The data fields you send are dynamic; you can selectively send data as long as the channel matches.
68+
69+
```c
70+
uint8_t addDigitalInput(uint8_t channel, uint8_t value);
71+
uint8_t addDigitalOutput(uint8_t channel, uint8_t value);
72+
73+
uint8_t addAnalogInput(uint8_t channel, float value);
74+
uint8_t addAnalogOutput(uint8_t channel, float value);
75+
76+
uint8_t addLuminosity(uint8_t channel, uint16_t lux);
77+
uint8_t addPresence(uint8_t channel, uint8_t value);
78+
uint8_t addTemperature(uint8_t channel, float celsius);
79+
uint8_t addRelativeHumidity(uint8_t channel, float rh);
80+
uint8_t addAccelerometer(uint8_t channel, float x, float y, float z);
81+
uint8_t addBarometricPressure(uint8_t channel, float hpa);
82+
uint8_t addGyrometer(uint8_t channel, float x, float y, float z);
83+
uint8_t addGPS(uint8_t channel, float latitude, float longitude, float meters);
84+
```

docs/RN2903A-1.0.3-AU915.zip

113 KB
Binary file not shown.

docs/RN2903A-programming.docx

2.27 MB
Binary file not shown.

docs/RN2903A-uart-bootloader.docx

696 KB
Binary file not shown.

docs/TheThingsMessage.md

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# API Reference
2-
The `TheThingsMessage` class provides structs for sensor and application data you can encode and decode as bytes.
32

4-
## Class: TheThingsMessage
3+
## Class: `TheThingsMessage`
4+
The `TheThingsMessage` class provides structs for sensor and application data you can encode and decode as bytes.
55

66
```c
77
#include <TheThingsMessage.h>
88
```
99

10-
## Type: sensordata_t
10+
## Type: `devicedata_t`
1111

12-
Create a struct of this type using `api_SensorData_init_default` as defaults.
12+
Create a struct of this type using `api_DeviceData_init_default` as defaults.
1313

1414
```c
15-
sensordata_t data = api_SensorData_init_default;
15+
devicedata_t data = api_DeviceData_init_default;
1616
```
1717

1818
Then in your `setup()` function select what fields of the struct should be included when encoding it as bytes:
@@ -41,21 +41,42 @@ You can also add other analog readings.
4141

4242
> **TODO:** Document how this works and include in example.
4343
44-
## Method: encodeSensorData
44+
## Method: `encodeDeviceData`
45+
4546
Encode the message you want to send.
4647

4748
```c
48-
static void encodeSensorData(sensordata_t *data, byte **buffer, size_t *size);
49+
static void encodeDeviceData(devicedata_t *data, byte **buffer, size_t *size);
4950
```
5051
51-
- `sensordata_t *data`: Structure containing all the message we can send.
52-
- `const byte **buffer`: Bytes received.
53-
- `size_t *size`: The number of bytes.
52+
- `devicedata_t *data`: Structure containing typical fields that devices send.
53+
- `byte **buffer`: Bytes to send.
54+
- `size_t *size`: The number of bytes to send.
5455
5556
Usage:
5657
5758
```c
5859
byte *buffer;
5960
size_t size;
60-
TheThingsMessage::encodeSensorData(&data, &buffer, &size);
61+
TheThingsMessage::encodeDeviceData(&data, &buffer, &size);
62+
```
63+
64+
## Method: `decodeAppData`
65+
66+
Decode the message you received.
67+
68+
```c
69+
static bool decodeAppData(appdata_t *receiveData, const byte *payload, size_t length);
70+
```
71+
72+
- `appdata_t *receiveData`: Structure containing all the message we can interpret.
73+
- `const byte *payload`: Bytes received.
74+
- `size_t *length`: The number of bytes.
75+
76+
Usage:
77+
78+
```c
79+
const byte *payload;
80+
size_t length;
81+
TheThingsMessage::decodeAppData(&receiveData, payload, length);
6182
```

0 commit comments

Comments
 (0)