mirror of https://github.com/arendst/Tasmota.git
v3.9.12
3.9.12 20170208 * Fix compile error when webserver is disabled (#30) * Fix possible ESP8285 flash problem by updating Flash Chip Mode to DOUT during OTA upload * Fix hostname issues by not allowing user entry of string formatting and removing from user_config.h (#36)
This commit is contained in:
parent
f751ad1e26
commit
971ffef4a9
|
@ -1,7 +1,7 @@
|
||||||
## Sonoff-Tasmota
|
## 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.
|
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 **3.9.11** - See ```sonoff/_releasenotes.ino``` for change information.
|
Current version is **3.9.12** - See ```sonoff/_releasenotes.ino``` for change information.
|
||||||
|
|
||||||
- This version provides all (Sonoff) modules in one file and starts up with Sonoff Basic.
|
- 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```.
|
- Once uploaded select module using the configuration webpage or the commands ```Modules``` and ```Module```.
|
||||||
|
|
Binary file not shown.
|
@ -1,5 +1,7 @@
|
||||||
/* 3.9.11a
|
/* 3.9.12 20170208
|
||||||
* Fix compile error when webserver is disabled (#30)
|
* Fix compile error when webserver is disabled (#30)
|
||||||
|
* Fix possible ESP8285 flash problem by updating Flash Chip Mode to DOUT during OTA upload
|
||||||
|
* Fix hostname issues by not allowing user entry of string formatting and removing from user_config.h (#36)
|
||||||
*
|
*
|
||||||
* 3.9.11 20170204
|
* 3.9.11 20170204
|
||||||
* Fix command I2Cscan
|
* Fix command I2Cscan
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
* ====================================================
|
* ====================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define VERSION 0x03090B00 // 3.9.11
|
#define VERSION 0x03090C00 // 3.9.12
|
||||||
|
|
||||||
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};
|
||||||
|
@ -58,7 +58,7 @@ enum emul_t {EMUL_NONE, EMUL_WEMO, EMUL_HUE, EMUL_MAX};
|
||||||
#define WS2812_LEDS 30 // [Pixels] Number of LEDs
|
#define WS2812_LEDS 30 // [Pixels] Number of LEDs
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEF_WIFI_HOSTNAME "%s-%04d" // Expands to <MQTT_TOPIC>-<last 4 decimal chars of MAC address>
|
#define WIFI_HOSTNAME "%s-%04d" // Expands to <MQTT_TOPIC>-<last 4 decimal chars of MAC address>
|
||||||
|
|
||||||
#define HLW_PREF_PULSE 12530 // was 4975us = 201Hz = 1000W
|
#define HLW_PREF_PULSE 12530 // was 4975us = 201Hz = 1000W
|
||||||
#define HLW_UREF_PULSE 1950 // was 1666us = 600Hz = 220V
|
#define HLW_UREF_PULSE 1950 // was 1666us = 600Hz = 220V
|
||||||
|
@ -1087,7 +1087,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
||||||
uint16_t i = 0, grpflg = 0, index;
|
uint16_t i = 0, grpflg = 0, index;
|
||||||
char topicBuf[TOPSZ], dataBuf[data_len+1], dataBufUc[MESSZ];
|
char topicBuf[TOPSZ], dataBuf[data_len+1], dataBufUc[MESSZ];
|
||||||
char *p, *mtopic = NULL, *type = NULL;
|
char *p, *mtopic = NULL, *type = NULL;
|
||||||
char stopic[TOPSZ], stemp1[TOPSZ], stemp2[10];
|
char stemp1[TOPSZ], stemp2[10];
|
||||||
|
|
||||||
strncpy(topicBuf, topic, sizeof(topicBuf));
|
strncpy(topicBuf, topic, sizeof(topicBuf));
|
||||||
memcpy(dataBuf, data, sizeof(dataBuf));
|
memcpy(dataBuf, data, sizeof(dataBuf));
|
||||||
|
@ -1306,6 +1306,12 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
||||||
}
|
}
|
||||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Sleep\":\"%d%s (%d%s)\"}"), sleep, (sysCfg.value_units) ? " mS" : "", sysCfg.sleep, (sysCfg.value_units) ? " mS" : "");
|
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Sleep\":\"%d%s (%d%s)\"}"), sleep, (sysCfg.value_units) ? " mS" : "", sysCfg.sleep, (sysCfg.value_units) ? " mS" : "");
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(type,"FLASHCHIPMODE")) {
|
||||||
|
if ((data_len > 0) && (payload >= 2) && (payload <= 3)) {
|
||||||
|
if (ESP.getFlashChipMode() != payload) setFlashChipMode(0, payload &3);
|
||||||
|
}
|
||||||
|
snprintf_P(svalue, sizeof(svalue), PSTR("{\"FlashChipMode\":%d}"), ESP.getFlashChipMode());
|
||||||
|
}
|
||||||
else if (!strcmp(type,"UPGRADE") || !strcmp(type,"UPLOAD")) {
|
else if (!strcmp(type,"UPGRADE") || !strcmp(type,"UPLOAD")) {
|
||||||
if ((data_len > 0) && (payload == 1)) {
|
if ((data_len > 0) && (payload == 1)) {
|
||||||
otaflag = 3;
|
otaflag = 3;
|
||||||
|
@ -1383,8 +1389,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
||||||
else if (!grpflg && !strcmp(type,"HOSTNAME")) {
|
else if (!grpflg && !strcmp(type,"HOSTNAME")) {
|
||||||
if ((data_len > 0) && (data_len < sizeof(sysCfg.hostname))) {
|
if ((data_len > 0) && (data_len < sizeof(sysCfg.hostname))) {
|
||||||
strlcpy(sysCfg.hostname, (payload == 1) ? WIFI_HOSTNAME : dataBuf, sizeof(sysCfg.hostname));
|
strlcpy(sysCfg.hostname, (payload == 1) ? WIFI_HOSTNAME : dataBuf, sizeof(sysCfg.hostname));
|
||||||
if (strstr(sysCfg.hostname,"%"))
|
if (strstr(sysCfg.hostname,"%")) strlcpy(sysCfg.hostname, WIFI_HOSTNAME, sizeof(sysCfg.hostname));
|
||||||
strlcpy(sysCfg.hostname, DEF_WIFI_HOSTNAME, sizeof(sysCfg.hostname));
|
|
||||||
restartflag = 2;
|
restartflag = 2;
|
||||||
}
|
}
|
||||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Hostname\":\"%s\"}"), sysCfg.hostname);
|
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Hostname\":\"%s\"}"), sysCfg.hostname);
|
||||||
|
@ -1838,9 +1843,7 @@ void do_cmnd(char *cmnd)
|
||||||
|
|
||||||
void publish_status(uint8_t payload)
|
void publish_status(uint8_t payload)
|
||||||
{
|
{
|
||||||
char svalue[MESSZ], stemp1[TOPSZ], stemp2[10], stemp3[10];
|
char svalue[MESSZ];
|
||||||
float ped, pi, pc;
|
|
||||||
uint16_t pe, pw, pu;
|
|
||||||
uint8_t option = 0;
|
uint8_t option = 0;
|
||||||
|
|
||||||
// Workaround MQTT - TCP/IP stack queueing when SUB_PREFIX = PUB_PREFIX
|
// Workaround MQTT - TCP/IP stack queueing when SUB_PREFIX = PUB_PREFIX
|
||||||
|
@ -1966,7 +1969,7 @@ void every_second_cb()
|
||||||
|
|
||||||
void every_second()
|
void every_second()
|
||||||
{
|
{
|
||||||
char log[LOGSZ], stopic[TOPSZ], svalue[MESSZ], stime[21];
|
char svalue[MESSZ], stime[21];
|
||||||
|
|
||||||
snprintf_P(stime, sizeof(stime), PSTR("%04d-%02d-%02dT%02d:%02d:%02d"),
|
snprintf_P(stime, sizeof(stime), PSTR("%04d-%02d-%02dT%02d:%02d:%02d"),
|
||||||
rtcTime.Year, rtcTime.Month, rtcTime.Day, rtcTime.Hour, rtcTime.Minute, rtcTime.Second);
|
rtcTime.Year, rtcTime.Month, rtcTime.Day, rtcTime.Hour, rtcTime.Minute, rtcTime.Second);
|
||||||
|
@ -2246,6 +2249,7 @@ void stateloop()
|
||||||
if (otaflag == 10) { // Allow MQTT to reconnect
|
if (otaflag == 10) { // Allow MQTT to reconnect
|
||||||
otaflag = 0;
|
otaflag = 0;
|
||||||
if (otaok) {
|
if (otaok) {
|
||||||
|
if ((sysCfg.module == SONOFF_TOUCH) || (sysCfg.module == SONOFF_4CH)) setFlashChipMode(1, 3); // DOUT - ESP8285
|
||||||
snprintf_P(svalue, sizeof(svalue), PSTR("Successful. Restarting"));
|
snprintf_P(svalue, sizeof(svalue), PSTR("Successful. Restarting"));
|
||||||
restartflag = 2;
|
restartflag = 2;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2508,8 +2512,8 @@ void setup()
|
||||||
Serial.println();
|
Serial.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strstr(sysCfg.hostname, "%")) strlcpy(sysCfg.hostname, DEF_WIFI_HOSTNAME, sizeof(sysCfg.hostname));
|
if (strstr(sysCfg.hostname, "%")) {
|
||||||
if (!strcmp(sysCfg.hostname, DEF_WIFI_HOSTNAME)) {
|
strlcpy(sysCfg.hostname, WIFI_HOSTNAME, sizeof(sysCfg.hostname));
|
||||||
snprintf_P(Hostname, sizeof(Hostname)-1, sysCfg.hostname, sysCfg.mqtt_topic, ESP.getChipId() & 0x1FFF);
|
snprintf_P(Hostname, sizeof(Hostname)-1, sysCfg.hostname, sysCfg.mqtt_topic, ESP.getChipId() & 0x1FFF);
|
||||||
} else {
|
} else {
|
||||||
snprintf_P(Hostname, sizeof(Hostname)-1, sysCfg.hostname);
|
snprintf_P(Hostname, sizeof(Hostname)-1, sysCfg.hostname);
|
||||||
|
|
|
@ -275,26 +275,40 @@ void initSpiffs()
|
||||||
}
|
}
|
||||||
#endif // USE_SPIFFS
|
#endif // USE_SPIFFS
|
||||||
|
|
||||||
|
#include "eboot_command.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void setFlashChipMode(byte mode)
|
* Based on cores/esp8266/Updater.cpp
|
||||||
|
*/
|
||||||
|
void setFlashChipMode(byte option, byte mode)
|
||||||
{
|
{
|
||||||
char log[LOGSZ];
|
char log[LOGSZ];
|
||||||
uint32_t data;
|
uint8_t *_buffer;
|
||||||
|
uint32_t address;
|
||||||
|
|
||||||
uint8_t * bytes = (uint8_t *) &data;
|
if (option) {
|
||||||
// read first 4 byte (magic byte + flash config)
|
eboot_command ebcmd;
|
||||||
if (spi_flash_read(0x0000, &data, 4) == SPI_FLASH_RESULT_OK) {
|
eboot_command_read(&ebcmd);
|
||||||
|
address = ebcmd.args[0];
|
||||||
snprintf_P(log, sizeof(log), PSTR("FLSH: Magic byte and flash config %08X"), data);
|
} else {
|
||||||
addLog(LOG_LEVEL_DEBUG, log);
|
address = 0;
|
||||||
|
}
|
||||||
if (bytes[2] != mode) {
|
_buffer = new uint8_t[FLASH_SECTOR_SIZE];
|
||||||
bytes[2] = mode &3;
|
if (spi_flash_read(address, (uint32_t*)_buffer, FLASH_SECTOR_SIZE) == SPI_FLASH_RESULT_OK) {
|
||||||
// spi_flash_write(0x0000, &data, 4);
|
if (_buffer[2] != mode) {
|
||||||
|
_buffer[2] = mode &3;
|
||||||
|
noInterrupts();
|
||||||
|
if (spi_flash_erase_sector(address / FLASH_SECTOR_SIZE) == SPI_FLASH_RESULT_OK) {
|
||||||
|
spi_flash_write(address, (uint32_t*)_buffer, FLASH_SECTOR_SIZE);
|
||||||
|
}
|
||||||
|
interrupts();
|
||||||
|
snprintf_P(log, sizeof(log), PSTR("FLSH: Updated Flash Chip Mode to %d"), (option) ? mode : ESP.getFlashChipMode());
|
||||||
|
addLog(LOG_LEVEL_DEBUG, log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
delete[] _buffer;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* Wifi
|
* Wifi
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
@ -629,7 +643,6 @@ void IPtoCharArray(IPAddress address, char *ip_str, size_t size)
|
||||||
|
|
||||||
int32_t i2c_read(uint8_t addr, uint8_t reg, uint8_t size)
|
int32_t i2c_read(uint8_t addr, uint8_t reg, uint8_t size)
|
||||||
{
|
{
|
||||||
char log[LOGSZ];
|
|
||||||
byte x = 0;
|
byte x = 0;
|
||||||
int32_t data = 0;
|
int32_t data = 0;
|
||||||
|
|
||||||
|
@ -646,10 +659,6 @@ int32_t i2c_read(uint8_t addr, uint8_t reg, uint8_t size)
|
||||||
}
|
}
|
||||||
x++;
|
x++;
|
||||||
} while (Wire.endTransmission(true) != 0 && x <= I2C_RETRY_COUNTER); // end transmission
|
} while (Wire.endTransmission(true) != 0 && x <= I2C_RETRY_COUNTER); // end transmission
|
||||||
|
|
||||||
// snprintf_P(log, sizeof(log), PSTR("I2C: received %X, retries %d"), data, x -1);
|
|
||||||
// addLog(LOG_LEVEL_DEBUG_MORE, log);
|
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#define STA_PASS1 "VnsqrtnrsddbrN" // [Password1] Wifi password
|
#define STA_PASS1 "VnsqrtnrsddbrN" // [Password1] Wifi password
|
||||||
#define STA_SSID2 "indebuurt2" // [Ssid2] Optional alternate AP Wifi SSID
|
#define STA_SSID2 "indebuurt2" // [Ssid2] Optional alternate AP Wifi SSID
|
||||||
#define STA_PASS2 "VnsqrtnrsddbrN" // [Password2] Optional alternate AP Wifi password
|
#define STA_PASS2 "VnsqrtnrsddbrN" // [Password2] Optional alternate AP Wifi password
|
||||||
#define WIFI_HOSTNAME "%s-%04d" // [Hostname] Expands to <MQTT_TOPIC>-<last 4 decimal chars of MAC address>
|
|
||||||
#define WIFI_CONFIG_TOOL WIFI_WPSCONFIG // [WifiConfig] Default tool if wifi fails to connect
|
#define WIFI_CONFIG_TOOL WIFI_WPSCONFIG // [WifiConfig] Default tool if wifi fails to connect
|
||||||
// (WIFI_RESTART, WIFI_SMARTCONFIG, WIFI_MANAGER, WIFI_WPSCONFIG, WIFI_RETRY)
|
// (WIFI_RESTART, WIFI_SMARTCONFIG, WIFI_MANAGER, WIFI_WPSCONFIG, WIFI_RETRY)
|
||||||
// -- Syslog --------------------------------------
|
// -- Syslog --------------------------------------
|
||||||
|
@ -37,7 +36,7 @@
|
||||||
// -- MQTT ----------------------------------------
|
// -- MQTT ----------------------------------------
|
||||||
#define MQTT_USE 1 // [Mqtt] Select default MQTT use (0 = Off, 1 = On)
|
#define MQTT_USE 1 // [Mqtt] Select default MQTT use (0 = Off, 1 = On)
|
||||||
// !!! TLS uses a LOT OF MEMORY (20k) so be careful to enable other options at the same time !!!
|
// !!! TLS uses a LOT OF MEMORY (20k) so be careful to enable other options at the same time !!!
|
||||||
//#define USE_MQTT_TLS // EXPERIMENTAL Use TLS for MQTT connection (+53k code, +20k mem)
|
//#define USE_MQTT_TLS // EXPERIMENTAL Use TLS for MQTT connection (+53k code, +20k mem) - Disable by //
|
||||||
// Needs Fingerprint, TLS Port, UserId and Password
|
// Needs Fingerprint, TLS Port, UserId and Password
|
||||||
#ifdef USE_MQTT_TLS
|
#ifdef USE_MQTT_TLS
|
||||||
#define MQTT_HOST "m20.cloudmqtt.com" // [MqttHost]
|
#define MQTT_HOST "m20.cloudmqtt.com" // [MqttHost]
|
||||||
|
@ -72,20 +71,20 @@
|
||||||
#define TELE_PERIOD 300 // [TelePeriod] Telemetry (0 = disable, 10 - 3600 seconds)
|
#define TELE_PERIOD 300 // [TelePeriod] Telemetry (0 = disable, 10 - 3600 seconds)
|
||||||
|
|
||||||
// -- MQTT - Domoticz -----------------------------
|
// -- MQTT - Domoticz -----------------------------
|
||||||
#define USE_DOMOTICZ // Enable Domoticz (+5k code, +0.3k mem) - Disable by //
|
#define USE_DOMOTICZ // Enable Domoticz (+7k code, +0.3k mem) - Disable by //
|
||||||
#define DOMOTICZ_IN_TOPIC "domoticz/in" // [DomoticzInTopic]
|
#define DOMOTICZ_IN_TOPIC "domoticz/in" // [DomoticzInTopic]
|
||||||
#define DOMOTICZ_OUT_TOPIC "domoticz/out" // [DomoticzOutTopic]
|
#define DOMOTICZ_OUT_TOPIC "domoticz/out" // [DomoticzOutTopic]
|
||||||
#define DOMOTICZ_UPDATE_TIMER 0 // [DomoticzUpdateTimer] Send relay status (0 = disable, 1 - 3600 seconds) (Optional)
|
#define DOMOTICZ_UPDATE_TIMER 0 // [DomoticzUpdateTimer] Send relay status (0 = disable, 1 - 3600 seconds) (Optional)
|
||||||
|
|
||||||
// -- HTTP ----------------------------------------
|
// -- HTTP ----------------------------------------
|
||||||
#define USE_WEBSERVER // Enable web server and wifi manager (+43k code, +2k mem) - Disable by //
|
#define USE_WEBSERVER // Enable web server and wifi manager (+60k code, +4k mem) - Disable by //
|
||||||
#define FRIENDLY_NAME "Sonoff" // [FriendlyName] Friendlyname up to 32 characters used by webpages and Alexa
|
#define FRIENDLY_NAME "Sonoff" // [FriendlyName] Friendlyname up to 32 characters used by webpages and Alexa
|
||||||
#define WEB_SERVER 2 // [WebServer] Web server (0 = Off, 1 = Start as User, 2 = Start as Admin)
|
#define WEB_SERVER 2 // [WebServer] Web server (0 = Off, 1 = Start as User, 2 = Start as Admin)
|
||||||
#define USE_EMULATION // Enable Belkin WeMo and Hue Bridge emulation for Alexa (+11k code, +2k mem)
|
#define USE_EMULATION // Enable Belkin WeMo and Hue Bridge emulation for Alexa (+11k code, +2k mem)
|
||||||
#define EMULATION EMUL_NONE // [Emulation] Select Belkin WeMo or Hue Bridge emulation (EMUL_NONE, EMUL_WEMO or EMUL_HUE)
|
#define EMULATION EMUL_NONE // [Emulation] Select Belkin WeMo or Hue Bridge emulation (EMUL_NONE, EMUL_WEMO or EMUL_HUE)
|
||||||
|
|
||||||
// -- mDNS ----------------------------------------
|
// -- mDNS ----------------------------------------
|
||||||
#define USE_DISCOVERY // Enable mDNS for the following services (+8k code, +0.3k mem)
|
#define USE_DISCOVERY // Enable mDNS for the following services (+8k code, +0.3k mem) - Disable by //
|
||||||
#define WEBSERVER_ADVERTISE // Provide access to webserver by name <Hostname>.local/
|
#define WEBSERVER_ADVERTISE // Provide access to webserver by name <Hostname>.local/
|
||||||
#define MQTT_HOST_DISCOVERY // Find MQTT host server (overrides MQTT_HOST if found)
|
#define MQTT_HOST_DISCOVERY // Find MQTT host server (overrides MQTT_HOST if found)
|
||||||
|
|
||||||
|
@ -121,12 +120,12 @@
|
||||||
//#define USE_DHT2 // Optional using Adafruit DHT library
|
//#define USE_DHT2 // Optional using Adafruit DHT library
|
||||||
//#define USE_DS18x20 // Optional using OneWire library for multiple DS18B20 and/or DS18S20
|
//#define USE_DS18x20 // Optional using OneWire library for multiple DS18B20 and/or DS18S20
|
||||||
|
|
||||||
#define USE_I2C // I2C Support (+10k code, 0.2k mem)
|
#define USE_I2C // I2C using library wire (+10k code, 0.2k mem) - Disable by //
|
||||||
#define USE_BH1750 // Add I2C code for BH1750 sensor
|
#define USE_BH1750 // Add I2C code for BH1750 sensor
|
||||||
#define USE_BMP // Add I2C code for BMP/BME280 sensor
|
#define USE_BMP // Add I2C code for BMP/BME280 sensor
|
||||||
#define USE_HTU // Add I2C code for HTU21 sensor
|
#define USE_HTU // Add I2C code for HTU21 sensor
|
||||||
|
|
||||||
#define USE_WS2812 // WS2812 Led string support (+8k code, +1k mem)
|
#define USE_WS2812 // WS2812 Led string using library NeoPixelBus (+8k code, +1k mem) - Disable by //
|
||||||
#define USE_WS2812_CTYPE 1 // WS2812 Color type (0 - RGB, 1 - GRB)
|
#define USE_WS2812_CTYPE 1 // WS2812 Color type (0 - RGB, 1 - GRB)
|
||||||
// #define USE_WS2812_DMA // DMA supports only GPIO03 (= Serial TXD) (+1k mem)
|
// #define USE_WS2812_DMA // DMA supports only GPIO03 (= Serial TXD) (+1k mem)
|
||||||
// When USE_WS2812_DMA is enabled expect Exceptions on Pow
|
// When USE_WS2812_DMA is enabled expect Exceptions on Pow
|
||||||
|
|
|
@ -130,7 +130,7 @@ const char HTTP_FORM_WIFI[] PROGMEM =
|
||||||
"<br/><b>AP1 Password</b></br><input id='p1' name='p1' length=64 type='password' placeholder='" STA_PASS1 "' value='{p1}'><br/>"
|
"<br/><b>AP1 Password</b></br><input id='p1' name='p1' length=64 type='password' placeholder='" STA_PASS1 "' value='{p1}'><br/>"
|
||||||
"<br/><b>AP2 SSId</b> (" STA_SSID2 ")<br/><input id='s2' name='s2' length=32 placeholder='" STA_SSID2 "' value='{s2}'><br/>"
|
"<br/><b>AP2 SSId</b> (" STA_SSID2 ")<br/><input id='s2' name='s2' length=32 placeholder='" STA_SSID2 "' value='{s2}'><br/>"
|
||||||
"<br/><b>AP2 Password</b></br><input id='p2' name='p2' length=64 type='password' placeholder='" STA_PASS2 "' value='{p2}'><br/>"
|
"<br/><b>AP2 Password</b></br><input id='p2' name='p2' length=64 type='password' placeholder='" STA_PASS2 "' value='{p2}'><br/>"
|
||||||
"<br/><b>Hostname</b> ({h0})<br/><input id='h' name='h' length=32 placeholder='" WIFI_HOSTNAME" ' value='{h1}'><br/>";
|
"<br/><b>Hostname</b> (" WIFI_HOSTNAME ")<br/><input id='h' name='h' length=32 placeholder='" WIFI_HOSTNAME" ' value='{h1}'><br/>";
|
||||||
const char HTTP_FORM_MQTT[] PROGMEM =
|
const char HTTP_FORM_MQTT[] PROGMEM =
|
||||||
"<fieldset><legend><b> MQTT parameters </b></legend><form method='post' action='sv'>"
|
"<fieldset><legend><b> MQTT parameters </b></legend><form method='post' action='sv'>"
|
||||||
"<input id='w' name='w' value='2' hidden><input id='r' name='r' value='1' hidden>"
|
"<input id='w' name='w' value='2' hidden><input id='r' name='r' value='1' hidden>"
|
||||||
|
@ -414,7 +414,6 @@ void showPage(String &page)
|
||||||
{
|
{
|
||||||
page.replace("{ha}", my_module.name);
|
page.replace("{ha}", my_module.name);
|
||||||
page.replace("{h}", String(sysCfg.friendlyname[0]));
|
page.replace("{h}", String(sysCfg.friendlyname[0]));
|
||||||
// page.replace("{ha}", Hostname);
|
|
||||||
if (_httpflag == HTTP_MANAGER) {
|
if (_httpflag == HTTP_MANAGER) {
|
||||||
if (WIFI_configCounter()) {
|
if (WIFI_configCounter()) {
|
||||||
page.replace("<body>", "<body onload='u()'>");
|
page.replace("<body>", "<body onload='u()'>");
|
||||||
|
@ -557,7 +556,6 @@ void handleModule()
|
||||||
for (byte i = 0; i < MAX_GPIO_PIN; i++) {
|
for (byte i = 0; i < MAX_GPIO_PIN; i++) {
|
||||||
if (cmodule.gp.io[i] == GPIO_USER) {
|
if (cmodule.gp.io[i] == GPIO_USER) {
|
||||||
page += F("<br/><b>GPIO"); page += String(i); page += F("</b> <select id='g"); page += String(i); page += F("' name='g"); page += String(i); page += F("'>");
|
page += F("<br/><b>GPIO"); page += String(i); page += F("</b> <select id='g"); page += String(i); page += F("' name='g"); page += String(i); page += F("'>");
|
||||||
byte k = 0;
|
|
||||||
for (byte j = GPIO_SENSOR_START; j < GPIO_SENSOR_END; j++) {
|
for (byte j = GPIO_SENSOR_START; j < GPIO_SENSOR_END; j++) {
|
||||||
page += F("<option ");
|
page += F("<option ");
|
||||||
if (j == my_module.gp.io[i]) page += F("selected ");
|
if (j == my_module.gp.io[i]) page += F("selected ");
|
||||||
|
@ -672,14 +670,6 @@ void handleWifi(boolean scan)
|
||||||
}
|
}
|
||||||
|
|
||||||
page += FPSTR(HTTP_FORM_WIFI);
|
page += FPSTR(HTTP_FORM_WIFI);
|
||||||
|
|
||||||
char str[33];
|
|
||||||
if (!strcmp(WIFI_HOSTNAME, DEF_WIFI_HOSTNAME)) {
|
|
||||||
snprintf_P(str, sizeof(str), PSTR(DEF_WIFI_HOSTNAME), sysCfg.mqtt_topic, ESP.getChipId() & 0x1FFF);
|
|
||||||
} else {
|
|
||||||
snprintf_P(str, sizeof(str), PSTR(WIFI_HOSTNAME));
|
|
||||||
}
|
|
||||||
page.replace("{h0}", str);
|
|
||||||
page.replace("{h1}", String(sysCfg.hostname));
|
page.replace("{h1}", String(sysCfg.hostname));
|
||||||
page.replace("{s1}", String(sysCfg.sta_ssid[0]));
|
page.replace("{s1}", String(sysCfg.sta_ssid[0]));
|
||||||
page.replace("{p1}", String(sysCfg.sta_pwd[0]));
|
page.replace("{p1}", String(sysCfg.sta_pwd[0]));
|
||||||
|
@ -820,7 +810,7 @@ void handleSave()
|
||||||
switch (what) {
|
switch (what) {
|
||||||
case 1:
|
case 1:
|
||||||
strlcpy(sysCfg.hostname, (!strlen(webServer->arg("h").c_str())) ? WIFI_HOSTNAME : webServer->arg("h").c_str(), sizeof(sysCfg.hostname));
|
strlcpy(sysCfg.hostname, (!strlen(webServer->arg("h").c_str())) ? WIFI_HOSTNAME : webServer->arg("h").c_str(), sizeof(sysCfg.hostname));
|
||||||
if (strstr(sysCfg.hostname,"%")) strlcpy(sysCfg.hostname, DEF_WIFI_HOSTNAME, sizeof(sysCfg.hostname));
|
if (strstr(sysCfg.hostname,"%")) strlcpy(sysCfg.hostname, WIFI_HOSTNAME, sizeof(sysCfg.hostname));
|
||||||
strlcpy(sysCfg.sta_ssid[0], (!strlen(webServer->arg("s1").c_str())) ? STA_SSID1 : webServer->arg("s1").c_str(), sizeof(sysCfg.sta_ssid[0]));
|
strlcpy(sysCfg.sta_ssid[0], (!strlen(webServer->arg("s1").c_str())) ? STA_SSID1 : webServer->arg("s1").c_str(), sizeof(sysCfg.sta_ssid[0]));
|
||||||
strlcpy(sysCfg.sta_pwd[0], (!strlen(webServer->arg("p1").c_str())) ? STA_PASS1 : webServer->arg("p1").c_str(), sizeof(sysCfg.sta_pwd[0]));
|
strlcpy(sysCfg.sta_pwd[0], (!strlen(webServer->arg("p1").c_str())) ? STA_PASS1 : webServer->arg("p1").c_str(), sizeof(sysCfg.sta_pwd[0]));
|
||||||
strlcpy(sysCfg.sta_ssid[1], (!strlen(webServer->arg("s2").c_str())) ? STA_SSID2 : webServer->arg("s2").c_str(), sizeof(sysCfg.sta_ssid[1]));
|
strlcpy(sysCfg.sta_ssid[1], (!strlen(webServer->arg("s2").c_str())) ? STA_SSID2 : webServer->arg("s2").c_str(), sizeof(sysCfg.sta_ssid[1]));
|
||||||
|
@ -1076,13 +1066,10 @@ void handleUploadLoop()
|
||||||
_uploaderror = 4;
|
_uploaderror = 4;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((sysCfg.module == SONOFF_TOUCH) || (sysCfg.module == SONOFF_4CH) || (ESP.getFlashChipMode() == 3)) {
|
if ((sysCfg.module == SONOFF_TOUCH) || (sysCfg.module == SONOFF_4CH)) {
|
||||||
upload.buf[2] = 3; // DOUT - ESP8285
|
upload.buf[2] = 3; // DOUT - ESP8285
|
||||||
} else {
|
addLog_P(LOG_LEVEL_DEBUG, PSTR("FLSH: Updated Flash Chip Mode to 3"));
|
||||||
upload.buf[2] = 2; // DIO - ESP8266
|
|
||||||
}
|
}
|
||||||
// snprintf_P(log, sizeof(log), PSTR("Upload: Flash Chip Mode %02X"), upload.buf[2]);
|
|
||||||
// addLog(LOG_LEVEL_DEBUG, log);
|
|
||||||
}
|
}
|
||||||
if (!_uploaderror && (Update.write(upload.buf, upload.currentSize) != upload.currentSize)) {
|
if (!_uploaderror && (Update.write(upload.buf, upload.currentSize) != upload.currentSize)) {
|
||||||
if (_serialoutput) Update.printError(Serial);
|
if (_serialoutput) Update.printError(Serial);
|
||||||
|
|
|
@ -42,7 +42,7 @@ byte domoticz_update_flag = 1;
|
||||||
|
|
||||||
unsigned long getKeyIntValue(const char *json, const char *key)
|
unsigned long getKeyIntValue(const char *json, const char *key)
|
||||||
{
|
{
|
||||||
char *p, *b, log[LOGSZ];
|
char *p, *b;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// search key
|
// search key
|
||||||
|
|
Loading…
Reference in New Issue