Skip to content

Commit

Permalink
v5.0.1
Browse files Browse the repository at this point in the history
5.0.1 20170429
* Adjust Sonoff SC messages to prepare for display feature
* Move static data from RAM to Flash
* Fix PowerOnState for some devices not reporting "Power on" state
(#284, #380, #383)
  • Loading branch information
arendst committed Apr 29, 2017
1 parent 9b69cea commit 1dcde6a
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 133 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## 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.0.0** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino) for change information.
Current version is **5.0.1** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino) for change information.

### **** ATTENTION Version 5.0.0 specific information ****
### **** ATTENTION Version 5.0.x specific information ****

This version uses a new linker script to free flash memory for future code additions. It moves the settings from Spiffs to Eeprom. If you compile your own firmware download the new linker to your IDE or Platformio base folder. See [Wiki > Prerequisite](https://github.com/arendst/Sonoff-Tasmota/wiki/Prerequisite).

Expand Down
Binary file modified api/arduino/sonoff.ino.bin
Binary file not shown.
7 changes: 6 additions & 1 deletion sonoff/_releasenotes.ino
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
/* 5.0.0 20170425
/* 5.0.1 20170429
* Adjust Sonoff SC messages to prepare for display feature
* Move static data from RAM to Flash
* Fix PowerOnState for some devices not reporting "Power on" state (#284, #380, #383)
*
* 5.0.0 20170425
* Memory status message update
* Fix setting migration to better preserve settings during move (#382)
* Best practice is first doing a Backup Configuration before installing version 5.0.0
Expand Down
154 changes: 81 additions & 73 deletions sonoff/sonoff.ino

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions sonoff/xdrv_domoticz.ino
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ boolean domoticz_mqttData(char *topicBuf, uint16_t stopicBuf, char *dataBuf, uin
if (!domoticz.success()) {
return 1;
}
// if (strcmp(domoticz["dtype"],"Light/Switch")) {
// if (strcmp_P(domoticz["dtype"],PSTR("Light/Switch"))) {
// return 1;
// }
idx = domoticz["idx"];
Expand Down Expand Up @@ -210,47 +210,47 @@ boolean domoticz_command(const char *type, uint16_t index, char *dataBuf, uint16
{
boolean serviced = true;

if (!strncmp(type,"DOMOTICZ",8)) {
if (!strcmp(type +8,"INTOPIC")) {
if (!strncmp_P(type,PSTR("DOMOTICZ"),8)) {
if (!strcmp_P(type +8,PSTR("INTOPIC"))) {
if ((data_len > 0) && (data_len < sizeof(sysCfg.domoticz_in_topic))) {
strlcpy(sysCfg.domoticz_in_topic, (1 == payload) ? DOMOTICZ_IN_TOPIC : dataBuf, sizeof(sysCfg.domoticz_in_topic));
restartflag = 2;
}
snprintf_P(svalue, ssvalue, PSTR("{\"DomoticzInTopic\":\"%s\"}"), sysCfg.domoticz_in_topic);
}
else if (!strcmp(type +8,"OUTTOPIC")) {
else if (!strcmp_P(type +8,PSTR("OUTTOPIC"))) {
if ((data_len > 0) && (data_len < sizeof(sysCfg.domoticz_out_topic))) {
strlcpy(sysCfg.domoticz_out_topic, (1 == payload) ? DOMOTICZ_OUT_TOPIC : dataBuf, sizeof(sysCfg.domoticz_out_topic));
restartflag = 2;
}
snprintf_P(svalue, ssvalue, PSTR("{\"DomoticzOutTopic\":\"%s\"}"), sysCfg.domoticz_out_topic);
}
else if (!strcmp(type +8,"IDX") && (index > 0) && (index <= Maxdevice)) {
else if (!strcmp_P(type +8,PSTR("IDX")) && (index > 0) && (index <= Maxdevice)) {
if ((data_len > 0) && (payload >= 0)) {
sysCfg.domoticz_relay_idx[index -1] = payload;
restartflag = 2;
}
snprintf_P(svalue, ssvalue, PSTR("{\"DomoticzIdx%d\":%d}"), index, sysCfg.domoticz_relay_idx[index -1]);
}
else if (!strcmp(type +8,"KEYIDX") && (index > 0) && (index <= Maxdevice)) {
else if (!strcmp_P(type +8,PSTR("KEYIDX")) && (index > 0) && (index <= Maxdevice)) {
if ((data_len > 0) && (payload >= 0)) {
sysCfg.domoticz_key_idx[index -1] = payload;
}
snprintf_P(svalue, ssvalue, PSTR("{\"DomoticzKeyIdx%d\":%d}"), index, sysCfg.domoticz_key_idx[index -1]);
}
else if (!strcmp(type +8,"SWITCHIDX") && (index > 0) && (index <= Maxdevice)) {
else if (!strcmp_P(type +8,PSTR("SWITCHIDX")) && (index > 0) && (index <= Maxdevice)) {
if ((data_len > 0) && (payload >= 0)) {
sysCfg.domoticz_switch_idx[index -1] = payload;
}
snprintf_P(svalue, ssvalue, PSTR("{\"DomoticzSwitchIdx%d\":%d}"), index, sysCfg.domoticz_key_idx[index -1]);
}
else if (!strcmp(type +8,"SENSORIDX") && (index > 0) && (index <= DOMOTICZ_MAX_SENSORS)) {
else if (!strcmp_P(type +8,PSTR("SENSORIDX")) && (index > 0) && (index <= DOMOTICZ_MAX_SENSORS)) {
if ((data_len > 0) && (payload >= 0)) {
sysCfg.domoticz_sensor_idx[index -1] = payload;
}
snprintf_P(svalue, ssvalue, PSTR("{\"DomoticzSensorIdx%d\":%d}"), index, sysCfg.domoticz_sensor_idx[index -1]);
}
else if (!strcmp(type +8,"UPDATETIMER")) {
else if (!strcmp_P(type +8,PSTR("UPDATETIMER"))) {
if ((data_len > 0) && (payload >= 0) && (payload < 3601)) {
sysCfg.domoticz_update_timer = payload;
}
Expand Down
22 changes: 11 additions & 11 deletions sonoff/xdrv_ir_send.ino
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ boolean ir_send_command(char *type, uint16_t index, char *dataBufUc, uint16_t da

// char log[LOGSZ];

if (!strcmp(type,"IRSEND")) {
if (!strcmp_P(type,PSTR("IRSEND"))) {
if (data_len) {
StaticJsonBuffer<128> jsonBuf;
JsonObject &ir_json = jsonBuf.parseObject(dataBufUc);
Expand All @@ -102,13 +102,13 @@ boolean ir_send_command(char *type, uint16_t index, char *dataBufUc, uint16_t da
bits = ir_json["BITS"];
data = ir_json["DATA"];
if (protocol && bits && data) {
if (!strcmp(protocol,"NEC")) irsend->sendNEC(data, bits);
else if (!strcmp(protocol,"SONY")) irsend->sendSony(data, bits);
else if (!strcmp(protocol,"RC5")) irsend->sendRC5(data, bits);
else if (!strcmp(protocol,"RC6")) irsend->sendRC6(data, bits);
else if (!strcmp(protocol,"DISH")) irsend->sendDISH(data, bits);
else if (!strcmp(protocol,"JVC")) irsend->sendJVC(data, bits, 1);
else if (!strcmp(protocol,"SAMSUNG")) irsend->sendSAMSUNG(data, bits);
if (!strcmp_P(protocol,PSTR("NEC"))) irsend->sendNEC(data, bits);
else if (!strcmp_P(protocol,PSTR("SONY"))) irsend->sendSony(data, bits);
else if (!strcmp_P(protocol,PSTR("RC5"))) irsend->sendRC5(data, bits);
else if (!strcmp_P(protocol,PSTR("RC6"))) irsend->sendRC6(data, bits);
else if (!strcmp_P(protocol,PSTR("DISH"))) irsend->sendDISH(data, bits);
else if (!strcmp_P(protocol,PSTR("JVC"))) irsend->sendJVC(data, bits, 1);
else if (!strcmp_P(protocol,PSTR("SAMSUNG"))) irsend->sendSAMSUNG(data, bits);
else {
snprintf_P(svalue, ssvalue, PSTR("{\"IRSend\":\"Protocol not supported\"}"));
}
Expand All @@ -120,7 +120,7 @@ boolean ir_send_command(char *type, uint16_t index, char *dataBufUc, uint16_t da
}
}
#ifdef USE_IR_HVAC
else if (!strcmp(type,"IRHVAC")) {
else if (!strcmp_P(type,PSTR("IRHVAC"))) {
if (data_len) {
StaticJsonBuffer<164> jsonBufer;
JsonObject &root = jsonBufer.parseObject(dataBufUc);
Expand All @@ -138,10 +138,10 @@ boolean ir_send_command(char *type, uint16_t index, char *dataBufUc, uint16_t da
// HVAC_Vendor, HVAC_Power, HVAC_Mode, HVAC_FanMode, HVAC_Temp);
// addLog(LOG_LEVEL_DEBUG, log);

if (HVAC_Vendor == NULL || !strcmp(HVAC_Vendor,"TOSHIBA")) {
if (HVAC_Vendor == NULL || !strcmp_P(HVAC_Vendor,PSTR("TOSHIBA"))) {
error = ir_hvac_toshiba(HVAC_Mode, HVAC_FanMode, HVAC_Power, HVAC_Temp);
}
else if (!strcmp(HVAC_Vendor,"MITSUBISHI")) {
else if (!strcmp_P(HVAC_Vendor,PSTR("MITSUBISHI"))) {
error = ir_hvac_mitsubishi(HVAC_Mode, HVAC_FanMode, HVAC_Power, HVAC_Temp);
}
else error = true;
Expand Down
14 changes: 7 additions & 7 deletions sonoff/xdrv_snfled.ino
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ boolean sl_command(char *type, uint16_t index, char *dataBufUc, uint16_t data_le
boolean serviced = true;
boolean coldim = false;

if (!strcmp(type,"COLOR")) {
if (!strcmp_P(type,PSTR("COLOR"))) {
uint8_t my_color[5];
if (4 == data_len) {
char ccold[3], cwarm[3];
Expand Down Expand Up @@ -212,15 +212,15 @@ boolean sl_command(char *type, uint16_t index, char *dataBufUc, uint16_t data_le
snprintf_P(svalue, ssvalue, PSTR("{\"Color\":\"%04X\"}"), color);
}
}
else if (!strcmp(type,"DIMMER")) {
else if (!strcmp_P(type,PSTR("DIMMER"))) {
if ((data_len > 0) && (payload >= 0) && (payload <= 100)) {
sysCfg.led_dimmer[0] = payload;
coldim = true;
} else {
snprintf_P(svalue, ssvalue, PSTR("{\"Dimmer\":%d}"), sysCfg.led_dimmer[0]);
}
}
else if (!strcmp(type,"LEDTABLE")) {
else if (!strcmp_P(type,PSTR("LEDTABLE"))) {
if ((data_len > 0) && (payload >= 0) && (payload <= 2)) {
switch (payload) {
case 0: // Off
Expand All @@ -235,7 +235,7 @@ boolean sl_command(char *type, uint16_t index, char *dataBufUc, uint16_t data_le
}
snprintf_P(svalue, ssvalue, PSTR("{\"LedTable\":\"%s\"}"), getStateText(sysCfg.led_table));
}
else if (!strcmp(type,"FADE")) {
else if (!strcmp_P(type,PSTR("FADE"))) {
if ((data_len > 0) && (payload >= 0) && (payload <= 2)) {
switch (payload) {
case 0: // Off
Expand All @@ -249,20 +249,20 @@ boolean sl_command(char *type, uint16_t index, char *dataBufUc, uint16_t data_le
}
snprintf_P(svalue, ssvalue, PSTR("{\"Fade\":\"%s\"}"), getStateText(sysCfg.led_fade));
}
else if (!strcmp(type,"SPEED")) { // 1 - fast, 8 - slow
else if (!strcmp_P(type,PSTR("SPEED"))) { // 1 - fast, 8 - slow
if ((data_len > 0) && (payload > 0) && (payload <= 8)) {
sysCfg.led_speed = payload;
}
snprintf_P(svalue, ssvalue, PSTR("{\"Speed\":%d}"), sysCfg.led_speed);
}
else if (!strcmp(type,"WAKEUPDURATION")) {
else if (!strcmp_P(type,PSTR("WAKEUPDURATION"))) {
if ((data_len > 0) && (payload > 0) && (payload < 3601)) {
sysCfg.led_wakeup = payload;
sl_wakeupActive = 0;
}
snprintf_P(svalue, ssvalue, PSTR("{\"WakeUpDuration\":%d}"), sysCfg.led_wakeup);
}
else if (!strcmp(type,"WAKEUP")) {
else if (!strcmp_P(type,PSTR("WAKEUP"))) {
do_cmnd_power(index, 1);
sl_wakeupActive = 1;
snprintf_P(svalue, ssvalue, PSTR("{\"Wakeup\":\"Started\"}"));
Expand Down
7 changes: 4 additions & 3 deletions sonoff/xdrv_snfsc.ino
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void sc_rcvstat(char *rcvstat)
Serial.write("AT+SEND=fail\e");
}
}
else if (!strcmp(rcvstat,"AT+STATUS?")) {
else if (!strcmp_P(rcvstat,PSTR("AT+STATUS?"))) {
Serial.write("AT+STATUS=4\e");
}
}
Expand All @@ -118,7 +118,8 @@ void sc_mqttPresent(char* svalue, uint16_t ssvalue, uint8_t* djson)
dtostrf(t, 1, TEMP_RESOLUTION &3, stemp1);
float h = sc_value[0];
dtostrf(h, 1, HUMIDITY_RESOLUTION &3, stemp2);
snprintf_P(svalue, ssvalue, PSTR("%s, \"SC\":{\"Temperature\":%s, \"Humidity\":%s, \"Light\":%d, \"Noise\":%d, \"AirQuality\":%d}"),
// snprintf_P(svalue, ssvalue, PSTR("%s, \"SC\":{\"Temperature\":%s, \"Humidity\":%s, \"Light\":%d, \"Noise\":%d, \"AirQuality\":%d}"),
snprintf_P(svalue, ssvalue, PSTR("%s, \"Temperature\":%s, \"Humidity\":%s, \"Light\":%d, \"Noise\":%d, \"AirQuality\":%d"),
svalue, stemp1, stemp2, sc_value[2], sc_value[3], sc_value[4]);
*djson = 1;
#ifdef USE_DOMOTICZ
Expand All @@ -136,7 +137,7 @@ String sc_webPresent()
if (sc_value[0] > 0) {
char stemp[10];
char sensor[80];
char scstype[] = "SC";
char scstype[] = "";

float t = sc_value[1];
if (TEMP_CONVERSION) {
Expand Down
20 changes: 10 additions & 10 deletions sonoff/xdrv_ws2812.ino
Original file line number Diff line number Diff line change
Expand Up @@ -532,29 +532,29 @@ boolean ws2812_command(char *type, uint16_t index, char *dataBuf, uint16_t data_
{
boolean serviced = true;

if (!strcmp(type,"PIXELS")) {
if (!strcmp_P(type,PSTR("PIXELS"))) {
if ((data_len > 0) && (payload > 0) && (payload <= WS2812_MAX_LEDS)) {
sysCfg.ws_pixels = payload;
ws2812_pixels();
}
snprintf_P(svalue, ssvalue, PSTR("{\"Pixels\":%d}"), sysCfg.ws_pixels);
}
else if (!strcmp(type,"LED") && (index > 0) && (index <= sysCfg.ws_pixels)) {
else if (!strcmp_P(type,PSTR("LED")) && (index > 0) && (index <= sysCfg.ws_pixels)) {
if (6 == data_len) {
// ws2812_setColor(index, dataBufUc);
ws2812_setColor(index, dataBuf);
}
ws2812_getColor(index, svalue, ssvalue);
}
else if (!strcmp(type,"COLOR")) {
else if (!strcmp_P(type,PSTR("COLOR"))) {
if (6 == data_len) {
// ws2812_setColor(0, dataBufUc);
ws2812_setColor(0, dataBuf);
power = 1;
}
ws2812_getColor(0, svalue, ssvalue);
}
else if (!strcmp(type,"DIMMER")) {
else if (!strcmp_P(type,PSTR("DIMMER"))) {
if ((data_len > 0) && (payload >= 0) && (payload <= 100)) {
sysCfg.ws_dimmer = payload;
power = 1;
Expand All @@ -564,7 +564,7 @@ boolean ws2812_command(char *type, uint16_t index, char *dataBuf, uint16_t data_
}
snprintf_P(svalue, ssvalue, PSTR("{\"Dimmer\":%d}"), sysCfg.ws_dimmer);
}
else if (!strcmp(type,"LEDTABLE")) {
else if (!strcmp_P(type,PSTR("LEDTABLE"))) {
if ((data_len > 0) && (payload >= 0) && (payload <= 2)) {
switch (payload) {
case 0: // Off
Expand All @@ -579,7 +579,7 @@ boolean ws2812_command(char *type, uint16_t index, char *dataBuf, uint16_t data_
}
snprintf_P(svalue, ssvalue, PSTR("{\"LedTable\":\"%s\"}"), getStateText(sysCfg.ws_ledtable));
}
else if (!strcmp(type,"FADE")) {
else if (!strcmp_P(type,PSTR("FADE"))) {
if ((data_len > 0) && (payload >= 0) && (payload <= 2)) {
switch (payload) {
case 0: // Off
Expand All @@ -593,19 +593,19 @@ boolean ws2812_command(char *type, uint16_t index, char *dataBuf, uint16_t data_
}
snprintf_P(svalue, ssvalue, PSTR("{\"Fade\":\"%s\"}"), getStateText(sysCfg.ws_fade));
}
else if (!strcmp(type,"SPEED")) { // 1 - fast, 5 - slow
else if (!strcmp_P(type,PSTR("SPEED"))) { // 1 - fast, 5 - slow
if ((data_len > 0) && (payload > 0) && (payload <= 5)) {
sysCfg.ws_speed = payload;
}
snprintf_P(svalue, ssvalue, PSTR("{\"Speed\":%d}"), sysCfg.ws_speed);
}
else if (!strcmp(type,"WIDTH")) {
else if (!strcmp_P(type,PSTR("WIDTH"))) {
if ((data_len > 0) && (payload >= 0) && (payload <= 4)) {
sysCfg.ws_width = payload;
}
snprintf_P(svalue, ssvalue, PSTR("{\"Width\":%d}"), sysCfg.ws_width);
}
else if (!strcmp(type,"WAKEUP")) {
else if (!strcmp_P(type,PSTR("WAKEUP"))) {
if ((data_len > 0) && (payload > 0) && (payload < 3601)) {
sysCfg.ws_wakeup = payload;
if (1 == sysCfg.ws_scheme) {
Expand All @@ -614,7 +614,7 @@ boolean ws2812_command(char *type, uint16_t index, char *dataBuf, uint16_t data_
}
snprintf_P(svalue, ssvalue, PSTR("{\"WakeUp\":%d}"), sysCfg.ws_wakeup);
}
else if (!strcmp(type,"SCHEME")) {
else if (!strcmp_P(type,PSTR("SCHEME"))) {
if ((data_len > 0) && (payload >= 0) && (payload <= 9)) {
sysCfg.ws_scheme = payload;
if (1 == sysCfg.ws_scheme) {
Expand Down
Loading

0 comments on commit 1dcde6a

Please sign in to comment.