Soap dispenser firmware for xDot.
WARNING I seem to recieve RTX error codes at runtime if compiled using CLI, works find imported into online compiler..
Before you can use the firmware you need authentication keys for the network. For this you need your device EUI. To find the EUI:
- Flash this application on an xDot.
- Inspect the serial logs, and look for a line that starts with '[INFO] device ID/EUI' and '[INFO] network EUI' and '[INFO] network KEY'.
Next, provision the device in the LoRa bridge:
- Go to the LORIOT bridge.
- Click Create new device.
- Fill in the device ID/EUI and an mbed Device Connector certificate.
- Navigate to LORIOT.io->Applications/HPE/Devices
- Find the device matching the 'device ID/EUI'. Click on device, 'Remove Device'
- Navigate to LORIOT.io->Applications/HPE/Devices/ImportOTAA
- Copy 'device ID/EUI' and 'network EUI' and 'network KEY' into DevEUI and AppEUI and APPKEY respectively (Must be UPPERCASE)
Build and flash your application, the device now joins the network.
Next, set up LWM2M rules for the device.EUI
Resources
{
"soap/0/presses_left": {
"mode": "r",
"defaultValue": "0"
},
"lora/0/interval": {
"mode": "w"
},
"lora/0/timestamp": {
"mode": "r",
"defaultValue": "0"
}
}
Process Data
function (bytes) {
return {
"soap/0/presses_left": (bytes[0] << 8) + bytes[1],
"lora/0/timestamp": Date.now()
};
}
Write Data
{
"lora/0/interval": function (v) {
var b = Number(v);
return { port: 5, data: [ (b >> 8) & 0xff, b & 0xff ] };
}
}
Save the configuration. The device now shows up in mbed Device Connector.
This does not expose the device to mbed Device Connector, but is useful for troubleshooting.
- Go to the ARM LORIOT account - for credentials see one of the contributors.
- Under Applications, select HPE.
- Click Enroll device.
- Enter the Device EUI.
- On the device page find the
APPKEY
, and enter this inmain.cpp
as the value fornetwork_key
.
Build and flash the firmware, the device should now join the network.
-
Import this program using mbed CLI:
$ mbed import [email protected]:ARMmbed/example-deployment-soap-dispenser.git example-deployment-soap-dispenser
-
Configure your target and toolchain, and build the project:
$ mbed target xdot_l151cc $ mbed toolchain GCC_ARM $ mbed compile
See RadioEvent.h
for a hook on which to receive data. This hook is already used to process the interval frequency frames (on port 5).
- Verify that messages are received by the gateway via the Tap into data stream link in LORIOT.
- All communication between device and the network (downlink and uplink) can be found in the application log.