mirror of https://github.com/arendst/Tasmota.git
v4.2.0
4.2.0 20170424 * Prepare for SPIFFS removal by moving settings to EEPROM area * Fix compilation error when webserver is disabled (#378)
This commit is contained in:
parent
f60fab8f64
commit
8dd291b5c7
|
@ -1,7 +1,7 @@
|
|||
## Sonoff-Tasmota
|
||||
Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing 'Over the Air' or OTA firmware updates using Arduino IDE.
|
||||
|
||||
Current version is **4.1.3** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino) for change information.
|
||||
Current version is **4.2.0** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino) for change information.
|
||||
|
||||
- This version provides all (Sonoff) modules in one file and starts up with Sonoff Basic.
|
||||
- Once uploaded select module using the configuration webpage or the commands ```Modules``` and ```Module```.
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
/* 4.1.3 20170410
|
||||
/* 4.2.0 20170424
|
||||
* Prepare for SPIFFS removal by moving settings to EEPROM area
|
||||
* Fix compilation error when webserver is disabled (#378)
|
||||
*
|
||||
* 4.1.3 20170410
|
||||
* Add user configuarble GPIO to module S20 Socket and Slampher
|
||||
* Add support for Sonoff SC (#112)
|
||||
* Set PWM frequency from 1000Hz to 910Hz as used on iTead Sonoff Led firmware (#122)
|
||||
|
|
|
@ -103,7 +103,7 @@ void RTC_Dump()
|
|||
#endif // DEBUG_THEO
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Config - Flash or Spiffs
|
||||
* Config - Flash
|
||||
\*********************************************************************************************/
|
||||
|
||||
extern "C" {
|
||||
|
@ -111,15 +111,18 @@ extern "C" {
|
|||
}
|
||||
#include "eboot_command.h"
|
||||
|
||||
#define SPIFFS_START ((uint32_t)&_SPIFFS_start - 0x40200000) / SPI_FLASH_SEC_SIZE
|
||||
//extern "C" uint32_t _SPIFFS_start;
|
||||
extern "C" uint32_t _SPIFFS_end;
|
||||
|
||||
#define SPIFFS_END ((uint32_t)&_SPIFFS_end - 0x40200000) / SPI_FLASH_SEC_SIZE
|
||||
|
||||
// Version 3.x config
|
||||
#define SPIFFS_CONFIG "/cfg.ini"
|
||||
#define CFG_LOCATION SPIFFS_END - 4
|
||||
#define CFG_LOCATION_3 SPIFFS_END - 4
|
||||
|
||||
// Version 4.2 config = eeprom area
|
||||
#define CFG_LOCATION SPIFFS_END // No need for SPIFFS as it uses EEPROM area
|
||||
|
||||
uint32_t _cfgHash = 0;
|
||||
int spiffsflag = 0;
|
||||
|
||||
/********************************************************************************************/
|
||||
/*
|
||||
|
@ -164,11 +167,6 @@ void setModuleFlashMode(byte option)
|
|||
setFlashMode(option, mode);
|
||||
}
|
||||
|
||||
boolean spiffsPresent()
|
||||
{
|
||||
return (SPIFFS_END - SPIFFS_START);
|
||||
}
|
||||
|
||||
uint32_t getHash()
|
||||
{
|
||||
uint32_t hash = 0;
|
||||
|
@ -179,7 +177,7 @@ uint32_t getHash()
|
|||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Config Save - Save parameters to Flash or Spiffs ONLY if any parameter has changed
|
||||
* Config Save - Save parameters to Flash ONLY if any parameter has changed
|
||||
\*********************************************************************************************/
|
||||
|
||||
void CFG_Save()
|
||||
|
@ -187,20 +185,14 @@ void CFG_Save()
|
|||
char log[LOGSZ];
|
||||
|
||||
#ifndef BE_MINIMAL
|
||||
if ((getHash() != _cfgHash) && (spiffsPresent())) {
|
||||
if (!spiffsflag) {
|
||||
if (getHash() != _cfgHash) {
|
||||
noInterrupts();
|
||||
if (sysCfg.saveFlag == 0) { // Handle default and rollover
|
||||
spi_flash_erase_sector(CFG_LOCATION + (sysCfg.saveFlag &1));
|
||||
spi_flash_write((CFG_LOCATION + (sysCfg.saveFlag &1)) * SPI_FLASH_SEC_SIZE, (uint32*)&sysCfg, sizeof(SYSCFG));
|
||||
}
|
||||
sysCfg.saveFlag++;
|
||||
spi_flash_erase_sector(CFG_LOCATION + (sysCfg.saveFlag &1));
|
||||
spi_flash_write((CFG_LOCATION + (sysCfg.saveFlag &1)) * SPI_FLASH_SEC_SIZE, (uint32*)&sysCfg, sizeof(SYSCFG));
|
||||
spi_flash_erase_sector(CFG_LOCATION);
|
||||
spi_flash_write(CFG_LOCATION * SPI_FLASH_SEC_SIZE, (uint32*)&sysCfg, sizeof(SYSCFG));
|
||||
interrupts();
|
||||
snprintf_P(log, sizeof(log), PSTR("Config: Saved configuration (%d bytes) to flash at %X and count %d"), sizeof(SYSCFG), CFG_LOCATION + (sysCfg.saveFlag &1), sysCfg.saveFlag);
|
||||
snprintf_P(log, sizeof(log), PSTR("Config: Saved configuration (%d bytes) to flash at %X and count %d"), sizeof(SYSCFG), CFG_LOCATION, sysCfg.saveFlag);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
_cfgHash = getHash();
|
||||
}
|
||||
#endif // BE_MINIMAL
|
||||
|
@ -211,24 +203,32 @@ void CFG_Load()
|
|||
{
|
||||
char log[LOGSZ];
|
||||
|
||||
if (spiffsPresent()) {
|
||||
if (!spiffsflag) {
|
||||
struct SYSCFGH {
|
||||
unsigned long cfg_holder;
|
||||
unsigned long saveFlag;
|
||||
} _sysCfgH;
|
||||
|
||||
noInterrupts();
|
||||
spi_flash_read((CFG_LOCATION) * SPI_FLASH_SEC_SIZE, (uint32*)&sysCfg, sizeof(SYSCFG));
|
||||
spi_flash_read((CFG_LOCATION + 1) * SPI_FLASH_SEC_SIZE, (uint32*)&_sysCfgH, sizeof(SYSCFGH));
|
||||
if (sysCfg.saveFlag < _sysCfgH.saveFlag)
|
||||
spi_flash_read((CFG_LOCATION + 1) * SPI_FLASH_SEC_SIZE, (uint32*)&sysCfg, sizeof(SYSCFG));
|
||||
spi_flash_read(CFG_LOCATION * SPI_FLASH_SEC_SIZE, (uint32*)&sysCfg, sizeof(SYSCFG));
|
||||
interrupts();
|
||||
snprintf_P(log, sizeof(log), PSTR("Config: Loaded configuration from flash at %X and count %d"), CFG_LOCATION + (sysCfg.saveFlag &1), sysCfg.saveFlag);
|
||||
snprintf_P(log, sizeof(log), PSTR("Config: Loaded configuration from flash at %X and count %d"), CFG_LOCATION, sysCfg.saveFlag);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
|
||||
if (sysCfg.cfg_holder != CFG_HOLDER) {
|
||||
if ((sysCfg.version < 0x04020000) || (sysCfg.version > 0x73000000)) {
|
||||
noInterrupts();
|
||||
spi_flash_read((CFG_LOCATION_3) * SPI_FLASH_SEC_SIZE, (uint32*)&sysCfg, sizeof(SYSCFG));
|
||||
spi_flash_read((CFG_LOCATION_3 + 1) * SPI_FLASH_SEC_SIZE, (uint32*)&_sysCfgH, sizeof(SYSCFGH));
|
||||
if (sysCfg.saveFlag < _sysCfgH.saveFlag)
|
||||
spi_flash_read((CFG_LOCATION_3 + 1) * SPI_FLASH_SEC_SIZE, (uint32*)&sysCfg, sizeof(SYSCFG));
|
||||
interrupts();
|
||||
if (sysCfg.cfg_holder != CFG_HOLDER) {
|
||||
CFG_Default();
|
||||
}
|
||||
} else {
|
||||
CFG_Default();
|
||||
}
|
||||
}
|
||||
if (sysCfg.cfg_holder != CFG_HOLDER) CFG_Default();
|
||||
_cfgHash = getHash();
|
||||
|
||||
RTC_Load();
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
* - Change libraries/PubSubClient/src/PubSubClient.h
|
||||
* #define MQTT_MAX_PACKET_SIZE 512
|
||||
*
|
||||
* - Select IDE Tools - Flash size: "1M (64K SPIFFS)"
|
||||
* - Select IDE Tools - Flash size: "1M (no SPIFFS)"
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
#define VERSION 0x04010300 // 4.1.3
|
||||
#define VERSION 0x04020000 // 4.2.0
|
||||
|
||||
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};
|
||||
|
@ -160,9 +160,6 @@ enum butt_t {PRESSED, NOT_PRESSED};
|
|||
|
||||
typedef void (*rtcCallback)();
|
||||
|
||||
extern "C" uint32_t _SPIFFS_start;
|
||||
extern "C" uint32_t _SPIFFS_end;
|
||||
|
||||
#define MAX_BUTTON_COMMANDS 5 // Max number of button commands supported
|
||||
const char commands[MAX_BUTTON_COMMANDS][14] PROGMEM = {
|
||||
{"wificonfig 1"}, // Press button three times
|
||||
|
@ -204,7 +201,7 @@ int SerialInByteCounter = 0; // Index in receive buffer
|
|||
char serialInBuf[INPUT_BUFFER_SIZE + 2]; // Receive buffer
|
||||
byte Hexcode = 0; // Sonoff dual input flag
|
||||
uint16_t ButtonCode = 0; // Sonoff dual received code
|
||||
int16_t savedatacounter; // Counter and flag for config save to Flash or Spiffs
|
||||
int16_t savedatacounter; // Counter and flag for config save to Flash
|
||||
char Version[16]; // Version string from VERSION define
|
||||
char Hostname[33]; // Composed Wifi hostname
|
||||
char MQTTClient[33]; // Composed MQTT Clientname
|
||||
|
@ -512,10 +509,6 @@ void mqtt_connected()
|
|||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Started\":\"%s\"}"),
|
||||
(getResetReason() == "Exception") ? ESP.getResetInfo().c_str() : getResetReason().c_str());
|
||||
mqtt_publish_topic_P(1, PSTR("INFO3"), svalue);
|
||||
if (!spiffsPresent()) {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Warning1\":\"No persistent config. Please reflash with at least 16K SPIFFS\"}"));
|
||||
mqtt_publish_topic_P(1, PSTR("WARNING1"), svalue);
|
||||
}
|
||||
if (sysCfg.tele_period) tele_period = sysCfg.tele_period -9;
|
||||
status_update_timer = 2;
|
||||
#ifdef USE_DOMOTICZ
|
||||
|
@ -1434,9 +1427,8 @@ void publish_status(uint8_t payload)
|
|||
}
|
||||
|
||||
if ((payload == 0) || (payload == 4)) {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"StatusMEM\":{\"ProgramSize\":%d, \"Free\":%d, \"Heap\":%d, \"SpiffsStart\":%d, \"SpiffsSize\":%d, \"FlashSize\":%d, \"ProgramFlashSize\":%d, \"FlashMode\":%d}}"),
|
||||
ESP.getSketchSize()/1024, ESP.getFreeSketchSpace()/1024, ESP.getFreeHeap()/1024, ((uint32_t)&_SPIFFS_start - 0x40200000)/1024,
|
||||
(((uint32_t)&_SPIFFS_end - 0x40200000) - ((uint32_t)&_SPIFFS_start - 0x40200000))/1024, ESP.getFlashChipRealSize()/1024, ESP.getFlashChipSize()/1024, ESP.getFlashChipMode());
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"StatusMEM\":{\"ProgramSize\":%d, \"Free\":%d, \"Heap\":%d, \"FlashSize\":%d, \"ProgramFlashSize\":%d, \"FlashMode\":%d}}"),
|
||||
ESP.getSketchSize()/1024, ESP.getFreeSketchSpace()/1024, ESP.getFreeHeap()/1024, ESP.getFlashChipRealSize()/1024, ESP.getFlashChipSize()/1024, ESP.getFlashChipMode());
|
||||
mqtt_publish_topic_P(option, PSTR("STATUS4"), svalue);
|
||||
}
|
||||
|
||||
|
@ -2133,8 +2125,6 @@ void setup()
|
|||
Version[idx] = 96 + (VERSION & 0x1f);
|
||||
Version[idx +1] = 0;
|
||||
}
|
||||
if (!spiffsPresent())
|
||||
addLog_P(LOG_LEVEL_ERROR, PSTR("SPIFFS: ERROR - No spiffs present. Please reflash with at least 16K SPIFFS"));
|
||||
CFG_Load();
|
||||
CFG_Delta();
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#define DOMOTICZ_MAX_SENSORS 5
|
||||
|
||||
#ifdef USE_WEBSERVER
|
||||
const char HTTP_FORM_DOMOTICZ[] PROGMEM =
|
||||
"<fieldset><legend><b> Domoticz parameters </b></legend><form method='post' action='sv'>"
|
||||
"<input id='w' name='w' value='4' hidden><input id='r' name='r' value='1' hidden>"
|
||||
|
@ -42,6 +43,7 @@ const char HTTP_FORM_DOMOTICZ_SENSOR[] PROGMEM =
|
|||
"<tr><td><b>Sensor idx {1</b> - {2</td><td><input id='l{1' name='l{1' length=8 placeholder='0' value='{5'></td></tr>";
|
||||
const char HTTP_FORM_DOMOTICZ_TIMER[] PROGMEM =
|
||||
"<tr><td><b>Update timer</b> (" STR(DOMOTICZ_UPDATE_TIMER) ")</td><td><input id='ut' name='ut' length=32 placeholder='" STR(DOMOTICZ_UPDATE_TIMER) "' value='{6'</td></tr>";
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
const char domoticz_sensors[DOMOTICZ_MAX_SENSORS][14] PROGMEM =
|
||||
{ "Temp", "Temp,Hum", "Temp,Hum,Baro", "Power,Energy", "Illuminance" };
|
||||
|
|
Loading…
Reference in New Issue