Two way data over LoRaWAN using Multitech mDot

Dependencies:   libmDot-mbed5

This is example firmware for the Multitech mDot. It demonstrates how to:

  • Do two-way data.
  • Sleep aggressively and only wake up when the wake-up pin is triggered.
  • Handle errors, retries and duty cycle errors.
  • Cache data in non-volatile storage.

Based on mbed OS 5.1, hard faults against mbed OS 5.3 unfortunately. Can be compiled with GCC and ARMCC (but not IAR).

To do a new transmission, short pin D6 / PA_1.

Committer:
Jan Jongboom
Date:
Wed Jan 04 13:45:49 2017 +0000
Revision:
4:0fd5e5e121ea
Parent:
3:ac5101a47080
Retry OTA join when fails during startup

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jan Jongboom 1:b604a2d6c54d 1 # Two way data using Multitech mDot
janjongboom 0:20fbd6f66b11 2
Jan Jongboom 4:0fd5e5e121ea 3 Demonstrates two-way data over LoRaWAN using Multitech mDot.
janjongboom 0:20fbd6f66b11 4
Jan Jongboom 1:b604a2d6c54d 5 1. Triggers transmission when D6 goes high - this is the special wake-up pin on the mDot. Short D6 to test quickly.
Jan Jongboom 1:b604a2d6c54d 6 2. The RX window is used to toggle D2. If 0x00 is received the pin goes high, if 0x01 is received the pin goes low (as the LEDs are inverted on the break-out board).
janjongboom 0:20fbd6f66b11 7
Jan Jongboom 1:b604a2d6c54d 8 ## Using this software with mbed Device Connector
janjongboom 0:20fbd6f66b11 9
Jan Jongboom 1:b604a2d6c54d 10 1. Connect your gateway to LORIOT EU1.
Jan Jongboom 1:b604a2d6c54d 11 2. Go to http://apm-lora-eu2.cloudapp.net:5101 and click on 'Create new device'.
Jan Jongboom 1:b604a2d6c54d 12 3. Paste in a security.h file from your Connector account.
Jan Jongboom 1:b604a2d6c54d 13 4. Copy the keys over to ``main.cpp``.
Jan Jongboom 1:b604a2d6c54d 14 5. Compile and flash, and verify that messages arrive.
Jan Jongboom 1:b604a2d6c54d 15 6. Configure the device like this:
Jan Jongboom 1:b604a2d6c54d 16 * Resources:
Jan Jongboom 1:b604a2d6c54d 17 ```json
Jan Jongboom 1:b604a2d6c54d 18 {
Jan Jongboom 1:b604a2d6c54d 19 "button/0/clicks": {
Jan Jongboom 1:b604a2d6c54d 20 "mode": "r",
Jan Jongboom 1:b604a2d6c54d 21 "defaultValue": "0"
Jan Jongboom 1:b604a2d6c54d 22 },
Jan Jongboom 1:b604a2d6c54d 23 "led/0/value": {
Jan Jongboom 1:b604a2d6c54d 24 "mode": "w"
Jan Jongboom 1:b604a2d6c54d 25 }
janjongboom 0:20fbd6f66b11 26 }
Jan Jongboom 1:b604a2d6c54d 27 ```
Jan Jongboom 1:b604a2d6c54d 28 * Process Data:
Jan Jongboom 1:b604a2d6c54d 29 ```js
Jan Jongboom 1:b604a2d6c54d 30 function (bytes) {
Jan Jongboom 1:b604a2d6c54d 31 return {
Jan Jongboom 1:b604a2d6c54d 32 "button/0/clicks": (bytes[0] << 8) + bytes[1]
Jan Jongboom 1:b604a2d6c54d 33 };
janjongboom 0:20fbd6f66b11 34 }
Jan Jongboom 1:b604a2d6c54d 35 ```
Jan Jongboom 1:b604a2d6c54d 36 * Write Data:
Jan Jongboom 1:b604a2d6c54d 37 ```js
Jan Jongboom 1:b604a2d6c54d 38 {
Jan Jongboom 1:b604a2d6c54d 39 "led/0/value": function (v) {
Jan Jongboom 3:ac5101a47080 40 return { port: 2, data: [ Number(v) ? 0x1 : 0x0 ] };
Jan Jongboom 1:b604a2d6c54d 41 }
Jan Jongboom 1:b604a2d6c54d 42 }
Jan Jongboom 1:b604a2d6c54d 43 ```
Jan Jongboom 1:b604a2d6c54d 44 7. Click 'Save'.