Skip to content

Instantly share code, notes, and snippets.

@judepereira
Last active December 20, 2020 21:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save judepereira/4055040a0b4c602c298b8249801bbd83 to your computer and use it in GitHub Desktop.
Wrapper script for sending OTA updates to your ESP8266/NodeMCU.
#!/bin/bash
# Wrapper script for sending OTA updates to your ESP8266 running NodeMCU.
# See https://judepereira.com/blog/sending-ota-updates-over-wifi-to-your-esp8266/
HOST=192.168.178.25
PORT=8080
for i in "$@"; do
FILE=$i
echo "Sending $i..."
echo -n "BEGIN $FILE" | nc $HOST $PORT
while read -r line; do
#echo -n "write: $line ... "
if ! echo "$line" | nc $HOST $PORT | grep "ok" &>/dev/null; then
echo "Write failed! Please retry..."
exit 1
fi
done <"$FILE"
echo -n "DONE" | nc $HOST $PORT
done
echo -n "RESTART" | nc $HOST $PORT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment