Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coolFlasher #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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