-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |