Skip to content

Commit

Permalink
v5.12.0k - Fix two define changes
Browse files Browse the repository at this point in the history
5.12.0k
 * Prepare for simple rules by enlarging Settings area to now
2048 bytes
 * Fix freeing more code space when emulation is disabled
(arendst#1592)
 * Fix compile error when not defined USE_TIMERS (arendst#2400)
  • Loading branch information
arendst committed Apr 10, 2018
1 parent ca692c4 commit 40498b7
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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 **5.12.0j** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
Current version is **5.12.0k** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.

### Quick install

Expand Down
7 changes: 6 additions & 1 deletion sonoff/_releasenotes.ino
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
/* 5.12.0j
/* 5.12.0k
* Prepare for simple rules by enlarging Settings area to now 2048 bytes
* Fix freeing more code space when emulation is disabled (#1592)
* Fix compile error when not defined USE_TIMERS (#2400)
*
* 5.12.0j
* Add optional Sunrise and Sunset timers with commands Latitide and Longitude to be enabled with define USE_SUNRISE in user_config.h (#2317)
*
* 5.12.0i
Expand Down
9 changes: 7 additions & 2 deletions sonoff/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t not_power_linked : 1; // bit 20 (v5.11.1f)
uint32_t no_power_on_check : 1; // bit 21 (v5.11.1i)
uint32_t mqtt_serial : 1; // bit 22 (v5.12.0f)
uint32_t spare23 : 1;
uint32_t rules_enabled : 1; // bit 23 (v5.12.0j)
uint32_t spare24 : 1;
uint32_t spare25 : 1;
uint32_t spare26 : 1;
Expand Down Expand Up @@ -255,7 +255,12 @@ struct SYSCFG {
Timer timer[MAX_TIMERS]; // 670
int latitude; // 6B0
int longitude; // 6B4
// 6B8 - FFF free locations

byte free_6b8[72]; // 6B8

char rules[256]; // 700

// 800 - FFF free locations
} Settings;

struct RTCMEM {
Expand Down
4 changes: 4 additions & 0 deletions sonoff/settings.ino
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,10 @@ void SettingsDelta()
Settings.latitude = (int)((double)LATITUDE * 1000000);
Settings.longitude = (int)((double)LONGITUDE * 1000000);
}
if (Settings.version < 0x050C000B) {
memset(&Settings.free_6b8, 0x00, sizeof(Settings.free_6b8));
memset(&Settings.rules, 0x00, sizeof(Settings.rules));
}

Settings.version = VERSION;
SettingsSave(1);
Expand Down
12 changes: 6 additions & 6 deletions sonoff/sonoff.ino
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
- Select IDE Tools - Flash Size: "1M (no SPIFFS)"
====================================================*/

#define VERSION 0x050C000A // 5.12.0j
#define VERSION 0x050C000B // 5.12.0k

// Location specific includes
#include <core_version.h> // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0)
Expand Down Expand Up @@ -558,7 +558,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
XsnsCall(FUNC_COMMAND);
// if (!XsnsCall(FUNC_COMMAND)) type = NULL;
}
else if ((CMND_SETOPTION == command_code) && ((index <= 21) || ((index > 31) && (index <= P_MAX_PARAM8 + 31)))) {
else if ((CMND_SETOPTION == command_code) && ((index <= 23) || ((index > 31) && (index <= P_MAX_PARAM8 + 31)))) {
if (index <= 31) {
ptype = 0; // SetOption0 .. 31
} else {
Expand Down Expand Up @@ -588,6 +588,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
case 19: // hass_discovery
case 20: // not_power_linked
case 21: // no_power_on_check
case 23: // rules_enabled
bitWrite(Settings.flag.data, index, payload);
}
if (12 == index) { // stop_flash_rotate
Expand Down Expand Up @@ -1305,13 +1306,13 @@ void PublishStatus(uint8_t payload)
}

if ((0 == payload) || (7 == payload)) {
#ifdef USE_SUNRISE
#if defined(USE_TIMERS) && defined(USE_SUNRISE)
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_STATUS D_STATUS7_TIME "\":{\"" D_JSON_UTC_TIME "\":\"%s\",\"" D_JSON_LOCAL_TIME "\":\"%s\",\"" D_JSON_STARTDST "\":\"%s\",\"" D_JSON_ENDDST "\":\"%s\",\"" D_CMND_TIMEZONE "\":%d,\"" D_JSON_SUNRISE "\":\"%s\",\"" D_JSON_SUNSET "\":\"%s\"}}"),
GetTime(0).c_str(), GetTime(1).c_str(), GetTime(2).c_str(), GetTime(3).c_str(), Settings.timezone, GetSun(0).c_str(), GetSun(1).c_str());
#else
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_STATUS D_STATUS7_TIME "\":{\"" D_JSON_UTC_TIME "\":\"%s\",\"" D_JSON_LOCAL_TIME "\":\"%s\",\"" D_JSON_STARTDST "\":\"%s\",\"" D_JSON_ENDDST "\":\"%s\",\"" D_CMND_TIMEZONE "\":%d}}"),
GetTime(0).c_str(), GetTime(1).c_str(), GetTime(2).c_str(), GetTime(3).c_str(), Settings.timezone);
#endif // USE_SUNRISE
#endif // USE_TIMERS and USE_SUNRISE
MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "7"));
}

