Skip to content

Commit

Permalink
coolFlasher
Browse files Browse the repository at this point in the history
  • Loading branch information
trap98 committed Sep 21, 2018
1 parent 84ae8cf commit d8bc7b4
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
26 changes: 26 additions & 0 deletions flasher/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# COOL FLASHER

With coolFlasher.sh you can send config to the shadow when you flash your board !


## Prerequisites:

- aws cli
If you haven't, contact your admin for credentials. Then follow those instructions :
- `pip install awscli`
- `aws configure`: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html
- your board is plugged and in _load_ mode
- platformIO

You always need to use option -e [...] for environnement and you can use -s [...] to flash SPIFFS (configuration) if you use this option you need to give your macAddress ([A-Z0-9]) ex: 32AEA4583D84.

## Example :

I want to flash only the code:

`flasher/flasher.sh -e debug`

i want to flash the code, the configuration and to send it to the shadow:

`flash/flasher.sh -e debug -s 32AEA4583D84`

34 changes: 34 additions & 0 deletions flasher/coolFlasher.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
if [ ${#} -lt 2 ]
then
echo $'Usage : ./coolFlasher.sh -e [env] -s [macAddress] (optionnal) for more information read flasher/README.md\n\n -e [...] choose compilation environnement [minified, prod, debug, trace]\n -s [...] flash SPIFFS and send configuration to aws [yourMacAddress]'
else
if [ ${1} = "-e" ]
then
pio run -e $2 -t upload
fi
if [ ${#} -eq 4 ]
then
if [ ${3} = "-s" ]
then
start='{"state":{"reported":{"config":'
end='}}}'

general=$(<examples/WeatherStation/data/general.json)
aws iot-data update-thing-shadow --thing-name ${4} --payload "${start}${general}${end}" general
rm general

sensors=$(<examples/WeatherStation/data/sensors.json)
aws iot-data update-thing-shadow --thing-name ${4} --payload "${start}${sensors}${end}" sensors
rm sensors

if [ -r examples/WeatherStation/data/actuators.json ]
then
actuators=$(<examples/WeatherStation/data/actuators.json)
aws iot-data update-thing-shadow --thing-name ${4} --payload "${start}${actuators}${end}" actuators
rm actuators
fi
pio run -e ${2} -t uploadfs
fi
fi
fi

0 comments on commit d8bc7b4

Please sign in to comment.