From 0129fc98255880ce6ac84a50fae3bcaffbcfeba1 Mon Sep 17 00:00:00 2001 From: arendst Date: Mon, 18 Dec 2017 18:20:28 +0100 Subject: [PATCH] Change some output to JSON Array (#1363) * Change output to valid JSON Array if needed (#1363) --- sonoff/_releasenotes.ino | 3 ++- sonoff/settings.ino | 2 +- sonoff/sonoff.h | 2 +- sonoff/sonoff.ino | 18 ++++++------- sonoff/support.ino | 4 +-- sonoff/webserver.ino | 2 +- sonoff/xsns_01_counter.ino | 6 ++--- sonoff/xsns_03_energy.ino | 31 +++++++++++----------- sonoff/xsns_04_snfsc.ino | 4 +-- sonoff/xsns_05_ds18b20.ino | 4 +-- sonoff/xsns_05_ds18x20.ino | 4 +-- sonoff/xsns_05_ds18x20_legacy.ino | 4 +-- sonoff/xsns_06_dht.ino | 4 +-- sonoff/xsns_07_sht1x.ino | 4 +-- sonoff/xsns_08_htu21.ino | 4 +-- sonoff/xsns_09_bmp.ino | 4 +-- sonoff/xsns_10_bh1750.ino | 4 +-- sonoff/xsns_11_veml6070.ino | 4 +-- sonoff/xsns_12_ads1115.ino | 4 +-- sonoff/xsns_12_ads1115_i2cdev.ino | 4 +-- sonoff/xsns_13_ina219.ino | 4 +-- sonoff/xsns_14_sht3x.ino | 4 +-- sonoff/xsns_14_sht3x_v2.ino | 4 +-- sonoff/xsns_14_sht3x_v3.ino | 4 +-- sonoff/xsns_15_mhz_hardserial.ino | 4 +-- sonoff/xsns_15_mhz_softserial.ino | 4 +-- sonoff/xsns_15_mhz_softserial_obsolete.ino | 4 +-- sonoff/xsns_16_tsl2561.ino | 4 +-- sonoff/xsns_interface.ino | 6 ++--- 29 files changed, 77 insertions(+), 77 deletions(-) diff --git a/sonoff/_releasenotes.ino b/sonoff/_releasenotes.ino index 826c4011b..e8eb00501 100644 --- a/sonoff/_releasenotes.ino +++ b/sonoff/_releasenotes.ino @@ -1,8 +1,9 @@ /* 5.10.0b * Add optional support for PZEM004T energy sensor - * Change Sonoff Pow Enenrgy MQTT data message and consolidate Status 8 into Status 10 + * Change Sonoff Pow Energy MQTT data message and consolidate Status 8 into Status 10 * Change Wemo SetBinaryState to distinguish from GetBinaryState (#1357) * Change output of HTTP command to valid JSON only (#1363) + * Change output to valid JSON Array if needed (#1363) * * 5.10.0a * Add (experimental) support for sensor SHT3x diff --git a/sonoff/settings.ino b/sonoff/settings.ino index 1a2035c22..a177e86e4 100644 --- a/sonoff/settings.ino +++ b/sonoff/settings.ino @@ -182,7 +182,7 @@ void SettingsSaveAll() } else { Settings.power = 0; } - XsnsCall(FUNC_XSNS_SAVE_STATE); + XsnsCall(FUNC_XSNS_SAVE_BEFORE_RESTART); SettingsSave(0); } diff --git a/sonoff/sonoff.h b/sonoff/sonoff.h index e2e1553f9..92725a58b 100644 --- a/sonoff/sonoff.h +++ b/sonoff/sonoff.h @@ -132,7 +132,7 @@ enum LightTypes {LT_BASIC, LT_PWM1, LT_PWM2, LT_PWM3, LT_PWM4, LT_PWM5, LT_PWM6, enum LichtSubtypes {LST_NONE, LST_SINGLE, LST_COLDWARM, LST_RGB, LST_RGBW, LST_RGBWC}; enum LichtSchemes {LS_POWER, LS_WAKEUP, LS_CYCLEUP, LS_CYCLEDN, LS_RANDOM, LS_MAX}; -enum XsnsFunctions {FUNC_XSNS_INIT, FUNC_XSNS_EVERY_SECOND, FUNC_XSNS_PREP, FUNC_XSNS_JSON_APPEND, FUNC_XSNS_WEB, FUNC_XSNS_SAVE_STATE}; +enum XsnsFunctions {FUNC_XSNS_INIT, FUNC_XSNS_EVERY_SECOND, FUNC_XSNS_PREP_BEFORE_TELEPERIOD, FUNC_XSNS_JSON_APPEND, FUNC_XSNS_WEB_APPEND, FUNC_XSNS_SAVE_BEFORE_RESTART}; const uint8_t kDefaultRfCode[9] PROGMEM = { 0x21, 0x16, 0x01, 0x0E, 0x03, 0x48, 0x2E, 0x1A, 0x00 }; diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 2db39f36a..6ddf00e05 100644 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -1100,15 +1100,15 @@ void MqttDataCallback(char* topic, byte* data, unsigned int data_len) else if (CMND_MODULES == command_code) { for (byte i = 0; i < MAXMODULE; i++) { if (!jsflg) { - snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_MODULES "%d\":\""), lines); + snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_MODULES "%d\":["), lines); } else { snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,"), mqtt_data); } jsflg = 1; snprintf_P(stemp1, sizeof(stemp1), kModules[i].name); - snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s%d (%s)"), mqtt_data, i +1, stemp1); - if ((strlen(mqtt_data) > 200) || (i == MAXMODULE -1)) { - snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s\"}"), mqtt_data); + snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s\"%d (%s)\""), mqtt_data, i +1, stemp1); + if ((strlen(mqtt_data) > 300) || (i == MAXMODULE -1)) { + snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s]}"), mqtt_data); MqttPublishPrefixTopic_P(5, type); jsflg = 0; lines++; @@ -1149,15 +1149,15 @@ void MqttDataCallback(char* topic, byte* data, unsigned int data_len) else if (CMND_GPIOS == command_code) { for (byte i = 0; i < GPIO_SENSOR_END; i++) { if (!jsflg) { - snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_GPIOS "%d\":\""), lines); + snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_GPIOS "%d\":["), lines); } else { snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,"), mqtt_data); } jsflg = 1; snprintf_P(stemp1, sizeof(stemp1), kSensors[i]); - snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s%d (%s)"), mqtt_data, i, stemp1); - if ((strlen(mqtt_data) > 200) || (i == GPIO_SENSOR_END -1)) { - snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s\"}"), mqtt_data); + snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s\"%d (%s)\""), mqtt_data, i, stemp1); + if ((strlen(mqtt_data) > 300) || (i == GPIO_SENSOR_END -1)) { + snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s]}"), mqtt_data); MqttPublishPrefixTopic_P(5, type); jsflg = 0; lines++; @@ -1871,7 +1871,7 @@ void PerformEverySecond() if (Settings.tele_period) { tele_period++; if (tele_period == Settings.tele_period -1) { - XsnsCall(FUNC_XSNS_PREP); + XsnsCall(FUNC_XSNS_PREP_BEFORE_TELEPERIOD); } if (tele_period >= Settings.tele_period) { tele_period = 0; diff --git a/sonoff/support.ino b/sonoff/support.ino index dd6d6c92d..9ae7af452 100644 --- a/sonoff/support.ino +++ b/sonoff/support.ino @@ -1339,13 +1339,13 @@ boolean Xsns02(byte function) switch (function) { // case FUNC_XSNS_INIT: // break; -// case FUNC_XSNS_PREP: +// case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: // break; case FUNC_XSNS_JSON_APPEND: AdcShow(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: AdcShow(0); break; #endif // USE_WEBSERVER diff --git a/sonoff/webserver.ino b/sonoff/webserver.ino index 0f08635d0..54fb26f19 100644 --- a/sonoff/webserver.ino +++ b/sonoff/webserver.ino @@ -511,7 +511,7 @@ void HandleAjaxStatusRefresh() String page = ""; mqtt_data[0] = '\0'; - XsnsCall(FUNC_XSNS_WEB); + XsnsCall(FUNC_XSNS_WEB_APPEND); if (strlen(mqtt_data)) { page += FPSTR(HTTP_TABLE100); page += mqtt_data; diff --git a/sonoff/xsns_01_counter.ino b/sonoff/xsns_01_counter.ino index 007662aff..7b3f72d9f 100644 --- a/sonoff/xsns_01_counter.ino +++ b/sonoff/xsns_01_counter.ino @@ -133,17 +133,17 @@ boolean Xsns01(byte function) case FUNC_XSNS_INIT: CounterInit(); break; -// case FUNC_XSNS_PREP: +// case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: // break; case FUNC_XSNS_JSON_APPEND: CounterShow(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: CounterShow(0); break; #endif // USE_WEBSERVER - case FUNC_XSNS_SAVE_STATE: + case FUNC_XSNS_SAVE_BEFORE_RESTART: CounterSaveState(); break; } diff --git a/sonoff/xsns_03_energy.ino b/sonoff/xsns_03_energy.ino index 649ea2993..c23664873 100644 --- a/sonoff/xsns_03_energy.ino +++ b/sonoff/xsns_03_energy.ino @@ -401,9 +401,6 @@ void PzemSerialRxRead() { #define PZEM_POWER_ALARM (uint8_t)0xB5 #define RESP_POWER_ALARM (uint8_t)0xA5 -#define RESPONSE_SIZE sizeof(PZEMCommand) -#define RESPONSE_DATA_SIZE RESPONSE_SIZE - 2 - #define PZEM_DEFAULT_READ_TIMEOUT 500 #define PZEM_ERROR_VALUE -1.0 @@ -418,7 +415,7 @@ IPAddress pzem_ip(192, 168, 1, 1); float PZEM004T_voltage_rcv() { - uint8_t data[RESPONSE_DATA_SIZE]; + uint8_t data[sizeof(PZEMCommand) -2]; if (!PZEM004T_recieve(RESP_VOLTAGE, data)) { return PZEM_ERROR_VALUE; @@ -428,7 +425,7 @@ float PZEM004T_voltage_rcv() float PZEM004T_current_rcv() { - uint8_t data[RESPONSE_DATA_SIZE]; + uint8_t data[sizeof(PZEMCommand) -2]; if (!PZEM004T_recieve(RESP_CURRENT, data)) { return PZEM_ERROR_VALUE; @@ -438,7 +435,7 @@ float PZEM004T_current_rcv() float PZEM004T_power_rcv() { - uint8_t data[RESPONSE_DATA_SIZE]; + uint8_t data[sizeof(PZEMCommand) -2]; if (!PZEM004T_recieve(RESP_POWER, data)) { return PZEM_ERROR_VALUE; @@ -448,7 +445,7 @@ float PZEM004T_power_rcv() float PZEM004T_energy_rcv() { - uint8_t data[RESPONSE_DATA_SIZE]; + uint8_t data[sizeof(PZEMCommand) -2]; if (!PZEM004T_recieve(RESP_ENERGY, data)) { return PZEM_ERROR_VALUE; @@ -482,17 +479,16 @@ void PZEM004T_send(uint8_t cmd) bool PZEM004T_isReady() { - return PzemSerialAvailable() >= RESPONSE_SIZE; + return PzemSerialAvailable() >= sizeof(PZEMCommand); } bool PZEM004T_recieve(uint8_t resp, uint8_t *data) { - uint8_t buffer[RESPONSE_SIZE]; + uint8_t buffer[sizeof(PZEMCommand)]; unsigned long startTime = millis(); uint8_t len = 0; -// while ((len < RESPONSE_SIZE) && (millis() - startTime < PZEM_DEFAULT_READ_TIMEOUT)) { - while ((len < RESPONSE_SIZE) && (millis() - startTime < PZEM_DEFAULT_READ_TIMEOUT)) { + while ((len < sizeof(PZEMCommand)) && (millis() - startTime < PZEM_DEFAULT_READ_TIMEOUT)) { if (PzemSerialAvailable() > 0) { uint8_t c = (uint8_t)PzemSerialRead(); if (!c && !len) { @@ -503,17 +499,20 @@ bool PZEM004T_recieve(uint8_t resp, uint8_t *data) // yield(); // do background netw tasks while blocked for IO (prevents ESP watchdog trigger) - This triggers Watchdog!!! } - if (len != RESPONSE_SIZE) { + if (len != sizeof(PZEMCommand)) { +// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Pzem comms timeout")); return false; } if (buffer[6] != PZEM004T_crc(buffer, len - 1)) { +// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Pzem crc error")); return false; } if (buffer[0] != resp) { +// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Pzem bad response")); return false; } if (data) { - for (int i = 0; i < RESPONSE_DATA_SIZE; i++) { + for (int i = 0; i < sizeof(PZEMCommand) -2; i++) { data[i] = buffer[1 + i]; } } @@ -1150,17 +1149,17 @@ boolean Xsns03(byte function) case FUNC_XSNS_EVERY_SECOND: EnergyMarginCheck(); break; -// case FUNC_XSNS_PREP: +// case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: // break; case FUNC_XSNS_JSON_APPEND: EnergyShow(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: EnergyShow(0); break; #endif // USE_WEBSERVER - case FUNC_XSNS_SAVE_STATE: + case FUNC_XSNS_SAVE_BEFORE_RESTART: EnergySaveState(); break; } diff --git a/sonoff/xsns_04_snfsc.ino b/sonoff/xsns_04_snfsc.ino index fbe2a2e8a..98ff02c0f 100644 --- a/sonoff/xsns_04_snfsc.ino +++ b/sonoff/xsns_04_snfsc.ino @@ -151,13 +151,13 @@ boolean Xsns04(byte function) case FUNC_XSNS_INIT: SonoffScInit(); break; -// case FUNC_XSNS_PREP: +// case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: // break; case FUNC_XSNS_JSON_APPEND: SonoffScShow(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: SonoffScShow(0); break; #endif // USE_WEBSERVER diff --git a/sonoff/xsns_05_ds18b20.ino b/sonoff/xsns_05_ds18b20.ino index 5c9ff013d..343b42fea 100644 --- a/sonoff/xsns_05_ds18b20.ino +++ b/sonoff/xsns_05_ds18b20.ino @@ -222,14 +222,14 @@ boolean Xsns05(byte function) case FUNC_XSNS_INIT: Ds18x20Init(); break; - case FUNC_XSNS_PREP: + case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: Ds18x20Convert(); // Start conversion, takes up to one second break; case FUNC_XSNS_JSON_APPEND: Ds18b20Show(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: Ds18b20Show(0); Ds18x20Convert(); // Start conversion, takes up to one second break; diff --git a/sonoff/xsns_05_ds18x20.ino b/sonoff/xsns_05_ds18x20.ino index de334b4d2..0e7553940 100644 --- a/sonoff/xsns_05_ds18x20.ino +++ b/sonoff/xsns_05_ds18x20.ino @@ -404,14 +404,14 @@ boolean Xsns05(byte function) case FUNC_XSNS_INIT: Ds18x20Init(); break; - case FUNC_XSNS_PREP: + case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: Ds18x20Convert(); // Start conversion, takes up to one second break; case FUNC_XSNS_JSON_APPEND: Ds18x20Show(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: Ds18x20Show(0); Ds18x20Convert(); // Start conversion, takes up to one second break; diff --git a/sonoff/xsns_05_ds18x20_legacy.ino b/sonoff/xsns_05_ds18x20_legacy.ino index beffe780d..5d6553f6d 100644 --- a/sonoff/xsns_05_ds18x20_legacy.ino +++ b/sonoff/xsns_05_ds18x20_legacy.ino @@ -222,7 +222,7 @@ boolean Xsns05(byte function) case FUNC_XSNS_INIT: Ds18x20Init(); break; - case FUNC_XSNS_PREP: + case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: Ds18x20Search(); // Check for changes in sensors number Ds18x20Convert(); // Start Conversion, takes up to one second break; @@ -230,7 +230,7 @@ boolean Xsns05(byte function) Ds18x20Show(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: Ds18x20Show(0); break; #endif // USE_WEBSERVER diff --git a/sonoff/xsns_06_dht.ino b/sonoff/xsns_06_dht.ino index 8af52efe1..64d8baf78 100644 --- a/sonoff/xsns_06_dht.ino +++ b/sonoff/xsns_06_dht.ino @@ -256,14 +256,14 @@ boolean Xsns06(byte function) case FUNC_XSNS_INIT: DhtInit(); break; - case FUNC_XSNS_PREP: + case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: DhtReadPrep(); break; case FUNC_XSNS_JSON_APPEND: DhtShow(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: DhtShow(0); break; #endif // USE_WEBSERVER diff --git a/sonoff/xsns_07_sht1x.ino b/sonoff/xsns_07_sht1x.ino index db1ad3717..9b74d31a0 100644 --- a/sonoff/xsns_07_sht1x.ino +++ b/sonoff/xsns_07_sht1x.ino @@ -225,14 +225,14 @@ boolean Xsns07(byte function) switch (function) { // case FUNC_XSNS_INIT: // break; - case FUNC_XSNS_PREP: + case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: ShtDetect(); break; case FUNC_XSNS_JSON_APPEND: ShtShow(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: ShtShow(0); break; #endif // USE_WEBSERVER diff --git a/sonoff/xsns_08_htu21.ino b/sonoff/xsns_08_htu21.ino index 6a1053145..7bafad1d9 100644 --- a/sonoff/xsns_08_htu21.ino +++ b/sonoff/xsns_08_htu21.ino @@ -286,14 +286,14 @@ boolean Xsns08(byte function) switch (function) { // case FUNC_XSNS_INIT: // break; - case FUNC_XSNS_PREP: + case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: HtuDetect(); break; case FUNC_XSNS_JSON_APPEND: HtuShow(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: HtuShow(0); break; #endif // USE_WEBSERVER diff --git a/sonoff/xsns_09_bmp.ino b/sonoff/xsns_09_bmp.ino index 742fa71c3..74e310ef1 100644 --- a/sonoff/xsns_09_bmp.ino +++ b/sonoff/xsns_09_bmp.ino @@ -504,7 +504,7 @@ boolean Xsns09(byte function) switch (function) { // case FUNC_XSNS_INIT: // break; - case FUNC_XSNS_PREP: + case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: BmpDetect(); #ifdef USE_BME680 Bme680PerformReading(); @@ -514,7 +514,7 @@ boolean Xsns09(byte function) BmpShow(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: BmpShow(0); #ifdef USE_BME680 Bme680PerformReading(); diff --git a/sonoff/xsns_10_bh1750.ino b/sonoff/xsns_10_bh1750.ino index 7653e2beb..f8be2cfbb 100644 --- a/sonoff/xsns_10_bh1750.ino +++ b/sonoff/xsns_10_bh1750.ino @@ -101,14 +101,14 @@ boolean Xsns10(byte function) switch (function) { // case FUNC_XSNS_INIT: // break; - case FUNC_XSNS_PREP: + case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: Bh1750Detect(); break; case FUNC_XSNS_JSON_APPEND: Bh1750Show(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: Bh1750Show(0); break; #endif // USE_WEBSERVER diff --git a/sonoff/xsns_11_veml6070.ino b/sonoff/xsns_11_veml6070.ino index b6d680d45..cc62771c1 100644 --- a/sonoff/xsns_11_veml6070.ino +++ b/sonoff/xsns_11_veml6070.ino @@ -106,14 +106,14 @@ boolean Xsns11(byte function) switch (function) { // case FUNC_XSNS_INIT: // break; - case FUNC_XSNS_PREP: + case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: Veml6070Detect(); break; case FUNC_XSNS_JSON_APPEND: Veml6070Show(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: Veml6070Show(0); break; #endif // USE_WEBSERVER diff --git a/sonoff/xsns_12_ads1115.ino b/sonoff/xsns_12_ads1115.ino index 132d2725d..675b15101 100644 --- a/sonoff/xsns_12_ads1115.ino +++ b/sonoff/xsns_12_ads1115.ino @@ -220,14 +220,14 @@ boolean Xsns12(byte function) switch (function) { // case FUNC_XSNS_INIT: // break; - case FUNC_XSNS_PREP: + case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: Ads1115Detect(); break; case FUNC_XSNS_JSON_APPEND: Ads1115Show(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: Ads1115Show(0); break; #endif // USE_WEBSERVER diff --git a/sonoff/xsns_12_ads1115_i2cdev.ino b/sonoff/xsns_12_ads1115_i2cdev.ino index 1da6c62e6..8856da70f 100644 --- a/sonoff/xsns_12_ads1115_i2cdev.ino +++ b/sonoff/xsns_12_ads1115_i2cdev.ino @@ -140,14 +140,14 @@ boolean Xsns12(byte function) switch (function) { // case FUNC_XSNS_INIT: // break; - case FUNC_XSNS_PREP: + case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: Ads1115Detect(); break; case FUNC_XSNS_JSON_APPEND: Ads1115Show(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: Ads1115Show(0); break; #endif // USE_WEBSERVER diff --git a/sonoff/xsns_13_ina219.ino b/sonoff/xsns_13_ina219.ino index 169e51426..485c91452 100644 --- a/sonoff/xsns_13_ina219.ino +++ b/sonoff/xsns_13_ina219.ino @@ -221,14 +221,14 @@ boolean Xsns13(byte function) switch (function) { // case FUNC_XSNS_INIT: // break; - case FUNC_XSNS_PREP: + case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: Ina219Detect(); break; case FUNC_XSNS_JSON_APPEND: Ina219Show(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: Ina219Show(0); break; #endif // USE_WEBSERVER diff --git a/sonoff/xsns_14_sht3x.ino b/sonoff/xsns_14_sht3x.ino index 420e8d078..f58fc3999 100644 --- a/sonoff/xsns_14_sht3x.ino +++ b/sonoff/xsns_14_sht3x.ino @@ -128,14 +128,14 @@ boolean Xsns14(byte function) case FUNC_XSNS_INIT: Sht3xDetect(); break; - case FUNC_XSNS_PREP: + case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: Sht3xConvert(); break; case FUNC_XSNS_JSON_APPEND: Sht3xShow(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: Sht3xShow(0); Sht3xConvert(); break; diff --git a/sonoff/xsns_14_sht3x_v2.ino b/sonoff/xsns_14_sht3x_v2.ino index 5329b373b..0ed9d0bd8 100644 --- a/sonoff/xsns_14_sht3x_v2.ino +++ b/sonoff/xsns_14_sht3x_v2.ino @@ -125,13 +125,13 @@ boolean Xsns14(byte function) case FUNC_XSNS_INIT: Sht3xDetect(); break; -// case FUNC_XSNS_PREP: +// case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: // break; case FUNC_XSNS_JSON_APPEND: Sht3xShow(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: Sht3xShow(0); break; #endif // USE_WEBSERVER diff --git a/sonoff/xsns_14_sht3x_v3.ino b/sonoff/xsns_14_sht3x_v3.ino index cfc933afb..a078fff91 100644 --- a/sonoff/xsns_14_sht3x_v3.ino +++ b/sonoff/xsns_14_sht3x_v3.ino @@ -135,14 +135,14 @@ boolean Xsns14(byte function) case FUNC_XSNS_INIT: Sht3xDetect(); break; - case FUNC_XSNS_PREP: + case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: Sht3xConvert(); break; case FUNC_XSNS_JSON_APPEND: Sht3xShow(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: Sht3xShow(0); Sht3xConvert(); break; diff --git a/sonoff/xsns_15_mhz_hardserial.ino b/sonoff/xsns_15_mhz_hardserial.ino index cde575f2d..3f635436d 100644 --- a/sonoff/xsns_15_mhz_hardserial.ino +++ b/sonoff/xsns_15_mhz_hardserial.ino @@ -257,14 +257,14 @@ boolean Xsns15(byte function) case FUNC_XSNS_INIT: Mhz19Init(); break; - case FUNC_XSNS_PREP: + case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: // Mhz19Prep(); break; case FUNC_XSNS_JSON_APPEND: Mhz19Show(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: Mhz19Show(0); // Mhz19Prep(); break; diff --git a/sonoff/xsns_15_mhz_softserial.ino b/sonoff/xsns_15_mhz_softserial.ino index b77faeb20..2e9c5ae0c 100644 --- a/sonoff/xsns_15_mhz_softserial.ino +++ b/sonoff/xsns_15_mhz_softserial.ino @@ -357,14 +357,14 @@ boolean Xsns15(byte function) case FUNC_XSNS_INIT: Mhz19Init(); break; - case FUNC_XSNS_PREP: + case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: // Mhz19Prep(); break; case FUNC_XSNS_JSON_APPEND: Mhz19Show(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: Mhz19Show(0); // Mhz19Prep(); break; diff --git a/sonoff/xsns_15_mhz_softserial_obsolete.ino b/sonoff/xsns_15_mhz_softserial_obsolete.ino index 4f468b17e..be307e467 100644 --- a/sonoff/xsns_15_mhz_softserial_obsolete.ino +++ b/sonoff/xsns_15_mhz_softserial_obsolete.ino @@ -257,14 +257,14 @@ boolean Xsns15(byte function) case FUNC_XSNS_INIT: Mhz19Init(); break; - case FUNC_XSNS_PREP: + case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: // Mhz19Prep(); break; case FUNC_XSNS_JSON_APPEND: Mhz19Show(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: Mhz19Show(0); // Mhz19Prep(); break; diff --git a/sonoff/xsns_16_tsl2561.ino b/sonoff/xsns_16_tsl2561.ino index 24c9468fd..2769b9a1d 100644 --- a/sonoff/xsns_16_tsl2561.ino +++ b/sonoff/xsns_16_tsl2561.ino @@ -93,14 +93,14 @@ boolean Xsns16(byte function) switch (function) { // case FUNC_XSNS_INIT: // break; - case FUNC_XSNS_PREP: + case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: Tsl2561Detect(); break; case FUNC_XSNS_JSON_APPEND: Tsl2561Show(1); break; #ifdef USE_WEBSERVER - case FUNC_XSNS_WEB: + case FUNC_XSNS_WEB_APPEND: Tsl2561Show(0); break; #endif // USE_WEBSERVER diff --git a/sonoff/xsns_interface.ino b/sonoff/xsns_interface.ino index 7ef5d8199..c7d5c3e2f 100644 --- a/sonoff/xsns_interface.ino +++ b/sonoff/xsns_interface.ino @@ -118,10 +118,10 @@ boolean XsnsCall(byte Function) switch (Function) { case FUNC_XSNS_INIT: case FUNC_XSNS_EVERY_SECOND: - case FUNC_XSNS_PREP: + case FUNC_XSNS_PREP_BEFORE_TELEPERIOD: case FUNC_XSNS_JSON_APPEND: - case FUNC_XSNS_WEB: - case FUNC_XSNS_SAVE_STATE: + case FUNC_XSNS_WEB_APPEND: + case FUNC_XSNS_SAVE_BEFORE_RESTART: for (byte x = 0; x < xsns_present; x++) { xsns_func_ptr[x](Function); }