Browse Source

Added LPP device ids in config file and added a script to generate binary for individual device (lora EUI/key parameters)

master
Anthony Hinsinger 7 years ago
parent
commit
80dedb1490
  1. 1
      .gitignore
  2. 8
      main.cpp
  3. 26
      mbed_app.json
  4. 40
      scripts/gen_images.sh

1
.gitignore vendored

@ -1,4 +1,3 @@
*.pyc *.pyc
BUILD BUILD
mbed_config.h mbed_config.h
mbed_app.json

8
main.cpp

@ -126,14 +126,14 @@ static void send_message() {
int16_t retcode; int16_t retcode;
#if MBED_CONF_APP_BATTERY_ENABLED && MBED_CONF_APP_BATTERY_IN_LPP #if MBED_CONF_APP_BATTERY_ENABLED && MBED_CONF_APP_BATTERY_IN_LPP
cayenne.addAnalogInput(1, battery_voltage()); cayenne.addAnalogInput(MBED_CONF_APP_BATTERY_LPP_ID, battery_voltage());
#endif #endif
#if MBED_CONF_APP_DHT_ENABLED #if MBED_CONF_APP_DHT_ENABLED
int err = dht.read(); int err = dht.read();
if(err == DHT::SUCCESS) { if(err == DHT::SUCCESS) {
cayenne.addTemperature(1, dht.getTemperature()); cayenne.addTemperature(MBED_CONF_APP_DHT_TEMP_LPP_ID, dht.getTemperature());
cayenne.addRelativeHumidity(1, dht.getHumidity()); cayenne.addRelativeHumidity(MBED_CONF_APP_DHT_HUM_LPP_ID, dht.getHumidity());
} else { } else {
debug("Error code : %d\r\n", err); debug("Error code : %d\r\n", err);
} }
@ -142,7 +142,7 @@ static void send_message() {
#if MBED_CONF_APP_HX711_ENABLED #if MBED_CONF_APP_HX711_ENABLED
loadcell.powerUp(); loadcell.powerUp();
if(loadcell.waitReadyRetry(20, 100)) { if(loadcell.waitReadyRetry(20, 100)) {
cayenne.addAnalogInput(2, loadcell.getUnits(5)); cayenne.addAnalogInput(MBED_CONF_APP_HX711_LPP_ID, loadcell.getUnits(5));
} }
loadcell.powerDown(); loadcell.powerDown();
#endif #endif

26
mbed_app.json

@ -25,17 +25,21 @@
"lora-pwr-amp-ctl": { "value": "NC" }, "lora-pwr-amp-ctl": { "value": "NC" },
"lora-tcxo": { "value": "NC" }, "lora-tcxo": { "value": "NC" },
"battery-enabled": { "value": "false" }, "battery-enabled": { "value": "false" },
"battery-lpp-id": { "value": 1 },
"battery-in-lpp": { "value": "false" }, "battery-in-lpp": { "value": "false" },
"battery-adc": { "value": "NC" }, "battery-adc": { "value": "NC" },
"battery-ratio": { "value": "2.0f" }, "battery-ratio": { "value": "2.0f" },
"dht-enabled": { "value": "false" },
"dht-type": { "value": "DHT::DHT22" },
"dht-data": { "value": "NC" },
"hx711-enabled": { "value": "false" }, "hx711-enabled": { "value": "false" },
"hx711-lpp-id": { "value": 2 },
"hx711-clk": { "value": "NC" }, "hx711-clk": { "value": "NC" },
"hx711-data": { "value": "NC" }, "hx711-data": { "value": "NC" },
"hx711-scale": { "value": "1.0f" }, "hx711-scale": { "value": "1.0f" },
"hx711-offset": { "value": 0 } "hx711-offset": { "value": 0 },
"dht-enabled": { "value": "false" },
"dht-temp-lpp-id": { "value": 3 },
"dht-hum-lpp-id": { "value": 4 },
"dht-type": { "value": "DHT::DHT22" },
"dht-data": { "value": "NC" }
}, },
"target_overrides": { "target_overrides": {
"*": { "*": {
@ -46,9 +50,9 @@
"lora.over-the-air-activation": true, "lora.over-the-air-activation": true,
"lora.duty-cycle-on": false, "lora.duty-cycle-on": false,
"lora.phy": 0, "lora.phy": 0,
"lora.device-eui": "{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }", "lora.device-eui": "{ 0xAB, 0xBA, 0xAB, 0xBA, 0xAB, 0xBA, 0xAB, 0xBA }",
"lora.application-eui": "{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }", "lora.application-eui": "{ 0xAC, 0xCA, 0xAC, 0xCA, 0xAC, 0xCA, 0xAC, 0xCA }",
"lora.application-key": "{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }" "lora.application-key": "{ 0xAD, 0xDA, 0xAD, 0xDA, 0xAD, 0xDA, 0xAD, 0xDA, 0xAD, 0xDA, 0xAD, 0xDA, 0xAD, 0xDA, 0xAD, 0xDA }"
}, },
"NUCLEO_L073RZ": { "NUCLEO_L073RZ": {
@ -80,14 +84,14 @@
"battery-in-lpp": true, "battery-in-lpp": true,
"battery-adc": "A1", "battery-adc": "A1",
"battery-ratio": "2.0f", "battery-ratio": "2.0f",
"dht-enabled": true,
"dht-data": "D8",
"dht-type": "DHT::DHT22",
"hx711-enabled": true, "hx711-enabled": true,
"hx711-clk": "D6", "hx711-clk": "D6",
"hx711-data": "D7", "hx711-data": "D7",
"hx711-scale": "21000.0f", "hx711-scale": "21000.0f",
"hx711-offset": 59600 "hx711-offset": 59600,
"dht-enabled": true,
"dht-data": "D8",
"dht-type": "DHT::DHT22"
}, },
"MTB_RAK811": { "MTB_RAK811": {

40
scripts/gen_images.sh

@ -0,0 +1,40 @@
#!/bin/sh
MASTERFILE=./BUILD/NUCLEO_L073RZ/GCC_ARM-RELEASE/waveofhoney-mbed5.bin
# patterns
DEVICEEUI=ABBAABBAABBAABBA
APPEUI=ACCAACCAACCAACCA
APPKEY=ADDAADDAADDAADDAADDAADDAADDAADDA
if [ $# -ne 2 ]; then
echo "gen_images <master_binary> <devices_file>\n"
echo "devices file must be in the form :\n"
echo "dev1name:dev1eui:dev1appeui:dev1appkey"
echo "dev2name:dev2eui:dev2appeui:dev2appkey\n"
exit 1;
fi
MASTER=$1
DEVICES=$2
if [ ! -e $MASTER ]; then
echo "The master file $MASTER doesn't exists"
exit 1;
fi
if [ ! -e $DEVICES ]; then
echo "The devices file $DEVICES doesn't exists"
exit 1;
fi
for DEVICE in $(cat $DEVICES); do
name=$(echo $DEVICE | cut -d : -f 1)
deviceeui=$(echo $DEVICE | cut -d : -f 2)
appeui=$(echo $DEVICE | cut -d : -f 3)
appkey=$(echo $DEVICE | cut -d : -f 4)
echo $name
hexdump -ve '1/1 "%.2X"' $MASTERFILE | sed "s/$DEVICEEUI/$deviceeui/; s/$APPEUI/$appeui/; s/$APPKEY/$appkey/" | xxd -r -p > waveofhoney-${name}.bin
done
exit;
Loading…
Cancel
Save