diff --git a/code/build-all b/code/build-all index 375ed666..9a7cfec2 100755 --- a/code/build-all +++ b/code/build-all @@ -1,10 +1,13 @@ #!/bin/bash +mv platformio.ini platformio.backup +cp platformio.custom.ini platformio.ini + # Environments to build -ENVIRONMENTS="sonoff-debug s20-debug" +ENVIRONMENTS="sonoff-debug sonoff-dht22-debug sonoff-ds18b20-debug s20-debug sonoff-pow-debug slampher-debug" # Get current version -version=`cat src/version.h | grep APP_VERSION | awk '{print $3}' | sed 's/"//g'` +version=`cat src/config/version.h | grep APP_VERSION | awk '{print $3}' | sed 's/"//g'` echo $version # Create output folder @@ -13,5 +16,10 @@ mkdir -p firmware # Build all the required firmwares for environment in $ENVIRONMENTS; do platformio run -vv -e $environment - mv .pioenvs/$environment/firmware.bin firmware/espurna-$environment-$version.bin + mv .pioenvs/$environment/firmware.bin firmware/espurna-$version-$environment.bin done + +platformio run -vv -t uploadfs -e node-debug +mv .pioenvs/node-debug/spiffs.bin firmware/espurna-$version-spiffs.bin + +mv platformio.backup platformio.ini diff --git a/code/platformio.custom.ini b/code/platformio.custom.ini index 1dda5f93..22178ada 100644 --- a/code/platformio.custom.ini +++ b/code/platformio.custom.ini @@ -10,10 +10,10 @@ env_default = node-debug [common] -platform = espressif8266 +platform = espressif8266_stage framework = arduino extra_script = pio_hooks.py -lib_ignore = FauxmoESP, ESPAsyncUDP +#lib_ignore = FauxmoESP, ESPAsyncUDP lib_deps = DHT sensor library Adafruit Unified Sensor @@ -37,6 +37,11 @@ upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 +[def] +build_flags_debug = -g -Wl,-Tesp8266.flash.1m128.ld -DDEBUG_PORT=Serial -DENABLE_FAUXMO=1 +build_flags_ota = -Wl,-Tesp8266.flash.1m128.ld -DENABLE_FAUXMO=1 + + # ------------------------------------------------------------------------------ [env:node-debug] @@ -52,18 +57,37 @@ include = env:node-debug,ota [env:sonoff-debug] include = common board = esp01_1m -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF +build_flags = ${def.build_flags_debug} -DSONOFF -[env:sonoff-debug-ota] +[env:sonoff-ota] include = env:sonoff-debug,ota +build_flags = ${def.build_flags_ota} -DSONOFF + +[env:sonoff-dht22-debug] +include = env:sonoff-debug +build_flags = ${def.build_flags_debug} -DSONOFF -DENABLE_DHT=1 + +[env:sonoff-ds18b20-debug] +include = env:sonoff-debug +build_flags = ${def.build_flags_debug} -DSONOFF -DENABLE_DS18B20=1 [env:sonoff-pow-debug] include = common board = esp01_1m -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF_POW +build_flags = ${def.build_flags_debug} -DSONOFF_POW -[env:sonoff-pow-debug-ota] +[env:sonoff-pow-ota] include = env:sonoff-pow-debug,ota +build_flags = ${def.build_flags_ota} -DSONOFF_POW + +[env:sonoff-dual-debug] +include = common +board = esp12e +build_flags = ${def.build_flags_debug} -DSONOFF_DUAL + +[env:sonoff-dual-ota] +include = env:sonoff-dual-debug,ota +build_flags = ${def.build_flags_ota} -DSONOFF_DUAL [env:sonoff-dual-debug] include = common @@ -76,18 +100,20 @@ include = env:sonoff-dual-debug,ota [env:slampher-debug] include = common board = esp01_1m -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSLAMPHER +build_flags = ${def.build_flags_debug} -DSLAMPHER -[env:slampher-debug-ota] +[env:slampher-ota] include = env:slampher-debug,ota +build_flags = ${def.build_flags_ota} -DSLAMPHER [env:s20-debug] include = common board = esp01_1m -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DS20 +build_flags = ${def.build_flags_debug} -DS20 -[env:s20-debug-ota] +[env:s20-ota] include = env:s20-debug,ota +build_flags = ${def.build_flags_ota} -DS20 [env:electrodragon-debug] include = common @@ -106,18 +132,18 @@ include = env:s20-debug-ota [env:washer-device] topic = /home/cellar/washer/ip include = env:sonoff-debug-ota -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF -DENABLE_EMON=1 -DENABLE_DHT=1 +build_flags = -g -Wl,-Tesp8266.flash.1m128.ld -DDEBUG_PORT=Serial -DSONOFF -DENABLE_EMON=1 -DENABLE_DHT=1 [env:studio-lamp-device] topic = /home/studio/lamp/ip include = env:sonoff-debug-ota platform = espressif8266_stage -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF -DENABLE_FAUXMO=1 +build_flags = -g -Wl,-Tesp8266.flash.1m128.ld -DDEBUG_PORT=Serial -DSONOFF -DENABLE_FAUXMO=1 lib_ignore = [env:living-lamp-device] topic = /home/living/lamp/ip include = env:s20-debug-ota platform = espressif8266_stage -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DS20 -DENABLE_FAUXMO=1 +build_flags = -g -Wl,-Tesp8266.flash.1m128.ld -DDEBUG_PORT=Serial -DS20 -DENABLE_FAUXMO=1 lib_ignore = diff --git a/code/platformio.ini b/code/platformio.ini index 95c215b4..6b01fe16 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -53,7 +53,7 @@ board = esp01_1m lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} extra_script = pio_hooks.py -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF +build_flags = -g -Wl,-Tesp8266.flash.1m128.ld -DDEBUG_PORT=Serial -DSONOFF [env:sonoff-debug-ota] platform = espressif8266 @@ -62,11 +62,29 @@ board = esp01_1m lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} extra_script = pio_hooks.py -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF +build_flags = -g -Wl,-Tesp8266.flash.1m128.ld -DDEBUG_PORT=Serial -DSONOFF upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 +[env:sonoff-dht22-debug] +platform = espressif8266 +framework = arduino +board = esp01_1m +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +extra_script = pio_hooks.py +build_flags = -g -Wl,-Tesp8266.flash.1m128.ld -DDEBUG_PORT=Serial -DSONOFF -DENABLE_DHT=1 + +[env:sonoff-ds18b20-debug] +platform = espressif8266 +framework = arduino +board = esp01_1m +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +extra_script = pio_hooks.py +build_flags = -g -Wl,-Tesp8266.flash.1m128.ld -DDEBUG_PORT=Serial -DSONOFF -DENABLE_DS18B20=1 + [env:sonoff-pow-debug] platform = espressif8266 framework = arduino @@ -74,7 +92,7 @@ board = esp01_1m lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} extra_script = pio_hooks.py -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF_POW +build_flags = -g -Wl,-Tesp8266.flash.1m128.ld -DDEBUG_PORT=Serial -DSONOFF_POW [env:sonoff-pow-debug-ota] platform = espressif8266 @@ -83,7 +101,7 @@ board = esp01_1m lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} extra_script = pio_hooks.py -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF_POW +build_flags = -g -Wl,-Tesp8266.flash.1m128.ld -DDEBUG_PORT=Serial -DSONOFF_POW upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 @@ -116,7 +134,7 @@ board = esp01_1m lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} extra_script = pio_hooks.py -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSLAMPHER +build_flags = -g -Wl,-Tesp8266.flash.1m128.ld -DDEBUG_PORT=Serial -DSLAMPHER [env:slampher-debug-ota] platform = espressif8266 @@ -125,7 +143,7 @@ board = esp01_1m lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} extra_script = pio_hooks.py -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSLAMPHER +build_flags = -g -Wl,-Tesp8266.flash.1m128.ld -DDEBUG_PORT=Serial -DSLAMPHER upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 @@ -137,7 +155,7 @@ board = esp01_1m lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} extra_script = pio_hooks.py -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DS20 +build_flags = -g -Wl,-Tesp8266.flash.1m128.ld -DDEBUG_PORT=Serial -DS20 [env:s20-debug-ota] platform = espressif8266 @@ -146,7 +164,7 @@ board = esp01_1m lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} extra_script = pio_hooks.py -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DS20 +build_flags = -g -Wl,-Tesp8266.flash.1m128.ld -DDEBUG_PORT=Serial -DS20 upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 @@ -182,7 +200,7 @@ board = esp01_1m lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} extra_script = pio_hooks.py -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DS20 +build_flags = -g -Wl,-Tesp8266.flash.1m128.ld -DDEBUG_PORT=Serial -DS20 upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 @@ -198,7 +216,7 @@ extra_script = pio_hooks.py upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF -DENABLE_EMON=1 -DENABLE_DHT=1 +build_flags = -g -Wl,-Tesp8266.flash.1m128.ld -DDEBUG_PORT=Serial -DSONOFF -DENABLE_EMON=1 -DENABLE_DHT=1 [env:studio-lamp-device] topic = /home/studio/lamp/ip @@ -208,7 +226,7 @@ board = esp01_1m lib_deps = ${common.lib_deps} lib_ignore = extra_script = pio_hooks.py -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF -DENABLE_FAUXMO=1 +build_flags = -g -Wl,-Tesp8266.flash.1m128.ld -DDEBUG_PORT=Serial -DSONOFF -DENABLE_FAUXMO=1 upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 @@ -221,7 +239,7 @@ board = esp01_1m lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} extra_script = pio_hooks.py -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF -DENABLE_FAUXMO=1 +build_flags = -g -Wl,-Tesp8266.flash.1m128.ld -DDEBUG_PORT=Serial -DSONOFF -DENABLE_FAUXMO=1 upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 diff --git a/code/src/nofuss.ino b/code/src/nofuss.ino index 31c4ac97..bcb94415 100644 --- a/code/src/nofuss.ino +++ b/code/src/nofuss.ino @@ -24,51 +24,46 @@ NoFUSSClient.setVersion(APP_VERSION); NoFUSSClient.onMessage([](nofuss_t code) { if (code == NOFUSS_START) { - Serial.println(F("[NoFUSS] Start")); + DEBUG_MSG("[NoFUSS] Start\n"); } if (code == NOFUSS_UPTODATE) { - Serial.println(F("[NoFUSS] Already in the last version")); + DEBUG_MSG("[NoFUSS] Already in the last version\n"); } if (code == NOFUSS_PARSE_ERROR) { - Serial.println(F("[NoFUSS] Error parsing server response")); + DEBUG_MSG("[NoFUSS] Error parsing server response\n"); } if (code == NOFUSS_UPDATING) { - Serial.println(F("[NoFUSS] Updating")); - Serial.print( F(" New version: ")); - Serial.println(NoFUSSClient.getNewVersion()); - Serial.print( F(" Firmware: ")); - Serial.println(NoFUSSClient.getNewFirmware()); - Serial.print( F(" File System: ")); - Serial.println(NoFUSSClient.getNewFileSystem()); + DEBUG_MSG("[NoFUSS] Updating"); + DEBUG_MSG(" New version: %s\n", (char *) NoFUSSClient.getNewVersion().c_str()); + DEBUG_MSG(" Firmware: %s\n", (char *) NoFUSSClient.getNewFirmware().c_str()); + DEBUG_MSG(" File System: %s", (char *) NoFUSSClient.getNewFileSystem().c_str()); } if (code == NOFUSS_FILESYSTEM_UPDATE_ERROR) { - Serial.print(F("[NoFUSS] File System Update Error: ")); - Serial.println(NoFUSSClient.getErrorString()); + DEBUG_MSG("[NoFUSS] File System Update Error: %s\n", (char *) NoFUSSClient.getErrorString().c_str()); } if (code == NOFUSS_FILESYSTEM_UPDATED) { - Serial.println(F("[NoFUSS] File System Updated")); + DEBUG_MSG("[NoFUSS] File System Updated\n"); } if (code == NOFUSS_FIRMWARE_UPDATE_ERROR) { - Serial.print(F("[NoFUSS] Firmware Update Error: ")); - Serial.println(NoFUSSClient.getErrorString()); + DEBUG_MSG("[NoFUSS] Firmware Update Error: %s\n", (char *) NoFUSSClient.getErrorString().c_str()); } if (code == NOFUSS_FIRMWARE_UPDATED) { - Serial.println(F("[NoFUSS] Firmware Updated")); + DEBUG_MSG("[NoFUSS] Firmware Updated\n"); } if (code == NOFUSS_RESET) { - Serial.println(F("[NoFUSS] Resetting board")); + DEBUG_MSG("[NoFUSS] Resetting board\n"); } if (code == NOFUSS_END) { - Serial.println(F("[NoFUSS] End")); + DEBUG_MSG("[NoFUSS] End\n"); } });