From 5f4e38023d1b6ab1516082d5844b033546e5a513 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 3 Nov 2019 12:33:36 +0100 Subject: [PATCH] Add SetOption comments to code --- tasmota/settings.h | 10 ++--- tasmota/support.ino | 14 +++---- tasmota/support_command.ino | 28 +++++++------ tasmota/support_wifi.ino | 6 ++- tasmota/tasmota.ino | 63 ++++++++++++++++-------------- tasmota/xdrv_01_webserver.ino | 20 +++++----- tasmota/xdrv_02_mqtt.ino | 62 ++++++++++++++--------------- tasmota/xdrv_03_energy.ino | 4 +- tasmota/xdrv_04_light.ino | 36 ++++++++--------- tasmota/xdrv_05_irremote.ino | 2 +- tasmota/xdrv_05_irremote_full.ino | 2 +- tasmota/xdrv_06_snfbridge.ino | 4 +- tasmota/xdrv_07_domoticz.ino | 6 +-- tasmota/xdrv_10_scripter.ino | 6 +-- tasmota/xdrv_12_home_assistant.ino | 32 +++++++-------- tasmota/xdrv_15_pca9685.ino | 2 +- tasmota/xdrv_16_tuyamcu.ino | 2 +- tasmota/xdrv_17_rcswitch.ino | 2 +- tasmota/xdrv_19_ps16dz_dimmer.ino | 2 +- tasmota/xdrv_22_sonoff_ifan.ino | 2 +- tasmota/xdrv_27_shutter.ino | 6 +-- tasmota/xdrv_30_exs_dimmer.ino | 2 +- tasmota/xdsp_08_ILI9488.ino | 2 +- tasmota/xdsp_10_RA8876.ino | 2 +- tasmota/xlgt_01_ws2812.ino | 6 ++- tasmota/xlgt_05_sonoff_l1.ino | 2 +- tasmota/xsns_27_apds9960.ino | 2 +- tasmota/xsns_29_mcp230xx.ino | 12 +++--- tasmota/xsns_34_hx711.ino | 2 +- tasmota/xsns_36_mgc3130.ino | 2 +- tasmota/xsns_39_max31855.ino | 4 +- tasmota/xsns_40_pn532.ino | 2 +- tasmota/xsns_44_sps30.ino | 2 +- tasmota/xsns_50_paj7620.ino | 2 +- tasmota/xsns_51_rdm6300.ino | 2 +- tasmota/xsns_52_ibeacon.ino | 2 +- tasmota/xsns_53_sml.ino | 2 +- 37 files changed, 188 insertions(+), 171 deletions(-) diff --git a/tasmota/settings.h b/tasmota/settings.h index 1eed62771..43909e6ee 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -28,7 +28,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t save_state : 1; // bit 0 - SetOption0 - Save power state and use after restart uint32_t button_restrict : 1; // bit 1 - SetOption1 - Control button multipress uint32_t ex_value_units : 1; // bit 2 - SetOption2 - Add units to JSON status messages - removed 6.6.0.21 - uint32_t mqtt_enabled : 1; // bit 3 - SetOption3 - Control MQTT + uint32_t mqtt_enabled : 1; // bit 3 - SetOption3 - Enable MQTT uint32_t mqtt_response : 1; // bit 4 - SetOption4 - Switch between MQTT RESULT or COMMAND uint32_t mqtt_power_retain : 1; // bit 5 - CMND_POWERRETAIN uint32_t mqtt_button_retain : 1; // bit 6 - CMND_BUTTONRETAIN @@ -39,10 +39,10 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t button_swap : 1; // bit 11 (v5.1.6) - SetOption11 - Swap button single and double press functionality uint32_t stop_flash_rotate : 1; // bit 12 (v5.2.0) - SetOption12 - Switch between dynamic or fixed slot flash save location uint32_t button_single : 1; // bit 13 (v5.4.0) - SetOption13 - Support only single press to speed up button press recognition - uint32_t interlock : 1; // bit 14 (v5.6.0) - CMND_INTERLOCK + uint32_t interlock : 1; // bit 14 (v5.6.0) - CMND_INTERLOCK - Enable/disable interlock uint32_t pwm_control : 1; // bit 15 (v5.8.1) - SetOption15 - Switch between commands PWM or COLOR/DIMMER/CT/CHANNEL uint32_t ws_clock_reverse : 1; // bit 16 (v5.8.1) - SetOption16 - Switch between clockwise or counter-clockwise - uint32_t decimal_text : 1; // bit 17 (v5.8.1) - SetOption17 - Switch between decimal or hexadecimal output + uint32_t decimal_text : 1; // bit 17 (v5.8.1) - SetOption17 - Switch between decimal or hexadecimal output (0 = hexadecimal, 1 = decimal) uint32_t light_signal : 1; // bit 18 (v5.10.0c) - SetOption18 - Pair light signal with CO2 sensor uint32_t hass_discovery : 1; // bit 19 (v5.11.1a) - SetOption19 - Control Home Assistantautomatic discovery (See SetOption59) uint32_t not_power_linked : 1; // bit 20 (v5.11.1f) - SetOption20 - Control power in relation to Dimmer/Color/Ct changes @@ -53,8 +53,8 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t knx_enabled : 1; // bit 25 (v5.12.0l) - CMND_KNX_ENABLED uint32_t device_index_enable : 1; // bit 26 (v5.13.1a) - SetOption26 - Switch between POWER or POWER1 uint32_t knx_enable_enhancement : 1; // bit 27 (v5.14.0a) - CMND_KNX_ENHANCED - uint32_t rf_receive_decimal : 1; // bit 28 (v6.0.0a) - SetOption28 - RF receive data format - uint32_t ir_receive_decimal : 1; // bit 29 (v6.0.0a) - SetOption29 - IR receive data format + uint32_t rf_receive_decimal : 1; // bit 28 (v6.0.0a) - SetOption28 - RF receive data format (0 = hexadecimal, 1 = decimal) + uint32_t ir_receive_decimal : 1; // bit 29 (v6.0.0a) - SetOption29 - IR receive data format (0 = hexadecimal, 1 = decimal) uint32_t hass_light : 1; // bit 30 (v6.0.0b) - SetOption30 - Enforce HAss autodiscovery as light uint32_t global_state : 1; // bit 31 (v6.1.0) - SetOption31 - Control link led blinking }; diff --git a/tasmota/support.ino b/tasmota/support.ino index 2358d7f34..404acd3bc 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -619,8 +619,8 @@ float ConvertTemp(float c) global_update = uptime; global_temperature = c; - if (!isnan(c) && Settings.flag.temperature_conversion) { - result = c * 1.8 + 32; // Fahrenheit + if (!isnan(c) && Settings.flag.temperature_conversion) { // SetOption8 - Switch between Celsius or Fahrenheit + result = c * 1.8 + 32; // Fahrenheit } return result; } @@ -629,15 +629,15 @@ float ConvertTempToCelsius(float c) { float result = c; - if (!isnan(c) && Settings.flag.temperature_conversion) { - result = (c - 32) / 1.8; // Celsius + if (!isnan(c) && Settings.flag.temperature_conversion) { // SetOption8 - Switch between Celsius or Fahrenheit + result = (c - 32) / 1.8; // Celsius } return result; } char TempUnit(void) { - return (Settings.flag.temperature_conversion) ? 'F' : 'C'; + return (Settings.flag.temperature_conversion) ? 'F' : 'C'; // SetOption8 - Switch between Celsius or Fahrenheit } float ConvertHumidity(float h) @@ -655,8 +655,8 @@ float ConvertPressure(float p) global_update = uptime; global_pressure = p; - if (!isnan(p) && Settings.flag.pressure_conversion) { - result = p * 0.75006375541921; // mmHg + if (!isnan(p) && Settings.flag.pressure_conversion) { // SetOption24 - Switch between hPa or mmHg pressure unit + result = p * 0.75006375541921; // mmHg } return result; } diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 47908e2d0..6b2d878b2 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -300,7 +300,7 @@ void CmndPower(void) if ((XdrvMailbox.payload < POWER_OFF) || (XdrvMailbox.payload > POWER_BLINK_STOP)) { XdrvMailbox.payload = POWER_SHOW_STATE; } -// Settings.flag.device_index_enable = XdrvMailbox.usridx; +// Settings.flag.device_index_enable = XdrvMailbox.usridx; // SetOption26 - Switch between POWER or POWER1 ExecuteCommandPower(XdrvMailbox.index, XdrvMailbox.payload, SRC_IGNORE); mqtt_data[0] = '\0'; } @@ -324,7 +324,7 @@ void CmndStatus(void) // Workaround MQTT - TCP/IP stack queueing when SUB_PREFIX = PUB_PREFIX if (!strcmp(Settings.mqtt_prefix[0],Settings.mqtt_prefix[1]) && (!payload)) { option++; } // TELE - if ((!Settings.flag.mqtt_enabled) && (6 == payload)) { payload = 99; } + if ((!Settings.flag.mqtt_enabled) && (6 == payload)) { payload = 99; } // SetOption3 - Enable MQTT if (!energy_flg && (9 == payload)) { payload = 99; } if ((0 == payload) || (99 == payload)) { @@ -346,8 +346,14 @@ void CmndStatus(void) D_CMND_SWITCHMODE "\":[%s],\"" D_CMND_BUTTONRETAIN "\":%d,\"" D_CMND_SWITCHRETAIN "\":%d,\"" D_CMND_SENSORRETAIN "\":%d,\"" D_CMND_POWERRETAIN "\":%d}}"), ModuleNr(), stemp, mqtt_topic, Settings.button_topic, power, Settings.poweronstate, Settings.ledstate, - Settings.ledmask, Settings.save_data, Settings.flag.save_state, Settings.switch_topic, - stemp2, Settings.flag.mqtt_button_retain, Settings.flag.mqtt_switch_retain, Settings.flag.mqtt_sensor_retain, Settings.flag.mqtt_power_retain); + Settings.ledmask, Settings.save_data, + Settings.flag.save_state, // SetOption0 - Save power state and use after restart + Settings.switch_topic, + stemp2, + Settings.flag.mqtt_button_retain, // CMND_BUTTONRETAIN + Settings.flag.mqtt_switch_retain, // CMND_SWITCHRETAIN + Settings.flag.mqtt_sensor_retain, // CMND_SENSORRETAIN + Settings.flag.mqtt_power_retain); // CMND_POWERRETAIN MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS)); } @@ -404,7 +410,7 @@ void CmndStatus(void) MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "5")); } - if (((0 == payload) || (6 == payload)) && Settings.flag.mqtt_enabled) { + if (((0 == payload) || (6 == payload)) && Settings.flag.mqtt_enabled) { // SetOption3 - Enable MQTT #ifdef USE_MQTT_AWS_IOT Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS6_MQTT "\":{\"" D_CMND_MQTTHOST "\":\"%s%s\",\"" D_CMND_MQTTPORT "\":%d,\"" D_CMND_MQTTCLIENT D_JSON_MASK "\":\"%s\",\"" D_CMND_MQTTCLIENT "\":\"%s\",\"" D_JSON_MQTT_COUNT "\":%d,\"MAX_PACKET_SIZE\":%d,\"KEEPALIVE\":%d}}"), @@ -483,7 +489,7 @@ void CmndState(void) MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_STATE), MQTT_TELE_RETAIN); } #ifdef USE_HOME_ASSISTANT - if (Settings.flag.hass_discovery) { + if (Settings.flag.hass_discovery) { // SetOption19 - Control Home Assistantautomatic discovery (See SetOption59) HAssPublishStatus(); } #endif // USE_HOME_ASSISTANT @@ -526,7 +532,7 @@ void CmndOtaUrl(void) void CmndSeriallog(void) { if ((XdrvMailbox.payload >= LOG_LEVEL_NONE) && (XdrvMailbox.payload <= LOG_LEVEL_DEBUG_MORE)) { - Settings.flag.mqtt_serial = 0; + Settings.flag.mqtt_serial = 0; // CMND_SERIALSEND and CMND_SERIALLOG SetSeriallog(XdrvMailbox.payload); } Response_P(S_JSON_COMMAND_NVALUE_ACTIVE_NVALUE, XdrvMailbox.command, Settings.seriallog_level, seriallog_level); @@ -1061,8 +1067,8 @@ void CmndSerialSend(void) { if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= 5)) { SetSeriallog(LOG_LEVEL_NONE); - Settings.flag.mqtt_serial = 1; - Settings.flag.mqtt_serial_raw = (XdrvMailbox.index > 3) ? 1 : 0; + Settings.flag.mqtt_serial = 1; // CMND_SERIALSEND and CMND_SERIALLOG + Settings.flag.mqtt_serial_raw = (XdrvMailbox.index > 3) ? 1 : 0; // CMND_SERIALSEND3 if (XdrvMailbox.data_len > 0) { if (1 == XdrvMailbox.index) { Serial.printf("%s\n", XdrvMailbox.data); // "Hello Tiger\n" @@ -1290,7 +1296,7 @@ void CmndInterlock(void) if (minimal_bits < 2) { Settings.interlock[i] = 0; } // Discard single relay as interlock } } else { - Settings.flag.interlock = XdrvMailbox.payload &1; // Enable/disable interlock + Settings.flag.interlock = XdrvMailbox.payload &1; // CMND_INTERLOCK - Enable/disable interlock if (Settings.flag.interlock) { SetDevicePower(power, SRC_IGNORE); // Remove multiple relays if set } @@ -1320,7 +1326,7 @@ void CmndInterlock(void) } ResponseAppend_P(PSTR("\"}")); } else { - Settings.flag.interlock = 0; + Settings.flag.interlock = 0; // CMND_INTERLOCK - Enable/disable interlock ResponseCmndStateText(Settings.flag.interlock); } } diff --git a/tasmota/support_wifi.ino b/tasmota/support_wifi.ino index ba0e95eae..1d66928ea 100644 --- a/tasmota/support_wifi.ino +++ b/tasmota/support_wifi.ino @@ -520,7 +520,7 @@ void WifiCheck(uint8_t param) #endif // USE_WEBSERVER #ifdef USE_KNX - if (!knx_started && Settings.flag.knx_enabled) { + if (!knx_started && Settings.flag.knx_enabled) { // CMND_KNX_ENABLED KNXStart(); knx_started = true; } @@ -574,7 +574,9 @@ void WifiDisconnect(void) void EspRestart(void) { delay(100); // Allow time for message xfer - disabled v6.1.0b - if (Settings.flag.mqtt_enabled) MqttDisconnect(); + if (Settings.flag.mqtt_enabled) { // SetOption3 - Enable MQTT + MqttDisconnect(); + } WifiDisconnect(); // ESP.restart(); // This results in exception 3 on restarts on core 2.3.0 ESP.reset(); diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index 1240a60de..811536b81 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -342,7 +342,7 @@ void SetDevicePower(power_t rpower, uint32_t source) rpower = power; } - if (Settings.flag.interlock) { // Allow only one or no relay set + if (Settings.flag.interlock) { // Allow only one or no relay set - CMND_INTERLOCK - Enable/disable interlock for (uint32_t i = 0; i < MAX_INTERLOCKS; i++) { power_t mask = 1; uint32_t count = 0; @@ -526,12 +526,12 @@ bool SendKey(uint32_t key, uint32_t device, uint32_t state) char *tmp = (key) ? Settings.switch_topic : Settings.button_topic; Format(key_topic, tmp, sizeof(key_topic)); - if (Settings.flag.mqtt_enabled && MqttIsConnected() && (strlen(key_topic) != 0) && strcmp(key_topic, "0")) { + if (Settings.flag.mqtt_enabled && MqttIsConnected() && (strlen(key_topic) != 0) && strcmp(key_topic, "0")) { // SetOption3 - Enable MQTT if (!key && (device > devices_present)) { device = 1; // Only allow number of buttons up to number of devices } GetTopic_P(stopic, CMND, key_topic, - GetPowerDevice(scommand, device, sizeof(scommand), (key + Settings.flag.device_index_enable))); // cmnd/switchtopic/POWERx + GetPowerDevice(scommand, device, sizeof(scommand), (key + Settings.flag.device_index_enable))); // cmnd/switchtopic/POWERx - SetOption26 - Switch between POWER or POWER1 if (CLEAR_RETAIN == state) { mqtt_data[0] = '\0'; } else { @@ -542,10 +542,12 @@ bool SendKey(uint32_t key, uint32_t device, uint32_t state) } #ifdef USE_DOMOTICZ if (!(DomoticzSendKey(key, device, state, strlen(mqtt_data)))) { - MqttPublishDirect(stopic, ((key) ? Settings.flag.mqtt_switch_retain : Settings.flag.mqtt_button_retain) && (state != POWER_HOLD || !Settings.flag3.no_hold_retain)); +#endif // USE_DOMOTICZ + MqttPublishDirect(stopic, ((key) ? Settings.flag.mqtt_switch_retain // CMND_SWITCHRETAIN + : Settings.flag.mqtt_button_retain) && // CMND_BUTTONRETAIN + (state != POWER_HOLD || !Settings.flag3.no_hold_retain)); // SetOption62 - Don't use retain flag on HOLD messages +#ifdef USE_DOMOTICZ } -#else - MqttPublishDirect(stopic, ((key) ? Settings.flag.mqtt_switch_retain : Settings.flag.mqtt_button_retain) && (state != POWER_HOLD || !Settings.flag3.no_hold_retain)); #endif // USE_DOMOTICZ result = !Settings.flag3.button_switch_force_local; } else { @@ -577,7 +579,7 @@ void ExecuteCommandPower(uint32_t device, uint32_t state, uint32_t source) #ifdef USE_SONOFF_IFAN if (IsModuleIfan()) { blink_mask &= 1; // No blinking on the fan relays - Settings.flag.interlock = 0; // No interlock mode as it is already done by the microcontroller + Settings.flag.interlock = 0; // No interlock mode as it is already done by the microcontroller - CMND_INTERLOCK - Enable/disable interlock Settings.pulse_timer[1] = 0; // No pulsetimers on the fan relays Settings.pulse_timer[2] = 0; Settings.pulse_timer[3] = 0; @@ -605,7 +607,7 @@ void ExecuteCommandPower(uint32_t device, uint32_t state, uint32_t source) MqttPublishPowerBlinkState(device); } - if (Settings.flag.interlock && + if (Settings.flag.interlock && // CMND_INTERLOCK - Enable/disable interlock !interlock_mutex && ((POWER_ON == state) || ((POWER_TOGGLE == state) && !(power & mask))) ) { @@ -722,7 +724,8 @@ void MqttShowState(void) if (i == LightDevice()) { LightState(1); } // call it only once } else { #endif - ResponseAppend_P(PSTR(",\"%s\":\"%s\""), GetPowerDevice(stemp1, i, sizeof(stemp1), Settings.flag.device_index_enable), GetStateText(bitRead(power, i-1))); + ResponseAppend_P(PSTR(",\"%s\":\"%s\""), GetPowerDevice(stemp1, i, sizeof(stemp1), Settings.flag.device_index_enable), // SetOption26 - Switch between POWER or POWER1 + GetStateText(bitRead(power, i-1))); #ifdef USE_SONOFF_IFAN if (IsModuleIfan()) { ResponseAppend_P(PSTR(",\"" D_CMND_FANSPEED "\":%d"), GetFanspeed()); @@ -847,7 +850,7 @@ void PerformEverySecond(void) mqtt_data[0] = '\0'; if (MqttShowSensor()) { - MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR), Settings.flag.mqtt_sensor_retain); + MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR), Settings.flag.mqtt_sensor_retain); // CMND_SENSORRETAIN #if defined(USE_RULES) || defined(USE_SCRIPT) RulesTeleperiod(); // Allow rule based HA messages #endif // USE_RULES @@ -914,7 +917,7 @@ void Every250mSeconds(void) if (mqtt_cmnd_publish) mqtt_cmnd_publish--; // Clean up - if (!Settings.flag.global_state) { // Problem blinkyblinky enabled + if (!Settings.flag.global_state) { // Problem blinkyblinky enabled - SetOption31 - Control link led blinking if (global_state.data) { // Any problem if (global_state.mqtt_down) { blinkinterval = 7; } // MQTT problem so blink every 2 seconds (slowest) if (global_state.wifi_down) { blinkinterval = 3; } // Wifi problem so blink every second (slow) @@ -1027,7 +1030,7 @@ void Every250mSeconds(void) if (save_data_counter && BACKLOG_EMPTY) { save_data_counter--; if (save_data_counter <= 0) { - if (Settings.flag.save_state) { + if (Settings.flag.save_state) { // SetOption0 - Save power state and use after restart power_t mask = POWER_MASK; for (uint32_t i = 0; i < MAX_PULSETIMERS; i++) { if ((Settings.pulse_timer[i] > 0) && (Settings.pulse_timer[i] < 30)) { // 3 seconds @@ -1120,18 +1123,20 @@ void ArduinoOTAInit(void) ArduinoOTA.onStart([]() { - SettingsSave(1); // Free flash for OTA update + SettingsSave(1); // Free flash for OTA update #ifdef USE_WEBSERVER if (Settings.webserver) { StopWebserver(); } #endif // USE_WEBSERVER #ifdef USE_ARILUX_RF - AriluxRfDisable(); // Prevent restart exception on Arilux Interrupt routine + AriluxRfDisable(); // Prevent restart exception on Arilux Interrupt routine #endif // USE_ARILUX_RF - if (Settings.flag.mqtt_enabled) { MqttDisconnect(); } + if (Settings.flag.mqtt_enabled) { + MqttDisconnect(); // SetOption3 - Enable MQTT + } AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA " D_UPLOAD_STARTED)); arduino_ota_triggered = true; arduino_ota_progress_dot_count = 0; - delay(100); // Allow time for message xfer + delay(100); // Allow time for message xfer }); ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) @@ -1201,12 +1206,12 @@ void SerialInput(void) /*-------------------------------------------------------------------------------------------*/ - if (serial_in_byte > 127 && !Settings.flag.mqtt_serial_raw) { // Discard binary data above 127 if no raw reception allowed + if (serial_in_byte > 127 && !Settings.flag.mqtt_serial_raw) { // Discard binary data above 127 if no raw reception allowed - CMND_SERIALSEND3 serial_in_byte_counter = 0; Serial.flush(); return; } - if (!Settings.flag.mqtt_serial) { // SerialSend active + if (!Settings.flag.mqtt_serial) { // SerialSend active - CMND_SERIALSEND and CMND_SERIALLOG if (isprint(serial_in_byte)) { // Any char between 32 and 127 if (serial_in_byte_counter < INPUT_BUFFER_SIZE -1) { // Add char to string if it still fits serial_in_buffer[serial_in_byte_counter++] = serial_in_byte; @@ -1215,11 +1220,11 @@ void SerialInput(void) } } } else { - if (serial_in_byte || Settings.flag.mqtt_serial_raw) { // Any char between 1 and 127 or any char (0 - 255) + if (serial_in_byte || Settings.flag.mqtt_serial_raw) { // Any char between 1 and 127 or any char (0 - 255) - CMND_SERIALSEND3 if ((serial_in_byte_counter < INPUT_BUFFER_SIZE -1) && // Add char to string if it still fits and ... ((isprint(serial_in_byte) && (128 == Settings.serial_delimiter)) || // Any char between 32 and 127 ((serial_in_byte != Settings.serial_delimiter) && (128 != Settings.serial_delimiter)) || // Any char between 1 and 127 and not being delimiter - Settings.flag.mqtt_serial_raw)) { // Any char between 0 and 255 + Settings.flag.mqtt_serial_raw)) { // Any char between 0 and 255 - CMND_SERIALSEND3 serial_in_buffer[serial_in_byte_counter++] = serial_in_byte; serial_polling_window = millis(); } else { @@ -1245,7 +1250,7 @@ void SerialInput(void) #endif // USE_SONOFF_SC /*-------------------------------------------------------------------------------------------*/ - if (!Settings.flag.mqtt_serial && (serial_in_byte == '\n')) { + if (!Settings.flag.mqtt_serial && (serial_in_byte == '\n')) { // CMND_SERIALSEND and CMND_SERIALLOG serial_in_buffer[serial_in_byte_counter] = 0; // Serial data completed seriallog_level = (Settings.seriallog_level < LOG_LEVEL_INFO) ? (uint8_t)LOG_LEVEL_INFO : Settings.seriallog_level; AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "%s"), serial_in_buffer); @@ -1257,7 +1262,7 @@ void SerialInput(void) } } - if (Settings.flag.mqtt_serial && serial_in_byte_counter && (millis() > (serial_polling_window + SERIAL_POLLING))) { + if (Settings.flag.mqtt_serial && serial_in_byte_counter && (millis() > (serial_polling_window + SERIAL_POLLING))) { // CMND_SERIALSEND and CMND_SERIALLOG serial_in_buffer[serial_in_byte_counter] = 0; // Serial data completed char hex_char[(serial_in_byte_counter * 2) + 2]; Response_P(PSTR(",\"" D_JSON_SERIALRECEIVED "\":\"%s\"}"), @@ -1410,18 +1415,18 @@ void GpioInit(void) // devices_present = 1; } else if (SONOFF_DUAL == my_module_type) { - Settings.flag.mqtt_serial = 0; + Settings.flag.mqtt_serial = 0; // CMND_SERIALSEND and CMND_SERIALLOG devices_present = 2; baudrate = 19200; } else if (CH4 == my_module_type) { - Settings.flag.mqtt_serial = 0; + Settings.flag.mqtt_serial = 0; // CMND_SERIALSEND and CMND_SERIALLOG devices_present = 4; baudrate = 19200; } #ifdef USE_SONOFF_SC else if (SONOFF_SC == my_module_type) { - Settings.flag.mqtt_serial = 0; + Settings.flag.mqtt_serial = 0; // CMND_SERIALSEND and CMND_SERIALLOG devices_present = 0; baudrate = 19200; } @@ -1524,7 +1529,7 @@ void setup(void) seriallog_level = Settings.seriallog_level; seriallog_timer = SERIALLOG_TIMER; syslog_level = Settings.syslog_level; - stop_flash_rotate = Settings.flag.stop_flash_rotate; + stop_flash_rotate = Settings.flag.stop_flash_rotate; // SetOption12 - Switch between dynamic or fixed slot flash save location save_data_counter = Settings.save_data; sleep = Settings.sleep; #ifndef USE_EMULATION @@ -1598,20 +1603,20 @@ void setup(void) break; case POWER_ALL_SAVED_TOGGLE: power = (Settings.power & ((1 << devices_present) -1)) ^ POWER_MASK; - if (Settings.flag.save_state) { + if (Settings.flag.save_state) { // SetOption0 - Save power state and use after restart SetDevicePower(power, SRC_RESTART); } break; case POWER_ALL_SAVED: power = Settings.power & ((1 << devices_present) -1); - if (Settings.flag.save_state) { + if (Settings.flag.save_state) { // SetOption0 - Save power state and use after restart SetDevicePower(power, SRC_RESTART); } break; } } else { power = Settings.power & ((1 << devices_present) -1); - if (Settings.flag.save_state) { + if (Settings.flag.save_state) { // SetOption0 - Save power state and use after restart SetDevicePower(power, SRC_RESTART); } } diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index c4e647d66..4dc07c44a 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -991,7 +991,7 @@ void HandleRoot(void) if (devices_present) { #ifdef USE_LIGHT if (light_type) { - if (!Settings.flag3.pwm_multi_channels) { + if (!Settings.flag3.pwm_multi_channels) { // SetOption68 0 if ((LST_COLDWARM == (light_type &7)) || (LST_RGBWC == (light_type &7))) { // Cold - Warm &t related to lb("t", value) and WebGetArg("t", tmp, sizeof(tmp)); WSContentSend_P(HTTP_MSG_SLIDER1, F(D_COLDLIGHT), F(D_WARMLIGHT), @@ -1000,7 +1000,7 @@ void HandleRoot(void) // Dark - Bright &d related to lb("d", value) and WebGetArg("d", tmp, sizeof(tmp)); WSContentSend_P(HTTP_MSG_SLIDER1, F(D_DARKLIGHT), F(D_BRIGHTLIGHT), 1, 100, Settings.light_dimmer, 'd'); - } else { // Settings.flag3.pwm_multi_channels + } else { // Settings.flag3.pwm_multi_channels - SetOption68 1 uint32_t pwm_channels = (light_type & 7) > LST_MAX ? LST_MAX : (light_type & 7); for (uint32_t i = 0; i < pwm_channels; i++) { snprintf_P(stemp, sizeof(stemp), PSTR("c%d"), i); @@ -1012,7 +1012,7 @@ void HandleRoot(void) } #endif #ifdef USE_SHUTTER - if (Settings.flag3.shutter_mode) { + if (Settings.flag3.shutter_mode) { // SetOption80 1 for (uint32_t i = 0; i < shutters_present; i++) { WSContentSend_P(HTTP_MSG_SLIDER2, F(D_CLOSE), F(D_OPEN), 0, 100, Settings.shutter_position[i], 'u', i+1); @@ -1625,7 +1625,7 @@ void HandleLoggingConfiguration(void) char stemp2[32]; uint8_t dlevel[4] = { LOG_LEVEL_INFO, LOG_LEVEL_INFO, LOG_LEVEL_NONE, LOG_LEVEL_NONE }; for (uint32_t idx = 0; idx < 4; idx++) { - if ((2==idx) && !Settings.flag.mqtt_enabled) { continue; } + if ((2==idx) && !Settings.flag.mqtt_enabled) { continue; } // SetOption3 - Enable MQTT uint32_t llevel = (0==idx)?Settings.seriallog_level:(1==idx)?Settings.weblog_level:(2==idx)?Settings.mqttlog_level:Settings.syslog_level; WSContentSend_P(PSTR("

%s (%s)