diff --git a/lib/MPU6050/Examples/MPU6050_DMP6/MPU6050_DMP6.ino b/lib/I2Cdevlib-MPU6050/Examples/MPU6050_DMP6/MPU6050_DMP6.ino similarity index 100% rename from lib/MPU6050/Examples/MPU6050_DMP6/MPU6050_DMP6.ino rename to lib/I2Cdevlib-MPU6050/Examples/MPU6050_DMP6/MPU6050_DMP6.ino diff --git a/lib/MPU6050/Examples/MPU6050_DMP6/Processing/MPUTeapot/MPUTeapot.pde b/lib/I2Cdevlib-MPU6050/Examples/MPU6050_DMP6/Processing/MPUTeapot/MPUTeapot.pde similarity index 100% rename from lib/MPU6050/Examples/MPU6050_DMP6/Processing/MPUTeapot/MPUTeapot.pde rename to lib/I2Cdevlib-MPU6050/Examples/MPU6050_DMP6/Processing/MPUTeapot/MPUTeapot.pde diff --git a/lib/MPU6050/Examples/MPU6050_raw/MPU6050_raw.ino b/lib/I2Cdevlib-MPU6050/Examples/MPU6050_raw/MPU6050_raw.ino similarity index 100% rename from lib/MPU6050/Examples/MPU6050_raw/MPU6050_raw.ino rename to lib/I2Cdevlib-MPU6050/Examples/MPU6050_raw/MPU6050_raw.ino diff --git a/lib/MPU6050/MPU6050.cpp b/lib/I2Cdevlib-MPU6050/MPU6050.cpp similarity index 100% rename from lib/MPU6050/MPU6050.cpp rename to lib/I2Cdevlib-MPU6050/MPU6050.cpp diff --git a/lib/MPU6050/MPU6050.h b/lib/I2Cdevlib-MPU6050/MPU6050.h similarity index 100% rename from lib/MPU6050/MPU6050.h rename to lib/I2Cdevlib-MPU6050/MPU6050.h diff --git a/lib/MPU6050/MPU6050_6Axis_MotionApps20.h b/lib/I2Cdevlib-MPU6050/MPU6050_6Axis_MotionApps20.h similarity index 100% rename from lib/MPU6050/MPU6050_6Axis_MotionApps20.h rename to lib/I2Cdevlib-MPU6050/MPU6050_6Axis_MotionApps20.h diff --git a/lib/MPU6050/MPU6050_9Axis_MotionApps41.h b/lib/I2Cdevlib-MPU6050/MPU6050_9Axis_MotionApps41.h similarity index 100% rename from lib/MPU6050/MPU6050_9Axis_MotionApps41.h rename to lib/I2Cdevlib-MPU6050/MPU6050_9Axis_MotionApps41.h diff --git a/lib/MPU6050/helper_3dmath.h b/lib/I2Cdevlib-MPU6050/helper_3dmath.h similarity index 100% rename from lib/MPU6050/helper_3dmath.h rename to lib/I2Cdevlib-MPU6050/helper_3dmath.h diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index 01108f603..a07a74af0 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -1,5 +1,17 @@ -/* 6.3.0.6 20181110 +/* 6.3.0.8 20181115 + * Stop enforcing flashmode dout. Still mandatory but this a chk for possible future flash corruption + * + * 6.3.0.7 20181111 + * Fix wifi connection errors using wifi disconnect and ESP.reset instead of ESP.restart + * Fix Sonoff Pow R2 and Sonoff S31 Serial interface hang caused by Sonoff Basic R2 driver delay implementation (and possibly core bug) + * Change command WebSend Host header field from IP address to hostname (#4331) + * Add to command WebSend option to send a direct path when command starts with a slash (#4329) + * Consolidate LTrim into Trim + * Increase log buffer size from 512 to 520 to accommodate http sensor data (#4354) + * + * 6.3.0.6 20181110 * Change GUI Configure Module by using AJAX for data fetch to cut page size (and memory use) by 40% + * In case of web page errors clear your browser cache or do Page Reload (F5 or Ctrl+R) * * 6.3.0.5 20181107 * Add code image and optional commit number to version diff --git a/sonoff/core_esp8266_timer.c b/sonoff/core_esp8266_timer.c index 478471a36..fdc7342e5 100644 --- a/sonoff/core_esp8266_timer.c +++ b/sonoff/core_esp8266_timer.c @@ -46,7 +46,7 @@ void ICACHE_RAM_ATTR timer1_isr_handler(void *para){ } } -void ICACHE_RAM_ATTR timer1_isr_init(){ +void ICACHE_RAM_ATTR timer1_isr_init(void){ ETS_FRC_TIMER1_INTR_ATTACH(timer1_isr_handler, NULL); } @@ -55,7 +55,7 @@ void timer1_attachInterrupt(timercallback userFunc) { ETS_FRC1_INTR_ENABLE(); } -void ICACHE_RAM_ATTR timer1_detachInterrupt() { +void ICACHE_RAM_ATTR timer1_detachInterrupt(void) { timer1_user_cb = 0; TEIE &= ~TEIE1;//edge int disable ETS_FRC1_INTR_DISABLE(); @@ -71,7 +71,7 @@ void ICACHE_RAM_ATTR timer1_write(uint32_t ticks){ if ((T1C & (1 << TCIT)) == 0) TEIE |= TEIE1;//edge int enable } -void ICACHE_RAM_ATTR timer1_disable(){ +void ICACHE_RAM_ATTR timer1_disable(void){ T1C = 0; T1I = 0; } @@ -92,7 +92,7 @@ void ICACHE_RAM_ATTR timer0_isr_handler(void* para){ } } -void timer0_isr_init(){ +void timer0_isr_init(void){ ETS_CCOMPARE0_INTR_ATTACH(timer0_isr_handler, NULL); } @@ -101,7 +101,7 @@ void timer0_attachInterrupt(timercallback userFunc) { ETS_CCOMPARE0_ENABLE(); } -void ICACHE_RAM_ATTR timer0_detachInterrupt() { +void ICACHE_RAM_ATTR timer0_detachInterrupt(void) { timer0_user_cb = NULL; ETS_CCOMPARE0_DISABLE(); } diff --git a/sonoff/core_esp8266_wiring_digital.c b/sonoff/core_esp8266_wiring_digital.c index 06323c1ce..b51a85aad 100644 --- a/sonoff/core_esp8266_wiring_digital.c +++ b/sonoff/core_esp8266_wiring_digital.c @@ -188,7 +188,7 @@ extern void ICACHE_RAM_ATTR __detachInterrupt(uint8_t pin) { } } -void initPins() { +void initPins(void) { //Disable UART interrupts system_set_os_print(0); U0IE = 0; diff --git a/sonoff/core_esp8266_wiring_pwm.c b/sonoff/core_esp8266_wiring_pwm.c index 0ef8cb67f..92d73a4b7 100644 --- a/sonoff/core_esp8266_wiring_pwm.c +++ b/sonoff/core_esp8266_wiring_pwm.c @@ -84,7 +84,7 @@ uint32_t pwm_get_mask(uint16_t value) return mask; } -void prep_pwm_steps() +void prep_pwm_steps(void) { if(pwm_mask == 0) { return; @@ -123,7 +123,7 @@ void prep_pwm_steps() pwm_steps_changed = 1; } -void ICACHE_RAM_ATTR pwm_timer_isr() //103-138 +void ICACHE_RAM_ATTR pwm_timer_isr(void) //103-138 { struct pwm_isr_table *table = &(_pwm_isr_data.tables[_pwm_isr_data.active]); static uint8_t current_step = 0; @@ -160,7 +160,7 @@ void ICACHE_RAM_ATTR pwm_timer_isr() //103-138 TEIE |= TEIE1;//13 } -void pwm_start_timer() +void pwm_start_timer(void) { timer1_disable(); ETS_FRC_TIMER1_INTR_ATTACH(NULL, NULL); diff --git a/sonoff/settings.h b/sonoff/settings.h index cde1b2283..124314f0a 100644 --- a/sonoff/settings.h +++ b/sonoff/settings.h @@ -68,7 +68,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t time_append_timezone : 1; // bit 2 (v6.2.1.2) uint32_t gui_hostname_ip : 1; // bit 3 (v6.2.1.20) uint32_t tuya_apply_o20 : 1; // bit 4 (v6.3.0.4) - uint32_t spare05 : 1; + uint32_t hass_short_discovery_msg : 1; // bit 5 (vTBD) uint32_t spare06 : 1; uint32_t spare07 : 1; uint32_t spare08 : 1; diff --git a/sonoff/settings.ino b/sonoff/settings.ino index a38e2113e..38e9bb3f3 100644 --- a/sonoff/settings.ino +++ b/sonoff/settings.ino @@ -69,7 +69,7 @@ uint32_t rtc_settings_crc = 0; -uint32_t GetRtcSettingsCrc() +uint32_t GetRtcSettingsCrc(void) { uint32_t crc = 0; uint8_t *bytes = (uint8_t*)&RtcSettings; @@ -80,7 +80,7 @@ uint32_t GetRtcSettingsCrc() return crc; } -void RtcSettingsSave() +void RtcSettingsSave(void) { if (GetRtcSettingsCrc() != rtc_settings_crc) { RtcSettings.valid = RTC_MEM_VALID; @@ -89,7 +89,7 @@ void RtcSettingsSave() } } -void RtcSettingsLoad() +void RtcSettingsLoad(void) { ESP.rtcUserMemoryRead(100, (uint32_t*)&RtcSettings, sizeof(RTCMEM)); // 0x290 if (RtcSettings.valid != RTC_MEM_VALID) { @@ -106,7 +106,7 @@ void RtcSettingsLoad() rtc_settings_crc = GetRtcSettingsCrc(); } -boolean RtcSettingsValid() +boolean RtcSettingsValid(void) { return (RTC_MEM_VALID == RtcSettings.valid); } @@ -115,7 +115,7 @@ boolean RtcSettingsValid() uint32_t rtc_reboot_crc = 0; -uint32_t GetRtcRebootCrc() +uint32_t GetRtcRebootCrc(void) { uint32_t crc = 0; uint8_t *bytes = (uint8_t*)&RtcReboot; @@ -126,7 +126,7 @@ uint32_t GetRtcRebootCrc() return crc; } -void RtcRebootSave() +void RtcRebootSave(void) { if (GetRtcRebootCrc() != rtc_reboot_crc) { RtcReboot.valid = RTC_MEM_VALID; @@ -135,7 +135,7 @@ void RtcRebootSave() } } -void RtcRebootLoad() +void RtcRebootLoad(void) { ESP.rtcUserMemoryRead(100 - sizeof(RTCRBT), (uint32_t*)&RtcReboot, sizeof(RTCRBT)); // 0x280 if (RtcReboot.valid != RTC_MEM_VALID) { @@ -147,7 +147,7 @@ void RtcRebootLoad() rtc_reboot_crc = GetRtcRebootCrc(); } -boolean RtcRebootValid() +boolean RtcRebootValid(void) { return (RTC_MEM_VALID == RtcReboot.valid); } @@ -179,7 +179,7 @@ uint8_t *settings_buffer = NULL; /* * Based on cores/esp8266/Updater.cpp */ -void SetFlashModeDout() +void SetFlashModeDout(void) { uint8_t *_buffer; uint32_t address; @@ -198,7 +198,7 @@ void SetFlashModeDout() delete[] _buffer; } -void SettingsBufferFree() +void SettingsBufferFree(void) { if (settings_buffer != NULL) { free(settings_buffer); @@ -206,7 +206,7 @@ void SettingsBufferFree() } } -bool SettingsBufferAlloc() +bool SettingsBufferAlloc(void) { SettingsBufferFree(); if (!(settings_buffer = (uint8_t *)malloc(sizeof(Settings)))) { @@ -216,7 +216,7 @@ bool SettingsBufferAlloc() return true; } -uint16_t GetSettingsCrc() +uint16_t GetSettingsCrc(void) { uint16_t crc = 0; uint8_t *bytes = (uint8_t*)&Settings; @@ -227,7 +227,7 @@ uint16_t GetSettingsCrc() return crc; } -void SettingsSaveAll() +void SettingsSaveAll(void) { if (Settings.flag.save_state) { Settings.power = power; @@ -242,7 +242,7 @@ void SettingsSaveAll() * Config Save - Save parameters to Flash ONLY if any parameter has changed \*********************************************************************************************/ -uint32_t GetSettingsAddress() +uint32_t GetSettingsAddress(void) { return settings_location * SPI_FLASH_SEC_SIZE; } @@ -294,7 +294,7 @@ void SettingsSave(byte rotate) RtcSettingsSave(); } -void SettingsLoad() +void SettingsLoad(void) { /* Load configuration from eeprom or one of 7 slots below if first load does not stop_flash_rotate */ @@ -377,7 +377,7 @@ bool SettingsEraseConfig(void) { return true; } -void SettingsSdkErase() +void SettingsSdkErase(void) { WiFi.disconnect(true); // Delete SDK wifi config SettingsErase(1); @@ -387,7 +387,7 @@ void SettingsSdkErase() /********************************************************************************************/ -void SettingsDefault() +void SettingsDefault(void) { AddLog_P(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG D_USE_DEFAULTS)); SettingsDefaultSet1(); @@ -395,7 +395,7 @@ void SettingsDefault() SettingsSave(2); } -void SettingsDefaultSet1() +void SettingsDefaultSet1(void) { memset(&Settings, 0x00, sizeof(SYSCFG)); @@ -407,7 +407,7 @@ void SettingsDefaultSet1() // Settings.cfg_crc = 0; } -void SettingsDefaultSet2() +void SettingsDefaultSet2(void) { memset((char*)&Settings +16, 0x00, sizeof(SYSCFG) -16); @@ -641,7 +641,7 @@ void SettingsDefaultSet2() /********************************************************************************************/ -void SettingsDefaultSet_5_8_1() +void SettingsDefaultSet_5_8_1(void) { // Settings.flag.ws_clock_reverse = 0; Settings.ws_width[WS_SECOND] = 1; @@ -658,7 +658,7 @@ void SettingsDefaultSet_5_8_1() Settings.ws_color[WS_HOUR][WS_BLUE] = 0; } -void SettingsDefaultSet_5_10_1() +void SettingsDefaultSet_5_10_1(void) { Settings.display_model = 0; Settings.display_mode = 1; @@ -680,7 +680,7 @@ void SettingsDefaultSet_5_10_1() Settings.display_address[7] = MTX_ADDRESS8; } -void SettingsResetStd() +void SettingsResetStd(void) { Settings.tflag[0].hemis = TIME_STD_HEMISPHERE; Settings.tflag[0].week = TIME_STD_WEEK; @@ -690,7 +690,7 @@ void SettingsResetStd() Settings.toffset[0] = TIME_STD_OFFSET; } -void SettingsResetDst() +void SettingsResetDst(void) { Settings.tflag[1].hemis = TIME_DST_HEMISPHERE; Settings.tflag[1].week = TIME_DST_WEEK; @@ -700,7 +700,7 @@ void SettingsResetDst() Settings.toffset[1] = TIME_DST_OFFSET; } -void SettingsDefaultSet_5_13_1c() +void SettingsDefaultSet_5_13_1c(void) { SettingsResetStd(); SettingsResetDst(); @@ -708,7 +708,7 @@ void SettingsDefaultSet_5_13_1c() /********************************************************************************************/ -void SettingsDelta() +void SettingsDelta(void) { if (Settings.version != VERSION) { // Fix version dependent changes diff --git a/sonoff/sonoff.h b/sonoff/sonoff.h index 1050557c0..d63ce9d35 100644 --- a/sonoff/sonoff.h +++ b/sonoff/sonoff.h @@ -119,7 +119,7 @@ typedef unsigned long power_t; // Power (Relay) type #define INPUT_BUFFER_SIZE 520 // Max number of characters in (serial and http) command buffer #define CMDSZ 24 // Max number of characters in command #define TOPSZ 100 // Max number of characters in topic string -#define LOGSZ 512 // Max number of characters in log +#define LOGSZ 520 // Max number of characters in log #define MIN_MESSZ 893 // Min number of characters in MQTT message #define SENSOR_MAX_MISS 5 // Max number of missed sensor reads before deciding it's offline diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index e92536a1b..4263ffa48 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -378,7 +378,7 @@ void SetLedPower(uint8_t state) digitalWrite(pin[GPIO_LED1], (bitRead(led_inverted, 0)) ? !state : state); } -uint8_t GetFanspeed() +uint8_t GetFanspeed(void) { uint8_t fanspeed = 0; @@ -531,7 +531,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len) char *blcommand = strtok(dataBuf, ";"); while ((blcommand != NULL) && (backlog_index != bl_pointer)) { while(true) { - blcommand = LTrim(blcommand); + blcommand = Trim(blcommand); if (!strncasecmp_P(blcommand, PSTR(D_CMND_BACKLOG), strlen(D_CMND_BACKLOG))) { blcommand += strlen(D_CMND_BACKLOG); // Skip unnecessary command Backlog } else { @@ -1224,9 +1224,9 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len) if (5 == tpos) { Settings.tflag[ts].hour = (value < 0) ? 0 : (value > 23) ? 23 : value; } if (6 == tpos) { Settings.toffset[ts] = (value < -900) ? -900 : (value > 900) ? 900 : value; } } - p = LTrim(p); // Skip spaces + p = Trim(p); // Skip spaces if (tpos && (*p == ',')) { p++; } // Skip separator - p = LTrim(p); // Skip spaces + p = Trim(p); // Skip spaces q = p; // Reset any value entered flag value = strtol(p, &p, 10); tpos++; // Next parameter @@ -1426,7 +1426,7 @@ void ExecuteCommandPower(byte device, byte state, int source) if (publish_power) MqttPublishPowerState(device); } -void StopAllPowerBlink() +void StopAllPowerBlink(void) { power_t mask; @@ -1571,7 +1571,7 @@ void PublishStatus(uint8_t payload) } -void MqttShowPWMState() +void MqttShowPWMState(void) { snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s\"" D_CMND_PWM "\":{"), mqtt_data); bool first = true; @@ -1584,7 +1584,7 @@ void MqttShowPWMState() snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s}"), mqtt_data); } -void MqttShowState() +void MqttShowState(void) { char stemp1[33]; @@ -1615,7 +1615,7 @@ void MqttShowState() mqtt_data, Settings.sta_active +1, Settings.sta_ssid[Settings.sta_active], WiFi.BSSIDstr().c_str(), WiFi.channel(), WifiGetRssiAsQuality(WiFi.RSSI())); } -boolean MqttShowSensor() +boolean MqttShowSensor(void) { snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s{\"" D_JSON_TIME "\":\"%s\""), mqtt_data, GetDateAndTime(DT_LOCAL).c_str()); int json_data_start = strlen(mqtt_data); @@ -1645,7 +1645,7 @@ boolean MqttShowSensor() /********************************************************************************************/ -void PerformEverySecond() +void PerformEverySecond(void) { uptime++; @@ -1718,7 +1718,7 @@ void PerformEverySecond() * Button handler with single press only or multi-press and hold on all buttons \*********************************************************************************************/ -void ButtonHandler() +void ButtonHandler(void) { uint8_t button = NOT_PRESSED; uint8_t button_present = 0; @@ -1956,7 +1956,7 @@ void SwitchHandler(byte mode) * Every 0.1 second \*-------------------------------------------------------------------------------------------*/ -void Every100mSeconds() +void Every100mSeconds(void) { // As the max amount of sleep = 250 mSec this loop will shift in time... power_t power_now; @@ -2005,7 +2005,7 @@ void Every100mSeconds() * Every 0.25 second \*-------------------------------------------------------------------------------------------*/ -void Every250mSeconds() +void Every250mSeconds(void) { // As the max amount of sleep = 250 mSec this loop should always be taken... @@ -2117,7 +2117,7 @@ void Every250mSeconds() if (90 == ota_state_flag) { // Allow MQTT to reconnect ota_state_flag = 0; if (ota_result) { - SetFlashModeDout(); // Force DOUT for both ESP8266 and ESP8285 +// SetFlashModeDout(); // Force DOUT for both ESP8266 and ESP8285 snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR(D_JSON_SUCCESSFUL ". " D_JSON_RESTARTING)); } else { snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR(D_JSON_FAILED " %s"), ESPhttpUpdate.getLastErrorString().c_str()); @@ -2201,7 +2201,7 @@ void Every250mSeconds() bool arduino_ota_triggered = false; uint16_t arduino_ota_progress_dot_count = 0; -void ArduinoOTAInit() +void ArduinoOTAInit(void) { ArduinoOTA.setPort(8266); ArduinoOTA.setHostname(Settings.hostname); @@ -2270,7 +2270,7 @@ void ArduinoOTAInit() /********************************************************************************************/ -void SerialInput() +void SerialInput(void) { while (Serial.available()) { yield(); @@ -2398,7 +2398,7 @@ void GpioSwitchPinMode(uint8_t index) } } -void GpioInit() +void GpioInit(void) { uint8_t mpin; uint8_t key_no_pullup = 0; @@ -2599,7 +2599,7 @@ extern "C" { extern struct rst_info resetInfo; } -void setup() +void setup(void) { byte idx; @@ -2751,7 +2751,7 @@ void setup() XsnsCall(FUNC_INIT); } -void loop() +void loop(void) { XdrvCall(FUNC_LOOP); diff --git a/sonoff/sonoff_version.h b/sonoff/sonoff_version.h index 7f25e0ebc..9ddcef51c 100644 --- a/sonoff/sonoff_version.h +++ b/sonoff/sonoff_version.h @@ -20,7 +20,7 @@ #ifndef _SONOFF_VERSION_H_ #define _SONOFF_VERSION_H_ -#define VERSION 0x06030006 +#define VERSION 0x06030008 #define D_PROGRAMNAME "Sonoff-Tasmota" #define D_AUTHOR "Theo Arends" diff --git a/sonoff/support.ino b/sonoff/support.ino index 68c091f29..02e8ad74f 100644 --- a/sonoff/support.ino +++ b/sonoff/support.ino @@ -39,7 +39,7 @@ byte oswatch_blocked_loop = 0; bool knx_started = false; #endif // USE_KNX -void OsWatchTicker() +void OsWatchTicker(void) { unsigned long t = millis(); unsigned long last_run = abs(t - oswatch_last_loop_time); @@ -57,7 +57,7 @@ void OsWatchTicker() } } -void OsWatchInit() +void OsWatchInit(void) { oswatch_blocked_loop = RtcSettings.oswatch_blocked_loop; RtcSettings.oswatch_blocked_loop = 0; @@ -65,13 +65,13 @@ void OsWatchInit() tickerOSWatch.attach_ms(((OSWATCH_RESET_TIME / 3) * 1000), OsWatchTicker); } -void OsWatchLoop() +void OsWatchLoop(void) { oswatch_last_loop_time = millis(); // while(1) delay(1000); // this will trigger the os watch } -String GetResetReason() +String GetResetReason(void) { char buff[32]; if (oswatch_blocked_loop) { @@ -82,7 +82,7 @@ String GetResetReason() } } -boolean OsWatchBlockedLoop() +boolean OsWatchBlockedLoop(void) { return oswatch_blocked_loop; } @@ -290,6 +290,7 @@ char* UpperCase_P(char* dest, const char* source) return dest; } +/* char* LTrim(char* p) { while ((*p != '\0') && (isblank(*p))) { @@ -308,14 +309,13 @@ char* RTrim(char* p) *q = '\0'; return p; } +*/ char* Trim(char* p) { - if (*p == '\0') { return p; } - while (isspace(*p)) { p++; } // Trim leading spaces - if (*p == '\0') { return p; } + while ((*p != '\0') && isblank(*p)) { p++; } // Trim leading spaces char* q = p + strlen(p) -1; - while (isspace(*q) && q >= p) { q--; } // Trim trailing spaces + while ((q >= p) && isblank(*q)) { q--; } // Trim trailing spaces q++; *q = '\0'; return p; @@ -470,7 +470,7 @@ float ConvertTemp(float c) return result; } -char TempUnit() +char TempUnit(void) { return (Settings.flag.temperature_conversion) ? 'F' : 'C'; } @@ -485,7 +485,7 @@ float ConvertPressure(float p) return result; } -String PressureUnit() +String PressureUnit(void) { return (Settings.flag.pressure_conversion) ? String(D_UNIT_MILLIMETER_MERCURY) : String(D_UNIT_PRESSURE); } @@ -497,7 +497,7 @@ void SetGlobalValues(float temperature, float humidity) global_humidity = humidity; } -void ResetGlobalValues() +void ResetGlobalValues(void) { if ((uptime - global_update) > GLOBAL_VALUES_VALID) { // Reset after 5 minutes global_update = 0; @@ -712,7 +712,7 @@ void SetSerialBaudrate(int baudrate) } } -void ClaimSerial() +void ClaimSerial(void) { serial_local = 1; AddLog_P(LOG_LEVEL_INFO, PSTR("SNS: Hardware Serial")); @@ -765,6 +765,15 @@ uint8_t ValidGPIO(uint8_t pin, uint8_t gpio) return result; } +void AppDelay(void) +{ + if (APP_BAUDRATE == baudrate) { // When baudrate too low it will fail on Sonoff Pow R2 and S31 serial interface initialization + if (global_state.wifi_down) { + delay(DRIVER_BOOT_DELAY); + } + } +} + /*********************************************************************************************\ * Sleep aware time scheduler functions borrowed from ESPEasy \*********************************************************************************************/ @@ -832,7 +841,7 @@ void SetNextTimeInterval(unsigned long& timer, const unsigned long step) * Fill feature list \*********************************************************************************************/ -void GetFeatures() +void GetFeatures(void) { feature_drv1 = 0x00000000; // xdrv_01_mqtt.ino, xdrv_01_light.ino, xdrv_04_snfbridge.ino @@ -1199,7 +1208,7 @@ int WifiGetRssiAsQuality(int rssi) return quality; } -boolean WifiConfigCounter() +boolean WifiConfigCounter(void) { if (wifi_config_counter) { wifi_config_counter = WIFI_CONFIG_SEC; @@ -1303,7 +1312,7 @@ void WifiConfig(uint8_t type) } } -void WiFiSetSleepMode() +void WiFiSetSleepMode(void) { /* Excerpt from the esp8266 non os sdk api reference (v2.2.1): * Sets sleep type for power saving. Set WIFI_NONE_SLEEP to disable power saving. @@ -1380,7 +1389,7 @@ void WifiSetState(uint8_t state) global_state.wifi_down = state ^1; } -void WifiCheckIp() +void WifiCheckIp(void) { if ((WL_CONNECTED == WiFi.status()) && (static_cast(WiFi.localIP()) != 0)) { WifiSetState(1); @@ -1567,7 +1576,7 @@ void WifiCheck(uint8_t param) } } -int WifiState() +int WifiState(void) { int state = -1; @@ -1576,19 +1585,19 @@ int WifiState() return state; } -void WifiConnect() +void WifiConnect(void) { WifiSetState(0); - WiFi.persistent(false); // Solve possible wifi init errors + WiFi.persistent(false); // Solve possible wifi init errors wifi_status = 0; wifi_retry_init = WIFI_RETRY_OFFSET_SEC + ((ESP.getChipId() & 0xF) * 2); wifi_retry = wifi_retry_init; wifi_counter = 1; } -/* // Enable from 6.0.0a until 6.1.0a - disabled due to possible cause of bad wifi connect on core 2.3.0 -void WifiDisconnect() +// Re-enabled from 6.3.0.7 with ESP.restart replaced by ESP.reset +void WifiDisconnect(void) { // Courtesy of EspEasy WiFi.persistent(true); // use SDK storage of SSID/WPA parameters @@ -1598,20 +1607,21 @@ void WifiDisconnect() WiFi.persistent(false); // Do not use SDK storage of SSID/WPA parameters } -void EspRestart() +void EspRestart(void) { - // This results in exception 3 on restarts delay(100); // Allow time for message xfer - disabled v6.1.0b WifiDisconnect(); +// ESP.restart(); // This results in exception 3 on restarts on core 2.3.0 + ESP.reset(); +} + +/* +void EspRestart(void) +{ ESP.restart(); } */ -void EspRestart() -{ - ESP.restart(); -} - /*********************************************************************************************\ * Basic I2C routines \*********************************************************************************************/ @@ -1855,7 +1865,7 @@ int32_t time_timezone = 0; uint8_t midnight_now = 0; uint8_t ntp_sync_minute = 0; -String GetBuildDateAndTime() +String GetBuildDateAndTime(void) { // "2017-03-07T11:08:02" - ISO8601:2004 char bdt[21]; @@ -1884,7 +1894,7 @@ String GetBuildDateAndTime() return String(bdt); // 2017-03-07T11:08:02 } -String GetTimeZone() +String GetTimeZone(void) { char tz[7]; @@ -1958,7 +1968,7 @@ String GetTime(int type) return String(stime); // Thu Nov 01 11:41:02 2018 } -String GetUptime() +String GetUptime(void) { char dt[16]; @@ -1980,7 +1990,7 @@ String GetUptime() return String(dt); // 128T14:35:44 } -uint32_t GetMinutesUptime() +uint32_t GetMinutesUptime(void) { TIME_T ut; @@ -1993,7 +2003,7 @@ uint32_t GetMinutesUptime() return (ut.days *1440) + (ut.hour *60) + ut.minute; } -uint32_t GetMinutesPastMidnight() +uint32_t GetMinutesPastMidnight(void) { uint32_t minutes = 0; @@ -2125,24 +2135,24 @@ uint32_t RuleToTime(TimeRule r, int yr) return t; } -uint32_t LocalTime() +uint32_t LocalTime(void) { return local_time; } -uint32_t Midnight() +uint32_t Midnight(void) { return midnight; } -boolean MidnightNow() +boolean MidnightNow(void) { boolean mnflg = midnight_now; if (mnflg) midnight_now = 0; return mnflg; } -void RtcSecond() +void RtcSecond(void) { TIME_T tmpTime; @@ -2210,7 +2220,7 @@ void RtcSecond() RtcTime.year += 1970; } -void RtcInit() +void RtcInit(void) { sntp_setservername(0, Settings.ntp_server[0]); sntp_setservername(1, Settings.ntp_server[1]); @@ -2265,7 +2275,7 @@ void GetLog(byte idx, char** entry_pp, size_t* len_p) } #endif // USE_WEBSERVER -void Syslog() +void Syslog(void) { // Destroys log_data char syslog_preamble[64]; // Hostname + Id diff --git a/sonoff/xdrv_01_webserver.ino b/sonoff/xdrv_01_webserver.ino index 37d63d566..a55fdd1fa 100644 --- a/sonoff/xdrv_01_webserver.ino +++ b/sonoff/xdrv_01_webserver.ino @@ -43,12 +43,13 @@ const char HTTP_HEAD[] PROGMEM = "{h} - {v}" ""; + +const char HTTP_SCRIPT_ROOT[] PROGMEM = "function la(p){" "var a='';" "if(la.arguments.length==1){" @@ -84,44 +84,17 @@ const char HTTP_HEAD[] PROGMEM = "function lc(p){" "la('?t='+p);" // ?t related to WebGetArg("t", tmp, sizeof(tmp)); "}"; - -const char HTTP_HEAD_RELOAD[] PROGMEM = - "setTimeout(function(){location.href='.';},4000);"; -const char HTTP_HEAD_STYLE[] PROGMEM = - "" +const char HTTP_SCRIPT_WIFI[] PROGMEM = + "function c(l){" + "eb('s1').value=l.innerText||l.textContent;" + "eb('p1').focus();" + "}"; - "" +const char HTTP_SCRIPT_RELOAD[] PROGMEM = + "setTimeout(function(){location.href='.';},5000);" + ""; - "" - "" - "
" -#ifdef BE_MINIMAL - "

" D_MINIMAL_FIRMWARE_PLEASE_UPGRADE "

" -#endif - "
" -#ifdef LANGUAGE_MODULE_NAME - "

" D_MODULE " {ha

" -#else - "

{ha " D_MODULE "

" -#endif - "

{h}

{j}
"; const char HTTP_SCRIPT_CONSOL[] PROGMEM = "var sn=0;" // Scroll position "var id=0;" // Get most of weblog initially @@ -158,21 +131,22 @@ const char HTTP_SCRIPT_CONSOL[] PROGMEM = "return false;" "}" ""; + const char HTTP_SCRIPT_MODULE1[] PROGMEM = "var os;" - "function sk(s,g){" // s = value, g = id and name + "function sk(s,g){" // s = value, g = id and name "var o=os.replace(\"value='\"+s+\"'\",\"selected value='\"+s+\"'\");" "eb('g'+g).innerHTML=o;" "}" "function sl(){" - "if(x!=null){x.abort();}" // Abort any request pending + "if(x!=null){x.abort();}" // Abort any request pending "x=new XMLHttpRequest();" "x.onreadystatechange=function(){" "if(x.readyState==4&&x.status==200){" "var i,o=x.responseText.replace(/}1/g,\"