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.

Revision:
1:b604a2d6c54d
Parent:
0:20fbd6f66b11
Child:
3:ac5101a47080
--- a/README.md	Tue Jan 03 13:20:36 2017 +0000
+++ b/README.md	Tue Jan 03 13:30:12 2017 +0000
@@ -1,52 +1,44 @@
-# LoRa Soap dispenser
+# Two way data using Multitech mDot
 
-Smart soap dispenser that sends out stuff over LoRa. Does not build with GCC, only ARMCC (also with mbed CLI).
-
-## Setup
+Only builds with ARMCC, not with GCC. Demonstrates two-way data over LoRaWAN using Multitech mDot.
 
-1. Set jumper JP95 (next to RESET button) to the two pins closest to the mDot.
-2. Attach something that generates an interrupt on D6 / PA_1.
-3. RFID code needs to be implemented, currently spits out a random ID.
+1. Triggers transmission when D6 goes high - this is the special wake-up pin on the mDot. Short D6 to test quickly.
+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).
 
-To get data into Device Connector:
-
-1. First get keys by exchanging a device cert for LoRa keys at http://apm-lora-eu2.cloudapp.net:5101.
-2. Add the keys to ``main.cpp``.
-3. Then under 'Resources' add:
+## Using this software with mbed Device Connector
 
-    ```
-    {
-        "dispenser/0/value": {
-            "mode": "r",
-            "defaultValue": "0"
-        },
-        "meta/0/timestamp": {
-            "mode": "r",
-            "defaultValue": ""
-        },
-        "meta/0/ids_seen": {
-            "mode": "r",
-            "defaultValue": ""
+1. Connect your gateway to LORIOT EU1.
+2. Go to http://apm-lora-eu2.cloudapp.net:5101 and click on 'Create new device'.
+3. Paste in a security.h file from your Connector account.
+4. Copy the keys over to ``main.cpp``.
+5. Compile and flash, and verify that messages arrive.
+6. Configure the device like this:
+    * Resources:
+        ```json
+        {
+            "button/0/clicks": {
+                "mode": "r",
+                "defaultValue": "0"
+            },
+            "led/0/value": {
+                "mode": "w"
+            }
         }
-    }
-    ```
-
-4. Under 'Process Data' add:
-
-    ```js
-    function (bytes) {
-        var ids = [];
-        for (var i = 0; i < (bytes.length - 2) / 4; i++) {
-            var c = bytes.slice(2 + (i * 4), 2 + (i * 4) + 4);
-            ids.push((c[0] << 24) + (c[1] << 16) + (c[2] << 8) + (c[3]));
+        ```
+    * Process Data:
+        ```js
+        function (bytes) {
+            return {
+                "button/0/clicks": (bytes[0] << 8) + bytes[1]
+            };
         }
-
-        return {
-            "dispenser/0/value": (bytes[0] << 8) + bytes[1],
-            "meta/0/timestamp": new Date().toISOString(),
-            "meta/0/ids_seen": ids.join(',')
-        };
-    }
-    ```
-
-5. Click 'Save' and your data should show up in Device Connector (after the next transmission).
+        ```
+    * Write Data:
+        ```js
+        {
+            "led/0/value": function (v) {
+                return { port: 2, data: [ v ? 0x1 : 0x0 ] };
+            }
+        }
+        ```
+7. Click 'Save'.