From 295d9839d5f32b48ff562022a4623411657efc97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Sun, 31 Jul 2016 00:54:30 +0200 Subject: [PATCH] Automate build process for multiple environments --- code/build | 17 ++++++++++ code/data/index.html | 4 +-- code/platformio.ini | 75 ++++++++++++++++++++++++++++++-------------- code/src/Config.cpp | 2 -- code/src/main.cpp | 57 ++++++++++++++++++--------------- code/src/version.h | 4 +++ 6 files changed, 106 insertions(+), 53 deletions(-) create mode 100755 code/build create mode 100644 code/src/version.h diff --git a/code/build b/code/build new file mode 100755 index 00000000..375ed666 --- /dev/null +++ b/code/build @@ -0,0 +1,17 @@ +#!/bin/bash + +# Environments to build +ENVIRONMENTS="sonoff-debug s20-debug" + +# Get current version +version=`cat src/version.h | grep APP_VERSION | awk '{print $3}' | sed 's/"//g'` +echo $version + +# Create output folder +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 +done diff --git a/code/data/index.html b/code/data/index.html index 1c40ae68..4591959a 100644 --- a/code/data/index.html +++ b/code/data/index.html @@ -159,10 +159,10 @@
- +
- +
diff --git a/code/platformio.ini b/code/platformio.ini index c45f9cb4..2f4ce0e4 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -1,44 +1,73 @@ -# -# Project Configuration File -# -# A detailed documentation with the EXAMPLES is located here: -# http://docs.platformio.org/en/latest/projectconf.html -# - -# A sign `#` at the beginning of the line indicates a comment -# Comment lines are ignored. +[env:sonoff-debug] +platform = espressif +framework = arduino +board = esp01_1m +lib_install = 89,64,19 +build_flags = -Wl,-Tesp8266.flash.1m256.ld +build_flags = -D SONOFF -D DEBUG -# Simple and base environment -# [env:mybaseenv] -# platform = %INSTALLED_PLATFORM_NAME_HERE% -# framework = -# board = -# -# Automatic targets - enable auto-uploading -# targets = upload +[env:sonoff-debug-ota] +platform = espressif +framework = arduino +board = esp01_1m +lib_install = 89,64,19 +build_flags = -Wl,-Tesp8266.flash.1m256.ld +build_flags = -D SONOFF -D DEBUG +upload_speed = 115200 +upload_port = "192.168.4.1" +upload_flags = --auth=fibonacci --port 8266 -[platformio] -#env_default = wire +[env:slampher-debug] +platform = espressif +framework = arduino +board = esp01_1m +lib_install = 89,64,19 +build_flags = -Wl,-Tesp8266.flash.1m256.ld +build_flags = -D SLAMPHER -D DEBUG -[env:wire] +[env:slampher-debug-ota] platform = espressif framework = arduino board = esp01_1m lib_install = 89,64,19 build_flags = -Wl,-Tesp8266.flash.1m256.ld +build_flags = -D SLAMPHER -D DEBUG +upload_speed = 115200 +upload_port = "192.168.4.1" +upload_flags = --auth=fibonacci --port 8266 -[env:node] +[env:s20-debug] platform = espressif framework = arduino -board = nodemcuv2 +board = esp01_1m lib_install = 89,64,19 +build_flags = -Wl,-Tesp8266.flash.1m256.ld +build_flags = -D S20 -D DEBUG -[env:ota] +[env:s20-debug-ota] platform = espressif framework = arduino board = esp01_1m lib_install = 89,64,19 build_flags = -Wl,-Tesp8266.flash.1m256.ld +build_flags = -D S20 -D DEBUG +upload_speed = 115200 +upload_port = "192.168.4.1" +upload_flags = --auth=fibonacci --port 8266 + +[env:node-debug] +platform = espressif +framework = arduino +board = nodemcuv2 +lib_install = 89,64,19 +build_flags = -D NODEMCUV2 -D DEBUG + +[env:node-debug-ota] +platform = espressif +framework = arduino +board = nodemcuv2 +lib_install = 89,64,19 +build_flags = -D NODEMCUV2 -D DEBUG upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 diff --git a/code/src/Config.cpp b/code/src/Config.cpp index a00df8a2..f4223003 100644 --- a/code/src/Config.cpp +++ b/code/src/Config.cpp @@ -7,8 +7,6 @@ #include "Config.h" #include "EEPROM.h" -#define DEBUG - bool ConfigClass::save() { #ifdef DEBUG diff --git a/code/src/main.cpp b/code/src/main.cpp index b3682d8e..e89454f9 100644 --- a/code/src/main.cpp +++ b/code/src/main.cpp @@ -39,48 +39,52 @@ along with this program. If not, see . #include #include "DHT.h" +#include "version.h" + // ----------------------------------------------------------------------------- -// ConfiguraciĆ³ +// Configuration // ----------------------------------------------------------------------------- -#define DEBUG - +// Managed from platformio.ini +//#define DEBUG //#define ESPURNA //#define SONOFF -#define SLAMPHER +//#define SLAMPHER //#define S20 +//#define NODEMCUV2 -#define ENABLE_RF 0 #define ENABLE_OTA 1 -#define ENABLE_NOFUSS 1 #define ENABLE_MQTT 1 #define ENABLE_WEBSERVER 1 -#define ENABLE_POWERMONITOR 1 -#define ENABLE_DHT 0 -#define APP_NAME "Espurna" -#define APP_VERSION "0.9.4" -#define APP_AUTHOR "xose.perez@gmail.com" -#define APP_WEBSITE "http://tinkerman.cat" +#define ENABLE_NOFUSS 0 +#define ENABLE_POWERMONITOR 0 +#define ENABLE_RF 0 +#define ENABLE_DHT 0 #ifdef ESPURNA #define MANUFACTURER "TINKERMAN" - #define MODEL "ESPURNA" + #define DEVICE "ESPURNA" #endif #ifdef SONOFF #define MANUFACTURER "ITEAD" - #define MODEL "SONOFF" + #define DEVICE "SONOFF" #endif #ifdef SLAMPHER #define MANUFACTURER "ITEAD" - #define MODEL "SLAMPHER" + #define DEVICE "SLAMPHER" #endif #ifdef S20 #define MANUFACTURER "ITEAD" - #define MODEL "S20" + #define DEVICE "S20" +#endif + +#ifdef NODEMCUV2 + #define MANUFACTURER "NODEMCU" + #define DEVICE "LOLIN" #endif #define BUTTON_PIN 0 @@ -88,7 +92,6 @@ along with this program. If not, see . #define LED_PIN 13 #define ADMIN_PASS "fibonacci" - #define BUFFER_SIZE 1024 #define STATUS_UPDATE_INTERVAL 10000 @@ -102,9 +105,8 @@ along with this program. If not, see . #define MQTT_RECONNECT_DELAY 10000 #define MQTT_RETAIN true -#define WIFI_CONNECT_TIMEOUT 5000 +#define WIFI_CONNECT_TIMEOUT 10000 #define WIFI_RECONNECT_DELAY 2000 - #define WIFI_STATUS_CONNECTING 0 #define WIFI_STATUS_CONNECTED 1 #define WIFI_STATUS_AP 2 @@ -167,7 +169,7 @@ DebounceEvent button1 = false; // Utils // ----------------------------------------------------------------------------- -char * getCompileTime(char * buffer) { +void getCompileTime(char * buffer) { int day, month, year, hour, minute, second; @@ -197,13 +199,12 @@ char * getCompileTime(char * buffer) { sprintf(buffer, "%d%02d%02d%02d%02d%02d", year, month, day, hour, minute, second); buffer[14] = 0; - return buffer; } String getIdentifier() { char identifier[20]; - sprintf(identifier, "%s_%06X", MODEL, ESP.getChipId()); + sprintf(identifier, "%s_%06X", DEVICE, ESP.getChipId()); return String(identifier); } @@ -284,7 +285,7 @@ void toggleRelay() { void nofussSetup() { NoFUSSClient.setServer(config.nofussServer); - NoFUSSClient.setDevice(MODEL); + NoFUSSClient.setDevice(DEVICE); NoFUSSClient.setVersion(APP_VERSION); NoFUSSClient.onMessage([](nofuss_t code) { @@ -683,7 +684,7 @@ void wifiLoop() { root["appname"] = String(buffer); root["manufacturer"] = String(MANUFACTURER); - root["model"] = String(MODEL); + root["device"] = String(DEVICE); root["hostname"] = config.hostname; root["network"] = (WiFi.status() == WL_CONNECTED) ? WiFi.SSID() : "ACCESS POINT"; root["ip"] = (WiFi.status() == WL_CONNECTED) ? WiFi.localIP().toString() : WiFi.softAPIP().toString(); @@ -1187,10 +1188,14 @@ void setup() { hardwareSetup(); delay(1000); welcome(); - config.hostname = getIdentifier(); config.load(); - // We are handling first connection in the loop + // At the moment I am overriding any possible hostname stored in EEPROM + // with the generated one until I have a way to change them from the + // configuration interface + config.hostname = getIdentifier(); + + // I am handling first connection in the loop //wifiSetup(false); #if ENABLE_OTA diff --git a/code/src/version.h b/code/src/version.h new file mode 100644 index 00000000..2a0e39e6 --- /dev/null +++ b/code/src/version.h @@ -0,0 +1,4 @@ +#define APP_NAME "Espurna" +#define APP_VERSION "0.9.5" +#define APP_AUTHOR "xose.perez@gmail.com" +#define APP_WEBSITE "http://tinkerman.cat"