From 3e84c832387cdf1849fa09ae9ac4ae59b56260aa Mon Sep 17 00:00:00 2001 From: Martijn Bakker Date: Tue, 5 Sep 2017 20:56:17 +0200 Subject: [PATCH 1/6] Add Huacanxing H802 support --- code/espurna/config/arduino.h | 1 + code/espurna/config/hardware.h | 24 ++++++++++++++++++++++++ code/espurna/hardware.ino | 15 +++++++++++++++ code/platformio.ini | 23 +++++++++++++++++++++++ 4 files changed, 63 insertions(+) diff --git a/code/espurna/config/arduino.h b/code/espurna/config/arduino.h index 856456ac..d2afba64 100644 --- a/code/espurna/config/arduino.h +++ b/code/espurna/config/arduino.h @@ -39,6 +39,7 @@ //#define JANGOE_WIFI_RELAY_NO //#define JORGEGARCIA_WIFI_RELAYS //#define OPENENERGYMONITOR_MQTT_RELAY +//#define HUACANXING_H802 //-------------------------------------------------------------------------------- // Features (values below are non-default values) diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index bdfad3a7..50c7787f 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -809,6 +809,30 @@ #define RELAY1_TYPE RELAY_TYPE_LATCHED #define RELAY1_RESET_PIN 12 +// ----------------------------------------------------------------------------- +// HUACANXING H802 +// ----------------------------------------------------------------------------- + +#elif defined(HUACANXING_H802) + + // Info + #define MANUFACTURER "HUACANXING" + #define DEVICE "H802" + #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT + #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER + #define DUMMY_RELAY_COUNT 1 + + // Channels + #define LIGHT_CH1_PIN 12 // RED + #define LIGHT_CH2_PIN 14 // GREEN + #define LIGHT_CH3_PIN 13 // BLUE + #define LIGHT_CH4_PIN 15 // WHITE + + #define LIGHT_CH1_INVERSE 0 + #define LIGHT_CH2_INVERSE 0 + #define LIGHT_CH3_INVERSE 0 + #define LIGHT_CH4_INVERSE 0 + // ----------------------------------------------------------------------------- // Unknown hardware // ----------------------------------------------------------------------------- diff --git a/code/espurna/hardware.ino b/code/espurna/hardware.ino index d465a487..e38ae2df 100644 --- a/code/espurna/hardware.ino +++ b/code/espurna/hardware.ino @@ -419,6 +419,21 @@ void hwUpwardsCompatibility() { setSetting("relayResetGPIO", 1, 12); setSetting("relayType", 1, RELAY_TYPE_NORMAL); + #elif defined(HUACANXING_H802) + + setSetting("board", 36); + setSetting("relayProvider", RELAY_PROVIDER_LIGHT); + setSetting("lightProvider", LIGHT_PROVIDER_DIMMER); + setSetting("chGPIO", 1, 12); + setSetting("chGPIO", 2, 14); + setSetting("chGPIO", 3, 13); + setSetting("chGPIO", 4, 15); + setSetting("chLogic", 1, 0); + setSetting("chLogic", 2, 0); + setSetting("chLogic", 3, 0); + setSetting("chLogic", 4, 0); + setSetting("relays", 1); + #else #error "UNSUPPORTED HARDWARE!" diff --git a/code/platformio.ini b/code/platformio.ini index 3dbc4734..006c26e9 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -831,3 +831,26 @@ build_flags = ${common.build_flags} -D${env.BOARD} upload_speed = 115200 upload_port = "${env.IP}" upload_flags = --auth=${env.AUTH} --port 8266 + +[env:huacanxing-h802] +platform = espressif8266 +framework = arduino +board = esp01_1m +board_flash_mode = dout +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DHUACANXING_H802 -DDEBUG_PORT=Serial1 +monitor_baud = 115200 + +[env:huacanxing-h802-ota] +platform = espressif8266 +framework = arduino +board = esp01_1m +board_flash_mode = dout +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DHUACANXING_H802 -DDEBUG_PORT=Serial1 +upload_speed = 115200 +upload_port = "192.168.4.1" +upload_flags = --auth=fibonacci --port 8266 +monitor_baud = 115200 From 9834df1c63cf66664c825bc6207832fc85e8bd92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Wed, 6 Sep 2017 00:01:00 +0200 Subject: [PATCH 2/6] Beta version --- code/espurna/config/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/espurna/config/version.h b/code/espurna/config/version.h index 245fb7fa..85b7977f 100644 --- a/code/espurna/config/version.h +++ b/code/espurna/config/version.h @@ -1,4 +1,4 @@ #define APP_NAME "ESPURNA" -#define APP_VERSION "1.9.3" +#define APP_VERSION "1.9.4b" #define APP_AUTHOR "xose.perez@gmail.com" #define APP_WEBSITE "http://tinkerman.cat" From a9a980ab103a5dd1348621994518e8b346347255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Wed, 6 Sep 2017 00:01:26 +0200 Subject: [PATCH 3/6] Add espurna-specific texts to MDNS register --- code/espurna/config/general.h | 3 ++- code/espurna/ota.ino | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index 03cebcdc..e13234b1 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -8,6 +8,7 @@ //------------------------------------------------------------------------------ #define ADMIN_PASS "fibonacci" // Default password (WEB, OTA, WIFI) +#define DEVICE_NAME MANUFACTURER "_" DEVICE // Concatenate both to get a unique device name //------------------------------------------------------------------------------ // TELNET @@ -321,7 +322,7 @@ PROGMEM const char* const custom_reset_string[] = { // ----------------------------------------------------------------------------- #ifndef MDNS_SUPPORT -#define MDNS_SUPPORT 1 // Enable MDNS by default +#define MDNS_SUPPORT 1 // Publish services using mDNS by default #endif // ----------------------------------------------------------------------------- diff --git a/code/espurna/ota.ino b/code/espurna/ota.ino index c5a307dd..6f649ad3 100644 --- a/code/espurna/ota.ino +++ b/code/espurna/ota.ino @@ -55,6 +55,11 @@ void otaSetup() { ArduinoOTA.begin(); + // Public ESPurna related txt for OTA discovery + MDNS.addServiceTxt("arduino", "tcp", "firmware", APP_NAME); + MDNS.addServiceTxt("arduino", "tcp", "espurna_version", APP_VERSION); + MDNS.addServiceTxt("arduino", "tcp", "espurna_board", DEVICE_NAME); + } void otaLoop() { From a645ab6f1ac466ced9bec98c368ee651467149e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Wed, 6 Sep 2017 00:02:01 +0200 Subject: [PATCH 4/6] Custom (not general) OTA flasher utility using Avahi --- code/flash.sh | 198 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) create mode 100755 code/flash.sh diff --git a/code/flash.sh b/code/flash.sh new file mode 100755 index 00000000..c29e51e3 --- /dev/null +++ b/code/flash.sh @@ -0,0 +1,198 @@ +#!/bin/bash + +ip= +board= +auth= +flags= + +export boards=() +ips="" + +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 + + ip_file="/tmp/espurna.flash.ips" + board_file="/tmp/espurna.flash.boards" + count_file="/tmp/espurna.flash.count" + echo -n "" > $ip_file + echo -n "" > $board_file + echo -n "$counter" > $count_file + + avahi-browse -t -r -p "_arduino._tcp" 2>/dev/null | grep ^= | while read line; do + + (( counter++ )) + echo "$counter" > $count_file + + 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 -n "$ip;" >> $ip_file + echo -n "$board;" >> $board_file + + echo_pad "$counter" 4 + echo_pad "$hostname" 20 + echo_pad "$ip" 20 + echo_pad "$board" 30 + echo_pad "$version" 10 + echo + + + done + + echo + read -p "Choose the board you want to flash (empty if none of these): " num + + # None of these + if [ "$num" == "" ]; then + return + fi + + # Check boundaries + counter=`cat $count_file` + if [ $num -lt 1 ] || [ $num -gt $counter ]; then + echo "Board number must be between 1 and $counter" + exit 1 + fi + + # Fill the fields + ip=`cat $ip_file | cut -d ';' -f$num` + board=`cat $board_file | cut -d ';' -f$num` + +} + +getBoard() { + + boards=(`cat espurna/config/hardware.h | grep "defined" | sed "s/.*(\(.*\)).*/\1/" | sort`) + + echo_pad "#" 4 + echo_pad "DEVICE" 30 + echo + + printf -v line '%*s\n' 34 + echo ${line// /-} + + counter=0 + for board in "${boards[@]}"; do + (( counter++ )) + echo_pad "$counter" 4 + echo_pad "$board" 30 + echo + done + + echo + read -p "Choose the board you want to flash (empty if none of these): " num + + # None of these + if [ "$num" == "" ]; then + return + fi + + # Check boundaries + counter=${#boards[*]} + if [ $num -lt 1 ] || [ $num -gt $counter ]; then + echo "Board code must be between 1 and $counter" + exit 1 + fi + + # Fill the fields + (( num -- )) + board=${boards[$num]} + +} + +# ------------------------------------------------------------------------------ + +# Welcome +echo +echo "--------------------------------------------------------------" +echo "ESPURNA FIRMWARE OTA FLASHER" + +# Get current version +version=`cat espurna/config/version.h | grep APP_VERSION | awk '{print $3}' | sed 's/"//g'` +echo "Building for version $version" + +echo "--------------------------------------------------------------" +echo + +if exists avahi-browse; then + useAvahi +fi + +if [ "$board" == "" ]; then + getBoard +fi + +if [ "$board" == "" ]; then + read -p "Board type of the device to flash: " -e -i "NODEMCU_LOLIN" board +fi + +if [ "$board" == "" ]; then + echo "You must define the board type" + exit 2 +fi + +if [ "$ip" == "" ]; then + read -p "IP of the device to flash: " -e -i 192.168.1.4 ip +fi + +if [ "$ip" == "" ]; then + echo "You must define the IP of the device" + exit 2 +fi + +if [ "$auth" == "" ]; then + read -p "Authorization key of the device to flash: " auth +fi + +if [ "$flags" == "" ]; then + read -p "Extra flags for the build: " flags +fi + +read -p "Environment to build: " -e -i "esp8266-1m-ota" env + +echo +echo "IP = $ip" +echo "BOARD = $board" +echo "AUTH = $auth" +echo "FLAGS = $flags" +echo "ENV = $env" + +echo +echo -n "Are these values corrent [y/N]: " +read response + +if [ "$response" != "y" ]; then + exit +fi + +export IP=$ip +export BOARD=$board +export AUTH=$auth +export FLAGS=$flags + +pio run -e $env -t upload 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 5/6] 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 From 97f3557e3faa1aca238ae80e1d7e1d9e74af2d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Wed, 6 Sep 2017 10:31:43 +0200 Subject: [PATCH 6/6] Homogenize board names and build flags --- code/espurna/config/hardware.h | 54 +++++++++++++------------- code/ota_flash.sh | 20 +++++----- code/platformio.ini | 70 +++++++++++++++++----------------- 3 files changed, 72 insertions(+), 72 deletions(-) diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index 50c7787f..0d65134f 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -95,7 +95,7 @@ #elif defined(ITEAD_SONOFF_BASIC) // Info - #define MANUFACTURER "ITEAD_STUDIO" + #define MANUFACTURER "ITEAD" #define DEVICE "SONOFF_BASIC" // Buttons @@ -114,7 +114,7 @@ #elif defined(ITEAD_SONOFF_RF) // Info - #define MANUFACTURER "ITEAD_STUDIO" + #define MANUFACTURER "ITEAD" #define DEVICE "SONOFF_RF" // Buttons @@ -133,7 +133,7 @@ #elif defined(ITEAD_SONOFF_TH) // Info - #define MANUFACTURER "ITEAD_STUDIO" + #define MANUFACTURER "ITEAD" #define DEVICE "SONOFF_TH" // Buttons @@ -152,7 +152,7 @@ #elif defined(ITEAD_SONOFF_SV) // Info - #define MANUFACTURER "ITEAD_STUDIO" + #define MANUFACTURER "ITEAD" #define DEVICE "SONOFF_SV" // Buttons @@ -171,7 +171,7 @@ #elif defined(ITEAD_SLAMPHER) // Info - #define MANUFACTURER "ITEAD_STUDIO" + #define MANUFACTURER "ITEAD" #define DEVICE "SLAMPHER" // Buttons @@ -190,7 +190,7 @@ #elif defined(ITEAD_S20) // Info - #define MANUFACTURER "ITEAD_STUDIO" + #define MANUFACTURER "ITEAD" #define DEVICE "S20" // Buttons @@ -209,7 +209,7 @@ #elif defined(ITEAD_SONOFF_TOUCH) // Info - #define MANUFACTURER "ITEAD_STUDIO" + #define MANUFACTURER "ITEAD" #define DEVICE "SONOFF_TOUCH" // Buttons @@ -228,7 +228,7 @@ #elif defined(ITEAD_SONOFF_POW) // Info - #define MANUFACTURER "ITEAD_STUDIO" + #define MANUFACTURER "ITEAD" #define DEVICE "SONOFF_POW" // Buttons @@ -253,7 +253,7 @@ #elif defined(ITEAD_SONOFF_DUAL) // Info - #define MANUFACTURER "ITEAD_STUDIO" + #define MANUFACTURER "ITEAD" #define DEVICE "SONOFF_DUAL" #define SERIAL_BAUDRATE 19230 #define RELAY_PROVIDER RELAY_PROVIDER_DUAL @@ -271,7 +271,7 @@ #elif defined(ITEAD_SONOFF_4CH) // Info - #define MANUFACTURER "ITEAD_STUDIO" + #define MANUFACTURER "ITEAD" #define DEVICE "SONOFF_4CH" // Buttons @@ -308,7 +308,7 @@ #elif defined(ITEAD_SONOFF_4CH_PRO) // Info - #define MANUFACTURER "ITEAD_STUDIO" + #define MANUFACTURER "ITEAD" #define DEVICE "SONOFF_4CH_PRO" // Buttons @@ -354,7 +354,7 @@ // without problem. // Info - #define MANUFACTURER "ITEAD_STUDIO" + #define MANUFACTURER "ITEAD" #define DEVICE "1CH_INCHING" // Buttons @@ -373,7 +373,7 @@ #elif defined(ITEAD_MOTOR) // Info - #define MANUFACTURER "ITEAD_STUDIO" + #define MANUFACTURER "ITEAD" #define DEVICE "MOTOR" // Buttons @@ -389,11 +389,11 @@ #define LED1_PIN 13 #define LED1_PIN_INVERSE 1 -#elif defined(ITEAD_BN_SZ01) +#elif defined(ITEAD_BNSZ01) // Info - #define MANUFACTURER "ITEAD_STUDIO" - #define DEVICE "BN-SZ01" + #define MANUFACTURER "ITEAD" + #define DEVICE "BNSZ01" #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER #define DUMMY_RELAY_COUNT 1 @@ -409,7 +409,7 @@ #elif defined(ITEAD_SONOFF_RFBRIDGE) // Info - #define MANUFACTURER "ITEAD_STUDIO" + #define MANUFACTURER "ITEAD" #define DEVICE "SONOFF_RFBRIDGE" #define SERIAL_BAUDRATE 19200 #define RELAY_PROVIDER RELAY_PROVIDER_RFBRIDGE @@ -429,7 +429,7 @@ #elif defined(ITEAD_SONOFF_B1) // Info - #define MANUFACTURER "ITEAD_STUDIO" + #define MANUFACTURER "ITEAD" #define DEVICE "SONOFF_B1" #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT #define LIGHT_PROVIDER LIGHT_PROVIDER_MY9192 @@ -442,7 +442,7 @@ #elif defined(ITEAD_SONOFF_LED) // Info - #define MANUFACTURER "ITEAD_STUDIO" + #define MANUFACTURER "ITEAD" #define DEVICE "SONOFF_LED" #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER @@ -462,7 +462,7 @@ #elif defined(ITEAD_SONOFF_T1_1CH) // Info - #define MANUFACTURER "ITEAD_STUDIO" + #define MANUFACTURER "ITEAD" #define DEVICE "SONOFF_T1_1CH" // Buttons @@ -481,7 +481,7 @@ #elif defined(ITEAD_SONOFF_T1_2CH) // Info - #define MANUFACTURER "ITEAD_STUDIO" + #define MANUFACTURER "ITEAD" #define DEVICE "SONOFF_T1_2CH" // Buttons @@ -508,7 +508,7 @@ #elif defined(ITEAD_SONOFF_T1_3CH) // Info - #define MANUFACTURER "ITEAD_STUDIO" + #define MANUFACTURER "ITEAD" #define DEVICE "SONOFF_T1_3CH" // Buttons @@ -598,7 +598,7 @@ #elif defined(AITHINKER_AI_LIGHT) // Info - #define MANUFACTURER "AI_THINKER" + #define MANUFACTURER "AITHINKER" #define DEVICE "AI_LIGHT" #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT #define LIGHT_PROVIDER LIGHT_PROVIDER_MY9192 @@ -615,7 +615,7 @@ #elif defined(MAGICHOME_LED_CONTROLLER) // Info - #define MANUFACTURER "MAGIC_HOME" + #define MANUFACTURER "MAGICHOME" #define DEVICE "LED_CONTROLLER" #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER @@ -674,7 +674,7 @@ #elif defined(JANGOE_WIFI_RELAY_NC) // Info - #define MANUFACTURER "JAN_GOEDEKE" + #define MANUFACTURER "JANGOE" #define DEVICE "WIFI_RELAY_NC" // Buttons @@ -697,7 +697,7 @@ #elif defined(JANGOE_WIFI_RELAY_NO) // Info - #define MANUFACTURER "JAN_GOEDEKE" + #define MANUFACTURER "JANGOE" #define DEVICE "WIFI_RELAY_NO" // Buttons @@ -726,7 +726,7 @@ #elif defined(JORGEGARCIA_WIFI_RELAYS) // Info - #define MANUFACTURER "JORGE_GARCIA" + #define MANUFACTURER "JORGEGARCIA" #define DEVICE "WIFI_RELAYS" // Relays diff --git a/code/ota_flash.sh b/code/ota_flash.sh index 7e6df7f0..f8c12c4a 100755 --- a/code/ota_flash.sh +++ b/code/ota_flash.sh @@ -157,7 +157,7 @@ if [ "$board" == "" ]; then fi if [ "$ip" == "" ]; then - read -p "IP of the device to flash: " -e -i 192.168.1.4 ip + read -p "IP of the device to flash: " -e -i 192.168.4.1 ip fi if [ "$ip" == "" ]; then @@ -176,11 +176,11 @@ fi read -p "Environment to build: " -e -i "esp8266-1m-ota" env echo -echo "IP = $ip" -echo "BOARD = $board" -echo "AUTH = $auth" -echo "FLAGS = $flags" -echo "ENV = $env" +echo "ESPURNA_IP = $ip" +echo "ESPURNA_BOARD = $board" +echo "ESPURNA_AUTH = $auth" +echo "ESPURNA_FLAGS = $flags" +echo "ESPURNA_ENV = $env" echo echo -n "Are these values corrent [y/N]: " @@ -190,9 +190,9 @@ if [ "$response" != "y" ]; then exit fi -export IP=$ip -export BOARD=$board -export AUTH=$auth -export FLAGS=$flags +export ESPURNA_IP=$ip +export ESPURNA_BOARD=$board +export ESPURNA_AUTH=$auth +export ESPURNA_FLAGS=$flags pio run -e $env -t upload diff --git a/code/platformio.ini b/code/platformio.ini index 006c26e9..15cf222a 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -4,7 +4,7 @@ src_dir = espurna data_dir = espurna/data [common] -build_flags = -g -DMQTT_MAX_PACKET_SIZE=400 ${env.FLAGS} +build_flags = -g -DMQTT_MAX_PACKET_SIZE=400 ${env.ESPURNA_FLAGS} debug_flags = -DDEBUG_ESP_CORE -DDEBUG_ESP_SSL -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_TLS_MEM build_flags_512k = ${common.build_flags} -Wl,-Tesp8266.flash.512k0.ld build_flags_1m = ${common.build_flags} -Wl,-Tesp8266.flash.1m0.ld @@ -723,6 +723,29 @@ upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 monitor_baud = 115200 +[env:huacanxing-h802] +platform = espressif8266 +framework = arduino +board = esp01_1m +board_flash_mode = dout +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DHUACANXING_H802 -DDEBUG_PORT=Serial1 +monitor_baud = 115200 + +[env:huacanxing-h802-ota] +platform = espressif8266 +framework = arduino +board = esp01_1m +board_flash_mode = dout +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DHUACANXING_H802 -DDEBUG_PORT=Serial1 +upload_speed = 115200 +upload_port = "192.168.4.1" +upload_flags = --auth=fibonacci --port 8266 +monitor_baud = 115200 + [env:itead-bnsz01] platform = espressif8266 framework = arduino @@ -730,7 +753,7 @@ board = esp8285 board_flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_BN_SZ01 +build_flags = ${common.build_flags_1m} -DITEAD_BNSZ01 monitor_baud = 115200 [env:itead-bnsz01-ota] @@ -740,7 +763,7 @@ board = esp8285 board_flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_BN_SZ01 +build_flags = ${common.build_flags_1m} -DITEAD_BNSZ01 upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 @@ -803,10 +826,10 @@ board = esp8285 board_flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -D${env.BOARD} +build_flags = ${common.build_flags_1m} -D${env.ESPURNA_BOARD} upload_speed = 115200 -upload_port = "${env.IP}" -upload_flags = --auth=${env.AUTH} --port 8266 +upload_port = "${env.ESPURNA_IP}" +upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 [env:esp8266-1m-ota] platform = espressif8266 @@ -815,10 +838,10 @@ board = esp01_1m board_flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -D${env.BOARD} +build_flags = ${common.build_flags_1m} -D${env.ESPURNA_BOARD} upload_speed = 115200 -upload_port = "${env.IP}" -upload_flags = --auth=${env.AUTH} --port 8266 +upload_port = "${env.ESPURNA_IP}" +upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 [env:esp8266-4m-ota] platform = espressif8266 @@ -827,30 +850,7 @@ board = esp12e board_flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -D${env.BOARD} +build_flags = ${common.build_flags} -D${env.ESPURNA_BOARD} upload_speed = 115200 -upload_port = "${env.IP}" -upload_flags = --auth=${env.AUTH} --port 8266 - -[env:huacanxing-h802] -platform = espressif8266 -framework = arduino -board = esp01_1m -board_flash_mode = dout -lib_deps = ${common.lib_deps} -lib_ignore = ${common.lib_ignore} -build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DHUACANXING_H802 -DDEBUG_PORT=Serial1 -monitor_baud = 115200 - -[env:huacanxing-h802-ota] -platform = espressif8266 -framework = arduino -board = esp01_1m -board_flash_mode = dout -lib_deps = ${common.lib_deps} -lib_ignore = ${common.lib_ignore} -build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DHUACANXING_H802 -DDEBUG_PORT=Serial1 -upload_speed = 115200 -upload_port = "192.168.4.1" -upload_flags = --auth=fibonacci --port 8266 -monitor_baud = 115200 +upload_port = "${env.ESPURNA_IP}" +upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266