diff --git a/README.md b/README.md index 6c4133ddc..9fef62adb 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ If you like **Sonoff-Tasmota**, give it a star, or fork it and contribute! ### Development [![Build Status](https://img.shields.io/travis/arendst/Sonoff-Tasmota.svg)](https://travis-ci.org/arendst/Sonoff-Tasmota) -Current version is **6.0.0b** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information. +Current version is **6.0.0c** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information. ### Disclaimer :warning: **DANGER OF ELECTROCUTION** :warning: @@ -123,6 +123,7 @@ Different firmware images are released based on Features and Sensors selection g | USE_SHT | x | x | - | x | x | | USE_SHT3X | x | x | - | x | x | | USE_HTU | x | x | - | x | x | +| USE_LM75AD | x | - | - | x | x | | USE_BMP | x | x | - | x | x | | USE_BME680 | - | - | - | - | x | | USE_SGP30 | x | - | - | x | x | @@ -133,6 +134,7 @@ Different firmware images are released based on Features and Sensors selection g | USE_ADS1115 | - | - | - | - | x | | USE_ADS1115_I2CDEV | - | - | - | - | - | | USE_INA219 | - | - | - | - | x | +| USE_APDS9960 | - | - | - | - | - | | USE_MGS | - | - | - | - | x | | USE_SPI | - | - | - | - | - | | USE_MHZ19 | x | x | - | x | x | @@ -141,7 +143,8 @@ Different firmware images are released based on Features and Sensors selection g | USE_NOVA_SDS | x | - | - | x | x | | USE_PZEM004T | x | x | - | x | x | | USE_SERIAL_BRIDGE | x | - | - | x | x | -| USE_SDM120 | - | - | - | - | x | +| USE_SDM120 | x | - | - | - | x | +| USE_SDM630 | x | - | - | - | x | | USE_IR_REMOTE | x | x | - | x | x | | USE_IR_HVAC | - | - | - | - | x | | USE_IR_RECEIVE | x | - | - | x | x | @@ -149,6 +152,8 @@ Different firmware images are released based on Features and Sensors selection g | USE_WS2812_DMA | - | - | - | - | - | | USE_ARILUX_RF | x | x | - | x | x | | USE_SR04 | x | - | - | x | x | +| USE_TM1638 | - | - | - | - | - | +| USE_RF_FLASH | x | - | - | x | x | #### Typical File Size diff --git a/sonoff/_releasenotes.ino b/sonoff/_releasenotes.ino index 580e5a0be..dae998c73 100644 --- a/sonoff/_releasenotes.ino +++ b/sonoff/_releasenotes.ino @@ -1,4 +1,7 @@ -/* 6.0.0b +/* 6.0.0c + * Add support for bitflags SetOption50 .. SetOption81 (#3118) + * + * 6.0.0b * Add support for BlitzWolf BW-SHP2 (and Homecube, Gosund SP1) Energy Monitoring Smart Socket (#2223) * Add support for Sonoff iFan02 as module 44 introducing command FanSpeed 0..3 (#2839) * Add support for Sonoff S26 Smart Socket (#2808) diff --git a/sonoff/settings.h b/sonoff/settings.h index 1c702356f..c4de3d659 100644 --- a/sonoff/settings.h +++ b/sonoff/settings.h @@ -20,21 +20,21 @@ #ifndef _SETTINGS_H_ #define _SETTINGS_H_ -#define PARAM8_SIZE 18 // Number of param bytes +#define PARAM8_SIZE 18 // Number of param bytes (SetOption) typedef union { // Restricted by MISRA-C Rule 18.4 but so usefull... uint32_t data; // Allow bit manipulation using SetOption - struct { + struct { // SetOption0 .. SetOption31 uint32_t save_state : 1; // bit 0 uint32_t button_restrict : 1; // bit 1 uint32_t value_units : 1; // bit 2 uint32_t mqtt_enabled : 1; // bit 3 uint32_t mqtt_response : 1; // bit 4 - uint32_t mqtt_power_retain : 1; - uint32_t mqtt_button_retain : 1; - uint32_t mqtt_switch_retain : 1; + uint32_t mqtt_power_retain : 1; // CMND_POWERRETAIN + uint32_t mqtt_button_retain : 1; // CMND_BUTTONRETAIN + uint32_t mqtt_switch_retain : 1; // CMND_SWITCHRETAIN uint32_t temperature_conversion : 1; // bit 8 - uint32_t mqtt_sensor_retain : 1; + uint32_t mqtt_sensor_retain : 1; // CMND_SENSORRETAIN uint32_t mqtt_offline : 1; // bit 10 uint32_t button_swap : 1; // bit 11 (v5.1.6) uint32_t stop_flash_rotate : 1; // bit 12 (v5.2.0) @@ -60,8 +60,46 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu }; } SysBitfield; -typedef union { +typedef union { // Restricted by MISRA-C Rule 18.4 but so usefull... uint32_t data; // Allow bit manipulation using SetOption + struct { // SetOption50 .. SetOption81 + uint32_t spare00 : 1; + uint32_t spare01 : 1; + uint32_t spare02 : 1; + uint32_t spare03 : 1; + uint32_t spare04 : 1; + uint32_t spare05 : 1; + uint32_t spare06 : 1; + uint32_t spare07 : 1; + uint32_t spare08 : 1; + uint32_t spare09 : 1; + uint32_t spare10 : 1; + uint32_t spare11 : 1; + uint32_t spare12 : 1; + uint32_t spare13 : 1; + uint32_t spare14 : 1; + uint32_t spare15 : 1; + uint32_t spare16 : 1; + uint32_t spare17 : 1; + uint32_t spare18 : 1; + uint32_t spare19 : 1; + uint32_t spare20 : 1; + uint32_t spare21 : 1; + uint32_t spare22 : 1; + uint32_t spare23 : 1; + uint32_t spare24 : 1; + uint32_t spare25 : 1; + uint32_t spare26 : 1; + uint32_t spare27 : 1; + uint32_t spare28 : 1; + uint32_t spare29 : 1; + uint32_t spare30 : 1; + uint32_t spare31 : 1; + }; +} SysBitfield3; + +typedef union { + uint32_t data; // Allow bit manipulation struct { uint32_t spare00 : 1; uint32_t spare01 : 1; @@ -192,7 +230,7 @@ struct SYSCFG { byte free_2fa[1]; // 2FA uint8_t ledstate; // 2FB - uint8_t param[PARAM8_SIZE]; // 2FC + uint8_t param[PARAM8_SIZE]; // 2FC SetOption32 .. SetOption49 int16_t toffset[2]; // 30E byte free_312[1]; // 312 @@ -229,9 +267,7 @@ struct SYSCFG { uint16_t blinktime; // 39A uint16_t blinkcount; // 39C uint16_t light_rotation; // 39E - - byte free_3A0[4]; // 3A0 - + SysBitfield3 flag3; // 3A0 uint8_t switchmode[MAX_SWITCHES]; // 3A4 (6.0.0b - moved from 0x4CA) char friendlyname[MAX_FRIENDLYNAMES][33]; // 3AC char switch_topic[33]; // 430 diff --git a/sonoff/settings.ino b/sonoff/settings.ino index f472e2685..d39c4e7a3 100644 --- a/sonoff/settings.ino +++ b/sonoff/settings.ino @@ -777,6 +777,11 @@ void SettingsDelta() } } } + if (Settings.version < 0x06000003) { + Settings.flag.rules_enabled = 0; + Settings.flag.rules_once = 0; + Settings.flag3.data = 0; + } Settings.version = VERSION; SettingsSave(1); diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 3fac2d502..3d51f2490 100644 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -25,7 +25,7 @@ - Select IDE Tools - Flash Size: "1M (no SPIFFS)" ====================================================*/ -#define VERSION 0x06000002 // 6.0.0b +#define VERSION 0x06000003 // 6.0.0c // Location specific includes #include // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0) @@ -402,7 +402,6 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len) char stemp1[TOPSZ]; char *p; char *type = NULL; - byte ptype = 0; byte jsflg = 0; byte lines = 1; uint8_t grpflg = 0; @@ -602,75 +601,76 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len) XsnsCall(FUNC_COMMAND); // if (!XsnsCall(FUNC_COMMAND)) type = NULL; } - else if ((CMND_SETOPTION == command_code) && (index <= P_MAX_PARAM8 + 31)) { - if (index <= 31) { - ptype = 0; // SetOption0 .. 31 - } else { - ptype = 1; // SetOption32 .. - index = index -32; + else if ((CMND_SETOPTION == command_code) && (index < 82)) { + byte ptype; + byte pindex; + if (index <= 31) { // SetOption0 .. 31 = Settings.flag + ptype = 0; + pindex = index; // 0 .. 31 + } + else if (index <= 49) { // SetOption32 .. 49 = Settings.param + ptype = 2; + pindex = index -32; // 0 .. 17 (= PARAM8_SIZE -1) + } + else { // SetOption50 .. 81 = Settings.flag3 + ptype = 1; + pindex = index -50; // 0 .. 31 } if (payload >= 0) { - if (0 == ptype) { // SetOption0 .. 31 + if (0 == ptype) { // SetOption0 .. 31 if (payload <= 1) { - switch (index) { - case 3: // mqtt - case 15: // pwm_control + switch (pindex) { + case 5: // mqtt_power_retain (CMND_POWERRETAIN) + case 6: // mqtt_button_retain (CMND_BUTTONRETAIN) + case 7: // mqtt_switch_retain (CMND_SWITCHRETAIN) + case 9: // mqtt_sensor_retain (CMND_SENSORRETAIN) + case 22: // mqtt_serial (SerialSend and SerialLog) + ptype = 99; // Command Error + break; // Ignore command SetOption + case 3: // mqtt + case 15: // pwm_control restart_flag = 2; - case 0: // save_state - case 1: // button_restrict - case 2: // value_units - case 4: // mqtt_response - case 8: // temperature_conversion - case 10: // mqtt_offline - case 11: // button_swap - case 12: // stop_flash_rotate - case 13: // button_single - case 14: // interlock - case 16: // ws_clock_reverse - case 17: // decimal_text - case 18: // light_signal - case 19: // hass_discovery - case 20: // not_power_linked - case 21: // no_power_on_check -// case 22: // mqtt_serial - use commands SerialSend and SerialLog -// case 23: // rules_enabled - use command Rule -// case 24: // rules_once -// case 25: // knx_enabled - case 26: // device_index_enable -// case 27: // knx_enable_enhancement - case 28: // rf_receive_decimal - case 29: // ir_receive_decimal - case 30: // hass_light - bitWrite(Settings.flag.data, index, payload); + default: + bitWrite(Settings.flag.data, pindex, payload); } - if (12 == index) { // stop_flash_rotate + if (12 == pindex) { // stop_flash_rotate stop_flash_rotate = payload; SettingsSave(2); } #ifdef USE_HOME_ASSISTANT - if ((19 == index) || (30 == index)) { // hass_discovery or hass_light - HAssDiscovery(1); + if ((19 == pindex) || (30 == pindex)) { + HAssDiscovery(1); // hass_discovery or hass_light } #endif // USE_HOME_ASSISTANT } } - else { // SetOption32 .. - switch (index) { + else if (1 == ptype) { // SetOption50 .. 81 + if (payload <= 1) { + bitWrite(Settings.flag3.data, pindex, payload); + } + } + else { // SetOption32 .. 49 +/* + switch (pindex) { case P_HOLD_TIME: - if ((payload >= 1) && (payload <= 250)) { - Settings.param[P_HOLD_TIME] = payload; - } - break; case P_MAX_POWER_RETRY: if ((payload >= 1) && (payload <= 250)) { - Settings.param[P_MAX_POWER_RETRY] = payload; + Settings.param[pindex] = payload; } break; + default: + ptype = 99; // Command Error + } +*/ + if ((payload >= 1) && (payload <= 250)) { + Settings.param[pindex] = payload; } } } - if (ptype) snprintf_P(stemp1, sizeof(stemp1), PSTR("%d"), Settings.param[index]); - snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_SVALUE, command, (ptype) ? index +32 : index, (ptype) ? stemp1 : GetStateText(bitRead(Settings.flag.data, index))); + if (ptype < 99) { + if (2 == ptype) snprintf_P(stemp1, sizeof(stemp1), PSTR("%d"), Settings.param[pindex]); + snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_SVALUE, command, index, (2 == ptype) ? stemp1 : (1 == ptype) ? GetStateText(bitRead(Settings.flag3.data, pindex)) : GetStateText(bitRead(Settings.flag.data, pindex))); + } } else if (CMND_TEMPERATURE_RESOLUTION == command_code) { if ((payload >= 0) && (payload <= 3)) {