diff --git a/code/.github/stale.yml b/.github/stale.yml similarity index 100% rename from code/.github/stale.yml rename to .github/stale.yml diff --git a/.gitignore b/.gitignore index 9278245d..e61c68af 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ custom.h .python .env .DS_Store +.vscode diff --git a/README.md b/README.md index 4ea42ee9..d47d19d2 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ESPurna ("spark" in Catalan) is a custom firmware for ESP8285/ESP8266 based smart switches, lights and sensors. It uses the Arduino Core for ESP8266 framework and a number of 3rd party libraries. -[![version](https://img.shields.io/badge/version-1.12.7a-brightgreen.svg)](CHANGELOG.md) +[![version](https://img.shields.io/badge/version-1.13.0c-brightgreen.svg)](CHANGELOG.md) [![branch](https://img.shields.io/badge/branch-sensors-orange.svg)](https://github.org/xoseperez/espurna/tree/sensors/) [![travis](https://travis-ci.org/xoseperez/espurna.svg?branch=sensors)](https://travis-ci.org/xoseperez/espurna) [![codacy](https://img.shields.io/codacy/grade/c9496e25cf07434cba786b462cb15f49/sensors.svg)](https://www.codacy.com/app/xoseperez/espurna/dashboard) diff --git a/code/esp8266.flash.1m0.ld b/code/eagle.flash.1m0m1s.ld similarity index 75% rename from code/esp8266.flash.1m0.ld rename to code/eagle.flash.1m0m1s.ld index dbb44e94..36477dc8 100644 --- a/code/esp8266.flash.1m0.ld +++ b/code/eagle.flash.1m0m1s.ld @@ -1,4 +1,4 @@ -/* Flash Split for 1M chips, no SPIFFS */ +/* Flash Split for 1M chips */ /* sketch 999KB */ /* eeprom 20KB */ @@ -12,7 +12,7 @@ MEMORY PROVIDE ( _SPIFFS_start = 0x402FB000 ); PROVIDE ( _SPIFFS_end = 0x402FB000 ); -PROVIDE ( _SPIFFS_page = 0 ); -PROVIDE ( _SPIFFS_block = 0 ); +PROVIDE ( _SPIFFS_page = 0x0 ); +PROVIDE ( _SPIFFS_block = 0x0 ); -INCLUDE "esp8266.flash.common.ld" +INCLUDE "../ld/eagle.app.v6.common.ld" diff --git a/code/eagle.flash.1m0m2s.ld b/code/eagle.flash.1m0m2s.ld new file mode 100644 index 00000000..bf07dccd --- /dev/null +++ b/code/eagle.flash.1m0m2s.ld @@ -0,0 +1,19 @@ +/* Flash Split for 1M chips, no SPIFFS */ +/* sketch 995KB */ +/* eeprom 8KB */ +/* reserved 16KB */ + +MEMORY +{ + dport0_0_seg : org = 0x3FF00000, len = 0x10 + dram0_0_seg : org = 0x3FFE8000, len = 0x14000 + iram1_0_seg : org = 0x40100000, len = 0x8000 + irom0_0_seg : org = 0x40201010, len = 0xf8ff0 +} + +PROVIDE ( _SPIFFS_start = 0x402FA000 ); +PROVIDE ( _SPIFFS_end = 0x402FA000 ); +PROVIDE ( _SPIFFS_page = 0 ); +PROVIDE ( _SPIFFS_block = 0 ); + +INCLUDE "../ld/eagle.app.v6.common.ld" diff --git a/code/eagle.flash.4m1m4s.ld b/code/eagle.flash.4m1m4s.ld new file mode 100644 index 00000000..696adcdc --- /dev/null +++ b/code/eagle.flash.4m1m4s.ld @@ -0,0 +1,21 @@ +/* Flash Split for 4M chips */ +/* sketch 1019KB */ +/* empty/ota? 2048KB */ +/* spiffs 992KB */ +/* eeprom 16KB */ +/* reserved 16KB */ + +MEMORY +{ + dport0_0_seg : org = 0x3FF00000, len = 0x10 + dram0_0_seg : org = 0x3FFE8000, len = 0x14000 + iram1_0_seg : org = 0x40100000, len = 0x8000 + irom0_0_seg : org = 0x40201010, len = 0xfeff0 +} + +PROVIDE ( _SPIFFS_start = 0x40500000 ); +PROVIDE ( _SPIFFS_end = 0x405F8000 ); +PROVIDE ( _SPIFFS_page = 0x100 ); +PROVIDE ( _SPIFFS_block = 0x2000 ); + +INCLUDE "../ld/eagle.app.v6.common.ld" diff --git a/code/eagle.flash.4m3m4e.ld b/code/eagle.flash.4m3m4e.ld new file mode 100644 index 00000000..6470d827 --- /dev/null +++ b/code/eagle.flash.4m3m4e.ld @@ -0,0 +1,20 @@ +/* Flash Split for 4M chips */ +/* sketch 1019KB */ +/* spiffs 3040KB */ +/* eeprom 16KB */ +/* reserved 16KB */ + +MEMORY +{ + dport0_0_seg : org = 0x3FF00000, len = 0x10 + dram0_0_seg : org = 0x3FFE8000, len = 0x14000 + iram1_0_seg : org = 0x40100000, len = 0x8000 + irom0_0_seg : org = 0x40201010, len = 0xfeff0 +} + +PROVIDE ( _SPIFFS_start = 0x40300000 ); +PROVIDE ( _SPIFFS_end = 0x405F8000 ); +PROVIDE ( _SPIFFS_page = 0x100 ); +PROVIDE ( _SPIFFS_block = 0x2000 ); + +INCLUDE "../ld/eagle.app.v6.common.ld" diff --git a/code/eagle.flash.512k0m1s.ld b/code/eagle.flash.512k0m1s.ld new file mode 100644 index 00000000..e28fc9f1 --- /dev/null +++ b/code/eagle.flash.512k0m1s.ld @@ -0,0 +1,18 @@ +/* Flash Split for 512K chips */ +/* sketch 487KB */ +/* eeprom 20KB */ + +MEMORY +{ + dport0_0_seg : org = 0x3FF00000, len = 0x10 + dram0_0_seg : org = 0x3FFE8000, len = 0x14000 + iram1_0_seg : org = 0x40100000, len = 0x8000 + irom0_0_seg : org = 0x40201010, len = 0x79ff0 +} + +PROVIDE ( _SPIFFS_start = 0x4027B000 ); +PROVIDE ( _SPIFFS_end = 0x4027B000 ); +PROVIDE ( _SPIFFS_page = 0x0 ); +PROVIDE ( _SPIFFS_block = 0x0 ); + +INCLUDE "../ld/eagle.app.v6.common.ld" diff --git a/code/espurna/api.ino b/code/espurna/api.ino index 58dcf50a..c1c33281 100644 --- a/code/espurna/api.ino +++ b/code/espurna/api.ino @@ -102,7 +102,11 @@ ArRequestHandlerFunction _bindAPI(unsigned int apiID) { // Format response according to the Accept header if (_asJson(request)) { char buffer[64]; - snprintf_P(buffer, sizeof(buffer), PSTR("{ \"%s\": %s }"), api.key, value); + if (isNumber(value)) { + snprintf_P(buffer, sizeof(buffer), PSTR("{ \"%s\": %s }"), api.key, value); + } else { + snprintf_P(buffer, sizeof(buffer), PSTR("{ \"%s\": \"%s\" }"), api.key, value); + } request->send(200, "application/json", buffer); } else { request->send(200, "text/plain", value); @@ -130,6 +134,7 @@ void _onAPIs(AsyncWebServerRequest *request) { root[_apis[i].key] = String(buffer); } root.printTo(output); + jsonBuffer.clear(); request->send(200, "application/json", output); } else { diff --git a/code/espurna/button.ino b/code/espurna/button.ino index e85fba43..ea550e1f 100644 --- a/code/espurna/button.ino +++ b/code/espurna/button.ino @@ -60,16 +60,18 @@ unsigned char buttonAction(unsigned char id, unsigned char event) { if (event == BUTTON_EVENT_DBLCLICK) return (actions >> 8) & 0x0F; if (event == BUTTON_EVENT_LNGCLICK) return (actions >> 12) & 0x0F; if (event == BUTTON_EVENT_LNGLNGCLICK) return (actions >> 16) & 0x0F; + if (event == BUTTON_EVENT_TRIPLECLICK) return (actions >> 20) & 0x0F; return BUTTON_MODE_NONE; } -unsigned long buttonStore(unsigned long pressed, unsigned long click, unsigned long dblclick, unsigned long lngclick, unsigned long lnglngclick) { +unsigned long buttonStore(unsigned long pressed, unsigned long click, unsigned long dblclick, unsigned long lngclick, unsigned long lnglngclick, unsigned long tripleclick) { unsigned int value; value = pressed; value += click << 4; value += dblclick << 8; value += lngclick << 12; value += lnglngclick << 16; + value += tripleclick << 20; return value; } @@ -77,12 +79,13 @@ uint8_t mapEvent(uint8_t event, uint8_t count, uint16_t length) { if (event == EVENT_PRESSED) return BUTTON_EVENT_PRESSED; if (event == EVENT_CHANGED) return BUTTON_EVENT_CLICK; if (event == EVENT_RELEASED) { - if (count == 1) { + if (1 == count) { if (length > BUTTON_LNGLNGCLICK_DELAY) return BUTTON_EVENT_LNGLNGCLICK; if (length > BUTTON_LNGCLICK_DELAY) return BUTTON_EVENT_LNGCLICK; return BUTTON_EVENT_CLICK; } - if (count == 2) return BUTTON_EVENT_DBLCLICK; + if (2 == count) return BUTTON_EVENT_DBLCLICK; + if (3 == count) return BUTTON_EVENT_TRIPLECLICK; } return BUTTON_EVENT_NONE; } @@ -113,7 +116,13 @@ void buttonEvent(unsigned int id, unsigned char event) { relayStatus(_buttons[id].relayID - 1, false); } } - if (action == BUTTON_MODE_AP) createAP(); + if (action == BUTTON_MODE_AP) wifiStartAP(); + #if defined(JUSTWIFI_ENABLE_WPS) + if (action == BUTTON_MODE_WPS) wifiStartWPS(); + #endif // defined(JUSTWIFI_ENABLE_WPS) + #if defined(JUSTWIFI_ENABLE_SMARTCONFIG) + if (action == BUTTON_MODE_SMART_CONFIG) wifiStartSmartConfig(); + #endif // defined(JUSTWIFI_ENABLE_SMARTCONFIG) if (action == BUTTON_MODE_RESET) { deferredReset(100, CUSTOM_RESET_HARDWARE); } @@ -129,7 +138,7 @@ void buttonSetup() { #ifdef ITEAD_SONOFF_DUAL - unsigned int actions = buttonStore(BUTTON_MODE_NONE, BUTTON_MODE_TOGGLE, BUTTON_MODE_NONE, BUTTON_MODE_NONE, BUTTON_MODE_NONE); + unsigned int actions = buttonStore(BUTTON_MODE_NONE, BUTTON_MODE_TOGGLE, BUTTON_MODE_NONE, BUTTON_MODE_NONE, BUTTON_MODE_NONE, BUTTON_MODE_NONE); _buttons.push_back({new DebounceEvent(0, BUTTON_PUSHBUTTON), actions, 1}); _buttons.push_back({new DebounceEvent(0, BUTTON_PUSHBUTTON), actions, 2}); _buttons.push_back({new DebounceEvent(0, BUTTON_PUSHBUTTON), actions, BUTTON3_RELAY}); @@ -140,49 +149,49 @@ void buttonSetup() { #if BUTTON1_PIN != GPIO_NONE { - unsigned int actions = buttonStore(BUTTON1_PRESS, BUTTON1_CLICK, BUTTON1_DBLCLICK, BUTTON1_LNGCLICK, BUTTON1_LNGLNGCLICK); + unsigned int actions = buttonStore(BUTTON1_PRESS, BUTTON1_CLICK, BUTTON1_DBLCLICK, BUTTON1_LNGCLICK, BUTTON1_LNGLNGCLICK, BUTTON1_TRIPLECLICK); _buttons.push_back({new DebounceEvent(BUTTON1_PIN, BUTTON1_MODE, BUTTON_DEBOUNCE_DELAY, btnDelay), actions, BUTTON1_RELAY}); } #endif #if BUTTON2_PIN != GPIO_NONE { - unsigned int actions = buttonStore(BUTTON2_PRESS, BUTTON2_CLICK, BUTTON2_DBLCLICK, BUTTON2_LNGCLICK, BUTTON2_LNGLNGCLICK); + unsigned int actions = buttonStore(BUTTON2_PRESS, BUTTON2_CLICK, BUTTON2_DBLCLICK, BUTTON2_LNGCLICK, BUTTON2_LNGLNGCLICK, BUTTON2_TRIPLECLICK); _buttons.push_back({new DebounceEvent(BUTTON2_PIN, BUTTON2_MODE, BUTTON_DEBOUNCE_DELAY, btnDelay), actions, BUTTON2_RELAY}); } #endif #if BUTTON3_PIN != GPIO_NONE { - unsigned int actions = buttonStore(BUTTON3_PRESS, BUTTON3_CLICK, BUTTON3_DBLCLICK, BUTTON3_LNGCLICK, BUTTON3_LNGLNGCLICK); + unsigned int actions = buttonStore(BUTTON3_PRESS, BUTTON3_CLICK, BUTTON3_DBLCLICK, BUTTON3_LNGCLICK, BUTTON3_LNGLNGCLICK, BUTTON3_TRIPLECLICK); _buttons.push_back({new DebounceEvent(BUTTON3_PIN, BUTTON3_MODE, BUTTON_DEBOUNCE_DELAY, btnDelay), actions, BUTTON3_RELAY}); } #endif #if BUTTON4_PIN != GPIO_NONE { - unsigned int actions = buttonStore(BUTTON4_PRESS, BUTTON4_CLICK, BUTTON4_DBLCLICK, BUTTON4_LNGCLICK, BUTTON4_LNGLNGCLICK); + unsigned int actions = buttonStore(BUTTON4_PRESS, BUTTON4_CLICK, BUTTON4_DBLCLICK, BUTTON4_LNGCLICK, BUTTON4_LNGLNGCLICK, BUTTON4_TRIPLECLICK); _buttons.push_back({new DebounceEvent(BUTTON4_PIN, BUTTON4_MODE, BUTTON_DEBOUNCE_DELAY, btnDelay), actions, BUTTON4_RELAY}); } #endif #if BUTTON5_PIN != GPIO_NONE { - unsigned int actions = buttonStore(BUTTON5_PRESS, BUTTON5_CLICK, BUTTON5_DBLCLICK, BUTTON5_LNGCLICK, BUTTON5_LNGLNGCLICK); + unsigned int actions = buttonStore(BUTTON5_PRESS, BUTTON5_CLICK, BUTTON5_DBLCLICK, BUTTON5_LNGCLICK, BUTTON5_LNGLNGCLICK, BUTTON5_TRIPLECLICK); _buttons.push_back({new DebounceEvent(BUTTON5_PIN, BUTTON5_MODE, BUTTON_DEBOUNCE_DELAY, btnDelay), actions, BUTTON5_RELAY}); } #endif #if BUTTON6_PIN != GPIO_NONE { - unsigned int actions = buttonStore(BUTTON6_PRESS, BUTTON6_CLICK, BUTTON6_DBLCLICK, BUTTON6_LNGCLICK, BUTTON6_LNGLNGCLICK); + unsigned int actions = buttonStore(BUTTON6_PRESS, BUTTON6_CLICK, BUTTON6_DBLCLICK, BUTTON6_LNGCLICK, BUTTON6_LNGLNGCLICK, BUTTON6_TRIPLECLICK); _buttons.push_back({new DebounceEvent(BUTTON6_PIN, BUTTON6_MODE, BUTTON_DEBOUNCE_DELAY, btnDelay), actions, BUTTON6_RELAY}); } #endif #if BUTTON7_PIN != GPIO_NONE { - unsigned int actions = buttonStore(BUTTON7_PRESS, BUTTON7_CLICK, BUTTON7_DBLCLICK, BUTTON7_LNGCLICK, BUTTON7_LNGLNGCLICK); + unsigned int actions = buttonStore(BUTTON7_PRESS, BUTTON7_CLICK, BUTTON7_DBLCLICK, BUTTON7_LNGCLICK, BUTTON7_LNGLNGCLICK, BUTTON7_TRIPLECLICK); _buttons.push_back({new DebounceEvent(BUTTON7_PIN, BUTTON7_MODE, BUTTON_DEBOUNCE_DELAY, btnDelay), actions, BUTTON7_RELAY}); } #endif #if BUTTON8_PIN != GPIO_NONE { - unsigned int actions = buttonStore(BUTTON8_PRESS, BUTTON8_CLICK, BUTTON8_DBLCLICK, BUTTON8_LNGCLICK, BUTTON8_LNGLNGCLICK); + unsigned int actions = buttonStore(BUTTON8_PRESS, BUTTON8_CLICK, BUTTON8_DBLCLICK, BUTTON8_LNGCLICK, BUTTON8_LNGLNGCLICK, BUTTON8_TRIPLECLICK); _buttons.push_back({new DebounceEvent(BUTTON8_PIN, BUTTON8_MODE, BUTTON_DEBOUNCE_DELAY, btnDelay), actions, BUTTON8_RELAY}); } #endif diff --git a/code/espurna/config/all.h b/code/espurna/config/all.h index 39d2bef9..d21eb007 100644 --- a/code/espurna/config/all.h +++ b/code/espurna/config/all.h @@ -31,8 +31,8 @@ #include "general.h" #include "prototypes.h" #include "sensors.h" -#include "progmem.h" #include "dependencies.h" +#include "progmem.h" #include "debug.h" #ifdef USE_CORE_VERSION_H diff --git a/code/espurna/config/arduino.h b/code/espurna/config/arduino.h index ae43569b..5a978961 100644 --- a/code/espurna/config/arduino.h +++ b/code/espurna/config/arduino.h @@ -145,3 +145,4 @@ //#define SI7021_SUPPORT 1 //#define TMP3X_SUPPORT 1 //#define V9261F_SUPPORT 1 +//#define GEIGER_SUPPORT 1 diff --git a/code/espurna/config/defaults.h b/code/espurna/config/defaults.h index b16a466a..96bc7047 100644 --- a/code/espurna/config/defaults.h +++ b/code/espurna/config/defaults.h @@ -108,6 +108,31 @@ #define BUTTON8_DBLCLICK BUTTON_MODE_NONE #endif +#ifndef BUTTON1_TRIPLECLICK +#define BUTTON1_TRIPLECLICK BUTTON_MODE_SMART_CONFIG +#endif +#ifndef BUTTON2_TRIPLECLICK +#define BUTTON2_TRIPLECLICK BUTTON_MODE_NONE +#endif +#ifndef BUTTON3_TRIPLECLICK +#define BUTTON3_TRIPLECLICK BUTTON_MODE_NONE +#endif +#ifndef BUTTON4_TRIPLECLICK +#define BUTTON4_TRIPLECLICK BUTTON_MODE_NONE +#endif +#ifndef BUTTON5_TRIPLECLICK +#define BUTTON5_TRIPLECLICK BUTTON_MODE_NONE +#endif +#ifndef BUTTON6_TRIPLECLICK +#define BUTTON6_TRIPLECLICK BUTTON_MODE_NONE +#endif +#ifndef BUTTON7_TRIPLECLICK +#define BUTTON7_TRIPLECLICK BUTTON_MODE_NONE +#endif +#ifndef BUTTON8_TRIPLECLICK +#define BUTTON8_TRIPLECLICK BUTTON_MODE_NONE +#endif + #ifndef BUTTON1_LNGCLICK #define BUTTON1_LNGCLICK BUTTON_MODE_RESET #endif diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index 225d9c9b..fec8c9e8 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -142,12 +142,17 @@ //------------------------------------------------------------------------------ #define EEPROM_SIZE 4096 // EEPROM size in bytes +//#define EEPROM_RORATE_SECTORS 2 // Number of sectors to use for EEPROM rotation + // If not defined the firmware will use a number based + // on the number of available sectors + #define EEPROM_RELAY_STATUS 0 // Address for the relay status (1 byte) #define EEPROM_ENERGY_COUNT 1 // Address for the energy counter (4 bytes) #define EEPROM_CUSTOM_RESET 5 // Address for the reset reason (1 byte) #define EEPROM_CRASH_COUNTER 6 // Address for the crash counter (1 byte) #define EEPROM_MESSAGE_ID 7 // Address for the MQTT message id (4 bytes) -#define EEPROM_DATA_END 11 // End of custom EEPROM data block +#define EEPROM_ROTATE_DATA 11 // Reserved for the EEPROM_ROTATE library (3 bytes) +#define EEPROM_DATA_END 14 // End of custom EEPROM data block //------------------------------------------------------------------------------ // HEARTBEAT @@ -276,9 +281,6 @@ #define WIFI_AP_CAPTIVE 1 // Captive portal enabled when in AP mode #endif -#ifndef WIFI_AP_MODE -#define WIFI_AP_MODE AP_MODE_ALONE -#endif #ifndef WIFI_SLEEP_MODE #define WIFI_SLEEP_MODE WIFI_NONE_SLEEP // WIFI_NONE_SLEEP, WIFI_LIGHT_SLEEP or WIFI_MODEM_SLEEP @@ -682,6 +684,7 @@ #define MQTT_TOPIC_UARTOUT "uartout" #define MQTT_TOPIC_LOADAVG "loadavg" #define MQTT_TOPIC_BOARD "board" +#define MQTT_TOPIC_PULSE "pulse" // Light module #define MQTT_TOPIC_CHANNEL "channel" diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index d8361c4f..396c366f 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -70,6 +70,12 @@ #define LED1_PIN 2 #define LED1_PIN_INVERSE 1 +#elif defined(NODEMCU_BASIC) + // Info + // Generic NodeMCU Board without any buttons or relays connected. + #define MANUFACTURER "NODEMCU" + #define DEVICE "BASIC" + #elif defined(WEMOS_D1_MINI_RELAYSHIELD) // Info diff --git a/code/espurna/config/progmem.h b/code/espurna/config/progmem.h index 437e77b8..7f91f2da 100644 --- a/code/espurna/config/progmem.h +++ b/code/espurna/config/progmem.h @@ -23,19 +23,187 @@ PROGMEM const char* const custom_reset_string[] = { custom_reset_factory }; +//-------------------------------------------------------------------------------- +// Capabilities +//-------------------------------------------------------------------------------- + +PROGMEM const char espurna_modules[] = + #if ALEXA_SUPPORT + "ALEXA " + #endif + #if BROKER_SUPPORT + "BROKER " + #endif + #if DEBUG_SERIAL_SUPPORT + "DEBUG_SERIAL " + #endif + #if DEBUG_TELNET_SUPPORT + "DEBUG_TELNET " + #endif + #if DEBUG_UDP_SUPPORT + "DEBUG_UDP " + #endif + #if DEBUG_WEB_SUPPORT + "DEBUG_WEB " + #endif + #if DOMOTICZ_SUPPORT + "DOMOTICZ " + #endif + #if HOMEASSISTANT_SUPPORT + "HOMEASSISTANT " + #endif + #if I2C_SUPPORT + "I2C " + #endif + #if INFLUXDB_SUPPORT + "INFLUXDB " + #endif + #if LLMNR_SUPPORT + "LLMNR " + #endif + #if MDNS_SERVER_SUPPORT + "MDNS_SERVER " + #endif + #if MDNS_CLIENT_SUPPORT + "MDNS_CLIENT " + #endif + #if MQTT_SUPPORT + "MQTT " + #endif + #if NETBIOS_SUPPORT + "NETBIOS " + #endif + #if NOFUSS_SUPPORT + "NOFUSS " + #endif + #if NTP_SUPPORT + "NTP " + #endif + #if RF_SUPPORT + "RF " + #endif + #if SCHEDULER_SUPPORT + "SCHEDULER " + #endif + #if SENSOR_SUPPORT + "SENSOR " + #endif + #if SPIFFS_SUPPORT + "SPIFFS " + #endif + #if SSDP_SUPPORT + "SSDP " + #endif + #if TELNET_SUPPORT + "TELNET " + #endif + #if TERMINAL_SUPPORT + "TERMINAL " + #endif + #if THINGSPEAK_SUPPORT + "THINGSPEAK " + #endif + #if UART_MQTT_SUPPORT + "UART_MQTT " + #endif + #if WEB_SUPPORT + "WEB " + #endif + ""; + //-------------------------------------------------------------------------------- // Sensors //-------------------------------------------------------------------------------- #if SENSOR_SUPPORT +PROGMEM const char espurna_sensors[] = + #if AM2320_SUPPORT + "AM2320_I2C " + #endif + #if ANALOG_SUPPORT + "ANALOG " + #endif + #if BH1750_SUPPORT + "BH1750 " + #endif + #if BMX280_SUPPORT + "BMX280 " + #endif + #if CSE7766_SUPPORT + "CSE7766 " + #endif + #if DALLAS_SUPPORT + "DALLAS " + #endif + #if DHT_SUPPORT + "DHTXX " + #endif + #if DIGITAL_SUPPORT + "DIGITAL " + #endif + #if ECH1560_SUPPORT + "ECH1560 " + #endif + #if EMON_ADC121_SUPPORT + "EMON_ADC121 " + #endif + #if EMON_ADS1X15_SUPPORT + "EMON_ADX1X15 " + #endif + #if EMON_ANALOG_SUPPORT + "EMON_ANALOG " + #endif + #if EVENTS_SUPPORT + "EVENTS " + #endif + #if GEIGER_SUPPORT + "GEIGER " + #endif + #if GUVAS12SD_SUPPORT + "GUVAS12SD " + #endif + #if HCSR04_SUPPORT + "HCSR04 " + #endif + #if HLW8012_SUPPORT + "HLW8012 " + #endif + #if MHZ19_SUPPORT + "MHZ19 " + #endif + #if PMSX003_SUPPORT + "PMSX003 " + #endif + #if PZEM004T_SUPPORT + "PZEM004T " + #endif + #if SENSEAIR_SUPPORT + "SENSEAIR " + #endif + #if SHT3X_I2C_SUPPORT + "SHT3X_I2C " + #endif + #if SI7021_SUPPORT + "SI7021 " + #endif + #if TMP3X_SUPPORT + "TMP3X " + #endif + #if V9261F_SUPPORT + "V9261F " + #endif + ""; + + PROGMEM const unsigned char magnitude_decimals[] = { 0, 1, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 3, 3 + 0, 0, 3, 3, + 4, 4 // Geiger Counter decimals }; PROGMEM const char magnitude_unknown_topic[] = "unknown"; @@ -61,6 +229,8 @@ PROGMEM const char magnitude_lux_topic[] = "lux"; PROGMEM const char magnitude_uv_topic[] = "uv"; PROGMEM const char magnitude_distance_topic[] = "distance"; PROGMEM const char magnitude_hcho_topic[] = "hcho"; +PROGMEM const char magnitude_geiger_cpm_topic[] = "ldr_cpm"; // local dose rate [Counts per minute] +PROGMEM const char magnitude_geiger_sv_topic[] = "ldr_uSvh"; // local dose rate [µSievert per hour] PROGMEM const char* const magnitude_topics[] = { magnitude_unknown_topic, magnitude_temperature_topic, magnitude_humidity_topic, @@ -70,7 +240,8 @@ PROGMEM const char* const magnitude_topics[] = { magnitude_analog_topic, magnitude_digital_topic, magnitude_events_topic, magnitude_pm1dot0_topic, magnitude_pm2dot5_topic, magnitude_pm10_topic, magnitude_co2_topic, magnitude_lux_topic, magnitude_uv_topic, - magnitude_distance_topic, magnitude_hcho_topic + magnitude_distance_topic, magnitude_hcho_topic, + magnitude_geiger_cpm_topic, magnitude_geiger_sv_topic // Geiger Counter topics }; PROGMEM const char magnitude_empty[] = ""; @@ -90,6 +261,9 @@ PROGMEM const char magnitude_lux[] = "lux"; PROGMEM const char magnitude_uv[] = "uv"; PROGMEM const char magnitude_distance[] = "m"; PROGMEM const char magnitude_mgm3[] = "mg/m³"; +PROGMEM const char magnitude_geiger_cpm[] = "cpm"; // Counts per Minute: Unit of local dose rate (Geiger counting) +PROGMEM const char magnitude_geiger_sv[] = "µSv/h"; // µSievert per hour: 2nd unit of local dose rate (Geiger counting) + PROGMEM const char* const magnitude_units[] = { magnitude_empty, magnitude_celsius, magnitude_percentage, @@ -99,8 +273,8 @@ PROGMEM const char* const magnitude_units[] = { magnitude_empty, magnitude_empty, magnitude_empty, magnitude_ugm3, magnitude_ugm3, magnitude_ugm3, magnitude_ppm, magnitude_lux, magnitude_uv, - magnitude_distance, magnitude_mgm3 - + magnitude_distance, magnitude_mgm3, + magnitude_geiger_cpm, magnitude_geiger_sv // Geiger counter units }; #endif diff --git a/code/espurna/config/prototypes.h b/code/espurna/config/prototypes.h index 2a581218..6db0a23b 100644 --- a/code/espurna/config/prototypes.h +++ b/code/espurna/config/prototypes.h @@ -7,6 +7,12 @@ extern "C" { #include "user_interface.h" } +// ----------------------------------------------------------------------------- +// EEPROM_ROTATE +// ----------------------------------------------------------------------------- +#include +EEPROM_Rotate EEPROMr; + // ----------------------------------------------------------------------------- // WebServer // ----------------------------------------------------------------------------- @@ -67,6 +73,7 @@ void settingsGetJson(JsonObject& data); bool settingsRestoreJson(JsonObject& data); void settingsRegisterCommand(const String& name, void (*call)(Embedis*)); void settingsInject(void *data, size_t len); +Stream & settingsSerial(); // ----------------------------------------------------------------------------- // I2C diff --git a/code/espurna/config/sensors.h b/code/espurna/config/sensors.h index 42adc155..da8da1f0 100644 --- a/code/espurna/config/sensors.h +++ b/code/espurna/config/sensors.h @@ -285,7 +285,36 @@ #define EVENTS_INTERRUPT_MODE RISING // RISING, FALLING, BOTH #endif -#define EVENTS_DEBOUNCE 50 // Do not register events within less than 10 millis +#define EVENTS_DEBOUNCE 50 // Do not register events within less than 50 millis + +//------------------------------------------------------------------------------ +// Geiger sensor +// Enable support by passing GEIGER_SUPPORT=1 build flag +//------------------------------------------------------------------------------ + +#ifndef GEIGER_SUPPORT +#define GEIGER_SUPPORT 0 // Do not build with geiger support by default +#endif + +#ifndef GEIGER_PIN +#define GEIGER_PIN D1 // GPIO to monitor "D1" => "GPIO5" +#endif + +#ifndef GEIGER_PIN_MODE +#define GEIGER_PIN_MODE INPUT // INPUT, INPUT_PULLUP +#endif + +#ifndef GEIGER_INTERRUPT_MODE +#define GEIGER_INTERRUPT_MODE RISING // RISING, FALLING, BOTH +#endif + +#define GEIGER_DEBOUNCE 25 // Do not register events within less than 25 millis. + // Value derived here: Debounce time 25ms, because https://github.com/Trickx/espurna/wiki/Geiger-counter + +#define GEIGER_CPM2SIEVERT 240 // CPM to µSievert per hour conversion factor + // Typically the literature uses the invers, but I find an integer type more convienient. +#define GEIGER_REPORT_SIEVERTS 1 // Enabler for local dose rate reports in µSv/h +#define GEIGER_REPORT_CPM 1 // Enabler for local dose rate reports in counts per minute //------------------------------------------------------------------------------ // GUVAS12SD UV Sensor (analog) @@ -428,7 +457,7 @@ #endif #ifndef PZEM004T_USE_SOFT -#define PZEM004T_USE_SOFT 0 // Use software serial +#define PZEM004T_USE_SOFT 0 // Software serial is not working atm, use hardware serial #endif #ifndef PZEM004T_RX_PIN @@ -527,6 +556,7 @@ EMON_ADS1X15_SUPPORT || \ EMON_ANALOG_SUPPORT || \ EVENTS_SUPPORT || \ + GEIGER_SUPPORT || \ GUVAS12SD_SUPPORT || \ HCSR04_SUPPORT || \ HLW8012_SUPPORT || \ @@ -639,6 +669,10 @@ #include "../sensors/EventSensor.h" #endif +#if GEIGER_SUPPORT + #include "../sensors/GeigerSensor.h" // The main file for geiger counting module +#endif + #if GUVAS12SD_SUPPORT #include "../sensors/GUVAS12SDSensor.h" #endif diff --git a/code/espurna/config/types.h b/code/espurna/config/types.h index 9d10c62a..b6e11d51 100644 --- a/code/espurna/config/types.h +++ b/code/espurna/config/types.h @@ -3,6 +3,19 @@ // Do not touch this definitions //------------------------------------------------------------------------------ +// ----------------------------------------------------------------------------- +// WIFI +// ----------------------------------------------------------------------------- + +#define WIFI_STATE_AP 1 +#define WIFI_STATE_STA 2 +#define WIFI_STATE_AP_STA 3 +#define WIFI_STATE_WPS 4 +#define WIFI_STATE_SMARTCONFIG 8 + +#define WIFI_AP_ALLWAYS 1 +#define WIFI_AP_FALLBACK 2 + //------------------------------------------------------------------------------ // BUTTONS //------------------------------------------------------------------------------ @@ -14,6 +27,7 @@ #define BUTTON_EVENT_DBLCLICK 3 #define BUTTON_EVENT_LNGCLICK 4 #define BUTTON_EVENT_LNGLNGCLICK 5 +#define BUTTON_EVENT_TRIPLECLICK 6 #define BUTTON_MODE_NONE 0 #define BUTTON_MODE_TOGGLE 1 @@ -23,6 +37,8 @@ #define BUTTON_MODE_RESET 5 #define BUTTON_MODE_PULSE 6 #define BUTTON_MODE_FACTORY 7 +#define BUTTON_MODE_WPS 8 +#define BUTTON_MODE_SMART_CONFIG 9 // Needed for ESP8285 boards under Windows using PlatformIO (?) #ifndef BUTTON_PUSHBUTTON @@ -251,6 +267,7 @@ #define SENSOR_TMP3X_ID 0x22 #define SENSOR_HCSR04_ID 0x23 #define SENSOR_SENSEAIR_ID 0x24 +#define SENSOR_GEIGER_ID 0x25 //-------------------------------------------------------------------------------- // Magnitudes @@ -279,5 +296,7 @@ #define MAGNITUDE_UV 20 #define MAGNITUDE_DISTANCE 21 #define MAGNITUDE_HCHO 22 +#define MAGNITUDE_GEIGER_CPM 23 +#define MAGNITUDE_GEIGER_SIEVERT 24 -#define MAGNITUDE_MAX 23 +#define MAGNITUDE_MAX 25 diff --git a/code/espurna/config/version.h b/code/espurna/config/version.h index 13b490d2..6f2333e7 100644 --- a/code/espurna/config/version.h +++ b/code/espurna/config/version.h @@ -1,5 +1,5 @@ #define APP_NAME "ESPURNA" -#define APP_VERSION "1.12.7a" +#define APP_VERSION "1.13.0c" #define APP_REVISION "db84006" #define APP_AUTHOR "xose.perez@gmail.com" #define APP_WEBSITE "http://tinkerman.cat" diff --git a/code/espurna/debug.ino b/code/espurna/debug.ino index e7659693..7eea7ccb 100644 --- a/code/espurna/debug.ino +++ b/code/espurna/debug.ino @@ -10,7 +10,7 @@ Copyright (C) 2016-2018 by Xose Pérez #include #include -#include +#include extern "C" { #include "user_interface.h" @@ -26,6 +26,8 @@ char _udp_syslog_header[40] = {0}; void _debugSend(char * message) { + bool pause = false; + #if DEBUG_ADD_TIMESTAMP static bool add_timestamp = true; char timestamp[10] = {0}; @@ -50,6 +52,7 @@ void _debugSend(char * message) { #endif _udp_debug.write(message); _udp_debug.endPacket(); + pause = true; #if SYSTEM_CHECK_ENABLED } #endif @@ -60,24 +63,31 @@ void _debugSend(char * message) { _telnetWrite(timestamp, strlen(timestamp)); #endif _telnetWrite(message, strlen(message)); + pause = true; #endif #if DEBUG_WEB_SUPPORT if (wsConnected() && (getFreeHeap() > 10000)) { - String m = String(message); - m.replace("\"", """); - m.replace("{", "{"); - m.replace("}", "}"); - char buffer[m.length() + 24]; + DynamicJsonBuffer jsonBuffer(JSON_OBJECT_SIZE(1) + strlen(message) + 17); + JsonObject &root = jsonBuffer.createObject(); #if DEBUG_ADD_TIMESTAMP - snprintf_P(buffer, sizeof(buffer), PSTR("{\"weblog\": \"%s%s\"}"), timestamp, m.c_str()); + char buffer[strlen(timestamp) + strlen(message) + 1]; + snprintf_P(buffer, sizeof(buffer), "%s%s", timestamp, message); + root.set("weblog", buffer); #else - snprintf_P(buffer, sizeof(buffer), PSTR("{\"weblog\": \"%s\"}"), m.c_str()); + root.set("weblog", message); #endif - wsSend(buffer); + String out; + root.printTo(out); + jsonBuffer.clear(); + + wsSend(out.c_str()); + pause = true; } #endif + if (pause) optimistic_yield(100); + } // ----------------------------------------------------------------------------- @@ -204,31 +214,31 @@ extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack // write crash time to EEPROM uint32_t crash_time = millis(); - EEPROM.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_CRASH_TIME, crash_time); + EEPROMr.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_CRASH_TIME, crash_time); // write reset info to EEPROM - EEPROM.write(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_RESTART_REASON, rst_info->reason); - EEPROM.write(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EXCEPTION_CAUSE, rst_info->exccause); + EEPROMr.write(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_RESTART_REASON, rst_info->reason); + EEPROMr.write(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EXCEPTION_CAUSE, rst_info->exccause); // write epc1, epc2, epc3, excvaddr and depc to EEPROM - EEPROM.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC1, rst_info->epc1); - EEPROM.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC2, rst_info->epc2); - EEPROM.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC3, rst_info->epc3); - EEPROM.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EXCVADDR, rst_info->excvaddr); - EEPROM.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_DEPC, rst_info->depc); + EEPROMr.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC1, rst_info->epc1); + EEPROMr.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC2, rst_info->epc2); + EEPROMr.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC3, rst_info->epc3); + EEPROMr.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EXCVADDR, rst_info->excvaddr); + EEPROMr.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_DEPC, rst_info->depc); // write stack start and end address to EEPROM - EEPROM.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_STACK_START, stack_start); - EEPROM.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_STACK_END, stack_end); + EEPROMr.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_STACK_START, stack_start); + EEPROMr.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_STACK_END, stack_end); // write stack trace to EEPROM int16_t current_address = SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_STACK_TRACE; for (uint32_t i = stack_start; i < stack_end; i++) { byte* byteValue = (byte*) i; - EEPROM.write(current_address++, *byteValue); + EEPROMr.write(current_address++, *byteValue); } - EEPROM.commit(); + EEPROMr.commit(); } @@ -237,8 +247,8 @@ extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack */ void debugClearCrashInfo() { uint32_t crash_time = 0xFFFFFFFF; - EEPROM.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_CRASH_TIME, crash_time); - EEPROM.commit(); + EEPROMr.put(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_CRASH_TIME, crash_time); + EEPROMr.commit(); } /** @@ -247,28 +257,28 @@ void debugClearCrashInfo() { void debugDumpCrashInfo() { uint32_t crash_time; - EEPROM.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_CRASH_TIME, crash_time); + EEPROMr.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_CRASH_TIME, crash_time); if ((crash_time == 0) || (crash_time == 0xFFFFFFFF)) { DEBUG_MSG_P(PSTR("[DEBUG] No crash info\n")); return; } DEBUG_MSG_P(PSTR("[DEBUG] Latest crash was at %lu ms after boot\n"), crash_time); - DEBUG_MSG_P(PSTR("[DEBUG] Reason of restart: %u\n"), EEPROM.read(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_RESTART_REASON)); - DEBUG_MSG_P(PSTR("[DEBUG] Exception cause: %u\n"), EEPROM.read(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EXCEPTION_CAUSE)); + DEBUG_MSG_P(PSTR("[DEBUG] Reason of restart: %u\n"), EEPROMr.read(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_RESTART_REASON)); + DEBUG_MSG_P(PSTR("[DEBUG] Exception cause: %u\n"), EEPROMr.read(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EXCEPTION_CAUSE)); uint32_t epc1, epc2, epc3, excvaddr, depc; - EEPROM.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC1, epc1); - EEPROM.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC2, epc2); - EEPROM.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC3, epc3); - EEPROM.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EXCVADDR, excvaddr); - EEPROM.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_DEPC, depc); + EEPROMr.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC1, epc1); + EEPROMr.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC2, epc2); + EEPROMr.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EPC3, epc3); + EEPROMr.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_EXCVADDR, excvaddr); + EEPROMr.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_DEPC, depc); DEBUG_MSG_P(PSTR("[DEBUG] epc1=0x%08x epc2=0x%08x epc3=0x%08x\n"), epc1, epc2, epc3); DEBUG_MSG_P(PSTR("[DEBUG] excvaddr=0x%08x depc=0x%08x\n"), excvaddr, depc); uint32_t stack_start, stack_end; - EEPROM.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_STACK_START, stack_start); - EEPROM.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_STACK_END, stack_end); + EEPROMr.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_STACK_START, stack_start); + EEPROMr.get(SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_STACK_END, stack_end); DEBUG_MSG_P(PSTR("[DEBUG] >>>stack>>>\n[DEBUG] ")); int16_t current_address = SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_STACK_TRACE; int16_t stack_len = stack_end - stack_start; @@ -276,7 +286,7 @@ void debugDumpCrashInfo() { for (int16_t i = 0; i < stack_len; i += 0x10) { DEBUG_MSG_P(PSTR("%08x: "), stack_start + i); for (byte j = 0; j < 4; j++) { - EEPROM.get(current_address, stack_trace); + EEPROMr.get(current_address, stack_trace); DEBUG_MSG_P(PSTR("%08x "), stack_trace); current_address += 4; } diff --git a/code/espurna/eeprom.ino b/code/espurna/eeprom.ino new file mode 100644 index 00000000..2e79fcbb --- /dev/null +++ b/code/espurna/eeprom.ino @@ -0,0 +1,86 @@ +/* + +EEPROM MODULE + +*/ + +#include + +// ----------------------------------------------------------------------------- + +bool eepromRotate(bool value) { + // Enable/disable EEPROM rotation only if we are using more sectors than the + // reserved by the memory layout + if (EEPROMr.size() > EEPROMr.reserved()) { + if (value) { + DEBUG_MSG_P(PSTR("[EEPROM] Reenabling EEPROM rotation\n")); + } else { + DEBUG_MSG_P(PSTR("[EEPROM] Disabling EEPROM rotation\n")); + } + EEPROMr.rotate(value); + } +} + +String eepromSectors() { + String response; + for (uint32_t i = 0; i < EEPROMr.size(); i++) { + if (i > 0) response = response + String(", "); + response = response + String(EEPROMr.base() - i); + } + return response; +} + +#if TERMINAL_SUPPORT + +void _eepromInitCommands() { + + settingsRegisterCommand(F("EEPROM.DUMP"), [](Embedis* e) { + EEPROMr.dump(settingsSerial()); + DEBUG_MSG_P(PSTR("\n+OK\n")); + }); + + settingsRegisterCommand(F("FLASH.DUMP"), [](Embedis* e) { + if (e->argc < 2) { + DEBUG_MSG_P(PSTR("-ERROR: Wrong arguments\n")); + return; + } + uint32_t sector = String(e->argv[1]).toInt(); + uint32_t max = ESP.getFlashChipSize() / SPI_FLASH_SEC_SIZE; + if (sector >= max) { + DEBUG_MSG_P(PSTR("-ERROR: Sector out of range\n")); + return; + } + EEPROMr.dump(settingsSerial(), sector); + DEBUG_MSG_P(PSTR("\n+OK\n")); + }); + +} + +#endif + +// ----------------------------------------------------------------------------- + +void eepromSetup() { + + #ifdef EEPROM_ROTATE_SECTORS + EEPROMr.size(EEPROM_ROTATE_SECTORS); + #else + // If the memory layout has more than one sector reserved use those, + // otherwise calculate pool size based on memory size. + if (EEPROMr.size() == 1) { + if (EEPROMr.last() > 1000) { // 4Mb boards + EEPROMr.size(4); + } else if (EEPROMr.last() > 250) { // 1Mb boards + EEPROMr.size(2); + } + } + #endif + + EEPROMr.offset(EEPROM_ROTATE_DATA); + EEPROMr.begin(EEPROM_SIZE); + + #if TERMINAL_SUPPORT + _eepromInitCommands(); + #endif + +} diff --git a/code/espurna/espurna.ino b/code/espurna/espurna.ino index ac2f217f..def70f6b 100644 --- a/code/espurna/espurna.ino +++ b/code/espurna/espurna.ino @@ -47,7 +47,10 @@ void setup() { debugSetup(); #endif - // Init EEPROM, Serial, SPIFFS and system check + // Init EEPROM + eepromSetup(); + + // Init Serial, SPIFFS and system check systemSetup(); // Init persistance and terminal features diff --git a/code/espurna/homeassistant.ino b/code/espurna/homeassistant.ino index 070fc1ea..9b8c8934 100644 --- a/code/espurna/homeassistant.ino +++ b/code/espurna/homeassistant.ino @@ -44,6 +44,7 @@ void _haSendMagnitudes() { JsonObject& config = jsonBuffer.createObject(); _haSendMagnitude(i, config); config.printTo(output); + jsonBuffer.clear(); } mqttSendRaw(topic.c_str(), output.c_str()); @@ -123,6 +124,7 @@ void _haSendSwitches() { JsonObject& config = jsonBuffer.createObject(); _haSendSwitch(i, config); config.printTo(output); + jsonBuffer.clear(); } mqttSendRaw(topic.c_str(), output.c_str()); @@ -163,6 +165,8 @@ String _haGetConfig() { } output += "\n"; + jsonBuffer.clear(); + } #if SENSOR_SUPPORT @@ -186,6 +190,8 @@ String _haGetConfig() { } output += "\n"; + jsonBuffer.clear(); + } #endif @@ -255,13 +261,17 @@ void _haInitCommands() { settingsRegisterCommand(F("HA.SEND"), [](Embedis* e) { setSetting("haEnabled", "1"); _haConfigure(); - wsSend(_haWebSocketOnSend); + #if WEB_SUPPORT + wsSend(_haWebSocketOnSend); + #endif DEBUG_MSG_P(PSTR("+OK\n")); }); settingsRegisterCommand(F("HA.CLEAR"), [](Embedis* e) { setSetting("haEnabled", "0"); _haConfigure(); - wsSend(_haWebSocketOnSend); + #if WEB_SUPPORT + wsSend(_haWebSocketOnSend); + #endif DEBUG_MSG_P(PSTR("+OK\n")); }); } diff --git a/code/espurna/led.ino b/code/espurna/led.ino index b93013f8..06fac792 100644 --- a/code/espurna/led.ino +++ b/code/espurna/led.ino @@ -182,16 +182,18 @@ void ledSetup() { void ledLoop() { + uint8_t wifi_state = wifiState(); + for (unsigned char i=0; i<_leds.size(); i++) { if (_ledMode(i) == LED_MODE_WIFI) { - if (wifiConnected()) { - if (WiFi.getMode() == WIFI_AP) { - _ledBlink(i, 900, 100); - } else { - _ledBlink(i, 4900, 100); - } + if (wifi_state & WIFI_STATE_WPS || wifi_state & WIFI_STATE_SMARTCONFIG) { + _ledBlink(i, 100, 100); + } else if (wifi_state & WIFI_STATE_STA) { + _ledBlink(i, 4900, 100); + } else if (wifi_state & WIFI_STATE_AP) { + _ledBlink(i, 900, 100); } else { _ledBlink(i, 500, 500); } @@ -200,19 +202,19 @@ void ledLoop() { if (_ledMode(i) == LED_MODE_FINDME_WIFI) { - if (wifiConnected()) { + if (wifi_state & WIFI_STATE_WPS || wifi_state & WIFI_STATE_SMARTCONFIG) { + _ledBlink(i, 100, 100); + } else if (wifi_state & WIFI_STATE_STA) { if (relayStatus(_leds[i].relay-1)) { - if (WiFi.getMode() == WIFI_AP) { - _ledBlink(i, 900, 100); - } else { - _ledBlink(i, 4900, 100); - } + _ledBlink(i, 4900, 100); } else { - if (WiFi.getMode() == WIFI_AP) { - _ledBlink(i, 100, 900); - } else { - _ledBlink(i, 100, 4900); - } + _ledBlink(i, 100, 4900); + } + } else if (wifi_state & WIFI_STATE_AP) { + if (relayStatus(_leds[i].relay-1)) { + _ledBlink(i, 900, 100); + } else { + _ledBlink(i, 100, 900); } } else { _ledBlink(i, 500, 500); @@ -222,19 +224,19 @@ void ledLoop() { if (_ledMode(i) == LED_MODE_RELAY_WIFI) { - if (wifiConnected()) { + if (wifi_state & WIFI_STATE_WPS || wifi_state & WIFI_STATE_SMARTCONFIG) { + _ledBlink(i, 100, 100); + } else if (wifi_state & WIFI_STATE_STA) { if (relayStatus(_leds[i].relay-1)) { - if (WiFi.getMode() == WIFI_AP) { - _ledBlink(i, 100, 900); - } else { - _ledBlink(i, 100, 4900); - } + _ledBlink(i, 100, 4900); } else { - if (WiFi.getMode() == WIFI_AP) { - _ledBlink(i, 900, 100); - } else { - _ledBlink(i, 4900, 100); - } + _ledBlink(i, 4900, 100); + } + } else if (wifi_state & WIFI_STATE_AP) { + if (relayStatus(_leds[i].relay-1)) { + _ledBlink(i, 100, 900); + } else { + _ledBlink(i, 900, 100); } } else { _ledBlink(i, 500, 500); diff --git a/code/espurna/libs/fs_math.c b/code/espurna/libs/fs_math.c new file mode 100644 index 00000000..8f45eb26 --- /dev/null +++ b/code/espurna/libs/fs_math.c @@ -0,0 +1,636 @@ +/** + * This code is available at + * http://www.mindspring.com/~pfilandr/C/fs_math/ + * and it is believed to be public domain. + */ + +/* BEGIN fs_math.c */ + +#include "fs_math.h" + +#include +/* +** pi == (atan(1.0 / 3) + atan(1.0 / 2)) * 4 +*/ +static double fs_pi(void); +static long double fs_pil(void); + +double fs_sqrt(double x) +{ + int n; + double a, b; + + if (x > 0 && DBL_MAX >= x) { + for (n = 0; x > 2; x /= 4) { + ++n; + } + while (0.5 > x) { + --n; + x *= 4; + } + a = x; + b = (1 + x) / 2; + do { + x = b; + b = (a / x + x) / 2; + } while (x > b); + while (n > 0) { + x *= 2; + --n; + } + while (0 > n) { + x /= 2; + ++n; + } + } else { + if (x != 0) { + x = DBL_MAX; + } + } + return x; +} + +double fs_log(double x) +{ + int n; + double a, b, c, epsilon; + static double A, B, C; + static int initialized; + + if (x > 0 && DBL_MAX >= x) { + if (!initialized) { + initialized = 1; + A = fs_sqrt(2); + B = A / 2; + C = fs_log(A); + } + for (n = 0; x > A; x /= 2) { + ++n; + } + while (B > x) { + --n; + x *= 2; + } + a = (x - 1) / (x + 1); + x = C * n + a; + c = a * a; + n = 1; + epsilon = DBL_EPSILON * x; + if (0 > a) { + if (epsilon > 0) { + epsilon = -epsilon; + } + do { + n += 2; + a *= c; + b = a / n; + x += b; + } while (epsilon > b); + } else { + if (0 > epsilon) { + epsilon = -epsilon; + } + do { + n += 2; + a *= c; + b = a / n; + x += b; + } while (b > epsilon); + } + x *= 2; + } else { + x = -DBL_MAX; + } + return x; +} + +double fs_log10(double x) +{ + static double log_10; + static int initialized; + + if (!initialized) { + initialized = 1; + log_10 = fs_log(10); + } + return x > 0 && DBL_MAX >= x ? fs_log(x) / log_10 : fs_log(x); +} + +double fs_exp(double x) +{ + unsigned n, square; + double b, e; + static double x_max, x_min, epsilon; + static int initialized; + + if (!initialized) { + initialized = 1; + x_max = fs_log(DBL_MAX); + x_min = fs_log(DBL_MIN); + epsilon = DBL_EPSILON / 4; + } + if (x_max >= x && x >= x_min) { + for (square = 0; x > 1; x /= 2) { + ++square; + } + while (-1 > x) { + ++square; + x /= 2; + } + e = b = n = 1; + do { + b /= n++; + b *= x; + e += b; + b /= n++; + b *= x; + e += b; + } while (b > epsilon); + while (square-- != 0) { + e *= e; + } + } else { + e = x > 0 ? DBL_MAX : 0; + } + return e; +} + +double fs_modf(double value, double *iptr) +{ + double a, b; + const double c = value; + + if (0 > c) { + value = -value; + } + if (DBL_MAX >= value) { + for (*iptr = 0; value >= 1; value -= b) { + a = value / 2; + b = 1; + while (a >= b) { + b *= 2; + } + *iptr += b; + } + } else { + *iptr = value; + value = 0; + } + if (0 > c) { + *iptr = -*iptr; + value = -value; + } + return value; +} + +double fs_fmod(double x, double y) +{ + double a, b; + const double c = x; + + if (0 > c) { + x = -x; + } + if (0 > y) { + y = -y; + } + if (y != 0 && DBL_MAX >= y && DBL_MAX >= x) { + while (x >= y) { + a = x / 2; + b = y; + while (a >= b) { + b *= 2; + } + x -= b; + } + } else { + x = 0; + } + return 0 > c ? -x : x; +} + +double fs_pow(double x, double y) +{ + double p = 0; + + if (0 > x && fs_fmod(y, 1) == 0) { + if (fs_fmod(y, 2) == 0) { + p = fs_exp(fs_log(-x) * y); + } else { + p = -fs_exp(fs_log(-x) * y); + } + } else { + if (x != 0 || 0 >= y) { + p = fs_exp(fs_log( x) * y); + } + } + return p; +} + +static double fs_pi(void) +{ + unsigned n; + double a, b, epsilon; + static double p; + static int initialized; + + if (!initialized) { + initialized = 1; + epsilon = DBL_EPSILON / 4; + n = 1; + a = 3; + do { + a /= 9; + b = a / n; + n += 2; + a /= 9; + b -= a / n; + n += 2; + p += b; + } while (b > epsilon); + epsilon = DBL_EPSILON / 2; + n = 1; + a = 2; + do { + a /= 4; + b = a / n; + n += 2; + a /= 4; + b -= a / n; + n += 2; + p += b; + } while (b > epsilon); + p *= 4; + } + return p; +} + +double fs_cos(double x) +{ + unsigned n; + int negative, sine; + double a, b, c; + static double pi, two_pi, half_pi, third_pi, epsilon; + static int initialized; + + if (0 > x) { + x = -x; + } + if (DBL_MAX >= x) { + if (!initialized) { + initialized = 1; + pi = fs_pi(); + two_pi = 2 * pi; + half_pi = pi / 2; + third_pi = pi / 3; + epsilon = DBL_EPSILON / 2; + } + if (x > two_pi) { + x = fs_fmod(x, two_pi); + } + if (x > pi) { + x = two_pi - x; + } + if (x > half_pi) { + x = pi - x; + negative = 1; + } else { + negative = 0; + } + if (x > third_pi) { + x = half_pi - x; + sine = 1; + } else { + sine = 0; + } + c = x * x; + x = n = 0; + a = 1; + do { + b = a; + a *= c; + a /= ++n; + a /= ++n; + b -= a; + a *= c; + a /= ++n; + a /= ++n; + x += b; + } while (b > epsilon); + if (sine) { + x = fs_sqrt((1 - x) * (1 + x)); + } + if (negative) { + x = -x; + } + } else { + x = -DBL_MAX; + } + return x; +} + +double fs_log2(double x) +{ + static double log_2; + static int initialized; + + if (!initialized) { + initialized = 1; + log_2 = fs_log(2); + } + return x > 0 && DBL_MAX >= x ? fs_log(x) / log_2 : fs_log(x); +} + +double fs_exp2(double x) +{ + static double log_2; + static int initialized; + + if (!initialized) { + initialized = 1; + log_2 = fs_log(2); + } + return fs_exp(x * log_2); +} + +long double fs_powl(long double x, long double y) +{ + long double p; + + if (0 > x && fs_fmodl(y, 1) == 0) { + if (fs_fmodl(y, 2) == 0) { + p = fs_expl(fs_logl(-x) * y); + } else { + p = -fs_expl(fs_logl(-x) * y); + } + } else { + if (x != 0 || 0 >= y) { + p = fs_expl(fs_logl( x) * y); + } else { + p = 0; + } + } + return p; +} + +long double fs_sqrtl(long double x) +{ + long int n; + long double a, b; + + if (x > 0 && LDBL_MAX >= x) { + for (n = 0; x > 2; x /= 4) { + ++n; + } + while (0.5 > x) { + --n; + x *= 4; + } + a = x; + b = (1 + x) / 2; + do { + x = b; + b = (a / x + x) / 2; + } while (x > b); + while (n > 0) { + x *= 2; + --n; + } + while (0 > n) { + x /= 2; + ++n; + } + } else { + if (x != 0) { + x = LDBL_MAX; + } + } + return x; +} + +long double fs_logl(long double x) +{ + long int n; + long double a, b, c, epsilon; + static long double A, B, C; + static int initialized; + + if (x > 0 && LDBL_MAX >= x) { + if (!initialized) { + initialized = 1; + B = 1.5; + do { + A = B; + B = 1 / A + A / 2; + } while (A > B); + B /= 2; + C = fs_logl(A); + } + for (n = 0; x > A; x /= 2) { + ++n; + } + while (B > x) { + --n; + x *= 2; + } + a = (x - 1) / (x + 1); + x = C * n + a; + c = a * a; + n = 1; + epsilon = LDBL_EPSILON * x; + if (0 > a) { + if (epsilon > 0) { + epsilon = -epsilon; + } + do { + n += 2; + a *= c; + b = a / n; + x += b; + } while (epsilon > b); + } else { + if (0 > epsilon) { + epsilon = -epsilon; + } + do { + n += 2; + a *= c; + b = a / n; + x += b; + } while (b > epsilon); + } + x *= 2; + } else { + x = -LDBL_MAX; + } + return x; +} + +long double fs_expl(long double x) +{ + long unsigned n, square; + long double b, e; + static long double x_max, x_min, epsilon; + static int initialized; + + if (!initialized) { + initialized = 1; + x_max = fs_logl(LDBL_MAX); + x_min = fs_logl(LDBL_MIN); + epsilon = LDBL_EPSILON / 4; + } + if (x_max >= x && x >= x_min) { + for (square = 0; x > 1; x /= 2) { + ++square; + } + while (-1 > x) { + ++square; + x /= 2; + } + e = b = n = 1; + do { + b /= n++; + b *= x; + e += b; + b /= n++; + b *= x; + e += b; + } while (b > epsilon); + while (square-- != 0) { + e *= e; + } + } else { + e = x > 0 ? LDBL_MAX : 0; + } + return e; +} + +static long double fs_pil(void) +{ + long unsigned n; + long double a, b, epsilon; + static long double p; + static int initialized; + + if (!initialized) { + initialized = 1; + epsilon = LDBL_EPSILON / 4; + n = 1; + a = 3; + do { + a /= 9; + b = a / n; + n += 2; + a /= 9; + b -= a / n; + n += 2; + p += b; + } while (b > epsilon); + epsilon = LDBL_EPSILON / 2; + n = 1; + a = 2; + do { + a /= 4; + b = a / n; + n += 2; + a /= 4; + b -= a / n; + n += 2; + p += b; + } while (b > epsilon); + p *= 4; + } + return p; +} + +long double fs_cosl(long double x) +{ + long unsigned n; + int negative, sine; + long double a, b, c; + static long double pi, two_pi, half_pi, third_pi, epsilon; + static int initialized; + + if (0 > x) { + x = -x; + } + if (LDBL_MAX >= x) { + if (!initialized) { + initialized = 1; + pi = fs_pil(); + two_pi = 2 * pi; + half_pi = pi / 2; + third_pi = pi / 3; + epsilon = LDBL_EPSILON / 2; + } + if (x > two_pi) { + x = fs_fmodl(x, two_pi); + } + if (x > pi) { + x = two_pi - x; + } + if (x > half_pi) { + x = pi - x; + negative = 1; + } else { + negative = 0; + } + if (x > third_pi) { + x = half_pi - x; + sine = 1; + } else { + sine = 0; + } + c = x * x; + x = n = 0; + a = 1; + do { + b = a; + a *= c; + a /= ++n; + a /= ++n; + b -= a; + a *= c; + a /= ++n; + a /= ++n; + x += b; + } while (b > epsilon); + if (sine) { + x = fs_sqrtl((1 - x) * (1 + x)); + } + if (negative) { + x = -x; + } + } else { + x = -LDBL_MAX; + } + return x; +} + +long double fs_fmodl(long double x, long double y) +{ + long double a, b; + const long double c = x; + + if (0 > c) { + x = -x; + } + if (0 > y) { + y = -y; + } + if (y != 0 && LDBL_MAX >= y && LDBL_MAX >= x) { + while (x >= y) { + a = x / 2; + b = y; + while (a >= b) { + b *= 2; + } + x -= b; + } + } else { + x = 0; + } + return 0 > c ? -x : x; +} + +/* END fs_math.c */ diff --git a/code/espurna/libs/fs_math.h b/code/espurna/libs/fs_math.h new file mode 100644 index 00000000..1884fcdd --- /dev/null +++ b/code/espurna/libs/fs_math.h @@ -0,0 +1,116 @@ +/** + * This code is available at + * http://www.mindspring.com/~pfilandr/C/fs_math/ + * and it is believed to be public domain. + */ + +/* BEGIN fs_math.h */ +/* +** Portable freestanding code. +*/ +#ifndef H_FS_MATH_H +#define H_FS_MATH_H + +double fs_sqrt(double x); +double fs_log(double x); +double fs_log10(double x); +/* +** exp(x) = 1 + x + x^2/2! + x^3/3! + ... +*/ +double fs_exp(double x); +double fs_modf(double value, double *iptr); +double fs_fmod(double x, double y); +double fs_pow(double x, double y); +double fs_cos(double x); +/* +** C99 +*/ +double fs_log2(double x); +double fs_exp2(double x); +long double fs_powl(long double x, long double y); +long double fs_sqrtl(long double x); +long double fs_logl(long double x); +long double fs_expl(long double x); +long double fs_cosl(long double x); +long double fs_fmodl(long double x, long double y); + +#endif + +/* END fs_math.h */ + +#if 0 + +/* +> > Anybody know where I can get some source code for a +> > reasonably fast double +> > precision square root algorithm in C. +> > I'm looking for one that is not IEEE +> > compliant as I am running on a Z/OS mainframe. +> > +> > I would love to use the standard library but +> > unfortunatly I'm using a +> > stripped down version of C that looses the the runtime library +> > (we have to write our own). +> +> long double Ssqrt(long double x) +> { +> long double a, b; +> size_t c; + +size_t is a bug here. +c needs to be a signed type: + long c; + +> if (x > 0) { +> c = 0; +> while (x > 4) { +> x /= 4; +> ++c; +> } +> while (1.0 / 4 > x) { +> x *= 4; +> --c; +> } +> a = x; +> b = ((4 > a) + a) / 2; + +Not a bug, but should be: + b = (1 + a) / 2; + +> do { +> x = b; +> b = (a / x + x) / 2; +> } while (x > b); +> if (c > 0) { + +The above line is why c needs to be a signed type, +otherwise the decremented values of c, are greater than zero, +and the function won't work if the initial value of x +is less than 0.25 + +> while (c--) { +> x *= 2; +> } +> } else { +> while (c++) { +> x /= 2; +> } +> } +> } +> return x; +> } + +> +> > +> > That algorithm was actually 4 times slower +> > then the one below, and more +> > code. It was accurate though. +> > +> +> Sorry Pete, I wasn't looking very carefully. +> When I converted your function +> to double precision it's was much quicker, the best I've seen yet. + +*/ + +#endif diff --git a/code/espurna/pwm.c b/code/espurna/libs/pwm.c similarity index 100% rename from code/espurna/pwm.c rename to code/espurna/libs/pwm.c diff --git a/code/espurna/light.ino b/code/espurna/light.ino index 28a6293d..5ecd79cd 100644 --- a/code/espurna/light.ino +++ b/code/espurna/light.ino @@ -12,6 +12,10 @@ Copyright (C) 2016-2018 by Xose Pérez #include #include +extern "C" { + #include "libs/fs_math.h" +} + #if LIGHT_PROVIDER == LIGHT_PROVIDER_DIMMER #define PWM_CHANNEL_NUM_MAX LIGHT_CHANNELS extern "C" { @@ -275,53 +279,39 @@ void _fromHSV(const char * hsv) { // Thanks to Sacha Telgenhof for sharing this code in his AiLight library // https://github.com/stelgenhof/AiLight -void _fromKelvin(unsigned long kelvin, bool setMireds) { +void _fromKelvin(unsigned long kelvin) { if (!_light_has_color) return; - if (setMireds) { - _light_mireds = constrain(round(1000000UL / kelvin), LIGHT_MIN_MIREDS, LIGHT_MAX_MIREDS); - } - if (_light_use_cct) { _setRGBInputValue(LIGHT_MAX_VALUE, LIGHT_MAX_VALUE, LIGHT_MAX_VALUE); return; } + _light_mireds = constrain(round(1000000UL / kelvin), LIGHT_MIN_MIREDS, LIGHT_MAX_MIREDS); // Calculate colors + kelvin /= 100; unsigned int red = (kelvin <= 66) ? LIGHT_MAX_VALUE - : 329.698727446 * pow((kelvin - 60), -0.1332047592); + : 329.698727446 * fs_pow((double) (kelvin - 60), -0.1332047592); unsigned int green = (kelvin <= 66) - ? 99.4708025861 * log(kelvin) - 161.1195681661 - : 288.1221695283 * pow(kelvin, -0.0755148492); + ? 99.4708025861 * fs_log(kelvin) - 161.1195681661 + : 288.1221695283 * fs_pow((double) kelvin, -0.0755148492); unsigned int blue = (kelvin >= 66) ? LIGHT_MAX_VALUE : ((kelvin <= 19) ? 0 - : 138.5177312231 * log(kelvin - 10) - 305.0447927307); + : 138.5177312231 * fs_log(kelvin - 10) - 305.0447927307); _setRGBInputValue(red, green, blue); -} -void _fromKelvin(unsigned long kelvin) { - _fromKelvin(kelvin, true); } // Color temperature is measured in mireds (kelvin = 1e6/mired) void _fromMireds(unsigned long mireds) { - if (!_light_has_color) return; - - _light_mireds = mireds = constrain(mireds, LIGHT_MIN_MIREDS, LIGHT_MAX_MIREDS); - - if (_light_use_cct) { - _setRGBInputValue(LIGHT_MAX_VALUE, LIGHT_MAX_VALUE, LIGHT_MAX_VALUE); - return; - } - - unsigned long kelvin = constrain(1000000UL / mireds, 1000, 40000) / 100; - _fromKelvin(kelvin, false); + unsigned long kelvin = constrain(1000000UL / mireds, 1000, 40000); + _fromKelvin(kelvin); } // ----------------------------------------------------------------------------- diff --git a/code/espurna/mqtt.ino b/code/espurna/mqtt.ino index c935ba4b..fa02afde 100644 --- a/code/espurna/mqtt.ino +++ b/code/espurna/mqtt.ino @@ -8,7 +8,7 @@ Copyright (C) 2016-2018 by Xose Pérez #if MQTT_SUPPORT -#include +#include #include #include #include @@ -265,7 +265,7 @@ unsigned long _mqttNextMessageId() { if (id == 0) { // read id from EEPROM and shift it - id = EEPROM.read(EEPROM_MESSAGE_ID); + id = EEPROMr.read(EEPROM_MESSAGE_ID); if (id == 0xFF) { // There was nothing in EEPROM, @@ -274,9 +274,9 @@ unsigned long _mqttNextMessageId() { } else { - id = (id << 8) + EEPROM.read(EEPROM_MESSAGE_ID + 1); - id = (id << 8) + EEPROM.read(EEPROM_MESSAGE_ID + 2); - id = (id << 8) + EEPROM.read(EEPROM_MESSAGE_ID + 3); + id = (id << 8) + EEPROMr.read(EEPROM_MESSAGE_ID + 1); + id = (id << 8) + EEPROMr.read(EEPROM_MESSAGE_ID + 2); + id = (id << 8) + EEPROMr.read(EEPROM_MESSAGE_ID + 3); // Calculate next block and start from there id = MQTT_MESSAGE_ID_SHIFT * (1 + (id / MQTT_MESSAGE_ID_SHIFT)); @@ -287,11 +287,11 @@ unsigned long _mqttNextMessageId() { // Save to EEPROM every MQTT_MESSAGE_ID_SHIFT if (id % MQTT_MESSAGE_ID_SHIFT == 0) { - EEPROM.write(EEPROM_MESSAGE_ID + 0, (id >> 24) & 0xFF); - EEPROM.write(EEPROM_MESSAGE_ID + 1, (id >> 16) & 0xFF); - EEPROM.write(EEPROM_MESSAGE_ID + 2, (id >> 8) & 0xFF); - EEPROM.write(EEPROM_MESSAGE_ID + 3, (id >> 0) & 0xFF); - EEPROM.commit(); + EEPROMr.write(EEPROM_MESSAGE_ID + 0, (id >> 24) & 0xFF); + EEPROMr.write(EEPROM_MESSAGE_ID + 1, (id >> 16) & 0xFF); + EEPROMr.write(EEPROM_MESSAGE_ID + 2, (id >> 8) & 0xFF); + EEPROMr.write(EEPROM_MESSAGE_ID + 3, (id >> 0) & 0xFF); + EEPROMr.commit(); } id++; @@ -613,6 +613,8 @@ void mqttFlush() { // Send String output; root.printTo(output); + jsonBuffer.clear(); + mqttSendRaw(_mqtt_topic_json.c_str(), output.c_str(), false); // Clear queue diff --git a/code/espurna/ota.ino b/code/espurna/ota.ino index 2d730f43..4443431a 100644 --- a/code/espurna/ota.ino +++ b/code/espurna/ota.ino @@ -70,6 +70,7 @@ void _otaFrom(const char * host, unsigned int port, const char * url) { #ifdef DEBUG_PORT Update.printError(DEBUG_PORT); #endif + eepromRotate(true); } DEBUG_MSG_P(PSTR("[OTA] Disconnected\n")); @@ -133,6 +134,9 @@ void _otaFrom(const char * host, unsigned int port, const char * url) { } #endif + // Disabling EEPROM rotation to prevent writing to EEPROM after the upgrade + eepromRotate(false); + DEBUG_MSG_P(PSTR("[OTA] Downloading %s\n"), _ota_url); char buffer[strlen_P(OTA_REQUEST_TEMPLATE) + strlen(_ota_url) + strlen(_ota_host)]; snprintf_P(buffer, sizeof(buffer), OTA_REQUEST_TEMPLATE, _ota_url, _ota_host); @@ -140,7 +144,6 @@ void _otaFrom(const char * host, unsigned int port, const char * url) { }, NULL); - #if ASYNC_TCP_SSL_ENABLED bool connected = _ota_client->connect(host, port, 443 == port); #else @@ -214,10 +217,16 @@ void otaSetup() { // ------------------------------------------------------------------------- ArduinoOTA.onStart([]() { + + // Disabling EEPROM rotation to prevent writing to EEPROM after the upgrade + eepromRotate(false); + DEBUG_MSG_P(PSTR("[OTA] Start\n")); + #if WEB_SUPPORT wsSend_P(PSTR("{\"message\": 2}")); #endif + }); ArduinoOTA.onEnd([]() { @@ -242,6 +251,7 @@ void otaSetup() { else if (error == OTA_RECEIVE_ERROR) DEBUG_MSG_P(PSTR("Receive Failed\n")); else if (error == OTA_END_ERROR) DEBUG_MSG_P(PSTR("End Failed\n")); #endif + eepromRotate(true); }); ArduinoOTA.begin(); diff --git a/code/espurna/relay.ino b/code/espurna/relay.ino index 5d597e15..1c361a60 100644 --- a/code/espurna/relay.ino +++ b/code/espurna/relay.ino @@ -6,7 +6,7 @@ Copyright (C) 2016-2018 by Xose Pérez */ -#include +#include #include #include #include @@ -23,7 +23,6 @@ typedef struct { unsigned long delay_off; // Delay to turn relay OFF unsigned char pulse; // RELAY_PULSE_NONE, RELAY_PULSE_OFF or RELAY_PULSE_ON unsigned long pulse_ms; // Pulse length in millis - unsigned long pulse_start; // Current pulse start (millis), 0 means no pulse // Status variables @@ -35,6 +34,10 @@ typedef struct { bool report; // Whether to report to own topic bool group_report; // Whether to report to group topic + // Helping objects + + Ticker pulseTicker; // Holds the pulse back timer + } relay_t; std::vector _relays; bool _relayRecursive = false; @@ -200,27 +203,14 @@ void _relayProcess(bool mode) { } -/** - * Walks the relay vector check if any relay has to pulse back - */ -void _relayPulseCheck() { - unsigned long current_time = millis(); - for (unsigned char id = 0; id < _relays.size(); id++) { - if (_relays[id].pulse_start > 0) { - if (current_time - _relays[id].pulse_start > _relays[id].pulse_ms) { - _relays[id].pulse_start = 0; - relayToggle(id); - } - } - } -} - // ----------------------------------------------------------------------------- // RELAY // ----------------------------------------------------------------------------- void relayPulse(unsigned char id) { + _relays[id].pulseTicker.detach(); + byte mode = _relays[id].pulse; if (mode == RELAY_PULSE_NONE) return; unsigned long ms = _relays[id].pulse_ms; @@ -229,11 +219,12 @@ void relayPulse(unsigned char id) { bool status = relayStatus(id); bool pulseStatus = (mode == RELAY_PULSE_ON); - if (pulseStatus == status) { - _relays[id].pulse_start = 0; - } else { + if (pulseStatus != status) { DEBUG_MSG_P(PSTR("[RELAY] Scheduling relay #%d back in %lums (pulse)\n"), id, ms); - _relays[id].pulse_start = millis(); + _relays[id].pulseTicker.once_ms(ms, relayToggle, id); + // Reconfigure after dynamic pulse + _relays[id].pulse = getSetting("relayPulse", id, RELAY_PULSE_MODE).toInt(); + _relays[id].pulse_ms = 1000 * getSetting("relayTime", id, RELAY_PULSE_MODE).toFloat(); } } @@ -369,9 +360,9 @@ void relaySave() { if (relayStatus(i)) mask += bit; bit += bit; } - EEPROM.write(EEPROM_RELAY_STATUS, mask); + EEPROMr.write(EEPROM_RELAY_STATUS, mask); DEBUG_MSG_P(PSTR("[RELAY] Saving mask: %d\n"), mask); - EEPROM.commit(); + EEPROMr.commit(); } void relayToggle(unsigned char id, bool report, bool group_report) { @@ -449,7 +440,7 @@ void _relayBoot() { bool trigger_save = false; // Get last statuses from EEPROM - unsigned char mask = EEPROM.read(EEPROM_RELAY_STATUS); + unsigned char mask = EEPROMr.read(EEPROM_RELAY_STATUS); DEBUG_MSG_P(PSTR("[RELAY] Retrieving mask: %d\n"), mask); // Walk the relays @@ -476,7 +467,6 @@ void _relayBoot() { } _relays[i].current_status = !status; _relays[i].target_status = status; - _relays[i].pulse_start = 0; #if RELAY_PROVIDER == RELAY_PROVIDER_STM _relays[i].change_time = millis() + 3000 + 1000 * i; #else @@ -487,8 +477,8 @@ void _relayBoot() { // Save if there is any relay in the RELAY_BOOT_TOGGLE mode if (trigger_save) { - EEPROM.write(EEPROM_RELAY_STATUS, mask); - EEPROM.commit(); + EEPROMr.write(EEPROM_RELAY_STATUS, mask); + EEPROMr.commit(); } _relayRecursive = false; @@ -611,9 +601,9 @@ void relaySetupAPI() { // API entry points (protected with apikey) for (unsigned int relayID=0; relayID= relayCount()) { + DEBUG_MSG_P(PSTR("[RELAY] Wrong relayID (%d)\n"), id); + return; + } + + unsigned long pulse = 1000 * String(payload).toFloat(); + if (0 == pulse) return; + + if (RELAY_PULSE_NONE != _relays[id].pulse) { + DEBUG_MSG_P(PSTR("[RELAY] Overriding relay #%d pulse settings\n"), id); + } + + _relays[id].pulse_ms = pulse; + _relays[id].pulse = relayStatus(id) ? RELAY_PULSE_ON : RELAY_PULSE_OFF; + relayToggle(id, true, false); + + return; + + } + + // magnitude is relay/# + if (t.startsWith(MQTT_TOPIC_RELAY)) { // Get relay ID unsigned int id = t.substring(strlen(MQTT_TOPIC_RELAY)+1).toInt(); if (id >= relayCount()) { DEBUG_MSG_P(PSTR("[RELAY] Wrong relayID (%d)\n"), id); - } else { - relayStatusWrap(id, value, false); + return; } - return; + // Get value + unsigned char value = relayParsePayload(payload); + if (value == 0xFF) return; + + relayStatusWrap(id, value, false); + return; } + // Check group topics for (unsigned int i=0; i < _relays.size(); i++) { @@ -811,8 +857,14 @@ void _relayInitCommands() { settingsRegisterCommand(F("RELAY"), [](Embedis* e) { if (e->argc < 2) { DEBUG_MSG_P(PSTR("-ERROR: Wrong arguments\n")); + return; } int id = String(e->argv[1]).toInt(); + if (id >= relayCount()) { + DEBUG_MSG_P(PSTR("-ERROR: Wrong relayID (%d)\n"), id); + return; + } + if (e->argc > 2) { int value = String(e->argv[2]).toInt(); if (value == 2) { @@ -822,6 +874,11 @@ void _relayInitCommands() { } } DEBUG_MSG_P(PSTR("Status: %s\n"), _relays[id].target_status ? "true" : "false"); + if (_relays[id].pulse != RELAY_PULSE_NONE) { + DEBUG_MSG_P(PSTR("Pulse: %s\n"), (_relays[id].pulse == RELAY_PULSE_ON) ? "ON" : "OFF"); + DEBUG_MSG_P(PSTR("Pulse time: %d\n"), _relays[id].pulse_ms); + + } DEBUG_MSG_P(PSTR("+OK\n")); }); @@ -834,7 +891,6 @@ void _relayInitCommands() { //------------------------------------------------------------------------------ void _relayLoop() { - _relayPulseCheck(); _relayProcess(false); _relayProcess(true); } diff --git a/code/espurna/rfbridge.ino b/code/espurna/rfbridge.ino index a51f1f23..c19a7a74 100644 --- a/code/espurna/rfbridge.ino +++ b/code/espurna/rfbridge.ino @@ -156,6 +156,9 @@ void _rfbSendRaw(const byte *message, const unsigned char n = RF_MESSAGE_SIZE) { void _rfbSend(byte * message) { #if RFB_DIRECT unsigned int protocol = message[1]; + unsigned int timing = + (message[2] << 8) | + (message[3] << 0) ; unsigned int bitlength = message[4]; unsigned long rf_code = (message[5] << 24) | @@ -163,7 +166,11 @@ void _rfbSend(byte * message) { (message[7] << 8) | (message[8] << 0) ; _rfModem->setProtocol(protocol); + if (timing > 0) { + _rfModem->setPulseLength(timing); + } _rfModem->send(rf_code, bitlength); + _rfModem->resetAvailable(); #else Serial.println(); Serial.write(RF_CODE_START); @@ -202,6 +209,9 @@ void _rfbSend() { } void _rfbSend(byte * code, unsigned char times) { + #if RFB_DIRECT + times = 1; + #endif char buffer[RF_MESSAGE_SIZE]; _rfbToChar(code, buffer); @@ -231,7 +241,7 @@ void _rfbSendRawOnce(byte *code, unsigned char length) { #endif // RF_RAW_SUPPORT -bool _rfbMatch(char * code, unsigned char& relayID, unsigned char& value) { +bool _rfbMatch(char* code, unsigned char& relayID, unsigned char& value, char* buffer = NULL) { if (strlen(code) != 18) return false; @@ -247,6 +257,7 @@ bool _rfbMatch(char * code, unsigned char& relayID, unsigned char& value) { DEBUG_MSG_P(PSTR("[RFBRIDGE] Match ON code for relay %d\n"), i); value = 1; found = true; + if (buffer) strcpy(buffer, code_on.c_str()); } String code_off = rfbRetrieve(i, false); @@ -254,6 +265,7 @@ bool _rfbMatch(char * code, unsigned char& relayID, unsigned char& value) { DEBUG_MSG_P(PSTR("[RFBRIDGE] Match OFF code for relay %d\n"), i); if (found) value = 2; found = true; + if (buffer) strcpy(buffer, code_off.c_str()); } if (found) { @@ -285,12 +297,25 @@ void _rfbDecode() { #endif } + unsigned char id; + unsigned char status; + bool matched = false; + if (action == RF_CODE_LEARN_OK || action == RF_CODE_RFIN) { + _rfbAck(); + _rfbToChar(&_uartbuf[1], buffer); + + /* Look for the code, possibly replacing the code with the exact learned one on match + * we want to do this on learn too to be sure that the learned code is the same if it + * is equivalent + */ + DEBUG_MSG_P(PSTR("[RFBRIDGE] Received message '%s'\n"), buffer); + matched = _rfbMatch(buffer, id, status, buffer); + DEBUG_MSG_P(PSTR("[RFBRIDGE] Matched message '%s'\n"), buffer); + #if MQTT_SUPPORT - _rfbToChar(&_uartbuf[1], buffer); mqttSend(MQTT_TOPIC_RFIN, buffer); #endif - _rfbAck(); } if (action == RF_CODE_LEARN_OK) { @@ -308,13 +333,8 @@ void _rfbDecode() { } if (action == RF_CODE_RFIN) { - DEBUG_MSG_P(PSTR("[RFBRIDGE] Forward message '%s'\n"), buffer); - - // Look for the code - unsigned char id; - unsigned char status = 0; - if (_rfbMatch(buffer, id, status)) { + if (matched) { _rfbin = true; if (status == 2) { relayToggle(id); @@ -354,11 +374,14 @@ void _rfbReceive() { unsigned long rf_code = _rfModem->getReceivedValue(); if ( rf_code > 0) { DEBUG_MSG_P(PSTR("[RFBRIDGE] Received code: %08X\n"), rf_code); + unsigned int timing = _rfModem->getReceivedDelay(); memset(_uartbuf, 0, sizeof(_uartbuf)); unsigned char *msgbuf = _uartbuf + 1; _uartbuf[0] = _learning ? RF_CODE_LEARN_OK: RF_CODE_RFIN; msgbuf[0] = 0xC0; msgbuf[1] = _rfModem->getReceivedProtocol(); + msgbuf[2] = timing >> 8; + msgbuf[3] = timing >> 0; msgbuf[4] = _rfModem->getReceivedBitlength(); msgbuf[5] = rf_code >> 24; msgbuf[6] = rf_code >> 16; @@ -594,6 +617,7 @@ void rfbSetup() { _rfModem = new RCSwitch(); _rfModem->enableReceive(RFB_RX_PIN); _rfModem->enableTransmit(RFB_TX_PIN); + _rfModem->setRepeatTransmit(6); DEBUG_MSG_P(PSTR("[RFBRIDGE] RF receiver on GPIO %u\n"), RFB_RX_PIN); DEBUG_MSG_P(PSTR("[RFBRIDGE] RF transmitter on GPIO %u\n"), RFB_TX_PIN); #endif diff --git a/code/espurna/sensor.ino b/code/espurna/sensor.ino index a95f4a95..0177590a 100644 --- a/code/espurna/sensor.ino +++ b/code/espurna/sensor.ino @@ -451,6 +451,18 @@ void _sensorLoad() { } #endif + #if GEIGER_SUPPORT + { + GeigerSensor * sensor = new GeigerSensor(); // Create instance of thr Geiger module. + sensor->setGPIO(GEIGER_PIN); // Interrupt pin of the attached geiger counter board. + sensor->setMode(GEIGER_PIN_MODE); // This pin is an input. + sensor->setDebounceTime(GEIGER_DEBOUNCE); // Debounce time 25ms, because https://github.com/Trickx/espurna/wiki/Geiger-counter + sensor->setInterruptMode(GEIGER_INTERRUPT_MODE); // Interrupt triggering: edge detection rising. + sensor->setCPM2SievertFactor(GEIGER_CPM2SIEVERT); // Conversion factor from counts per minute to µSv/h + _sensors.push_back(sensor); + } + #endif + #if GUVAS12SD_SUPPORT { GUVAS12SDSensor * sensor = new GUVAS12SDSensor(); @@ -593,7 +605,7 @@ void _sensorInit() { new_magnitude.min_change = 0; if (type == MAGNITUDE_DIGITAL) { new_magnitude.filter = new MaxFilter(); - } else if (type == MAGNITUDE_EVENTS) { + } else if (type == MAGNITUDE_EVENTS || type == MAGNITUDE_GEIGER_CPM|| type == MAGNITUDE_GEIGER_SIEVERT) { // For geiger counting moving average filter is the most appropriate if needed at all. new_magnitude.filter = new MovingAverageFilter(); } else { new_magnitude.filter = new MedianFilter(); diff --git a/code/espurna/sensors/EmonSensor.h b/code/espurna/sensors/EmonSensor.h index 4dd14c10..527a4bda 100644 --- a/code/espurna/sensors/EmonSensor.h +++ b/code/espurna/sensors/EmonSensor.h @@ -10,9 +10,11 @@ #undef I2C_SUPPORT #define I2C_SUPPORT 1 // Explicitly request I2C support. - #include "Arduino.h" #include "I2CSensor.h" +extern "C" { + #include "libs/fs_math.h" +} class EmonSensor : public I2CSensor { @@ -43,6 +45,7 @@ class EmonSensor : public I2CSensor { if (actual == 0) return; if (expected == actual) return; _current_ratio[channel] = _current_ratio[channel] * ((double) expected / (double) actual); + calculateFactors(channel); _dirty = true; } @@ -70,6 +73,7 @@ class EmonSensor : public I2CSensor { if (channel >= _channels) return; if (_current_ratio[channel] == current_ratio) return; _current_ratio[channel] = current_ratio; + calculateFactors(channel); _dirty = true; } @@ -105,8 +109,7 @@ class EmonSensor : public I2CSensor { for (unsigned char i=0; i<_channels; i++) { _energy[i] = _current[i] = 0; _pivot[i] = _adc_counts >> 1; - _current_factor[i] = _current_ratio[i] * _reference / _adc_counts; - _multiplier[i] = calculateMultiplier(_current_factor[i]); + calculateFactors(i); } #if SENSOR_DEBUG @@ -145,18 +148,22 @@ class EmonSensor : public I2CSensor { virtual unsigned int readADC(unsigned char channel) {} - unsigned int calculateMultiplier(double current_factor) { + void calculateFactors(unsigned char channel) { + + _current_factor[channel] = _current_ratio[channel] * _reference / _adc_counts; + unsigned int s = 1; unsigned int i = 1; unsigned int m = s * i; unsigned int multiplier; - while (m * current_factor < 1) { + while (m * _current_factor[channel] < 1) { multiplier = m; i = (i == 1) ? 2 : (i == 2) ? 5 : 1; if (i == 1) s *= 10; m = s * i; } - return multiplier; + _multiplier[channel] = multiplier; + } double read(unsigned char channel) { @@ -192,7 +199,7 @@ class EmonSensor : public I2CSensor { } // Calculate current - double rms = _samples > 0 ? sqrt(sum / _samples) : 0; + double rms = _samples > 0 ? fs_sqrt(sum / _samples) : 0; double current = _current_factor[channel] * rms; current = (double) (int(current * _multiplier[channel]) - 1) / _multiplier[channel]; if (current < 0) current = 0; @@ -206,7 +213,7 @@ class EmonSensor : public I2CSensor { DEBUG_MSG("[EMON] Min value: %d\n", min); DEBUG_MSG("[EMON] Midpoint value: %d\n", int(_pivot[channel])); DEBUG_MSG("[EMON] RMS value: %d\n", int(rms)); - DEBUG_MSG("[EMON] Current (mA): %d\n", int(current)); + DEBUG_MSG("[EMON] Current (mA): %d\n", int(1000 * current)); #endif // Check timing diff --git a/code/espurna/sensors/GeigerSensor.h b/code/espurna/sensors/GeigerSensor.h new file mode 100644 index 00000000..7165ed61 --- /dev/null +++ b/code/espurna/sensors/GeigerSensor.h @@ -0,0 +1,298 @@ +// ----------------------------------------------------------------------------- +// Geiger Sensor based on Event Counter Sensor +// Copyright (C) 2018 by Sven Kopetzki +// Documentation: https://github.com/Trickx/espurna/wiki/Geiger-counter +// ----------------------------------------------------------------------------- + +#if SENSOR_SUPPORT && GEIGER_SUPPORT + +#pragma once + +#include "Arduino.h" +#include "BaseSensor.h" + +class GeigerSensor : public BaseSensor { + +public: + +// --------------------------------------------------------------------- +// Public +// --------------------------------------------------------------------- + +GeigerSensor() : BaseSensor() { + _count = 2; + _sensor_id = SENSOR_GEIGER_ID; +} + +~GeigerSensor() { + _enableInterrupts(false); +} + +// --------------------------------------------------------------------- + +void setGPIO(unsigned char gpio) { + _gpio = gpio; +} + +void setMode(unsigned char mode) { + _mode = mode; +} + +void setInterruptMode(unsigned char mode) { + _interrupt_mode = mode; +} + +void setDebounceTime(unsigned long debounce) { + _debounce = debounce; +} + +void setCPM2SievertFactor(unsigned int cpm2sievert) { + _cpm2sievert = cpm2sievert; +} + +// --------------------------------------------------------------------- + +unsigned char getGPIO() { + return _gpio; +} + +unsigned char getMode() { + return _mode; +} + +unsigned char getInterruptMode() { + return _interrupt_mode; +} + +unsigned long getDebounceTime() { + return _debounce; +} + +unsigned long getCPM2SievertFactor() { + return _cpm2sievert; +} + +// --------------------------------------------------------------------- +// Sensors API +// --------------------------------------------------------------------- + +// Initialization method, must be idempotent +// Defined outside the class body +void begin() { + pinMode(_gpio, _mode); + _enableInterrupts(true); + _ready = true; +} + +// Descriptive name of the sensor +String description() { + char buffer[20]; + snprintf(buffer, sizeof(buffer), "µSv/h @ GPIO%d", _gpio); + return String(buffer); +} + +// Descriptive name of the slot # index +String slot(unsigned char index) { + char buffer[30]; + unsigned char i=0; + #if GEIGER_REPORT_CPM + if (index == i++) { + snprintf(buffer, sizeof(buffer), "Counts per Minute @ GPIO%d", _gpio); + return String(buffer); + } + #endif + #if GEIGER_REPORT_SIEVERTS + if (index == i++) { + snprintf(buffer, sizeof(buffer), "CPM / %d = µSv/h", _cpm2sievert); + return String(buffer); + } + #endif + snprintf(buffer, sizeof(buffer), "Events @ GPIO%d", _gpio); + return String(buffer); +}; + +// Address of the sensor (it could be the GPIO or I2C address) +String address(unsigned char index) { + return String(_gpio); +} + +// Type for slot # index +unsigned char type(unsigned char index) { + unsigned char i=0; + #if GEIGER_REPORT_CPM + if (index == i++) return MAGNITUDE_GEIGER_CPM; + #endif + #if GEIGER_REPORT_SIEVERTS + if (index == i++) return MAGNITUDE_GEIGER_SIEVERT; + #endif + return MAGNITUDE_NONE; +} + +// Current value for slot # index +double value(unsigned char index) { + unsigned char i=0; + #if GEIGER_REPORT_CPM + if (index == i++) { + unsigned long _period_begin = _lastreport_cpm; + _lastreport_cpm = millis(); + double value = _events * 60000; + value = value / (_lastreport_cpm-_period_begin); + #if SENSOR_DEBUG + char data[128]; char buffer[10]; + dtostrf(value, 1-sizeof(buffer), 4, buffer); + snprintf(data, sizeof(data), "Ticks: %u | Interval: %u | CPM: %s", _ticks, (_lastreport_cpm-_period_begin), buffer); + DEBUG_MSG("[GEIGER] %s\n", data); + #endif + _events = 0; + return value; + } + #endif + #if GEIGER_REPORT_SIEVERTS + if (index == i++) { + unsigned long _period_begin = _lastreport_sv; + _lastreport_sv = millis(); + double value = _ticks * 60000 / _cpm2sievert; + value = value / (_lastreport_sv-_period_begin); + #if SENSOR_DEBUG + char data[128]; char buffer[10]; + dtostrf(value, 1-sizeof(buffer), 4, buffer); + snprintf(data, sizeof(data), "Ticks: %u | Interval: %u | µSievert: %s", _ticks, (_lastreport_sv-_period_begin), buffer); + DEBUG_MSG("[GEIGER] %s\n", data); + #endif + _ticks = 0; + return value; + } + #endif + return 0; +} + + +// Handle interrupt calls +void handleInterrupt(unsigned char gpio) { + (void) gpio; + static unsigned long last = 0; + if (millis() - last > _debounce) { + _events = _events + 1; + _ticks = _ticks + 1; + last = millis(); + } +} + +protected: + +// --------------------------------------------------------------------- +// Interrupt management +// --------------------------------------------------------------------- + +void _attach(GeigerSensor * instance, unsigned char gpio, unsigned char mode); +void _detach(unsigned char gpio); + +void _enableInterrupts(bool value) { + + static unsigned char _interrupt_gpio = GPIO_NONE; + + if (value) { + if (_interrupt_gpio != GPIO_NONE) _detach(_interrupt_gpio); + _attach(this, _gpio, _interrupt_mode); + _interrupt_gpio = _gpio; + } else if (_interrupt_gpio != GPIO_NONE) { + _detach(_interrupt_gpio); + _interrupt_gpio = GPIO_NONE; + } + +} + +// --------------------------------------------------------------------- +// Protected +// --------------------------------------------------------------------- + +volatile unsigned long _events = 0; +volatile unsigned long _ticks = 0; + +unsigned long _debounce = GEIGER_DEBOUNCE; +unsigned int _cpm2sievert = GEIGER_CPM2SIEVERT; +unsigned char _gpio; +unsigned char _mode; +unsigned char _interrupt_mode; + +// Added for µSievert calculations +unsigned long _lastreport_cpm = millis(); +unsigned long _lastreport_sv = _lastreport_cpm; + +}; + +// ----------------------------------------------------------------------------- +// Interrupt helpers +// ----------------------------------------------------------------------------- + +GeigerSensor * _geiger_sensor_instance[10] = {NULL}; + +void ICACHE_RAM_ATTR _geiger_sensor_isr(unsigned char gpio) { + unsigned char index = gpio > 5 ? gpio-6 : gpio; + if (_geiger_sensor_instance[index]) { + _geiger_sensor_instance[index]->handleInterrupt(gpio); + } +} + +void ICACHE_RAM_ATTR _geiger_sensor_isr_0() { + _geiger_sensor_isr(0); +} +void ICACHE_RAM_ATTR _geiger_sensor_isr_1() { + _geiger_sensor_isr(1); +} +void ICACHE_RAM_ATTR _geiger_sensor_isr_2() { + _geiger_sensor_isr(2); +} +void ICACHE_RAM_ATTR _geiger_sensor_isr_3() { + _geiger_sensor_isr(3); +} +void ICACHE_RAM_ATTR _geiger_sensor_isr_4() { + _geiger_sensor_isr(4); +} +void ICACHE_RAM_ATTR _geiger_sensor_isr_5() { + _geiger_sensor_isr(5); +} +void ICACHE_RAM_ATTR _geiger_sensor_isr_12() { + _geiger_sensor_isr(12); +} +void ICACHE_RAM_ATTR _geiger_sensor_isr_13() { + _geiger_sensor_isr(13); +} +void ICACHE_RAM_ATTR _geiger_sensor_isr_14() { + _geiger_sensor_isr(14); +} +void ICACHE_RAM_ATTR _geiger_sensor_isr_15() { + _geiger_sensor_isr(15); +} + +static void (*_geiger_sensor_isr_list[10])() = { + _geiger_sensor_isr_0, _geiger_sensor_isr_1, _geiger_sensor_isr_2, + _geiger_sensor_isr_3, _geiger_sensor_isr_4, _geiger_sensor_isr_5, + _geiger_sensor_isr_12, _geiger_sensor_isr_13, _geiger_sensor_isr_14, + _geiger_sensor_isr_15 +}; + +void GeigerSensor::_attach(GeigerSensor * instance, unsigned char gpio, unsigned char mode) { + if (!gpioValid(gpio)) return; + _detach(gpio); + unsigned char index = gpio > 5 ? gpio-6 : gpio; + _geiger_sensor_instance[index] = instance; + attachInterrupt(gpio, _geiger_sensor_isr_list[index], mode); + #if SENSOR_DEBUG + DEBUG_MSG_P(PSTR("[GEIGER] GPIO%d interrupt attached to %s\n"), gpio, instance->description().c_str()); + #endif +} + +void GeigerSensor::_detach(unsigned char gpio) { + if (!gpioValid(gpio)) return; + unsigned char index = gpio > 5 ? gpio-6 : gpio; + if (_geiger_sensor_instance[index]) { + detachInterrupt(gpio); + #if SENSOR_DEBUG + DEBUG_MSG_P(PSTR("[GEIGER] GPIO%d interrupt detached from %s\n"), gpio, _geiger_sensor_instance[index]->description().c_str()); + #endif + _geiger_sensor_instance[index] = NULL; + } +} + +#endif // SENSOR_SUPPORT && GEIGER_SUPPORT diff --git a/code/espurna/sensors/V9261FSensor.h b/code/espurna/sensors/V9261FSensor.h index c80ab44b..67068c17 100644 --- a/code/espurna/sensors/V9261FSensor.h +++ b/code/espurna/sensors/V9261FSensor.h @@ -9,6 +9,9 @@ #include "Arduino.h" #include "BaseSensor.h" +extern "C" { + #include "libs/fs_math.h" +} #include @@ -203,7 +206,7 @@ class V9261FSensor : public BaseSensor { if (_voltage < 0) _voltage = 0; if (_current < 0) _current = 0; - _apparent = sqrt(_reactive * _reactive + _active * _active); + _apparent = fs_sqrt(_reactive * _reactive + _active * _active); } diff --git a/code/espurna/settings.ino b/code/espurna/settings.ino index 9d5767b3..b05f9a08 100644 --- a/code/espurna/settings.ino +++ b/code/espurna/settings.ino @@ -6,7 +6,7 @@ Copyright (C) 2016-2018 by Xose Pérez */ -#include +#include #include #include "libs/EmbedisWrap.h" #include @@ -30,7 +30,7 @@ bool _settings_save = false; unsigned long settingsSize() { unsigned pos = SPI_FLASH_SEC_SIZE - 1; - while (size_t len = EEPROM.read(pos)) { + while (size_t len = EEPROMr.read(pos)) { pos = pos - len - 2; } return SPI_FLASH_SEC_SIZE - pos; @@ -41,9 +41,9 @@ unsigned long settingsSize() { unsigned int _settingsKeyCount() { unsigned count = 0; unsigned pos = SPI_FLASH_SEC_SIZE - 1; - while (size_t len = EEPROM.read(pos)) { + while (size_t len = EEPROMr.read(pos)) { pos = pos - len - 2; - len = EEPROM.read(pos); + len = EEPROMr.read(pos); pos = pos - len - 2; count ++; } @@ -56,17 +56,17 @@ String _settingsKeyName(unsigned int index) { unsigned count = 0; unsigned pos = SPI_FLASH_SEC_SIZE - 1; - while (size_t len = EEPROM.read(pos)) { + while (size_t len = EEPROMr.read(pos)) { pos = pos - len - 2; if (count == index) { s.reserve(len); for (unsigned char i = 0 ; i < len; i++) { - s += (char) EEPROM.read(pos + i + 1); + s += (char) EEPROMr.read(pos + i + 1); } break; } count++; - len = EEPROM.read(pos); + len = EEPROMr.read(pos); pos = pos - len - 2; } @@ -151,32 +151,21 @@ void _settingsKeysCommand() { DEBUG_MSG_P(PSTR("Current settings:\n")); for (unsigned int i=0; i %s => %s\n"), (keys[i]).c_str(), value.c_str()); + DEBUG_MSG_P(PSTR("> %s => \"%s\"\n"), (keys[i]).c_str(), value.c_str()); } unsigned long freeEEPROM = SPI_FLASH_SEC_SIZE - settingsSize(); DEBUG_MSG_P(PSTR("Number of keys: %d\n"), keys.size()); + DEBUG_MSG_P(PSTR("Current EEPROM sector: %u\n"), EEPROMr.current()); DEBUG_MSG_P(PSTR("Free EEPROM: %d bytes (%d%%)\n"), freeEEPROM, 100 * freeEEPROM / SPI_FLASH_SEC_SIZE); } void _settingsFactoryResetCommand() { for (unsigned int i = 0; i < SPI_FLASH_SEC_SIZE; i++) { - EEPROM.write(i, 0xFF); - } - EEPROM.commit(); -} - -void _settingsDumpCommand(bool ascii) { - for (unsigned int i = 0; i < SPI_FLASH_SEC_SIZE; i++) { - if (i % 16 == 0) DEBUG_MSG_P(PSTR("\n[%04X] "), i); - byte c = EEPROM.read(i); - if (ascii && 32 <= c && c <= 126) { - DEBUG_MSG_P(PSTR(" %c "), c); - } else { - DEBUG_MSG_P(PSTR("%02X "), c); - } + EEPROMr.write(i, 0xFF); } + EEPROMr.commit(); } void _settingsInitCommands() { @@ -194,13 +183,6 @@ void _settingsInitCommands() { DEBUG_MSG_P(PSTR("+OK\n")); }); - settingsRegisterCommand(F("EEPROM.DUMP"), [](Embedis* e) { - bool ascii = false; - if (e->argc == 2) ascii = String(e->argv[1]).toInt() == 1; - _settingsDumpCommand(ascii); - DEBUG_MSG_P(PSTR("\n+OK\n")); - }); - settingsRegisterCommand(F("ERASE.CONFIG"), [](Embedis* e) { DEBUG_MSG_P(PSTR("+OK\n")); resetReason(CUSTOM_RESET_TERMINAL); @@ -257,7 +239,7 @@ void _settingsInitCommands() { settingsRegisterCommand(F("INFO"), [](Embedis* e) { info(); - wifiStatus(); + wifiDebug(); //StreamString s; //WiFi.printDiag(s); //DEBUG_MSG(s.c_str()); @@ -269,18 +251,40 @@ void _settingsInitCommands() { DEBUG_MSG_P(PSTR("+OK\n")); }); - settingsRegisterCommand(F("RELOAD"), [](Embedis* e) { - wsReload(); + settingsRegisterCommand(F("GET"), [](Embedis* e) { + if (e->argc < 2) { + DEBUG_MSG_P(PSTR("-ERROR: Wrong arguments\n")); + return; + } + + for (unsigned char i = 1; i < e->argc; i++) { + String key = String(e->argv[i]); + String value; + if (!Embedis::get(key, value)) { + DEBUG_MSG_P(PSTR("> %s =>\n"), key.c_str()); + continue; + } + + DEBUG_MSG_P(PSTR("> %s => \"%s\"\n"), key.c_str(), value.c_str()); + } + DEBUG_MSG_P(PSTR("+OK\n")); }); + #if WEB_SUPPORT + settingsRegisterCommand(F("RELOAD"), [](Embedis* e) { + wsReload(); + DEBUG_MSG_P(PSTR("+OK\n")); + }); + #endif + settingsRegisterCommand(F("RESET"), [](Embedis* e) { DEBUG_MSG_P(PSTR("+OK\n")); deferredReset(100, CUSTOM_RESET_TERMINAL); }); settingsRegisterCommand(F("RESET.SAFE"), [](Embedis* e) { - EEPROM.write(EEPROM_CRASH_COUNTER, SYSTEM_CHECK_MAX); + EEPROMr.write(EEPROM_CRASH_COUNTER, SYSTEM_CHECK_MAX); DEBUG_MSG_P(PSTR("+OK\n")); deferredReset(100, CUSTOM_RESET_TERMINAL); }); @@ -358,6 +362,10 @@ void settingsInject(void *data, size_t len) { _serial.inject((char *) data, len); } +Stream & settingsSerial() { + return (Stream &) _serial; +} + size_t settingsMaxSize() { size_t size = EEPROM_SIZE; if (size > SPI_FLASH_SEC_SIZE) size = SPI_FLASH_SEC_SIZE; @@ -371,7 +379,7 @@ bool settingsRestoreJson(JsonObject& data) { if (strcmp(app, APP_NAME) != 0) return false; for (unsigned int i = EEPROM_DATA_END; i < SPI_FLASH_SEC_SIZE; i++) { - EEPROM.write(i, 0xFF); + EEPROMr.write(i, 0xFF); } for (auto element : data) { @@ -410,7 +418,7 @@ void settingsRegisterCommand(const String& name, void (*call)(Embedis*)) { void settingsSetup() { - EEPROM.begin(SPI_FLASH_SEC_SIZE); + EEPROMr.begin(SPI_FLASH_SEC_SIZE); _serial.callback([](uint8_t ch) { #if TELNET_SUPPORT @@ -423,8 +431,8 @@ void settingsSetup() { Embedis::dictionary( F("EEPROM"), SPI_FLASH_SEC_SIZE, - [](size_t pos) -> char { return EEPROM.read(pos); }, - [](size_t pos, char value) { EEPROM.write(pos, value); }, + [](size_t pos) -> char { return EEPROMr.read(pos); }, + [](size_t pos, char value) { EEPROMr.write(pos, value); }, #if SETTINGS_AUTOSAVE []() { _settings_save = true; } #else @@ -448,7 +456,7 @@ void settingsSetup() { void settingsLoop() { if (_settings_save) { - EEPROM.commit(); + EEPROMr.commit(); _settings_save = false; } diff --git a/code/espurna/system.ino b/code/espurna/system.ino index fb1d1ed0..e437bccc 100644 --- a/code/espurna/system.ino +++ b/code/espurna/system.ino @@ -6,7 +6,7 @@ Copyright (C) 2018 by Xose Pérez */ -#include +#include // ----------------------------------------------------------------------------- @@ -30,7 +30,7 @@ unsigned short int _load_average = 100; bool _systemStable = true; void systemCheck(bool stable) { - unsigned char value = EEPROM.read(EEPROM_CRASH_COUNTER); + unsigned char value = EEPROMr.read(EEPROM_CRASH_COUNTER); if (stable) { value = 0; DEBUG_MSG_P(PSTR("[MAIN] System OK\n")); @@ -41,8 +41,8 @@ void systemCheck(bool stable) { DEBUG_MSG_P(PSTR("[MAIN] System UNSTABLE\n")); } } - EEPROM.write(EEPROM_CRASH_COUNTER, value); - EEPROM.commit(); + EEPROMr.write(EEPROM_CRASH_COUNTER, value); + EEPROMr.commit(); } bool systemCheck() { @@ -148,8 +148,6 @@ void _systemSetupSpecificHardware() { void systemSetup() { - EEPROM.begin(EEPROM_SIZE); - #if SPIFFS_SUPPORT SPIFFS.begin(); #endif diff --git a/code/espurna/telnet.ino b/code/espurna/telnet.ino index 006d5d21..4f858ab4 100644 --- a/code/espurna/telnet.ino +++ b/code/espurna/telnet.ino @@ -138,7 +138,7 @@ void _telnetNewClient(AsyncClient *client) { // If there is no terminal support automatically dump info and crash data #if TERMINAL_SUPPORT == 0 info(); - wifiStatus(); + wifiDebug(); debugDumpCrashInfo(); debugClearCrashInfo(); #endif diff --git a/code/espurna/utils.ino b/code/espurna/utils.ino index e6850152..9a229c4a 100644 --- a/code/espurna/utils.ino +++ b/code/espurna/utils.ino @@ -64,6 +64,16 @@ unsigned int getFreeHeap() { return ESP.getFreeHeap(); } +String getEspurnaModules() { + return FPSTR(espurna_modules); +} + +#if SENSOR_SUPPORT +String getEspurnaSensors() { + return FPSTR(espurna_sensors); +} +#endif + String buildTime() { const char time_now[] = __TIME__; // hh:mm:ss @@ -211,10 +221,42 @@ void heartbeat() { #endif /// HEARTBEAT_ENABLED -unsigned int sectors(size_t size) { +// ----------------------------------------------------------------------------- +// INFO +// ----------------------------------------------------------------------------- + +extern "C" uint32_t _SPIFFS_start; +extern "C" uint32_t _SPIFFS_end; + +unsigned int info_bytes2sectors(size_t size) { return (int) (size + SPI_FLASH_SEC_SIZE - 1) / SPI_FLASH_SEC_SIZE; } +unsigned long info_ota_space() { + return (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000; +} + +unsigned long info_filesystem_space() { + return ((uint32_t)&_SPIFFS_end - (uint32_t)&_SPIFFS_start); +} + +unsigned long info_eeprom_space() { + return EEPROMr.reserved() * SPI_FLASH_SEC_SIZE; +} + +void _info_print_memory_layout_line(const char * name, unsigned long bytes, bool reset) { + static unsigned long index = 0; + if (reset) index = 0; + if (0 == bytes) return; + unsigned int _sectors = info_bytes2sectors(bytes); + DEBUG_MSG_P(PSTR("[INIT] %-20s: %8lu bytes / %4d sectors (%4d to %4d)\n"), name, bytes, _sectors, index, index + _sectors - 1); + index += _sectors; +} + +void _info_print_memory_layout_line(const char * name, unsigned long bytes) { + _info_print_memory_layout_line(name, bytes, false); +} + void info() { DEBUG_MSG_P(PSTR("\n\n")); @@ -235,13 +277,18 @@ void info() { DEBUG_MSG_P(PSTR("[INIT] Flash speed: %u Hz\n"), ESP.getFlashChipSpeed()); DEBUG_MSG_P(PSTR("[INIT] Flash mode: %s\n"), mode == FM_QIO ? "QIO" : mode == FM_QOUT ? "QOUT" : mode == FM_DIO ? "DIO" : mode == FM_DOUT ? "DOUT" : "UNKNOWN"); DEBUG_MSG_P(PSTR("\n")); - DEBUG_MSG_P(PSTR("[INIT] Flash sector size: %8u bytes\n"), SPI_FLASH_SEC_SIZE); - DEBUG_MSG_P(PSTR("[INIT] Flash size (CHIP): %8u bytes\n"), ESP.getFlashChipRealSize()); - DEBUG_MSG_P(PSTR("[INIT] Flash size (SDK): %8u bytes / %4d sectors\n"), ESP.getFlashChipSize(), sectors(ESP.getFlashChipSize())); - DEBUG_MSG_P(PSTR("[INIT] Firmware size: %8u bytes / %4d sectors\n"), ESP.getSketchSize(), sectors(ESP.getSketchSize())); - DEBUG_MSG_P(PSTR("[INIT] Max OTA size: %8u bytes / %4d sectors\n"), maxSketchSpace(), sectors(maxSketchSpace())); - DEBUG_MSG_P(PSTR("[INIT] EEPROM size: %8u bytes / %4d sectors\n"), settingsMaxSize(), sectors(settingsMaxSize())); - DEBUG_MSG_P(PSTR("[INIT] Empty space: %8u bytes / 4 sectors\n"), 4 * SPI_FLASH_SEC_SIZE); + + _info_print_memory_layout_line("Flash size (CHIP)", ESP.getFlashChipRealSize(), true); + _info_print_memory_layout_line("Flash size (SDK)", ESP.getFlashChipSize(), true); + _info_print_memory_layout_line("Reserved", 1 * SPI_FLASH_SEC_SIZE, true); + _info_print_memory_layout_line("Firmware size", ESP.getSketchSize()); + _info_print_memory_layout_line("Max OTA size", info_ota_space()); + _info_print_memory_layout_line("SPIFFS size", info_filesystem_space()); + _info_print_memory_layout_line("EEPROM size", info_eeprom_space()); + _info_print_memory_layout_line("Reserved", 4 * SPI_FLASH_SEC_SIZE); + DEBUG_MSG_P(PSTR("\n")); + + DEBUG_MSG_P(PSTR("[INIT] EEPROM sectors: %s\n"), (char *) eepromSectors().c_str()); DEBUG_MSG_P(PSTR("\n")); // ------------------------------------------------------------------------- @@ -265,171 +312,11 @@ void info() { // ------------------------------------------------------------------------- DEBUG_MSG_P(PSTR("[INIT] BOARD: %s\n"), getBoardName().c_str()); - DEBUG_MSG_P(PSTR("[INIT] SUPPORT:")); - - #if ALEXA_SUPPORT - DEBUG_MSG_P(PSTR(" ALEXA")); - #endif - #if BROKER_SUPPORT - DEBUG_MSG_P(PSTR(" BROKER")); - #endif - #if DEBUG_SERIAL_SUPPORT - DEBUG_MSG_P(PSTR(" DEBUG_SERIAL")); - #endif - #if DEBUG_TELNET_SUPPORT - DEBUG_MSG_P(PSTR(" DEBUG_TELNET")); - #endif - #if DEBUG_UDP_SUPPORT - DEBUG_MSG_P(PSTR(" DEBUG_UDP")); - #endif - #if DEBUG_WEB_SUPPORT - DEBUG_MSG_P(PSTR(" DEBUG_WEB")); - #endif - #if DOMOTICZ_SUPPORT - DEBUG_MSG_P(PSTR(" DOMOTICZ")); - #endif - #if HOMEASSISTANT_SUPPORT - DEBUG_MSG_P(PSTR(" HOMEASSISTANT")); - #endif - #if I2C_SUPPORT - DEBUG_MSG_P(PSTR(" I2C")); - #endif - #if INFLUXDB_SUPPORT - DEBUG_MSG_P(PSTR(" INFLUXDB")); - #endif - #if LLMNR_SUPPORT - DEBUG_MSG_P(PSTR(" LLMNR")); - #endif - #if MDNS_SERVER_SUPPORT - DEBUG_MSG_P(PSTR(" MDNS_SERVER")); - #endif - #if MDNS_CLIENT_SUPPORT - DEBUG_MSG_P(PSTR(" MDNS_CLIENT")); - #endif - #if MQTT_SUPPORT - DEBUG_MSG_P(PSTR(" MQTT")); - #endif - #if NETBIOS_SUPPORT - DEBUG_MSG_P(PSTR(" NETBIOS")); - #endif - #if NOFUSS_SUPPORT - DEBUG_MSG_P(PSTR(" NOFUSS")); - #endif - #if NTP_SUPPORT - DEBUG_MSG_P(PSTR(" NTP")); - #endif - #if RF_SUPPORT - DEBUG_MSG_P(PSTR(" RF")); - #endif - #if SCHEDULER_SUPPORT - DEBUG_MSG_P(PSTR(" SCHEDULER")); - #endif - #if SENSOR_SUPPORT - DEBUG_MSG_P(PSTR(" SENSOR")); - #endif - #if SPIFFS_SUPPORT - DEBUG_MSG_P(PSTR(" SPIFFS")); - #endif - #if SSDP_SUPPORT - DEBUG_MSG_P(PSTR(" SSDP")); - #endif - #if TELNET_SUPPORT - DEBUG_MSG_P(PSTR(" TELNET")); - #endif - #if TERMINAL_SUPPORT - DEBUG_MSG_P(PSTR(" TERMINAL")); - #endif - #if THINGSPEAK_SUPPORT - DEBUG_MSG_P(PSTR(" THINGSPEAK")); - #endif - #if UART_MQTT_SUPPORT - DEBUG_MSG_P(PSTR(" UART_MQTT")); - #endif - #if WEB_SUPPORT - DEBUG_MSG_P(PSTR(" WEB")); - #endif - + DEBUG_MSG_P(PSTR("[INIT] SUPPORT: %s\n"), getEspurnaModules().c_str()); #if SENSOR_SUPPORT - - DEBUG_MSG_P(PSTR("\n")); - DEBUG_MSG_P(PSTR("[INIT] SENSORS:")); - - #if AM2320_SUPPORT - DEBUG_MSG_P(PSTR(" AM2320_I2C")); - #endif - #if ANALOG_SUPPORT - DEBUG_MSG_P(PSTR(" ANALOG")); - #endif - #if BH1750_SUPPORT - DEBUG_MSG_P(PSTR(" BH1750")); - #endif - #if BMX280_SUPPORT - DEBUG_MSG_P(PSTR(" BMX280")); - #endif - #if CSE7766_SUPPORT - DEBUG_MSG_P(PSTR(" CSE7766")); - #endif - #if DALLAS_SUPPORT - DEBUG_MSG_P(PSTR(" DALLAS")); - #endif - #if DHT_SUPPORT - DEBUG_MSG_P(PSTR(" DHTXX")); - #endif - #if DIGITAL_SUPPORT - DEBUG_MSG_P(PSTR(" DIGITAL")); - #endif - #if ECH1560_SUPPORT - DEBUG_MSG_P(PSTR(" ECH1560")); - #endif - #if EMON_ADC121_SUPPORT - DEBUG_MSG_P(PSTR(" EMON_ADC121")); - #endif - #if EMON_ADS1X15_SUPPORT - DEBUG_MSG_P(PSTR(" EMON_ADX1X15")); - #endif - #if EMON_ANALOG_SUPPORT - DEBUG_MSG_P(PSTR(" EMON_ANALOG")); - #endif - #if EVENTS_SUPPORT - DEBUG_MSG_P(PSTR(" EVENTS")); - #endif - #if GUVAS12SD_SUPPORT - DEBUG_MSG_P(PSTR(" GUVAS12SD")); - #endif - #if HCSR04_SUPPORT - DEBUG_MSG_P(PSTR(" HCSR04")); - #endif - #if HLW8012_SUPPORT - DEBUG_MSG_P(PSTR(" HLW8012")); - #endif - #if MHZ19_SUPPORT - DEBUG_MSG_P(PSTR(" MHZ19")); - #endif - #if PMSX003_SUPPORT - DEBUG_MSG_P(PSTR(" PMSX003")); - #endif - #if PZEM004T_SUPPORT - DEBUG_MSG_P(PSTR(" PZEM004T")); - #endif - #if SENSEAIR_SUPPORT - DEBUG_MSG_P(PSTR(" SENSEAIR")); - #endif - #if SHT3X_I2C_SUPPORT - DEBUG_MSG_P(PSTR(" SHT3X_I2C")); - #endif - #if SI7021_SUPPORT - DEBUG_MSG_P(PSTR(" SI7021")); - #endif - #if TMP3X_SUPPORT - DEBUG_MSG_P(PSTR(" TMP3X")); - #endif - #if V9261F_SUPPORT - DEBUG_MSG_P(PSTR(" V9261F")); - #endif - + DEBUG_MSG_P(PSTR("[INIT] SENSORS: %s\n"), getEspurnaSensors().c_str()); #endif // SENSOR_SUPPORT - - DEBUG_MSG_P(PSTR("\n\n")); + DEBUG_MSG_P(PSTR("\n")); // ------------------------------------------------------------------------- @@ -508,7 +395,7 @@ bool sslFingerPrintChar(const char * fingerprint, char * destination) { unsigned char resetReason() { static unsigned char status = 255; if (status == 255) { - status = EEPROM.read(EEPROM_CUSTOM_RESET); + status = EEPROMr.read(EEPROM_CUSTOM_RESET); if (status > 0) resetReason(0); if (status > CUSTOM_RESET_MAX) status = 0; } @@ -516,8 +403,8 @@ unsigned char resetReason() { } void resetReason(unsigned char reason) { - EEPROM.write(EEPROM_CUSTOM_RESET, reason); - EEPROM.commit(); + EEPROMr.write(EEPROM_CUSTOM_RESET, reason); + EEPROMr.commit(); } void reset(unsigned char reason) { @@ -552,3 +439,19 @@ void nice_delay(unsigned long ms) { int __get_adc_mode() { return (int) (ADC_MODE_VALUE); } + +bool isNumber(const char * s) { + unsigned char len = strlen(s); + bool decimal = false; + for (unsigned char i=0; i0) return false; + } else if (s[i] == '.') { + if (decimal) return false; + decimal = true; + } else if (!isdigit(s[i])) { + return false; + } + } + return true; +} diff --git a/code/espurna/web.ino b/code/espurna/web.ino index 6323d40b..29d9b351 100644 --- a/code/espurna/web.ino +++ b/code/espurna/web.ino @@ -43,7 +43,9 @@ void _onReset(AsyncWebServerRequest *request) { void _onGetConfig(AsyncWebServerRequest *request) { webLog(request); - if (!webAuthenticate(request)) return request->requestAuthentication(getSetting("hostname").c_str()); + if (!webAuthenticate(request)) { + return request->requestAuthentication(getSetting("hostname").c_str()); + } AsyncResponseStream *response = request->beginResponseStream("text/json"); @@ -53,18 +55,23 @@ void _onGetConfig(AsyncWebServerRequest *request) { root["version"] = APP_VERSION; settingsGetJson(root); root.prettyPrintTo(*response); + jsonBuffer.clear(); char buffer[100]; snprintf_P(buffer, sizeof(buffer), PSTR("attachment; filename=\"%s-backup.json\""), (char *) getSetting("hostname").c_str()); response->addHeader("Content-Disposition", buffer); - + response->addHeader("X-XSS-Protection", "1; mode=block"); + response->addHeader("X-Content-Type-Options", "nosniff"); + response->addHeader("X-Frame-Options", "deny"); request->send(response); } void _onPostConfig(AsyncWebServerRequest *request) { webLog(request); - if (!webAuthenticate(request)) return request->requestAuthentication(getSetting("hostname").c_str()); + if (!webAuthenticate(request)) { + return request->requestAuthentication(getSetting("hostname").c_str()); + } request->send(_webConfigSuccess ? 200 : 400); } @@ -112,7 +119,9 @@ void _onPostConfigData(AsyncWebServerRequest *request, String filename, size_t i void _onHome(AsyncWebServerRequest *request) { webLog(request); - if (!webAuthenticate(request)) return request->requestAuthentication(getSetting("hostname").c_str()); + if (!webAuthenticate(request)) { + return request->requestAuthentication(getSetting("hostname").c_str()); + } if (request->header("If-Modified-Since").equals(_last_modified)) { @@ -151,6 +160,9 @@ void _onHome(AsyncWebServerRequest *request) { response->addHeader("Content-Encoding", "gzip"); response->addHeader("Last-Modified", _last_modified); + response->addHeader("X-XSS-Protection", "1; mode=block"); + response->addHeader("X-Content-Type-Options", "nosniff"); + response->addHeader("X-Frame-Options", "deny"); request->send(response); } @@ -212,7 +224,9 @@ int _onCertificate(void * arg, const char *filename, uint8_t **buf) { void _onUpgrade(AsyncWebServerRequest *request) { webLog(request); - if (!webAuthenticate(request)) return request->requestAuthentication(getSetting("hostname").c_str()); + if (!webAuthenticate(request)) { + return request->requestAuthentication(getSetting("hostname").c_str()); + } char buffer[10]; if (!Update.hasError()) { @@ -223,7 +237,12 @@ void _onUpgrade(AsyncWebServerRequest *request) { AsyncWebServerResponse *response = request->beginResponse(200, "text/plain", buffer); response->addHeader("Connection", "close"); - if (!Update.hasError()) { + response->addHeader("X-XSS-Protection", "1; mode=block"); + response->addHeader("X-Content-Type-Options", "nosniff"); + response->addHeader("X-Frame-Options", "deny"); + if (Update.hasError()) { + eepromRotate(true); + } else { deferredReset(100, CUSTOM_RESET_UPGRADE); } request->send(response); @@ -231,7 +250,12 @@ void _onUpgrade(AsyncWebServerRequest *request) { } void _onUpgradeData(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) { + if (!index) { + + // Disabling EEPROM rotation to prevent writing to EEPROM after the upgrade + eepromRotate(false); + DEBUG_MSG_P(PSTR("[UPGRADE] Start: %s\n"), filename.c_str()); Update.runAsync(true); if (!Update.begin((ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000)) { @@ -239,7 +263,9 @@ void _onUpgradeData(AsyncWebServerRequest *request, String filename, size_t inde Update.printError(DEBUG_PORT); #endif } + } + if (!Update.hasError()) { if (Update.write(data, len) != len) { #ifdef DEBUG_PORT @@ -247,6 +273,7 @@ void _onUpgradeData(AsyncWebServerRequest *request, String filename, size_t inde #endif } } + if (final) { if (Update.end(true)){ DEBUG_MSG_P(PSTR("[UPGRADE] Success: %u bytes\n"), index + len); diff --git a/code/espurna/wifi.ino b/code/espurna/wifi.ino index 04e98d4d..37f55464 100644 --- a/code/espurna/wifi.ino +++ b/code/espurna/wifi.ino @@ -10,11 +10,26 @@ Copyright (C) 2016-2018 by Xose Pérez #include uint32_t _wifi_scan_client_id = 0; +bool _wifi_wps_running = false; +bool _wifi_smartconfig_running = false; +uint8_t _wifi_ap_mode = WIFI_AP_FALLBACK; // ----------------------------------------------------------------------------- // PRIVATE // ----------------------------------------------------------------------------- +void _wifiCheckAP() { + + if ((WIFI_AP_FALLBACK == _wifi_ap_mode) && + (jw.connected()) && + ((WiFi.getMode() & WIFI_AP) > 0) && + (WiFi.softAPgetStationNum() == 0) + ) { + jw.enableAP(false); + } + +} + void _wifiConfigure() { jw.setHostname(getSetting("hostname").c_str()); @@ -25,9 +40,11 @@ void _wifiConfigure() { #endif jw.setConnectTimeout(WIFI_CONNECT_TIMEOUT); wifiReconnectCheck(); - jw.setAPMode(WIFI_AP_MODE); + jw.enableAPFallback(true); jw.cleanNetworks(); + _wifi_ap_mode = getSetting("apmode", WIFI_AP_FALLBACK).toInt(); + // If system is flagged unstable we do not init wifi networks #if SYSTEM_CHECK_ENABLED if (!systemCheck()) return; @@ -56,7 +73,7 @@ void _wifiConfigure() { } } - jw.scanNetworks(getSetting("wifiScan", WIFI_SCAN_NETWORKS).toInt() == 1); + jw.enableScan(getSetting("wifiScan", WIFI_SCAN_NETWORKS).toInt() == 1); } @@ -196,6 +213,47 @@ void _wifiInject() { } } +void _wifiCallback(justwifi_messages_t code, char * parameter) { + + if (MESSAGE_WPS_START == code) { + _wifi_wps_running = true; + } + + if (MESSAGE_SMARTCONFIG_START == code) { + _wifi_smartconfig_running = true; + } + + if (MESSAGE_WPS_ERROR == code || MESSAGE_SMARTCONFIG_ERROR == code) { + _wifi_wps_running = false; + _wifi_smartconfig_running = false; + } + + if (MESSAGE_WPS_SUCCESS == code || MESSAGE_SMARTCONFIG_SUCCESS == code) { + + String ssid = WiFi.SSID(); + String pass = WiFi.psk(); + + // Look for the same SSID + uint8_t count = 0; + while (count < WIFI_MAX_NETWORKS) { + if (!hasSetting("ssid", count)) break; + if (ssid.equals(getSetting("ssid", count, ""))) break; + count++; + } + + // If we have reached the max we overwrite the first one + if (WIFI_MAX_NETWORKS == count) count = 0; + + setSetting("ssid", count, ssid); + setSetting("pass", count, pass); + + _wifi_wps_running = false; + _wifi_smartconfig_running = false; + + } + +} + #if WIFI_AP_CAPTIVE #include "DNSServer.h" @@ -221,7 +279,9 @@ void _wifiCaptivePortal(justwifi_messages_t code, char * parameter) { #if DEBUG_SUPPORT -void _wifiDebug(justwifi_messages_t code, char * parameter) { +void _wifiDebugCallback(justwifi_messages_t code, char * parameter) { + + // ------------------------------------------------------------------------- if (code == MESSAGE_SCANNING) { DEBUG_MSG_P(PSTR("[WIFI] Scanning\n")); @@ -243,6 +303,8 @@ void _wifiDebug(justwifi_messages_t code, char * parameter) { DEBUG_MSG_P(PSTR("[WIFI] %s\n"), parameter); } + // ------------------------------------------------------------------------- + if (code == MESSAGE_CONNECTING) { DEBUG_MSG_P(PSTR("[WIFI] Connecting to %s\n"), parameter); } @@ -256,25 +318,59 @@ void _wifiDebug(justwifi_messages_t code, char * parameter) { } if (code == MESSAGE_CONNECTED) { - wifiStatus(); - } - - if (code == MESSAGE_ACCESSPOINT_CREATED) { - wifiStatus(); + wifiDebug(WIFI_STA); } if (code == MESSAGE_DISCONNECTED) { DEBUG_MSG_P(PSTR("[WIFI] Disconnected\n")); } + // ------------------------------------------------------------------------- + if (code == MESSAGE_ACCESSPOINT_CREATING) { DEBUG_MSG_P(PSTR("[WIFI] Creating access point\n")); } + if (code == MESSAGE_ACCESSPOINT_CREATED) { + wifiDebug(WIFI_AP); + } + if (code == MESSAGE_ACCESSPOINT_FAILED) { DEBUG_MSG_P(PSTR("[WIFI] Could not create access point\n")); } + if (code == MESSAGE_ACCESSPOINT_DESTROYED) { + DEBUG_MSG_P(PSTR("[WIFI] Access point destroyed\n")); + } + + // ------------------------------------------------------------------------- + + if (code == MESSAGE_WPS_START) { + DEBUG_MSG_P(PSTR("[WIFI] WPS started\n")); + } + + if (code == MESSAGE_WPS_SUCCESS) { + DEBUG_MSG_P(PSTR("[WIFI] WPS succeded!\n")); + } + + if (code == MESSAGE_WPS_ERROR) { + DEBUG_MSG_P(PSTR("[WIFI] WPS failed\n")); + } + + // ------------------------------------------------------------------------ + + if (code == MESSAGE_SMARTCONFIG_START) { + DEBUG_MSG_P(PSTR("[WIFI] Smart Config started\n")); + } + + if (code == MESSAGE_SMARTCONFIG_SUCCESS) { + DEBUG_MSG_P(PSTR("[WIFI] Smart Config succeded!\n")); + } + + if (code == MESSAGE_SMARTCONFIG_ERROR) { + DEBUG_MSG_P(PSTR("[WIFI] Smart Config failed\n")); + } + } #endif // DEBUG_SUPPORT @@ -294,10 +390,24 @@ void _wifiInitCommands() { }); settingsRegisterCommand(F("WIFI.AP"), [](Embedis* e) { - createAP(); + wifiStartAP(); DEBUG_MSG_P(PSTR("+OK\n")); }); + #if defined(JUSTWIFI_ENABLE_WPS) + settingsRegisterCommand(F("WIFI.WPS"), [](Embedis* e) { + wifiStartWPS(); + DEBUG_MSG_P(PSTR("+OK\n")); + }); + #endif // defined(JUSTWIFI_ENABLE_WPS) + + #if defined(JUSTWIFI_ENABLE_SMARTCONFIG) + settingsRegisterCommand(F("WIFI.SMARTCONFIG"), [](Embedis* e) { + wifiStartSmartConfig(); + DEBUG_MSG_P(PSTR("+OK\n")); + }); + #endif // defined(JUSTWIFI_ENABLE_SMARTCONFIG) + settingsRegisterCommand(F("WIFI.SCAN"), [](Embedis* e) { _wifiScan(); DEBUG_MSG_P(PSTR("+OK\n")); @@ -346,6 +456,59 @@ void _wifiWebSocketOnAction(uint32_t client_id, const char * action, JsonObject& #endif +// ----------------------------------------------------------------------------- +// INFO +// ----------------------------------------------------------------------------- + +void wifiDebug(WiFiMode_t modes) { + + bool footer = false; + + if (((modes & WIFI_STA) > 0) && ((WiFi.getMode() & WIFI_STA) > 0)) { + + uint8_t * bssid = WiFi.BSSID(); + DEBUG_MSG_P(PSTR("[WIFI] ------------------------------------- MODE STA\n")); + DEBUG_MSG_P(PSTR("[WIFI] SSID %s\n"), WiFi.SSID().c_str()); + DEBUG_MSG_P(PSTR("[WIFI] IP %s\n"), WiFi.localIP().toString().c_str()); + DEBUG_MSG_P(PSTR("[WIFI] MAC %s\n"), WiFi.macAddress().c_str()); + DEBUG_MSG_P(PSTR("[WIFI] GW %s\n"), WiFi.gatewayIP().toString().c_str()); + DEBUG_MSG_P(PSTR("[WIFI] DNS %s\n"), WiFi.dnsIP().toString().c_str()); + DEBUG_MSG_P(PSTR("[WIFI] MASK %s\n"), WiFi.subnetMask().toString().c_str()); + DEBUG_MSG_P(PSTR("[WIFI] HOST http://%s.local\n"), WiFi.hostname().c_str()); + DEBUG_MSG_P(PSTR("[WIFI] BSSID %02X:%02X:%02X:%02X:%02X:%02X\n"), + bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5], bssid[6] + ); + DEBUG_MSG_P(PSTR("[WIFI] CH %d\n"), WiFi.channel()); + DEBUG_MSG_P(PSTR("[WIFI] RSSI %d\n"), WiFi.RSSI()); + footer = true; + + } + + if (((modes & WIFI_AP) > 0) && ((WiFi.getMode() & WIFI_AP) > 0)) { + DEBUG_MSG_P(PSTR("[WIFI] -------------------------------------- MODE AP\n")); + DEBUG_MSG_P(PSTR("[WIFI] SSID %s\n"), getSetting("hostname").c_str()); + DEBUG_MSG_P(PSTR("[WIFI] PASS %s\n"), getSetting("adminPass", ADMIN_PASS).c_str()); + DEBUG_MSG_P(PSTR("[WIFI] IP %s\n"), WiFi.softAPIP().toString().c_str()); + DEBUG_MSG_P(PSTR("[WIFI] MAC %s\n"), WiFi.softAPmacAddress().c_str()); + footer = true; + } + + if (WiFi.getMode() == 0) { + DEBUG_MSG_P(PSTR("[WIFI] ------------------------------------- MODE OFF\n")); + DEBUG_MSG_P(PSTR("[WIFI] No connection\n")); + footer = true; + } + + if (footer) { + DEBUG_MSG_P(PSTR("[WIFI] ----------------------------------------------\n")); + } + +} + +void wifiDebug() { + wifiDebug(WIFI_AP_STA); +} + // ----------------------------------------------------------------------------- // API // ----------------------------------------------------------------------------- @@ -372,11 +535,30 @@ void wifiDisconnect() { jw.disconnect(); } -bool createAP() { - jw.disconnect(); - jw.resetReconnectTimeout(); - return jw.createAP(); +void wifiStartAP(bool only) { + if (only) { + jw.enableSTA(false); + jw.disconnect(); + jw.resetReconnectTimeout(); + } + jw.enableAP(true); +} + +void wifiStartAP() { + wifiStartAP(true); +} + +#if defined(JUSTWIFI_ENABLE_WPS) +void wifiStartWPS() { + jw.startWPS(); } +#endif // defined(JUSTWIFI_ENABLE_WPS) + +#if defined(JUSTWIFI_ENABLE_SMARTCONFIG) +void wifiStartSmartConfig() { + jw.startSmartConfig(); +} +#endif // defined(JUSTWIFI_ENABLE_SMARTCONFIG) void wifiReconnectCheck() { bool connected = false; @@ -389,44 +571,13 @@ void wifiReconnectCheck() { jw.setReconnectTimeout(connected ? 0 : WIFI_RECONNECT_INTERVAL); } -void wifiStatus() { - - if (WiFi.getMode() == WIFI_AP_STA) { - DEBUG_MSG_P(PSTR("[WIFI] MODE AP + STA --------------------------------\n")); - } else if (WiFi.getMode() == WIFI_AP) { - DEBUG_MSG_P(PSTR("[WIFI] MODE AP --------------------------------------\n")); - } else if (WiFi.getMode() == WIFI_STA) { - DEBUG_MSG_P(PSTR("[WIFI] MODE STA -------------------------------------\n")); - } else { - DEBUG_MSG_P(PSTR("[WIFI] MODE OFF -------------------------------------\n")); - DEBUG_MSG_P(PSTR("[WIFI] No connection\n")); - } - - if ((WiFi.getMode() & WIFI_AP) == WIFI_AP) { - DEBUG_MSG_P(PSTR("[WIFI] SSID %s\n"), jw.getAPSSID().c_str()); - DEBUG_MSG_P(PSTR("[WIFI] PASS %s\n"), getSetting("adminPass", ADMIN_PASS).c_str()); - DEBUG_MSG_P(PSTR("[WIFI] IP %s\n"), WiFi.softAPIP().toString().c_str()); - DEBUG_MSG_P(PSTR("[WIFI] MAC %s\n"), WiFi.softAPmacAddress().c_str()); - } - - if ((WiFi.getMode() & WIFI_STA) == WIFI_STA) { - uint8_t * bssid = WiFi.BSSID(); - DEBUG_MSG_P(PSTR("[WIFI] SSID %s\n"), WiFi.SSID().c_str()); - DEBUG_MSG_P(PSTR("[WIFI] IP %s\n"), WiFi.localIP().toString().c_str()); - DEBUG_MSG_P(PSTR("[WIFI] MAC %s\n"), WiFi.macAddress().c_str()); - DEBUG_MSG_P(PSTR("[WIFI] GW %s\n"), WiFi.gatewayIP().toString().c_str()); - DEBUG_MSG_P(PSTR("[WIFI] DNS %s\n"), WiFi.dnsIP().toString().c_str()); - DEBUG_MSG_P(PSTR("[WIFI] MASK %s\n"), WiFi.subnetMask().toString().c_str()); - DEBUG_MSG_P(PSTR("[WIFI] HOST http://%s.local\n"), WiFi.hostname().c_str()); - DEBUG_MSG_P(PSTR("[WIFI] BSSID %02X:%02X:%02X:%02X:%02X:%02X\n"), - bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5], bssid[6] - ); - DEBUG_MSG_P(PSTR("[WIFI] CH %d\n"), WiFi.channel()); - DEBUG_MSG_P(PSTR("[WIFI] RSSI %d\n"), WiFi.RSSI()); - } - - DEBUG_MSG_P(PSTR("[WIFI] ----------------------------------------------\n")); - +uint8_t wifiState() { + uint8_t state = 0; + if (jw.connected()) state += WIFI_STATE_STA; + if (jw.connectable()) state += WIFI_STATE_AP; + if (_wifi_wps_running) state += WIFI_STATE_WPS; + if (_wifi_smartconfig_running) state += WIFI_STATE_SMARTCONFIG; + return state; } void wifiRegister(wifi_callback_f callback) { @@ -445,11 +596,12 @@ void wifiSetup() { _wifiConfigure(); // Message callbacks + wifiRegister(_wifiCallback); #if WIFI_AP_CAPTIVE wifiRegister(_wifiCaptivePortal); #endif #if DEBUG_SUPPORT - wifiRegister(_wifiDebug); + wifiRegister(_wifiDebugCallback); #endif #if WEB_SUPPORT @@ -470,17 +622,27 @@ void wifiSetup() { void wifiLoop() { + // Main wifi loop jw.loop(); + // Process captrive portal DNS queries if in AP mode only #if WIFI_AP_CAPTIVE if ((WiFi.getMode() & WIFI_AP) == WIFI_AP) { _wifi_dnsServer.processNextRequest(); } #endif + // Do we have a pending scan? if (_wifi_scan_client_id > 0) { _wifiScan(_wifi_scan_client_id); _wifi_scan_client_id = 0; } + // Check if we should disable AP + static unsigned long last = 0; + if (millis() - last > 60000) { + last = millis(); + _wifiCheckAP(); + } + } diff --git a/code/espurna/ws.ino b/code/espurna/ws.ino index caf5ce98..de98f0e4 100644 --- a/code/espurna/ws.ino +++ b/code/espurna/ws.ino @@ -440,6 +440,7 @@ void wsSend(ws_on_send_callback_f callback) { callback(root); String output; root.printTo(output); + jsonBuffer.clear(); _ws.textAll((char *) output.c_str()); } } @@ -464,6 +465,7 @@ void wsSend(uint32_t client_id, ws_on_send_callback_f callback) { callback(root); String output; root.printTo(output); + jsonBuffer.clear(); _ws.text(client_id, (char *) output.c_str()); } diff --git a/code/html/custom.js b/code/html/custom.js index e7134182..ae09de5a 100644 --- a/code/html/custom.js +++ b/code/html/custom.js @@ -40,7 +40,7 @@ function sensorName(id) { "HLW8012", "V9261F", "ECH1560", "Analog", "Digital", "Events", "PMSX003", "BMX280", "MHZ19", "SI7021", "SHT3X I2C", "BH1750", "PZEM004T", "AM2320 I2C", "GUVAS12SD", - "TMP3X", "HC-SR04", "SenseAir" + "TMP3X", "HC-SR04", "SenseAir", "GeigerTicks", "GeigerCPM" ]; if (1 <= id && id <= names.length) { return names[id - 1]; @@ -54,7 +54,8 @@ function magnitudeType(type) { "Current", "Voltage", "Active Power", "Apparent Power", "Reactive Power", "Power Factor", "Energy", "Energy (delta)", "Analog", "Digital", "Events", - "PM1.0", "PM2.5", "PM10", "CO2", "Lux", "UV", "Distance" , "HCHO" + "PM1.0", "PM2.5", "PM10", "CO2", "Lux", "UV", "Distance" , "HCHO", + "Local Dose Rate", "Local Dose Rate" ]; if (1 <= type && type <= types.length) { return types[type - 1]; @@ -510,7 +511,7 @@ function onFileUpload(event) { if (data) { sendAction("restore", data); } else { - alert(messages[4]); + window.alert(messages[4]); } }; reader.readAsText(inputFile); @@ -1216,7 +1217,7 @@ function processData(data) { // Web log if ("weblog" === key) { - $("#weblog").append(value); + $("#weblog").append(new Text(value)); $("#weblog").scrollTop($("#weblog")[0].scrollHeight - $("#weblog").height()); return; } @@ -1356,9 +1357,14 @@ function initUrls(root) { urls["root"] = root; paths.forEach(function(path) { urls[path] = new URL(path, root); + urls[path].protocol = root.protocol; }); - urls.ws.protocol = "ws"; + if (root.protocol == "https:") { + urls.ws.protocol = "wss:"; + } else { + urls.ws.protocol = "ws:"; + } } diff --git a/code/html/index.html b/code/html/index.html index 9a8bda3f..29c0c9a7 100644 --- a/code/html/index.html +++ b/code/html/index.html @@ -1336,7 +1336,7 @@
-
+
diff --git a/code/ota.py b/code/ota.py index 2a268acf..16b86f82 100755 --- a/code/ota.py +++ b/code/ota.py @@ -8,6 +8,7 @@ # ------------------------------------------------------------------------------- from __future__ import print_function +import shutil import argparse import re import socket @@ -27,7 +28,7 @@ except NameError: DISCOVER_TIMEOUT = 2 -description = "ESPurna OTA Manager v0.2" +description = "ESPurna OTA Manager v0.3" devices = [] discover_last = 0 @@ -111,6 +112,11 @@ def get_boards(): boards.append(m.group(1)) return sorted(boards) +def get_device_size(device): + if device.get('mem_size', 0) == device.get('sdk_size', 0): + return int(device.get('mem_size', 0)) / 1024 + return 0 + def get_empty_board(): """ Returns the empty structure of a board to flash @@ -128,9 +134,26 @@ def get_board_by_index(index): board['hostname'] = device.get('hostname') board['board'] = device.get('target_board', '') board['ip'] = device.get('ip', '') - board['size'] = int(device.get('mem_size', 0) if device.get('mem_size', 0) == device.get('sdk_size', 0) else 0) / 1024 + board['size'] = get_device_size(device) return board +def get_board_by_mac(mac): + """ + Returns the required data to flash a given board + """ + hostname = hostname.lower() + for device in devices: + if device.get('mac', '').lower() == mac: + board = {} + board['hostname'] = device.get('hostname') + board['board'] = device.get('device') + board['ip'] = device.get('ip') + board['size'] = get_device_size(device) + if not board['board'] or not board['ip'] or board['size'] == 0: + return None + return board + return None + def get_board_by_hostname(hostname): """ Returns the required data to flash a given board @@ -141,13 +164,9 @@ def get_board_by_hostname(hostname): board = {} board['hostname'] = device.get('hostname') board['board'] = device.get('target_board') - if not board['board']: - return None board['ip'] = device.get('ip') - if not board['ip']: - return None - board['size'] = int(device.get('sdk_size', 0)) / 1024 - if board['size'] == 0: + board['size'] = get_device_size(device) + if not board['board'] or not board['ip'] or board['size'] == 0: return None return board return None @@ -201,13 +220,20 @@ def input_board(): return board +def boardname(board): + return board.get('hostname', board['ip']) + +def store(device, env): + source = ".pioenvs/%s/firmware.elf" % env + destination = ".pioenvs/elfs/%s.elf" % boardname(device).lower() + shutil.move(source, destination) def run(device, env): print("Building and flashing image over-the-air...") command = "export ESPURNA_IP=\"%s\"; export ESPURNA_BOARD=\"%s\"; export ESPURNA_AUTH=\"%s\"; export ESPURNA_FLAGS=\"%s\"; platformio run --silent --environment %s -t upload" command = command % (device['ip'], device['board'], device['auth'], device['flags'], env) subprocess.check_call(command, shell=True) - + store(device, env) # ------------------------------------------------------------------------------- @@ -287,7 +313,7 @@ if __name__ == '__main__': # Summary print() - print("HOST = %s" % board.get('hostname', board['ip'])) + print("HOST = %s" % boardname(board)) print("IP = %s" % board['ip']) print("BOARD = %s" % board['board']) print("AUTH = %s" % board['auth']) diff --git a/code/platformio.ini b/code/platformio.ini index c2dffd53..e5056070 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -35,9 +35,11 @@ debug_flags = -DDEBUG_ESP_CORE -DDEBUG_ESP_SSL -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP # -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY v2 Lower Memory # -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH v2 Higher Bandwidth # ------------------------------------------------------------------------------ -build_flags = -g -DMQTT_MAX_PACKET_SIZE=400 ${env.ESPURNA_FLAGS} -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH -build_flags_512k = ${common.build_flags} -Wl,-Tesp8266.flash.512k0.ld -build_flags_1m = ${common.build_flags} -Wl,-Tesp8266.flash.1m0.ld +build_flags = -g -w -DMQTT_MAX_PACKET_SIZE=400 -DNO_GLOBAL_EEPROM ${env.ESPURNA_FLAGS} -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH +build_flags_512k = ${common.build_flags} -Wl,-Teagle.flash.512k0m1s.ld +build_flags_1m0m = ${common.build_flags} -Wl,-Teagle.flash.1m0m1s.ld +build_flags_4m1m = ${common.build_flags} -Wl,-Teagle.flash.4m1m4s.ld +build_flags_4m3m = ${common.build_flags} -Wl,-Teagle.flash.4m3m4s.ld # ------------------------------------------------------------------------------ # GLOBALS: @@ -57,6 +59,7 @@ lib_deps = https://github.com/marvinroger/async-mqtt-client#v0.8.1 Brzo I2C https://bitbucket.org/xoseperez/debounceevent.git#2.0.1 + https://github.com/xoseperez/eeprom_rotate#0.9.1 Embedis https://github.com/plerup/espsoftwareserial#3.4.1 https://github.com/me-no-dev/ESPAsyncTCP#55cd520 @@ -64,7 +67,7 @@ lib_deps = https://bitbucket.org/xoseperez/fauxmoesp.git#2.4.2 https://github.com/xoseperez/hlw8012.git#1.1.0 https://github.com/markszabo/IRremoteESP8266#v2.2.0 - https://github.com/xoseperez/justwifi.git#1.2.0 + https://github.com/xoseperez/justwifi.git#2.0.0 https://github.com/madpilot/mDNSResolver#4cfcda1 https://github.com/xoseperez/my92xx#3.0.1 https://bitbucket.org/xoseperez/nofuss.git#0.2.5 @@ -85,22 +88,22 @@ extra_scripts = extra_scripts.py platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DESPURNA_CORE -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DESPURNA_CORE +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:espurna-core-4MB] platform = ${common.platform} framework = arduino board = d1_mini -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DESPURNA_CORE -monitor_baud = 115200 +build_flags = ${common.build_flags_4m1m} -DESPURNA_CORE +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} # ------------------------------------------------------------------------------ @@ -111,10 +114,10 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -D${env.ESPURNA_BOARD} +build_flags = ${common.build_flags_1m0m} -D${env.ESPURNA_BOARD} upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 @@ -124,10 +127,10 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp12e -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -D${env.ESPURNA_BOARD} +build_flags = ${common.build_flags_4m1m} -D${env.ESPURNA_BOARD} upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 @@ -142,8 +145,8 @@ framework = arduino board = esp12e lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DTRAVIS01 -monitor_baud = 115200 +build_flags = ${common.build_flags_4m1m} -DTRAVIS01 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:travis02] @@ -152,8 +155,8 @@ framework = arduino board = esp12e lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DTRAVIS02 -monitor_baud = 115200 +build_flags = ${common.build_flags_4m1m} -DTRAVIS02 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:travis03] @@ -162,8 +165,8 @@ framework = arduino board = esp12e lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DTRAVIS03 -DNOWSAUTH -DASYNC_TCP_SSL_ENABLED=1 -monitor_baud = 115200 +build_flags = ${common.build_flags_4m1m} -DTRAVIS03 -DNOWSAUTH -DASYNC_TCP_SSL_ENABLED=1 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} # ------------------------------------------------------------------------------ @@ -176,9 +179,9 @@ framework = arduino board = d1_mini lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DWEMOS_D1_MINI_RELAYSHIELD -DDEBUG_FAUXMO=Serial -DNOWSAUTH +build_flags = ${common.build_flags_4m1m} -DWEMOS_D1_MINI_RELAYSHIELD -DDEBUG_FAUXMO=Serial -DNOWSAUTH upload_speed = 460800 -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:wemos-d1mini-relayshield-ssl] @@ -187,9 +190,9 @@ framework = arduino board = d1_mini lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DWEMOS_D1_MINI_RELAYSHIELD -DDEBUG_FAUXMO=Serial -DNOWSAUTH -DASYNC_TCP_SSL_ENABLED=1 +build_flags = ${common.build_flags_4m1m} -DWEMOS_D1_MINI_RELAYSHIELD -DDEBUG_FAUXMO=Serial -DNOWSAUTH -DASYNC_TCP_SSL_ENABLED=1 upload_speed = 460800 -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:wemos-d1mini-relayshield-ota] @@ -198,7 +201,7 @@ framework = arduino board = d1_mini lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DWEMOS_D1_MINI_RELAYSHIELD -DDEBUG_FAUXMO=Serial -DNOWSAUTH +build_flags = ${common.build_flags_4m1m} -DWEMOS_D1_MINI_RELAYSHIELD -DDEBUG_FAUXMO=Serial -DNOWSAUTH upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} @@ -210,9 +213,9 @@ framework = arduino board = nodemcuv2 lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DNODEMCU_LOLIN -DDEBUG_FAUXMO=Serial -DNOWSAUTH +build_flags = ${common.build_flags_4m1m} -DNODEMCU_LOLIN -DDEBUG_FAUXMO=Serial -DNOWSAUTH upload_speed = 460800 -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:nodemcu-lolin-ssl] @@ -221,9 +224,9 @@ framework = arduino board = nodemcuv2 lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DNODEMCU_LOLIN -DDEBUG_FAUXMO=Serial -DNOWSAUTH -DASYNC_TCP_SSL_ENABLED=1 +build_flags = ${common.build_flags_4m1m} -DNODEMCU_LOLIN -DDEBUG_FAUXMO=Serial -DNOWSAUTH -DASYNC_TCP_SSL_ENABLED=1 upload_speed = 460800 -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:nodemcu-lolin-ota] @@ -232,11 +235,11 @@ framework = arduino board = nodemcuv2 lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DNODEMCU_LOLIN -DDEBUG_FAUXMO=Serial -DNOWSAUTH +build_flags = ${common.build_flags_4m1m} -DNODEMCU_LOLIN -DDEBUG_FAUXMO=Serial -DNOWSAUTH upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} # ------------------------------------------------------------------------------ @@ -249,8 +252,8 @@ framework = arduino board = esp12e lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DTINKERMAN_ESPURNA_H06 -monitor_baud = 115200 +build_flags = ${common.build_flags_4m1m} -DTINKERMAN_ESPURNA_H06 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:tinkerman-espurna-h06-ota] @@ -259,11 +262,11 @@ framework = arduino board = esp12e lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DTINKERMAN_ESPURNA_H06 +build_flags = ${common.build_flags_4m1m} -DTINKERMAN_ESPURNA_H06 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:tinkerman-espurna-h08] @@ -272,8 +275,8 @@ framework = arduino board = esp12e lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DTINKERMAN_ESPURNA_H08 -monitor_baud = 115200 +build_flags = ${common.build_flags_4m1m} -DTINKERMAN_ESPURNA_H08 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:tinkerman-espurna-h08-ota] @@ -282,11 +285,11 @@ framework = arduino board = esp12e lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DTINKERMAN_ESPURNA_H08 +build_flags = ${common.build_flags_4m1m} -DTINKERMAN_ESPURNA_H08 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:tinkerman-espurna-switch] @@ -295,8 +298,8 @@ framework = arduino board = esp12e lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DTINKERMAN_ESPURNA_SWITCH -monitor_baud = 115200 +build_flags = ${common.build_flags_4m1m} -DTINKERMAN_ESPURNA_SWITCH +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:wemos-d1-tarpunashield] @@ -305,8 +308,8 @@ framework = arduino board = esp12e lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DWEMOS_D1_TARPUNA_SHIELD -monitor_baud = 115200 +build_flags = ${common.build_flags_4m1m} -DWEMOS_D1_TARPUNA_SHIELD +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} # ------------------------------------------------------------------------------ @@ -315,181 +318,181 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_BASIC -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_BASIC +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-basic-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_BASIC +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_BASIC upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-basic-dht] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_BASIC -DDHT_SUPPORT=1 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_BASIC -DDHT_SUPPORT=1 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-basic-dht-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_BASIC -DDHT_SUPPORT=1 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_BASIC -DDHT_SUPPORT=1 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-basic-dallas] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_BASIC -DDALLAS_SUPPORT=1 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_BASIC -DDALLAS_SUPPORT=1 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-rf] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_RF -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_RF +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-rf-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_RF +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_RF upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-th] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_TH -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_TH +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-th-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_TH +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_TH upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-pow] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_POW -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_POW +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-pow-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_POW +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_POW upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-pow-r2] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_POW_R2 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_POW_R2 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-pow-r2-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_POW_R2 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_POW_R2 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-dual] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_DUAL +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_DUAL extra_scripts = ${common.extra_scripts} [env:itead-sonoff-dual-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_DUAL +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_DUAL upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} @@ -499,20 +502,20 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_DUAL_R2 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_DUAL_R2 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-dual-ota-r2] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_DUAL_R2 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_DUAL_R2 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} @@ -522,250 +525,250 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_4CH -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_4CH +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-4ch-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_4CH +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_4CH upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-4ch-pro] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_4CH_PRO -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_4CH_PRO +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-4ch-pro-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_4CH_PRO +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_4CH_PRO upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-touch] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_TOUCH -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_TOUCH +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-touch-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_TOUCH +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_TOUCH upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-b1] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_B1 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_B1 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-b1-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_B1 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_B1 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-t1-1ch] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_T1_1CH -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_T1_1CH +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-t1-1ch-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_T1_1CH +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_T1_1CH upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-t1-2ch] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_T1_2CH -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_T1_2CH +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-t1-2ch-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_T1_2CH +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_T1_2CH upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-t1-3ch] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_T1_3CH -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_T1_3CH +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-t1-3ch-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_T1_3CH +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_T1_3CH upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-led] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_LED -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_LED +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-led-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_LED +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_LED upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-rfbridge] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_RFBRIDGE -monitor_baud = 19200 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_RFBRIDGE +monitor_speed = 19200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-rfbridge-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_RFBRIDGE +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_RFBRIDGE upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 19200 +monitor_speed = 19200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-rfbridge-direct] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_RFBRIDGE -DRFB_DIRECT -monitor_baud = 19200 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_RFBRIDGE -DRFB_DIRECT +monitor_speed = 19200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-rfbridge-direct-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_RFBRIDGE -DRFB_DIRECT +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_RFBRIDGE -DRFB_DIRECT upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 -monitor_baud = 19200 +monitor_speed = 19200 extra_scripts = ${common.extra_scripts} # ------------------------------------------------------------------------------ @@ -774,148 +777,148 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SLAMPHER -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DITEAD_SLAMPHER +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-slampher-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SLAMPHER +build_flags = ${common.build_flags_1m0m} -DITEAD_SLAMPHER upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-s20] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_S20 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DITEAD_S20 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-s20-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_S20 +build_flags = ${common.build_flags_1m0m} -DITEAD_S20 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-1ch-inching] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_1CH_INCHING -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DITEAD_1CH_INCHING +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-1ch-inching-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_1CH_INCHING +build_flags = ${common.build_flags_1m0m} -DITEAD_1CH_INCHING upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-motor] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_MOTOR -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DITEAD_MOTOR +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-motor-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_MOTOR +build_flags = ${common.build_flags_1m0m} -DITEAD_MOTOR upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-sv] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_SV -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_SV +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-sv-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_SV +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_SV upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-s31] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_S31 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_S31 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-sonoff-s31-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_SONOFF_S31 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_S31 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} # ------------------------------------------------------------------------------ @@ -926,8 +929,8 @@ framework = arduino board = esp12e lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DELECTRODRAGON_WIFI_IOT -DDHT_SUPPORT=1 -monitor_baud = 115200 +build_flags = ${common.build_flags_4m1m} -DELECTRODRAGON_WIFI_IOT -DDHT_SUPPORT=1 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:electrodragon-wifi-iot-ota] @@ -936,36 +939,36 @@ framework = arduino board = esp12e lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DELECTRODRAGON_WIFI_IOT -DDHT_SUPPORT=1 +build_flags = ${common.build_flags_4m1m} -DELECTRODRAGON_WIFI_IOT -DDHT_SUPPORT=1 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:workchoice-ecoplug] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DWORKCHOICE_ECOPLUG -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DWORKCHOICE_ECOPLUG +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:workchoice-ecoplug-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DWORKCHOICE_ECOPLUG +build_flags = ${common.build_flags_1m0m} -DWORKCHOICE_ECOPLUG upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:jangoe-wifi-relay-nc] @@ -974,8 +977,8 @@ framework = arduino board = esp12e lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DJANGOE_WIFI_RELAY_NC -monitor_baud = 115200 +build_flags = ${common.build_flags_4m1m} -DJANGOE_WIFI_RELAY_NC +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:jangoe-wifi-relay-nc-ota] @@ -984,11 +987,11 @@ framework = arduino board = esp12e lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DJANGOE_WIFI_RELAY_NC +build_flags = ${common.build_flags_4m1m} -DJANGOE_WIFI_RELAY_NC upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:jangoe-wifi-relay-no] @@ -997,8 +1000,8 @@ framework = arduino board = esp12e lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DJANGOE_WIFI_RELAY_NO -monitor_baud = 115200 +build_flags = ${common.build_flags_4m1m} -DJANGOE_WIFI_RELAY_NO +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:jangoe-wifi-relay-no-ota] @@ -1007,11 +1010,11 @@ framework = arduino board = esp12e lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DJANGOE_WIFI_RELAY_NO +build_flags = ${common.build_flags_4m1m} -DJANGOE_WIFI_RELAY_NO upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:openenergymonitor-mqtt-relay] @@ -1020,8 +1023,8 @@ framework = arduino board = esp_wroom_02 lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DOPENENERGYMONITOR_MQTT_RELAY -DDALLAS_SUPPORT=1 -monitor_baud = 115200 +build_flags = ${common.build_flags_4m1m} -DOPENENERGYMONITOR_MQTT_RELAY -DDALLAS_SUPPORT=1 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:openenergymonitor-mqtt-relay-ota] @@ -1030,11 +1033,11 @@ framework = arduino board = esp_wroom_02 lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DOPENENERGYMONITOR_MQTT_RELAY -DDALLAS_SUPPORT=1 +build_flags = ${common.build_flags_4m1m} -DOPENENERGYMONITOR_MQTT_RELAY -DDALLAS_SUPPORT=1 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:jorgegarcia-wifi-relays] @@ -1043,8 +1046,8 @@ framework = arduino board = esp01_1m lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DJORGEGARCIA_WIFI_RELAYS -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DJORGEGARCIA_WIFI_RELAYS +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:jorgegarcia-wifi-relays-ota] @@ -1053,335 +1056,335 @@ framework = arduino board = esp01_1m lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DJORGEGARCIA_WIFI_RELAYS +build_flags = ${common.build_flags_1m0m} -DJORGEGARCIA_WIFI_RELAYS upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:aithinker-ai-light] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DAITHINKER_AI_LIGHT -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DAITHINKER_AI_LIGHT +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:aithinker-ai-light-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DAITHINKER_AI_LIGHT +build_flags = ${common.build_flags_1m0m} -DAITHINKER_AI_LIGHT upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:magichome-led-controller] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DMAGICHOME_LED_CONTROLLER -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DMAGICHOME_LED_CONTROLLER +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:magichome-led-controller-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DMAGICHOME_LED_CONTROLLER +build_flags = ${common.build_flags_1m0m} -DMAGICHOME_LED_CONTROLLER upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:magichome-led-controller-20] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DMAGICHOME_LED_CONTROLLER_20 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DMAGICHOME_LED_CONTROLLER_20 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:magichome-led-controller-20-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DMAGICHOME_LED_CONTROLLER_20 +build_flags = ${common.build_flags_1m0m} -DMAGICHOME_LED_CONTROLLER_20 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:huacanxing-h801] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DHUACANXING_H801 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DHUACANXING_H801 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:huacanxing-h801-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DHUACANXING_H801 +build_flags = ${common.build_flags_1m0m} -DHUACANXING_H801 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:huacanxing-h802] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DHUACANXING_H802 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DHUACANXING_H802 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:huacanxing-h802-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DHUACANXING_H802 +build_flags = ${common.build_flags_1m0m} -DHUACANXING_H802 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:arilux-al-lc01] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DARILUX_AL_LC01 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DARILUX_AL_LC01 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:arilux-al-lc01-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DARILUX_AL_LC01 +build_flags = ${common.build_flags_1m0m} -DARILUX_AL_LC01 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:arilux-al-lc02] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DARILUX_AL_LC02 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DARILUX_AL_LC02 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:arilux-al-lc02-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DARILUX_AL_LC02 +build_flags = ${common.build_flags_1m0m} -DARILUX_AL_LC02 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:arilux-al-lc06] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DARILUX_AL_LC06 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DARILUX_AL_LC06 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:arilux-al-lc06-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DARILUX_AL_LC06 +build_flags = ${common.build_flags_1m0m} -DARILUX_AL_LC06 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:arilux-al-lc11] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DARILUX_AL_LC11 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DARILUX_AL_LC11 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:arilux-al-lc11-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DARILUX_AL_LC11 +build_flags = ${common.build_flags_1m0m} -DARILUX_AL_LC11 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:arilux-e27] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DARILUX_E27 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DARILUX_E27 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:arilux-e27-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DARILUX_E27 +build_flags = ${common.build_flags_1m0m} -DARILUX_E27 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-bnsz01] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_BNSZ01 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DITEAD_BNSZ01 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:itead-bnsz01-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DITEAD_BNSZ01 +build_flags = ${common.build_flags_1m0m} -DITEAD_BNSZ01 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:wion-50055] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DWION_50055 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DWION_50055 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:wion-50055-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DWION_50055 +build_flags = ${common.build_flags_1m0m} -DWION_50055 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:exs-wifi-relay-v31] platform = ${common.platform} framework = arduino board = esp07 -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DEXS_WIFI_RELAY_V31 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DEXS_WIFI_RELAY_V31 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:exs-wifi-relay-v31-ota] platform = ${common.platform} framework = arduino board = esp07 -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DEXS_WIFI_RELAY_V31 +build_flags = ${common.build_flags_1m0m} -DEXS_WIFI_RELAY_V31 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:wemos-v9261f] @@ -1390,9 +1393,9 @@ framework = arduino board = d1_mini lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DGENERIC_V9261F +build_flags = ${common.build_flags_4m1m} -DGENERIC_V9261F upload_speed = 460800 -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:wemos-v9261f-ota] @@ -1401,36 +1404,36 @@ framework = arduino board = d1_mini lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DGENERIC_V9261F +build_flags = ${common.build_flags_4m1m} -DGENERIC_V9261F upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:esp01-v9261f] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DGENERIC_V9261F -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DGENERIC_V9261F +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:esp01-v9261f-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DGENERIC_V9261F +build_flags = ${common.build_flags_1m0m} -DGENERIC_V9261F upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:wemos-ech1560] @@ -1439,9 +1442,9 @@ framework = arduino board = d1_mini lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DGENERIC_ECH1560 +build_flags = ${common.build_flags_4m1m} -DGENERIC_ECH1560 upload_speed = 460800 -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:wemos-ech1560-ota] @@ -1450,36 +1453,36 @@ framework = arduino board = d1_mini lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DGENERIC_ECH1560 +build_flags = ${common.build_flags_4m1m} -DGENERIC_ECH1560 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:esp01-ech1560] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DGENERIC_ECH1560 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DGENERIC_ECH1560 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:esp01-ech1560-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DGENERIC_ECH1560 +build_flags = ${common.build_flags_1m0m} -DGENERIC_ECH1560 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:mancavemade-esplive] @@ -1488,9 +1491,9 @@ framework = arduino board = d1_mini lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DMANCAVEMADE_ESPLIVE +build_flags = ${common.build_flags_4m1m} -DMANCAVEMADE_ESPLIVE upload_speed = 460800 -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:mancavemade-esplive-ota] @@ -1499,136 +1502,136 @@ framework = arduino board = d1_mini lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DMANCAVEMADE_ESPLIVE +build_flags = ${common.build_flags_4m1m} -DMANCAVEMADE_ESPLIVE upload_speed = 460800 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:intermittech-quinled] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DINTERMITTECH_QUINLED -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DINTERMITTECH_QUINLED +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:intermittech-quinled-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DINTERMITTECH_QUINLED +build_flags = ${common.build_flags_1m0m} -DINTERMITTECH_QUINLED upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:xenon-sm-pw702u] platform = ${common.platform} framework = arduino board = esp12e -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DXENON_SM_PW702U -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DXENON_SM_PW702U +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:xenon-sm-pw702u-ota] platform = ${common.platform} framework = arduino board = esp12e -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DXENON_SM_PW702U +build_flags = ${common.build_flags_1m0m} -DXENON_SM_PW702U upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:authometion-lyt8266] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DAUTHOMETION_LYT8266 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DAUTHOMETION_LYT8266 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:authometion-lyt8266-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DAUTHOMETION_LYT8266 +build_flags = ${common.build_flags_1m0m} -DAUTHOMETION_LYT8266 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:kmc-70011] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DKMC_70011 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DKMC_70011 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:kmc-70011-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DKMC_70011 +build_flags = ${common.build_flags_1m0m} -DKMC_70011 upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:yjzk-switch-2ch] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DYJZK_SWITCH_2CH -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DYJZK_SWITCH_2CH +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:yjzk-switch-2ch-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DYJZK_SWITCH_2CH +build_flags = ${common.build_flags_1m0m} -DYJZK_SWITCH_2CH upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:generic-8ch] @@ -1637,30 +1640,30 @@ framework = arduino board = d1_mini lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DGENERIC_8CH +build_flags = ${common.build_flags_4m1m} -DGENERIC_8CH upload_speed = 460800 -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:gizwits-witty-cloud] platform = ${common.platform} framework = arduino board = esp12e -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DGIZWITS_WITTY_CLOUD -monitor_baud = 115200 +build_flags = ${common.build_flags_4m1m} -DGIZWITS_WITTY_CLOUD +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:gizwits-witty-cloud-ota] platform = ${common.platform} framework = arduino board = esp12e -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DGIZWITS_WITTY_CLOUD +build_flags = ${common.build_flags_4m1m} -DGIZWITS_WITTY_CLOUD upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 @@ -1670,21 +1673,21 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DEUROMATE_WIFI_STECKER_SCHUKO -monitor_baud = 115200 +build_flags = ${common.build_flags_4m1m} -DEUROMATE_WIFI_STECKER_SCHUKO +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:euromate-wifi-stecker-shuko-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DEUROMATE_WIFI_STECKER_SCHUKO +build_flags = ${common.build_flags_4m1m} -DEUROMATE_WIFI_STECKER_SCHUKO upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 @@ -1694,21 +1697,21 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DTONBUX_POWERSTRIP02 -monitor_baud = 115200 +build_flags = ${common.build_flags_4m1m} -DTONBUX_POWERSTRIP02 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:tonbux-powerstrip02-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DTONBUX_POWERSTRIP02 +build_flags = ${common.build_flags_4m1m} -DTONBUX_POWERSTRIP02 upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 @@ -1718,21 +1721,21 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DLINGAN_SWA1 -monitor_baud = 115200 +build_flags = ${common.build_flags_4m1m} -DLINGAN_SWA1 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:lingan-swa1-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DLINGAN_SWA1 +build_flags = ${common.build_flags_4m1m} -DLINGAN_SWA1 upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 @@ -1742,46 +1745,46 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DSTM_RELAY -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DSTM_RELAY +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:stm-relay-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DSTM_RELAY +build_flags = ${common.build_flags_1m0m} -DSTM_RELAY upload_speed = 115200 upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:heygo-hy02] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DHEYGO_HY02 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DHEYGO_HY02 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:heygo-hy02-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DHEYGO_HY02 +build_flags = ${common.build_flags_1m0m} -DHEYGO_HY02 upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 @@ -1791,21 +1794,21 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DMAXCIO_WUS002S -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DMAXCIO_WUS002S +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:maxcio-wus002s-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DMAXCIO_WUS002S +build_flags = ${common.build_flags_1m0m} -DMAXCIO_WUS002S upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 @@ -1815,21 +1818,21 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DYIDIAN_XSSSA05 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DYIDIAN_XSSSA05 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:yidian-xsssa05-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DYIDIAN_XSSSA05 +build_flags = ${common.build_flags_1m0m} -DYIDIAN_XSSSA05 upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 @@ -1839,21 +1842,21 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DTONBUX_XSSSA06 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DTONBUX_XSSSA06 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:tonbux-xsssa06-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DTONBUX_XSSSA06 +build_flags = ${common.build_flags_1m0m} -DTONBUX_XSSSA06 upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 @@ -1863,21 +1866,21 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp12e -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DGREEN_ESP8266RELAY -monitor_baud = 115200 +build_flags = ${common.build_flags_4m1m} -DGREEN_ESP8266RELAY +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:green-esp8266relay-ota] platform = ${common.platform} framework = arduino board = esp12e -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DGREEN_ESP8266RELAY +build_flags = ${common.build_flags_4m1m} -DGREEN_ESP8266RELAY upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 @@ -1887,21 +1890,21 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp12e -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DIKE_ESPIKE -monitor_baud = 115200 +build_flags = ${common.build_flags_4m1m} -DIKE_ESPIKE +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:ike-espike-ota] platform = ${common.platform} framework = arduino board = esp12e -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DIKE_ESPIKE +build_flags = ${common.build_flags_4m1m} -DIKE_ESPIKE upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 @@ -1911,21 +1914,21 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp12e -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DARNIEX_SWIFITCH +build_flags = ${common.build_flags_1m0m} -DARNIEX_SWIFITCH extra_scripts = ${common.extra_scripts} -monitor_baud = 115200 +monitor_speed = 115200 [env:arniex-swifitch-ota] platform = ${common.platform} framework = arduino board = esp12e -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DARNIEX_SWIFITCH +build_flags = ${common.build_flags_1m0m} -DARNIEX_SWIFITCH upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 @@ -1935,71 +1938,71 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DZHILDE_EU44_W -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DZHILDE_EU44_W +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:zhilde-eu44-w-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DZHILDE_EU44_W +build_flags = ${common.build_flags_1m0m} -DZHILDE_EU44_W upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:luani-hvio] platform = ${common.platform} framework = arduino board = esp07 -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DLUANI_HVIO -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DLUANI_HVIO +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:luani-hvio-ota] platform = ${common.platform} framework = arduino board = esp07 -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DZLUANI_HVIO +build_flags = ${common.build_flags_1m0m} -DZLUANI_HVIO upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 -monitor_baud = 115200 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:neo-coolcam-power-plug-wifi] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DNEO_COOLCAM_POWER_PLUG_WIFI -monitor_baud = 115200 +build_flags = ${common.build_flags_4m1m} -DNEO_COOLCAM_POWER_PLUG_WIFI +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:neo-coolcam-power-plug-wifi-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DNEO_COOLCAM_POWER_PLUG_WIFI +build_flags = ${common.build_flags_4m1m} -DNEO_COOLCAM_POWER_PLUG_WIFI upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 @@ -2009,21 +2012,21 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DESTINK_WIFI_POWER_STRIP -monitor_baud = 115200 +build_flags = ${common.build_flags_4m1m} -DESTINK_WIFI_POWER_STRIP +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:estink-wifi-power-strip-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags} -DESTINK_WIFI_POWER_STRIP +build_flags = ${common.build_flags_4m1m} -DESTINK_WIFI_POWER_STRIP upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 @@ -2037,21 +2040,21 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DGENERIC_ESP01S_RELAY_V40 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DGENERIC_ESP01S_RELAY_V40 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:generic-esp01s-relay-40-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DGENERIC_ESP01S_RELAY_V40 +build_flags = ${common.build_flags_1m0m} -DGENERIC_ESP01S_RELAY_V40 upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 @@ -2061,21 +2064,21 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DGENERIC_ESP01S_RGBLED_V10 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DGENERIC_ESP01S_RGBLED_V10 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:generic-esp01s-rgbled-10-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DGENERIC_ESP01S_RGBLED_V10 +build_flags = ${common.build_flags_1m0m} -DGENERIC_ESP01S_RGBLED_V10 upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 @@ -2085,21 +2088,21 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DGENERIC_ESP01S_DHT11_V10 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DGENERIC_ESP01S_DHT11_V10 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:generic-esp01s-dht11-10-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DGENERIC_ESP01S_DHT11_V10 +build_flags = ${common.build_flags_1m0m} -DGENERIC_ESP01S_DHT11_V10 upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 @@ -2109,21 +2112,21 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DGENERIC_ESP01S_DS18B20_V10 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DGENERIC_ESP01S_DS18B20_V10 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:generic-esp01s-ds18b20-10-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DGENERIC_ESP01S_DS18B20_V10 +build_flags = ${common.build_flags_1m0m} -DGENERIC_ESP01S_DS18B20_V10 upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 @@ -2133,21 +2136,21 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DHELTEC_TOUCHRELAY -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DHELTEC_TOUCHRELAY +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:heltec-touch-relay-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DHELTEC_TOUCHRELAY +build_flags = ${common.build_flags_1m0m} -DHELTEC_TOUCHRELAY upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 @@ -2157,21 +2160,21 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp12e -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DALLNET_4DUINO_IOT_WLAN_RELAIS -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DALLNET_4DUINO_IOT_WLAN_RELAIS +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:allnet-4duino-iot-wlan-relais-ota] platform = ${common.platform} framework = arduino board = esp12e -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DALLNET_4DUINO_IOT_WLAN_RELAIS +build_flags = ${common.build_flags_1m0m} -DALLNET_4DUINO_IOT_WLAN_RELAIS upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 @@ -2181,21 +2184,21 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DTONBUX_MOSQUITO_KILLER -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DTONBUX_MOSQUITO_KILLER +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:tonbux-mosquito-killer-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DTONBUX_MOSQUITO_KILLER +build_flags = ${common.build_flags_1m0m} -DTONBUX_MOSQUITO_KILLER upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 @@ -2205,22 +2208,33 @@ extra_scripts = ${common.extra_scripts} platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DPILOTAK_ESP_DIN_V1 -monitor_baud = 115200 +build_flags = ${common.build_flags_1m0m} -DPILOTAK_ESP_DIN_V1 +monitor_speed = 115200 extra_scripts = ${common.extra_scripts} [env:pilotak-esp-din-v1-ota] platform = ${common.platform} framework = arduino board = esp01_1m -board_flash_mode = dout +board_build.flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m} -DPILOTAK_ESP_DIN_V1 +build_flags = ${common.build_flags_1m0m} -DPILOTAK_ESP_DIN_V1 upload_speed = 115200 upload_port = "${env.ESPURNA_IP}" upload_flags = --auth=${env.ESPURNA_AUTH} --port 8266 extra_scripts = ${common.extra_scripts} + +[env:nodemcu-geiger] +platform = ${common.platform} +framework = arduino +board = nodemcu +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_1m0m} -DNODEMCU_BASIC -DNOWSAUTH -DGEIGER_SUPPORT=1 -DEVENTS_SUPPORT=0 -DINFLUXDB_SUPPORT=1 -DALEXA_SUPPORT=0 -DALEXA_ENABLED=0 +upload_speed = 460800 +monitor_speed = 115200 +extra_scripts = ${common.extra_scripts} diff --git a/code/symbols.sh b/code/symbols.sh new file mode 100755 index 00000000..4156a116 --- /dev/null +++ b/code/symbols.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# ------------------------------------------------------------------------------ +# CONFIGURATION +# ------------------------------------------------------------------------------ + +ENVIRONMENT="wemos-d1mini-relayshield" +READELF="xtensa-lx106-elf-readelf" +NUMBER=20 + +# ------------------------------------------------------------------------------ +# END CONFIGURATION - DO NOT EDIT FURTHER +# ------------------------------------------------------------------------------ + +# remove default trace file +rm -rf $FILE + +function help { + echo + echo "Syntax: $0 [-e ] [-n ]" + echo +} + +# get environment from command line +while [[ $# -gt 1 ]]; do + + key="$1" + + case $key in + -e) + ENVIRONMENT="$2" + shift + ;; + -n) + NUMBER="$2" + shift + ;; + esac + + shift # past argument or value + +done + +# check environment folder +if [ $ENVIRONMENT == "" ]; then + echo "No environment defined" + help + exit 1 +fi +ELF=.pioenvs/$ENVIRONMENT/firmware.elf +if [ ! -f $ELF ]; then + echo "Could not find ELF file for the selected environment: $ELF" + exit 2 +fi + +$READELF -s $ELF | head -3 | tail -1 +$READELF -s $ELF | sort -r -k3 -n | head -$NUMBER diff --git a/images/devices/geiger_espurna_configuration.png b/images/devices/geiger_espurna_configuration.png new file mode 100644 index 00000000..1316084d Binary files /dev/null and b/images/devices/geiger_espurna_configuration.png differ diff --git a/images/devices/geiger_espurna_status.png b/images/devices/geiger_espurna_status.png new file mode 100644 index 00000000..26bd8185 Binary files /dev/null and b/images/devices/geiger_espurna_status.png differ diff --git a/images/devices/geiger_grafana_dashboard.png b/images/devices/geiger_grafana_dashboard.png new file mode 100644 index 00000000..d997f7a4 Binary files /dev/null and b/images/devices/geiger_grafana_dashboard.png differ diff --git a/images/devices/geiger_scope_following_pulses.png b/images/devices/geiger_scope_following_pulses.png new file mode 100755 index 00000000..63fd5b5a Binary files /dev/null and b/images/devices/geiger_scope_following_pulses.png differ diff --git a/images/devices/geiger_scope_single_pulse.png b/images/devices/geiger_scope_single_pulse.png new file mode 100755 index 00000000..d5d38782 Binary files /dev/null and b/images/devices/geiger_scope_single_pulse.png differ diff --git a/images/devices/geiger_wiring_diagram.png b/images/devices/geiger_wiring_diagram.png new file mode 100644 index 00000000..730a0845 Binary files /dev/null and b/images/devices/geiger_wiring_diagram.png differ