5.5.1b
 * Extent max number of WS2812 pixels from 256 to 512 (#667)
 * Add OTA handling if server responds with no update available (#695)
 * Removed undocumented command FlashMode (#696)
 * Fix compile time error message due to increased message buffer size (#703)
This commit is contained in:
Theo Arends 2017-08-08 14:50:21 +02:00 committed by GitHub
parent c88080b2bd
commit eab7250102
4 changed files with 20 additions and 35 deletions

View File

@ -1,5 +1,8 @@
/* 5.5.1a /* 5.5.1b
* Extent max number of WS2812 pixels from 256 to 512 (#667) * Extent max number of WS2812 pixels from 256 to 512 (#667)
* Add OTA handling if server responds with no update available (#695)
* Removed undocumented command FlashMode (#696)
* Fix compile time error message due to increased message buffer size (#703)
* *
* 5.5.1 20170805 * 5.5.1 20170805
* Fix Sonoff Rf Bridge issues * Fix Sonoff Rf Bridge issues
@ -894,4 +897,4 @@
* 1.0.5 20160310 * 1.0.5 20160310
* Initial public release * Initial public release
* Show debug info by selecting option from IDE Tools Debug port: Serial * Show debug info by selecting option from IDE Tools Debug port: Serial
*/ */

View File

@ -141,33 +141,23 @@ uint32_t _cfgLocation = CFG_LOCATION;
/* /*
* Based on cores/esp8266/Updater.cpp * Based on cores/esp8266/Updater.cpp
*/ */
void setFlashMode(byte option, byte mode) void setFlashModeDout()
{ {
char log[LOGSZ];
uint8_t *_buffer; uint8_t *_buffer;
uint32_t address; uint32_t address;
// option 0 - Use absolute address 0 eboot_command ebcmd;
// option 1 - Use OTA/Upgrade relative address eboot_command_read(&ebcmd);
address = ebcmd.args[0];
if (option) {
eboot_command ebcmd;
eboot_command_read(&ebcmd);
address = ebcmd.args[0];
} else {
address = 0;
}
_buffer = new uint8_t[FLASH_SECTOR_SIZE]; _buffer = new uint8_t[FLASH_SECTOR_SIZE];
if (SPI_FLASH_RESULT_OK == spi_flash_read(address, (uint32_t*)_buffer, FLASH_SECTOR_SIZE)) { if (SPI_FLASH_RESULT_OK == spi_flash_read(address, (uint32_t*)_buffer, FLASH_SECTOR_SIZE)) {
if (_buffer[2] != mode) { if (_buffer[2] != 3) { // DOUT
_buffer[2] = mode &3; _buffer[2] = 3;
noInterrupts(); noInterrupts();
if (SPI_FLASH_RESULT_OK == spi_flash_erase_sector(address / FLASH_SECTOR_SIZE)) { if (SPI_FLASH_RESULT_OK == spi_flash_erase_sector(address / FLASH_SECTOR_SIZE)) {
spi_flash_write(address, (uint32_t*)_buffer, FLASH_SECTOR_SIZE); spi_flash_write(address, (uint32_t*)_buffer, FLASH_SECTOR_SIZE);
} }
interrupts(); interrupts();
snprintf_P(log, sizeof(log), PSTR("FLSH: Set Flash Mode to %d"), (option) ? mode : ESP.getFlashChipMode());
addLog(LOG_LEVEL_DEBUG, log);
} }
} }
delete[] _buffer; delete[] _buffer;
@ -729,4 +719,4 @@ void CFG_Delta()
} }
} }

View File

@ -25,7 +25,7 @@
- Select IDE Tools - Flash Size: "1M (no SPIFFS)" - Select IDE Tools - Flash Size: "1M (no SPIFFS)"
====================================================*/ ====================================================*/
#define VERSION 0x05050101 // 5.5.1a #define VERSION 0x05050102 // 5.5.1b
enum log_t {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE, LOG_LEVEL_ALL}; enum log_t {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE, LOG_LEVEL_ALL};
enum week_t {Last, First, Second, Third, Fourth}; enum week_t {Last, First, Second, Third, Fourth};
@ -1282,14 +1282,6 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
} }
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Sleep\":\"%d%s (%d%s)\"}"), sleep, (sysCfg.flag.value_units) ? " mS" : "", sysCfg.sleep, (sysCfg.flag.value_units) ? " mS" : ""); snprintf_P(svalue, sizeof(svalue), PSTR("{\"Sleep\":\"%d%s (%d%s)\"}"), sleep, (sysCfg.flag.value_units) ? " mS" : "", sysCfg.sleep, (sysCfg.flag.value_units) ? " mS" : "");
} }
else if (!strcmp_P(type,PSTR("FLASHMODE"))) { // 0 = QIO, 1 = QOUT, 2 = DIO, 3 = DOUT
if ((payload >= 0) && (payload <= 3)) {
if (ESP.getFlashChipMode() != payload) {
setFlashMode(0, payload &3);
}
}
snprintf_P(svalue, sizeof(svalue), PSTR("{\"FlashMode\":%d}"), ESP.getFlashChipMode());
}
else if (!strcmp_P(type,PSTR("UPGRADE")) || !strcmp_P(type,PSTR("UPLOAD"))) { else if (!strcmp_P(type,PSTR("UPGRADE")) || !strcmp_P(type,PSTR("UPLOAD"))) {
// Check if the payload is numerically 1, and had no trailing chars. // Check if the payload is numerically 1, and had no trailing chars.
// e.g. "1foo" or "1.2.3" could fool us. // e.g. "1foo" or "1.2.3" could fool us.
@ -2388,21 +2380,21 @@ void stateloop()
if (otaretry) { if (otaretry) {
// snprintf_P(log, sizeof(log), PSTR("OTA: Attempt %d"), OTA_ATTEMPTS - otaretry); // snprintf_P(log, sizeof(log), PSTR("OTA: Attempt %d"), OTA_ATTEMPTS - otaretry);
// addLog(LOG_LEVEL_INFO, log); // addLog(LOG_LEVEL_INFO, log);
otaok = (HTTP_UPDATE_OK == ESPhttpUpdate.update(sysCfg.otaUrl)); otaok = (HTTP_UPDATE_FAILED != ESPhttpUpdate.update(sysCfg.otaUrl));
if (!otaok) { if (!otaok) {
otaflag = 2; otaflag = 2;
} }
} }
} }
if (90 == otaflag) { // Allow MQTT to reconnect if (90 == otaflag) { // Allow MQTT to reconnect
otaflag = 0; otaflag = 0;
if (otaok) { if (otaok) {
setFlashMode(1, 3); // DOUT for both ESP8266 and ESP8285 setFlashModeDout(); // Force DOUT for both ESP8266 and ESP8285
snprintf_P(svalue, sizeof(svalue), PSTR("Successful. Restarting")); snprintf_P(svalue, sizeof(svalue), PSTR("Successful. Restarting"));
} else { } else {
snprintf_P(svalue, sizeof(svalue), PSTR("Failed %s"), ESPhttpUpdate.getLastErrorString().c_str()); snprintf_P(svalue, sizeof(svalue), PSTR("Failed %s"), ESPhttpUpdate.getLastErrorString().c_str());
} }
restartflag = 2; // Restart anyway to keep memory clean webserver restartflag = 2; // Restart anyway to keep memory clean webserver
mqtt_publish_topic_P(1, PSTR("UPGRADE"), svalue); mqtt_publish_topic_P(1, PSTR("UPGRADE"), svalue);
} }
} }
@ -2876,4 +2868,4 @@ void loop()
// yield(); // yield == delay(0), delay contains yield, auto yield in loop // yield(); // yield == delay(0), delay contains yield, auto yield in loop
delay(sleep); // https://github.com/esp8266/Arduino/issues/2021 delay(sleep); // https://github.com/esp8266/Arduino/issues/2021
} }

View File

@ -1245,7 +1245,7 @@ void handleUploadLoop()
_uploaderror = 4; _uploaderror = 4;
return; return;
} }
upload.buf[2] = 3; // Force DOUT - ESP8285 upload.buf[2] = 3; // Force DOUT - ESP8285
} }
} }
if (_uploadfiletype) { // config if (_uploadfiletype) { // config
@ -1615,4 +1615,4 @@ boolean isIp(String str)
} }
return true; return true;
} }
#endif // USE_WEBSERVER #endif // USE_WEBSERVER