Expand Down Expand Up @@ -2423,11 +2424,10 @@ void loop()

#ifdef USE_WEBSERVER
PollDnsWebserver();
#endif // USE_WEBSERVER

#ifdef USE_EMULATION
if (Settings.flag2.emulation) PollUdp();
#endif // USE_EMULATION
#endif // USE_WEBSERVER

if (millis() >= state_loop_timer) StateLoop();

Expand Down
6 changes: 3 additions & 3 deletions sonoff/support.ino
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ void WifiConfig(uint8_t type)
if (type >= WIFI_RETRY) { // WIFI_RETRY and WIFI_WAIT
return;
}
#ifdef USE_EMULATION
#if defined(USE_WEBSERVER) && defined(USE_EMULATION)
UdpDisconnect();
#endif // USE_EMULATION
WiFi.disconnect(); // Solve possible Wifi hangs
Expand Down Expand Up @@ -653,7 +653,7 @@ void WifiBegin(uint8_t flag)
{
const char kWifiPhyMode[] = " BGN";

#ifdef USE_EMULATION
#if defined(USE_WEBSERVER) && defined(USE_EMULATION)
UdpDisconnect();
#endif // USE_EMULATION

Expand Down Expand Up @@ -840,7 +840,7 @@ void WifiCheck(uint8_t param)
#endif // USE_EMULATION
#endif // USE_WEBSERVER
} else {
#ifdef USE_EMULATION
#if defined(USE_WEBSERVER) && defined(USE_EMULATION)
UdpDisconnect();
#endif // USE_EMULATION
mdns_begun = false;
Expand Down
2 changes: 1 addition & 1 deletion sonoff/xdrv_00_mqtt.ino
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ void MqttReconnect()
return;
}

#ifdef USE_EMULATION
#if defined(USE_WEBSERVER) && defined(USE_EMULATION)
UdpDisconnect();
#endif // USE_EMULATION

Expand Down
7 changes: 2 additions & 5 deletions sonoff/xplg_wemohue.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifdef USE_EMULATION
#if defined(USE_WEBSERVER) && defined(USE_EMULATION)
/*********************************************************************************************\
* Belkin WeMo and Philips Hue bridge emulation
\*********************************************************************************************/
Expand Down Expand Up @@ -266,7 +266,6 @@ void PollUdp()
}
}

#ifdef USE_WEBSERVER
/*********************************************************************************************\
* Wemo web server additions
\*********************************************************************************************/
Expand Down Expand Up @@ -814,6 +813,4 @@ void HandleHueApi(String *path)
else if (path->endsWith("/rules")) HueNotImplemented(path);
else HueGlobalConfig(path);
}
#endif // USE_WEBSERVER
#endif // USE_EMULATION

#endif // USE_WEBSERVER && USE_EMULATION

0 comments on commit 40498b7

Please sign in to comment.