diff --git a/sonoff/_releasenotes.ino b/sonoff/_releasenotes.ino index 533199886..7b0654a12 100644 --- a/sonoff/_releasenotes.ino +++ b/sonoff/_releasenotes.ino @@ -2,6 +2,7 @@ * Add Eastron SDM630 energy meter (#2735) * Add KNX communication enhancement (#2742) * Add KNX energy data (#2750) + * Add compiled feature information to Status 4 * Fix display selection of un-available GPIO options in Module Configuration webpage (#2718) * Fix timer re-trigger within one minute after restart (#2744) * Fix IRSend not accepting data value of 0 (#2751) diff --git a/sonoff/i18n.h b/sonoff/i18n.h index 365fee826..0890c5738 100644 --- a/sonoff/i18n.h +++ b/sonoff/i18n.h @@ -57,6 +57,7 @@ #define D_JSON_EVERY "Every" #define D_JSON_FAILED "Failed" #define D_JSON_FALLBACKTOPIC "FallbackTopic" +#define D_JSON_FEATURES "Features" #define D_JSON_FLASHMODE "FlashMode" #define D_JSON_FLASHSIZE "FlashSize" #define D_JSON_FREEMEMORY "Free" @@ -391,6 +392,9 @@ #define INCLUDE_FILE(x) QUOTEME(language/x.h) #include INCLUDE_FILE(MY_LANGUAGE) #endif +#ifndef LANGUAGE_LCID + #define LANGUAGE_LCID 2057 // en-GB +#endif // Common enum UnitNames { diff --git a/sonoff/language/bg-BG.h b/sonoff/language/bg-BG.h index d4856eb19..ce9e9b594 100644 --- a/sonoff/language/bg-BG.h +++ b/sonoff/language/bg-BG.h @@ -33,6 +33,7 @@ //#define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English) +#define LANGUAGE_LCID 1026 // HTML (ISO 639-1) Language Code #define D_HTML_LANGUAGE "bg" diff --git a/sonoff/language/cs-CZ.h b/sonoff/language/cs-CZ.h index bdaef9b36..9f939534a 100644 --- a/sonoff/language/cs-CZ.h +++ b/sonoff/language/cs-CZ.h @@ -33,6 +33,7 @@ //#define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English) +#define LANGUAGE_LCID 1029 // HTML (ISO 639-1) Language Code #define D_HTML_LANGUAGE "cs" diff --git a/sonoff/language/de-DE.h b/sonoff/language/de-DE.h index e1b925ac6..7d2e7285d 100644 --- a/sonoff/language/de-DE.h +++ b/sonoff/language/de-DE.h @@ -33,6 +33,7 @@ //#define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English) +#define LANGUAGE_LCID 1031 // HTML (ISO 639-1) Language Code #define D_HTML_LANGUAGE "de" diff --git a/sonoff/language/el-GR.h b/sonoff/language/el-GR.h index fa38c7c97..97eefcd7b 100644 --- a/sonoff/language/el-GR.h +++ b/sonoff/language/el-GR.h @@ -33,6 +33,7 @@ //#define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English) +#define LANGUAGE_LCID 1032 // HTML (ISO 639-1) Language Code #define D_HTML_LANGUAGE "el" diff --git a/sonoff/language/en-GB.h b/sonoff/language/en-GB.h index 3e5b0a0c0..9eb8c9d4a 100644 --- a/sonoff/language/en-GB.h +++ b/sonoff/language/en-GB.h @@ -33,6 +33,7 @@ //#define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English) +#define LANGUAGE_LCID 2057 // HTML (ISO 639-1) Language Code #define D_HTML_LANGUAGE "en" diff --git a/sonoff/language/es-AR.h b/sonoff/language/es-AR.h index d9c37fa0e..aff7b2665 100644 --- a/sonoff/language/es-AR.h +++ b/sonoff/language/es-AR.h @@ -33,6 +33,7 @@ #define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English) +#define LANGUAGE_LCID 11274 // HTML (ISO 639-1) Language Code #define D_HTML_LANGUAGE "es" diff --git a/sonoff/language/fr-FR.h b/sonoff/language/fr-FR.h index 843f4ef51..f37d3cfae 100644 --- a/sonoff/language/fr-FR.h +++ b/sonoff/language/fr-FR.h @@ -33,6 +33,7 @@ #define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English) +#define LANGUAGE_LCID 1036 // HTML (ISO 639-1) Language Code #define D_HTML_LANGUAGE "fr" diff --git a/sonoff/language/hu-HU.h b/sonoff/language/hu-HU.h index a5f373146..4ebeffbf6 100644 --- a/sonoff/language/hu-HU.h +++ b/sonoff/language/hu-HU.h @@ -33,6 +33,7 @@ //#define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English) +#define LANGUAGE_LCID 1038 // HTML (ISO 639-1) Language Code #define D_HTML_LANGUAGE "hu" diff --git a/sonoff/language/it-IT.h b/sonoff/language/it-IT.h index ceb1faa16..475db6b16 100644 --- a/sonoff/language/it-IT.h +++ b/sonoff/language/it-IT.h @@ -33,6 +33,7 @@ #define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English) +#define LANGUAGE_LCID 1040 // HTML (ISO 639-1) Language Code #define D_HTML_LANGUAGE "it" diff --git a/sonoff/language/nl-NL.h b/sonoff/language/nl-NL.h index df970798f..262daee7b 100644 --- a/sonoff/language/nl-NL.h +++ b/sonoff/language/nl-NL.h @@ -33,6 +33,7 @@ //#define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English) +#define LANGUAGE_LCID 1043 // HTML (ISO 639-1) Language Code #define D_HTML_LANGUAGE "nl" diff --git a/sonoff/language/pl-PL.h b/sonoff/language/pl-PL.h index 2b96e5195..683d43cb3 100644 --- a/sonoff/language/pl-PL.h +++ b/sonoff/language/pl-PL.h @@ -33,6 +33,7 @@ //#define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English) +#define LANGUAGE_LCID 1045 // HTML (ISO 639-1) Language Code #define D_HTML_LANGUAGE "pl" diff --git a/sonoff/language/pt-BR.h b/sonoff/language/pt-BR.h index 1740abbdd..02bdec2e4 100644 --- a/sonoff/language/pt-BR.h +++ b/sonoff/language/pt-BR.h @@ -33,6 +33,7 @@ //#define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English) +#define LANGUAGE_LCID 1046 // HTML (ISO 639-1) Language Code #define D_HTML_LANGUAGE "pt" diff --git a/sonoff/language/pt-PT.h b/sonoff/language/pt-PT.h index c8d8944af..4cf9e0da3 100644 --- a/sonoff/language/pt-PT.h +++ b/sonoff/language/pt-PT.h @@ -33,6 +33,7 @@ //#define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English) +#define LANGUAGE_LCID 2070 // HTML (ISO 639-1) Language Code #define D_HTML_LANGUAGE "pt" diff --git a/sonoff/language/ru-RU.h b/sonoff/language/ru-RU.h index bd1440d28..3336484e9 100644 --- a/sonoff/language/ru-RU.h +++ b/sonoff/language/ru-RU.h @@ -33,6 +33,7 @@ //#define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English) +#define LANGUAGE_LCID 1049 // HTML (ISO 639-1) Language Code #define D_HTML_LANGUAGE "ru" diff --git a/sonoff/language/zh-CN.h b/sonoff/language/zh-CN.h index 113c470b9..1c3ee0bb7 100644 --- a/sonoff/language/zh-CN.h +++ b/sonoff/language/zh-CN.h @@ -33,6 +33,7 @@ //#define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English) +#define LANGUAGE_LCID 2052 // HTML (ISO 639-1) Language Code #define D_HTML_LANGUAGE "zh" diff --git a/sonoff/language/zh-TW.h b/sonoff/language/zh-TW.h index 14e9cad00..e8505010f 100644 --- a/sonoff/language/zh-TW.h +++ b/sonoff/language/zh-TW.h @@ -33,6 +33,7 @@ //#define LANGUAGE_MODULE_NAME // Enable to display "Module Generic" (ie Spanish), Disable to display "Generic Module" (ie English) +#define LANGUAGE_LCID 1028 // HTML (ISO 639-1) Language Code #define D_HTML_LANGUAGE "zh" diff --git a/sonoff/sonoff.h b/sonoff/sonoff.h index a4077c8f1..25bc8ced1 100644 --- a/sonoff/sonoff.h +++ b/sonoff/sonoff.h @@ -112,6 +112,9 @@ typedef unsigned long power_t; // Power (Relay) type #define max(a,b) ((a)>(b)?(a):(b)) */ +#define STR_HELPER(x) #x +#define STR(x) STR_HELPER(x) + //enum ws2812NeopixelbusFeature { NEO_RGB, NEO_GRB, NEO_BRG, NEO_RBG, NEO_3LED, NEO_RGBW, NEO_GRBW }; // Doesn't work #define NEO_RGB 0 // Neopixel RGB leds #define NEO_GRB 1 // Neopixel GRB leds diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index d8e6eb2f5..a12a710b3 100644 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -97,6 +97,10 @@ const char kTasmotaCommands[] PROGMEM = D_CMND_I2CSCAN "|" D_CMND_SERIALSEND "|" D_CMND_BAUDRATE "|" D_CMND_SERIALDELIMITER; // Global variables +unsigned long feature_drv1; // Compiled driver feature map +unsigned long feature_drv2; // Compiled driver feature map +unsigned long feature_sns1; // Compiled sensor feature map +unsigned long feature_sns2; // Compiled sensor feature map int baudrate = APP_BAUDRATE; // Serial interface baud rate SerialConfig serial_config = SERIAL_8N1; // Serial interface configuration 8 data bits, No parity, 1 stop bit byte serial_in_byte; // Received byte @@ -176,7 +180,6 @@ uint8_t spi_flg = 0; // SPI configured uint8_t light_type = 0; // Light types bool pwm_present = false; // Any PWM channel configured with SetOption15 0 boolean mdns_begun = false; -unsigned long features = 0UL; uint8_t ntp_force_sync = 0; // Force NTP sync char my_version[33]; // Composed version string @@ -1333,8 +1336,8 @@ void PublishStatus(uint8_t payload) } if ((0 == payload) || (4 == payload)) { - snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_STATUS D_STATUS4_MEMORY "\":{\"" D_JSON_PROGRAMSIZE "\":%d,\"" D_JSON_FREEMEMORY "\":%d,\"" D_JSON_HEAPSIZE "\":%d,\"" D_JSON_PROGRAMFLASHSIZE "\":%d,\"" D_JSON_FLASHSIZE "\":%d,\"" D_JSON_FLASHMODE "\":%d}}"), - ESP.getSketchSize()/1024, ESP.getFreeSketchSpace()/1024, ESP.getFreeHeap()/1024, ESP.getFlashChipSize()/1024, ESP.getFlashChipRealSize()/1024, ESP.getFlashChipMode()); + snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_STATUS D_STATUS4_MEMORY "\":{\"" D_JSON_PROGRAMSIZE "\":%d,\"" D_JSON_FREEMEMORY "\":%d,\"" D_JSON_HEAPSIZE "\":%d,\"" D_JSON_PROGRAMFLASHSIZE "\":%d,\"" D_JSON_FLASHSIZE "\":%d,\"" D_JSON_FLASHMODE "\":%d,\"" D_JSON_FEATURES "\":[\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\"]}}"), + ESP.getSketchSize()/1024, ESP.getFreeSketchSpace()/1024, ESP.getFreeHeap()/1024, ESP.getFlashChipSize()/1024, ESP.getFlashChipRealSize()/1024, ESP.getFlashChipMode(), LANGUAGE_LCID, feature_drv1, feature_drv2, feature_sns1, feature_sns2); MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "4")); } @@ -2372,6 +2375,8 @@ void setup() OsWatchInit(); + GetFeatures(); + baudrate = Settings.baudrate * 1200; seriallog_level = Settings.seriallog_level; seriallog_timer = SERIALLOG_TIMER; diff --git a/sonoff/support.ino b/sonoff/support.ino index a12cbb6a1..454d4bdf0 100644 --- a/sonoff/support.ino +++ b/sonoff/support.ino @@ -516,6 +516,235 @@ uint32_t GetHash(const char *buffer, size_t size) return hash; } +/*********************************************************************************************\ + * Fill feature list +\*********************************************************************************************/ + +void GetFeatures() +{ + feature_drv1 = 0x00000000; // xdrv_00_mqtt.ino, xdrv_01_light.ino, xdrv_04_snfbridge.ino + +// feature_drv1 |= 0x00000001; +// feature_drv1 |= 0x00000002; + +#ifdef USE_I2C + feature_drv1 |= 0x00000004; // sonoff.ino +#endif +#ifdef USE_SPI + feature_drv1 |= 0x00000008; // sonoff.ino +#endif +#ifdef USE_DISCOVERY + feature_drv1 |= 0x00000010; // sonoff.ino +#endif +#ifdef USE_ARDUINO_OTA + feature_drv1 |= 0x00000020; // sonoff.ino +#endif +#ifdef USE_MQTT_TLS + feature_drv1 |= 0x00000040; // sonoff.ino +#endif +#ifdef USE_WEBSERVER + feature_drv1 |= 0x00000080; // webserver.ino +#endif +#ifdef WEBSERVER_ADVERTISE + feature_drv1 |= 0x00000100; // webserver.ino +#endif +#ifdef USE_EMULATION + feature_drv1 |= 0x00000200; // xplg_wemohue.ino +#endif +#if (MQTT_LIBRARY_TYPE == MQTT_PUBSUBCLIENT) + feature_drv1 |= 0x00000400; // xdrv_00_mqtt.ino +#endif +#if (MQTT_LIBRARY_TYPE == MQTT_TASMOTAMQTT) + feature_drv1 |= 0x00000800; // xdrv_00_mqtt.ino +#endif +#if (MQTT_LIBRARY_TYPE == MQTT_ESPMQTTARDUINO) + feature_drv1 |= 0x00001000; // xdrv_00_mqtt.ino +#endif +#ifdef MQTT_HOST_DISCOVERY + feature_drv1 |= 0x00002000; // xdrv_00_mqtt.ino +#endif +#ifdef USE_ARILUX_RF + feature_drv1 |= 0x00004000; // xdrv_01_light.ino +#endif +#ifdef USE_WS2812 + feature_drv1 |= 0x00008000; // xdrv_01_light.ino +#endif +#ifdef USE_WS2812_DMA + feature_drv1 |= 0x00010000; // xdrv_01_light.ino +#endif +#ifdef USE_IR_REMOTE + feature_drv1 |= 0x00020000; // xdrv_02_irremote.ino +#endif +#ifdef USE_IR_HVAC + feature_drv1 |= 0x00040000; // xdrv_02_irremote.ino +#endif +#ifdef USE_IR_RECEIVE + feature_drv1 |= 0x00080000; // xdrv_02_irremote.ino +#endif +#ifdef USE_DOMOTICZ + feature_drv1 |= 0x00100000; // xdrv_05_domoticz.ino +#endif +#ifdef USE_DISPLAY + feature_drv1 |= 0x00200000; // xdrv_06_display.ino +#endif +#ifdef USE_HOME_ASSISTANT + feature_drv1 |= 0x00400000; // xdrv_07_home_assistant.ino +#endif +#ifdef USE_SERIAL_BRIDGE + feature_drv1 |= 0x00800000; // xdrv_08_serial_bridge.ino +#endif +#ifdef USE_TIMERS + feature_drv1 |= 0x01000000; // xdrv_09_timers.ino +#endif +#ifdef USE_SUNRISE + feature_drv1 |= 0x02000000; // xdrv_09_timers.ino +#endif +#ifdef USE_TIMERS_WEB + feature_drv1 |= 0x04000000; // xdrv_09_timers.ino +#endif +#ifdef USE_RULES + feature_drv1 |= 0x08000000; // xdrv_10_rules.ino +#endif +#ifdef USE_KNX + feature_drv1 |= 0x10000000; // xdrv_11_knx.ino +#endif + +/*********************************************************************************************/ + + feature_drv2 = 0x00000000; + +#ifdef USE_CONFIG_OVERRIDE + feature_drv2 |= 0x00000001; // user_config(_override).h +#endif +#ifdef BE_MINIMAL + feature_drv2 |= 0x00000002; // user_config(_override).h +#endif +#ifdef USE_ALL_SENSORS + feature_drv2 |= 0x00000004; // user_config(_override).h +#endif +#ifdef USE_CLASSIC + feature_drv2 |= 0x00000008; // user_config(_override).h +#endif +#ifdef USE_KNX_NO_EMULATION + feature_drv2 |= 0x00000010; // user_config(_override).h +#endif + + +#ifdef VTABLES_IN_FLASH + feature_drv2 |= 0x04000000; // platformio.ini +#endif +#ifdef PIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH + feature_drv2 |= 0x08000000; // platformio.ini +#endif +#ifdef PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY + feature_drv2 |= 0x10000000; // platformio.ini +#endif +#ifdef PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH + feature_drv2 |= 0x20000000; // platformio.ini +#endif +#ifdef DEBUG_THEO + feature_drv2 |= 0x40000000; // xdrv_99_debug.ino +#endif +#ifdef USE_DEBUG_DRIVER + feature_drv2 |= 0x80000000; // xdrv_99_debug.ino +#endif + +/*********************************************************************************************/ + + feature_sns1 = 0x00000000; // xsns_01_counter.ino, xsns_04_snfsc.ino + +// feature_sns1 |= 0x00000001; + +#ifndef USE_ADC_VCC + feature_sns1 |= 0x00000002; // support.ino (ADC) +#endif +#ifdef USE_ENERGY_SENSOR + feature_sns1 |= 0x00000004; // xdrv_03_energy.ino +#endif +#ifdef USE_PZEM004T + feature_sns1 |= 0x00000008; // xdrv_03_energy.ino +#endif +#ifdef USE_DS18B20 + feature_sns1 |= 0x00000010; // xsns_05_ds18b20.ino +#endif +#ifdef USE_DS18x20_LEGACY + feature_sns1 |= 0x00000020; // xsns_05_ds18x20_legacy.ino +#endif +#ifdef USE_DS18x20 + feature_sns1 |= 0x00000040; // xsns_05_ds18x20.ino +#endif +#ifdef USE_DHT + feature_sns1 |= 0x00000080; // xsns_06_dht.ino +#endif +#ifdef USE_SHT + feature_sns1 |= 0x00000100; // xsns_07_sht1x.ino +#endif +#ifdef USE_HTU + feature_sns1 |= 0x00000200; // xsns_08_htu21.ino +#endif +#ifdef USE_BMP + feature_sns1 |= 0x00000400; // xsns_09_bmp.ino +#endif +#ifdef USE_BME680 + feature_sns1 |= 0x00000800; // xsns_09_bmp.ino - BME680 +#endif +#ifdef USE_BH1750 + feature_sns1 |= 0x00001000; // xsns_10_bh1750.ino +#endif +#ifdef USE_VEML6070 + feature_sns1 |= 0x00002000; // xsns_11_veml6070.ino +#endif +#ifdef USE_ADS1115_I2CDEV + feature_sns1 |= 0x00004000; // xsns_12_ads1115_i2cdev.ino +#endif +#ifdef USE_ADS1115 + feature_sns1 |= 0x00008000; // xsns_12_ads1115.ino +#endif +#ifdef USE_INA219 + feature_sns1 |= 0x00010000; // xsns_13_ina219.ino +#endif +#ifdef USE_SHT3X + feature_sns1 |= 0x00020000; // xsns_14_sht3x.ino +#endif +#ifdef USE_MHZ19 + feature_sns1 |= 0x00040000; // xsns_15_mhz19.ino +#endif +#ifdef USE_TSL2561 + feature_sns1 |= 0x00080000; // xsns_16_tsl2561.ino +#endif +#ifdef USE_SENSEAIR + feature_sns1 |= 0x00100000; // xsns_17_senseair.ino +#endif +#ifdef USE_PMS5003 + feature_sns1 |= 0x00200000; // xsns_18_pms5003.ino +#endif +#ifdef USE_MGS + feature_sns1 |= 0x00400000; // xsns_19_mgs.ino +#endif +#ifdef USE_NOVA_SDS + feature_sns1 |= 0x00800000; // xsns_20_novasds.ino +#endif +#ifdef USE_SGP30 + feature_sns1 |= 0x01000000; // xsns_21_sgp30.ino +#endif +#ifdef USE_SR04 + feature_sns1 |= 0x02000000; // xsns_22_sr04.ino +#endif +#ifdef USE_SDM120 + feature_sns1 |= 0x04000000; // xsns_23_sdm120.ino +#endif +#ifdef USE_SI1145 + feature_sns1 |= 0x08000000; // xsns_24_si1145.ino +#endif +#ifdef USE_SDM630 + feature_sns1 |= 0x10000000; // xsns_25_sdm630.ino +#endif + +/*********************************************************************************************/ + + feature_sns2 = 0x00000000; +} + /*********************************************************************************************\ * Wifi \*********************************************************************************************/ diff --git a/sonoff/webserver.ino b/sonoff/webserver.ino index e9f9eded5..0cb4cce27 100644 --- a/sonoff/webserver.ino +++ b/sonoff/webserver.ino @@ -25,9 +25,6 @@ * Based on source by AlexT (https://github.com/tzapu) \*********************************************************************************************/ -#define STR_HELPER(x) #x -#define STR(x) STR_HELPER(x) - const char HTTP_HEAD[] PROGMEM = "" ""