From 40155e79cc079ae40232fe6299eedb605238656d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Wed, 6 Sep 2017 00:12:22 +0200 Subject: [PATCH] Renaming new ota utilities --- code/{flash.sh => ota_flash.sh} | 2 +- code/ota_list.sh | 65 +++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) rename code/{flash.sh => ota_flash.sh} (98%) create mode 100755 code/ota_list.sh diff --git a/code/flash.sh b/code/ota_flash.sh similarity index 98% rename from code/flash.sh rename to code/ota_flash.sh index c29e51e3..7e6df7f0 100755 --- a/code/flash.sh +++ b/code/ota_flash.sh @@ -170,7 +170,7 @@ if [ "$auth" == "" ]; then fi if [ "$flags" == "" ]; then - read -p "Extra flags for the build: " flags + read -p "Extra flags for the build: " -e -i "-DTELNET_ONLY_AP=0" flags fi read -p "Environment to build: " -e -i "esp8266-1m-ota" env diff --git a/code/ota_list.sh b/code/ota_list.sh new file mode 100755 index 00000000..dbbf2b49 --- /dev/null +++ b/code/ota_list.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +exists() { + command -v "$1" >/dev/null 2>&1 +} + +echo_pad() { + string=$1 + pad=$2 + printf '%s' "$string" + printf '%*s' $(( $pad - ${#string} )) +} + +useAvahi() { + + echo_pad "#" 4 + echo_pad "HOSTNAME" 20 + echo_pad "IP" 20 + echo_pad "DEVICE" 30 + echo_pad "VERSION" 10 + echo + + printf -v line '%*s\n' 84 + echo ${line// /-} + + counter=0 + + avahi-browse -t -r -p "_arduino._tcp" 2>/dev/null | grep ^= | while read line; do + + (( counter++ )) + + hostname=`echo $line | cut -d ';' -f4` + ip=`echo $line | cut -d ';' -f8` + txt=`echo $line | cut -d ';' -f10` + board=`echo $txt | sed -n "s/.*espurna_board=\([^\"]*\).*/\1/p"` + version=`echo $txt | sed -n "s/.*espurna_version=\([^\"]*\).*/\1/p"` + + echo_pad "$counter" 4 + echo_pad "$hostname" 20 + echo_pad "$ip" 20 + echo_pad "$board" 30 + echo_pad "$version" 10 + echo + + done + + echo + +} + +# ------------------------------------------------------------------------------ + +# Welcome +echo +echo "--------------------------------------------------------------" +echo "OTA-UPDATABLE DEVICES" +echo "--------------------------------------------------------------" +echo + +if exists avahi-browse; then + useAvahi +else + echo "Avahi not installed" + exit 1 +fi