mirror of https://github.com/arendst/Tasmota.git
v5.0.1
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)
This commit is contained in:
parent
9b69cead60
commit
1dcde6aac4
|
@ -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).
|
||||
|
||||
|
|
Binary file not shown.
|
@ -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
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* ====================================================
|
||||
*/
|
||||
|
||||
#define VERSION 0x05000000 // 5.0.0
|
||||
#define VERSION 0x05000100 // 5.0.1
|
||||
|
||||
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};
|
||||
|
@ -156,6 +156,9 @@ enum butt_t {PRESSED, NOT_PRESSED};
|
|||
#ifdef USE_I2C
|
||||
#include <Wire.h> // I2C support library
|
||||
#endif // USE_I2C
|
||||
#ifdef USI_SPI
|
||||
#include <SPI.h> // SPI, TFT
|
||||
#endif // USE_SPI
|
||||
#include "settings.h"
|
||||
|
||||
typedef void (*rtcCallback)();
|
||||
|
@ -264,6 +267,7 @@ uint8_t swt_flg = 0; // Any external switch configured
|
|||
uint8_t dht_type = 0; // DHT type (DHT11, DHT21 or DHT22)
|
||||
uint8_t hlw_flg = 0; // Power monitor configured
|
||||
uint8_t i2c_flg = 0; // I2C configured
|
||||
uint8_t spi_flg = 0; // SPI configured
|
||||
uint8_t pwm_flg = 0; // PWM configured
|
||||
uint8_t pwm_idxoffset = 0; // Allowed PWM command offset (change for Sonoff Led)
|
||||
|
||||
|
@ -620,27 +624,27 @@ boolean mqtt_command(boolean grpflg, char *type, uint16_t index, char *dataBuf,
|
|||
char stemp2[10];
|
||||
uint16_t i;
|
||||
|
||||
if (!strcmp(type,"MQTTHOST")) {
|
||||
if (!strcmp_P(type,PSTR("MQTTHOST"))) {
|
||||
if ((data_len > 0) && (data_len < sizeof(sysCfg.mqtt_host))) {
|
||||
strlcpy(sysCfg.mqtt_host, (1 == payload) ? MQTT_HOST : dataBuf, sizeof(sysCfg.mqtt_host));
|
||||
restartflag = 2;
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"MqttHost\",\"%s\"}"), sysCfg.mqtt_host);
|
||||
}
|
||||
else if (!strcmp(type,"MQTTPORT")) {
|
||||
else if (!strcmp_P(type,PSTR("MQTTPORT"))) {
|
||||
if ((data_len > 0) && (payload > 0) && (payload < 32766)) {
|
||||
sysCfg.mqtt_port = (1 == payload) ? MQTT_PORT : payload;
|
||||
restartflag = 2;
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"MqttPort\":%d}"), sysCfg.mqtt_port);
|
||||
}
|
||||
else if (!strcmp(type,"MQTTRESPONSE")) {
|
||||
else if (!strcmp_P(type,PSTR("MQTTRESPONSE"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload <= 1)) {
|
||||
sysCfg.mqtt_response = payload;
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"MqttResponse\":\"%s\"}"), getStateText(sysCfg.mqtt_response));
|
||||
}
|
||||
else if (!strcmp(type,"STATETEXT") && (index > 0) && (index <= 3)) {
|
||||
else if (!strcmp_P(type,PSTR("STATETEXT")) && (index > 0) && (index <= 3)) {
|
||||
if ((data_len > 0) && (data_len < sizeof(sysCfg.state_text[0]))) {
|
||||
for(i = 0; i <= data_len; i++) {
|
||||
if (dataBuf[i] == ' ') {
|
||||
|
@ -652,7 +656,7 @@ boolean mqtt_command(boolean grpflg, char *type, uint16_t index, char *dataBuf,
|
|||
snprintf_P(svalue, ssvalue, PSTR("{\"StateText%d\":\"%s\"}"), index, getStateText(index -1));
|
||||
}
|
||||
#ifdef USE_MQTT_TLS
|
||||
else if (!strcmp(type,"MQTTFINGERPRINT")) {
|
||||
else if (!strcmp_P(type,PSTR("MQTTFINGERPRINT"))) {
|
||||
if ((data_len > 0) && (data_len < sizeof(sysCfg.mqtt_fingerprint))) {
|
||||
strlcpy(sysCfg.mqtt_fingerprint, (!strcmp(dataBuf,"0")) ? "" : (1 == payload) ? MQTT_FINGERPRINT : dataBuf, sizeof(sysCfg.mqtt_fingerprint));
|
||||
restartflag = 2;
|
||||
|
@ -660,28 +664,28 @@ boolean mqtt_command(boolean grpflg, char *type, uint16_t index, char *dataBuf,
|
|||
snprintf_P(svalue, ssvalue, PSTR("{\"MqttFingerprint\":\"%s\"}"), sysCfg.mqtt_fingerprint);
|
||||
}
|
||||
#endif
|
||||
else if (!grpflg && !strcmp(type,"MQTTCLIENT")) {
|
||||
else if (!grpflg && !strcmp_P(type,PSTR("MQTTCLIENT"))) {
|
||||
if ((data_len > 0) && (data_len < sizeof(sysCfg.mqtt_client))) {
|
||||
strlcpy(sysCfg.mqtt_client, (1 == payload) ? MQTT_CLIENT_ID : dataBuf, sizeof(sysCfg.mqtt_client));
|
||||
restartflag = 2;
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"MqttClient\":\"%s\"}"), sysCfg.mqtt_client);
|
||||
}
|
||||
else if (!strcmp(type,"MQTTUSER")) {
|
||||
else if (!strcmp_P(type,PSTR("MQTTUSER"))) {
|
||||
if ((data_len > 0) && (data_len < sizeof(sysCfg.mqtt_user))) {
|
||||
strlcpy(sysCfg.mqtt_user, (!strcmp(dataBuf,"0")) ? "" : (1 == payload) ? MQTT_USER : dataBuf, sizeof(sysCfg.mqtt_user));
|
||||
restartflag = 2;
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("[\"MqttUser\":\"%s\"}"), sysCfg.mqtt_user);
|
||||
}
|
||||
else if (!strcmp(type,"MQTTPASSWORD")) {
|
||||
else if (!strcmp_P(type,PSTR("MQTTPASSWORD"))) {
|
||||
if ((data_len > 0) && (data_len < sizeof(sysCfg.mqtt_pwd))) {
|
||||
strlcpy(sysCfg.mqtt_pwd, (!strcmp(dataBuf,"0")) ? "" : (1 == payload) ? MQTT_PASS : dataBuf, sizeof(sysCfg.mqtt_pwd));
|
||||
restartflag = 2;
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"MqttPassword\":\"%s\"}"), sysCfg.mqtt_pwd);
|
||||
}
|
||||
else if (!strcmp(type,"PREFIX") && (index > 0) && (index <= 3)) {
|
||||
else if (!strcmp_P(type,PSTR("PREFIX")) && (index > 0) && (index <= 3)) {
|
||||
if ((data_len > 0) && (data_len < sizeof(sysCfg.mqtt_prefix[0]))) {
|
||||
for(i = 0; i <= data_len; i++) {
|
||||
if ((dataBuf[i] == '+') || (dataBuf[i] == '#') || (dataBuf[i] == ' ')) {
|
||||
|
@ -694,7 +698,7 @@ boolean mqtt_command(boolean grpflg, char *type, uint16_t index, char *dataBuf,
|
|||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"Prefix%d\":\"%s\"}"), index, sysCfg.mqtt_prefix[index -1]);
|
||||
}
|
||||
else if (!strcmp(type,"GROUPTOPIC")) {
|
||||
else if (!strcmp_P(type,PSTR("GROUPTOPIC"))) {
|
||||
if ((data_len > 0) && (data_len < sizeof(sysCfg.mqtt_grptopic))) {
|
||||
for(i = 0; i <= data_len; i++) {
|
||||
if ((dataBuf[i] == '/') || (dataBuf[i] == '+') || (dataBuf[i] == '#')) {
|
||||
|
@ -709,7 +713,7 @@ boolean mqtt_command(boolean grpflg, char *type, uint16_t index, char *dataBuf,
|
|||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"GroupTopic\":\"%s\"}"), sysCfg.mqtt_grptopic);
|
||||
}
|
||||
else if (!grpflg && !strcmp(type,"TOPIC")) {
|
||||
else if (!grpflg && !strcmp_P(type,PSTR("TOPIC"))) {
|
||||
if ((data_len > 0) && (data_len < sizeof(sysCfg.mqtt_topic))) {
|
||||
for(i = 0; i <= data_len; i++) {
|
||||
if ((dataBuf[i] == '/') || (dataBuf[i] == '+') || (dataBuf[i] == '#') || (dataBuf[i] == ' ')) {
|
||||
|
@ -724,7 +728,7 @@ boolean mqtt_command(boolean grpflg, char *type, uint16_t index, char *dataBuf,
|
|||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"Topic\":\"%s\"}"), sysCfg.mqtt_topic);
|
||||
}
|
||||
else if (!grpflg && !strcmp(type,"BUTTONTOPIC")) {
|
||||
else if (!grpflg && !strcmp_P(type,PSTR("BUTTONTOPIC"))) {
|
||||
if ((data_len > 0) && (data_len < sizeof(sysCfg.button_topic))) {
|
||||
for(i = 0; i <= data_len; i++) {
|
||||
if ((dataBuf[i] == '/') || (dataBuf[i] == '+') || (dataBuf[i] == '#') || (dataBuf[i] == ' ')) {
|
||||
|
@ -738,7 +742,7 @@ boolean mqtt_command(boolean grpflg, char *type, uint16_t index, char *dataBuf,
|
|||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"ButtonTopic\":\"%s\"}"), sysCfg.button_topic);
|
||||
}
|
||||
else if (!grpflg && !strcmp(type,"SWITCHTOPIC")) {
|
||||
else if (!grpflg && !strcmp_P(type,PSTR("SWITCHTOPIC"))) {
|
||||
if ((data_len > 0) && (data_len < sizeof(sysCfg.switch_topic))) {
|
||||
for(i = 0; i <= data_len; i++) {
|
||||
if ((dataBuf[i] == '/') || (dataBuf[i] == '+') || (dataBuf[i] == '#') || (dataBuf[i] == ' ')) {
|
||||
|
@ -752,7 +756,7 @@ boolean mqtt_command(boolean grpflg, char *type, uint16_t index, char *dataBuf,
|
|||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"SwitchTopic\":\"%s\"}"), sysCfg.switch_topic);
|
||||
}
|
||||
else if (!strcmp(type,"BUTTONRETAIN")) {
|
||||
else if (!strcmp_P(type,PSTR("BUTTONRETAIN"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload <= 1)) {
|
||||
strlcpy(sysCfg.button_topic, sysCfg.mqtt_topic, sizeof(sysCfg.button_topic));
|
||||
if (!payload) {
|
||||
|
@ -764,7 +768,7 @@ boolean mqtt_command(boolean grpflg, char *type, uint16_t index, char *dataBuf,
|
|||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"ButtonRetain\":\"%s\"}"), getStateText(sysCfg.mqtt_button_retain));
|
||||
}
|
||||
else if (!strcmp(type,"SWITCHRETAIN")) {
|
||||
else if (!strcmp_P(type,PSTR("SWITCHRETAIN"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload <= 1)) {
|
||||
strlcpy(sysCfg.button_topic, sysCfg.mqtt_topic, sizeof(sysCfg.button_topic));
|
||||
if (!payload) {
|
||||
|
@ -776,7 +780,7 @@ boolean mqtt_command(boolean grpflg, char *type, uint16_t index, char *dataBuf,
|
|||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"SwitchRetain\":\"%s\"}"), getStateText(sysCfg.mqtt_switch_retain));
|
||||
}
|
||||
else if (!strcmp(type,"POWERRETAIN")) {
|
||||
else if (!strcmp_P(type,PSTR("POWERRETAIN"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload <= 1)) {
|
||||
if (!payload) {
|
||||
for(i = 1; i <= Maxdevice; i++) { // Clear MQTT retain in broker
|
||||
|
@ -897,50 +901,50 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
}
|
||||
int16_t payload = atoi(dataBuf); // -32766 - 32767
|
||||
uint16_t payload16 = atoi(dataBuf); // 0 - 65535
|
||||
if (!strcmp(dataBufUc,"OFF") || !strcmp(dataBufUc,"FALSE") || !strcmp(dataBufUc,"STOP")) {
|
||||
if (!strcmp_P(dataBufUc,PSTR("OFF")) || !strcmp_P(dataBufUc,PSTR("FALSE")) || !strcmp_P(dataBufUc,PSTR("STOP"))) {
|
||||
payload = 0;
|
||||
}
|
||||
if (!strcmp(dataBufUc,"ON") || !strcmp(dataBufUc,"TRUE") || !strcmp(dataBufUc,"START") || !strcmp(dataBufUc,"USER")) {
|
||||
if (!strcmp_P(dataBufUc,PSTR("ON")) || !strcmp_P(dataBufUc,PSTR("TRUE")) || !strcmp_P(dataBufUc,PSTR("START")) || !strcmp_P(dataBufUc,PSTR("USER"))) {
|
||||
payload = 1;
|
||||
}
|
||||
if (!strcmp(dataBufUc,"TOGGLE") || !strcmp(dataBufUc,"ADMIN")) {
|
||||
if (!strcmp_P(dataBufUc,PSTR("TOGGLE")) || !strcmp_P(dataBufUc,PSTR("ADMIN"))) {
|
||||
payload = 2;
|
||||
}
|
||||
if (!strcmp(dataBufUc,"BLINK")) {
|
||||
if (!strcmp_P(dataBufUc,PSTR("BLINK"))) {
|
||||
payload = 3;
|
||||
}
|
||||
if (!strcmp(dataBufUc,"BLINKOFF")) {
|
||||
if (!strcmp_P(dataBufUc,PSTR("BLINKOFF"))) {
|
||||
payload = 4;
|
||||
}
|
||||
|
||||
if (!strcmp(type,"POWER") && (index > 0) && (index <= Maxdevice)) {
|
||||
if (!strcmp_P(type,PSTR("POWER")) && (index > 0) && (index <= Maxdevice)) {
|
||||
if ((0 == data_len) || (payload > 4)) {
|
||||
payload = 9;
|
||||
}
|
||||
do_cmnd_power(index, payload);
|
||||
return;
|
||||
}
|
||||
else if (!strcmp(type,"STATUS")) {
|
||||
else if (!strcmp_P(type,PSTR("STATUS"))) {
|
||||
if ((0 == data_len) || (payload < 0) || (payload > MAX_STATUS)) {
|
||||
payload = 99;
|
||||
}
|
||||
publish_status(payload);
|
||||
return;
|
||||
}
|
||||
else if ((sysCfg.module != MOTOR) && !strcmp(type,"POWERONSTATE")) {
|
||||
else if ((sysCfg.module != MOTOR) && !strcmp_P(type,PSTR("POWERONSTATE"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload <= 3)) {
|
||||
sysCfg.poweronstate = payload;
|
||||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"PowerOnState\":%d}"), sysCfg.poweronstate);
|
||||
}
|
||||
else if (!strcmp(type,"PULSETIME") && (index > 0) && (index <= MAX_PULSETIMERS)) {
|
||||
else if (!strcmp_P(type,PSTR("PULSETIME")) && (index > 0) && (index <= MAX_PULSETIMERS)) {
|
||||
if (data_len > 0) {
|
||||
sysCfg.pulsetime[index -1] = payload16; // 0 - 65535
|
||||
pulse_timer[index -1] = 0;
|
||||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"PulseTime%d\":%d}"), index, sysCfg.pulsetime[index -1]);
|
||||
}
|
||||
else if (!strcmp(type,"BLINKTIME")) {
|
||||
else if (!strcmp_P(type,PSTR("BLINKTIME"))) {
|
||||
if ((data_len > 0) && (payload > 2) && (payload <= 3600)) {
|
||||
sysCfg.blinktime = payload;
|
||||
if (blink_timer) {
|
||||
|
@ -949,7 +953,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"BlinkTime\":%d}"), sysCfg.blinktime);
|
||||
}
|
||||
else if (!strcmp(type,"BLINKCOUNT")) {
|
||||
else if (!strcmp_P(type,PSTR("BLINKCOUNT"))) {
|
||||
if (data_len > 0) {
|
||||
sysCfg.blinkcount = payload16; // 0 - 65535
|
||||
if (blink_counter) {
|
||||
|
@ -961,7 +965,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
else if ((SONOFF_LED == sysCfg.module) && sl_command(type, index, dataBufUc, data_len, payload, svalue, sizeof(svalue))) {
|
||||
// Serviced
|
||||
}
|
||||
else if (!strcmp(type,"SAVEDATA")) {
|
||||
else if (!strcmp_P(type,PSTR("SAVEDATA"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload <= 3600)) {
|
||||
sysCfg.savedata = payload;
|
||||
savedatacounter = sysCfg.savedata;
|
||||
|
@ -975,32 +979,32 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"SaveData\":\"%s\"}"), (sysCfg.savedata > 1) ? stemp1 : getStateText(sysCfg.savedata));
|
||||
}
|
||||
else if (!strcmp(type,"SAVESTATE")) {
|
||||
else if (!strcmp_P(type,PSTR("SAVESTATE"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload <= 1)) {
|
||||
sysCfg.savestate = payload;
|
||||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"SaveState\":\"%s\"}"), getStateText(sysCfg.savestate));
|
||||
}
|
||||
else if (!strcmp(type,"BUTTONRESTRICT")) {
|
||||
else if (!strcmp_P(type,PSTR("BUTTONRESTRICT"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload <= 1)) {
|
||||
sysCfg.button_restrict = payload;
|
||||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"ButtonRestrict\":\"%s\"}"), getStateText(sysCfg.button_restrict));
|
||||
}
|
||||
else if (!strcmp(type,"UNITS")) {
|
||||
else if (!strcmp_P(type,PSTR("UNITS"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload <= 1)) {
|
||||
sysCfg.value_units = payload;
|
||||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Units\":\"%s\"}"), getStateText(sysCfg.value_units));
|
||||
}
|
||||
else if (!strcmp(type,"MQTT")) {
|
||||
else if (!strcmp_P(type,PSTR("MQTT"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload <= 1)) {
|
||||
sysCfg.mqtt_enabled = payload;
|
||||
restartflag = 2;
|
||||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Mqtt\":\"%s\"}"), getStateText(sysCfg.mqtt_enabled));
|
||||
}
|
||||
else if (!strcmp(type,"MODULE")) {
|
||||
else if (!strcmp_P(type,PSTR("MODULE"))) {
|
||||
if ((data_len > 0) && (payload > 0) && (payload <= MAXMODULE)) {
|
||||
payload--;
|
||||
byte new_modflg = (sysCfg.module != payload);
|
||||
|
@ -1016,7 +1020,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
snprintf_P(stemp1, sizeof(stemp1), modules[sysCfg.module].name);
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Module\":\"%d (%s)\"}"), sysCfg.module +1, stemp1);
|
||||
}
|
||||
else if (!strcmp(type,"MODULES")) {
|
||||
else if (!strcmp_P(type,PSTR("MODULES"))) {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Modules1\":\""), svalue);
|
||||
byte jsflg = 0;
|
||||
for (byte i = 0; i < MAXMODULE /2; i++) {
|
||||
|
@ -1041,7 +1045,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("%s\"}"), svalue);
|
||||
}
|
||||
else if (!strcmp(type,"GPIO") && (index < MAX_GPIO_PIN)) {
|
||||
else if (!strcmp_P(type,PSTR("GPIO")) && (index < MAX_GPIO_PIN)) {
|
||||
mytmplt cmodule;
|
||||
memcpy_P(&cmodule, &modules[sysCfg.module], sizeof(cmodule));
|
||||
if ((data_len > 0) && (GPIO_USER == cmodule.gp.io[index]) && (payload >= 0) && (payload < GPIO_SENSOR_END)) {
|
||||
|
@ -1071,7 +1075,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"GPIO\":\"Not supported\"}"));
|
||||
}
|
||||
}
|
||||
else if (!strcmp(type,"GPIOS")) {
|
||||
else if (!strcmp_P(type,PSTR("GPIOS"))) {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"GPIOs1\":\""), svalue);
|
||||
byte jsflg = 0;
|
||||
for (byte i = 0; i < GPIO_SENSOR_END /2; i++) {
|
||||
|
@ -1096,7 +1100,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("%s\"}"), svalue);
|
||||
}
|
||||
else if (!strcmp(type,"PWM") && (index > pwm_idxoffset) && (index <= 5)) {
|
||||
else if (!strcmp_P(type,PSTR("PWM")) && (index > pwm_idxoffset) && (index <= 5)) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload <= PWM_RANGE) && (pin[GPIO_PWM1 + index -1] < 99)) {
|
||||
sysCfg.pwmvalue[index -1] = payload;
|
||||
analogWrite(pin[GPIO_PWM1 + index -1], payload);
|
||||
|
@ -1111,7 +1115,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("%s}}"),svalue);
|
||||
}
|
||||
else if (!strcmp(type,"SLEEP")) {
|
||||
else if (!strcmp_P(type,PSTR("SLEEP"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload < 251)) {
|
||||
if ((!sysCfg.sleep && payload) || (sysCfg.sleep && !payload)) {
|
||||
restartflag = 2;
|
||||
|
@ -1121,7 +1125,7 @@ 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" : "");
|
||||
}
|
||||
else if (!strcmp(type,"FLASHMODE")) { // 0 = QIO, 1 = QOUT, 2 = DIO, 3 = DOUT
|
||||
else if (!strcmp_P(type,PSTR("FLASHMODE"))) { // 0 = QIO, 1 = QOUT, 2 = DIO, 3 = DOUT
|
||||
if ((data_len > 0) && (payload >= 0) && (payload <= 3)) {
|
||||
if (ESP.getFlashChipMode() != payload) {
|
||||
setFlashMode(0, payload &3);
|
||||
|
@ -1129,7 +1133,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"FlashMode\":%d}"), ESP.getFlashChipMode());
|
||||
}
|
||||
else if (!strcmp(type,"UPGRADE") || !strcmp(type,"UPLOAD")) {
|
||||
else if (!strcmp_P(type,PSTR("UPGRADE")) || !strcmp_P(type,PSTR("UPLOAD"))) {
|
||||
if ((data_len > 0) && (1 == payload)) {
|
||||
otaflag = 3;
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Upgrade\":\"Version %s from %s\"}"), Version, sysCfg.otaUrl);
|
||||
|
@ -1137,12 +1141,12 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Upgrade\":\"Option 1 to upgrade\"}"));
|
||||
}
|
||||
}
|
||||
else if (!strcmp(type,"OTAURL")) {
|
||||
else if (!strcmp_P(type,PSTR("OTAURL"))) {
|
||||
if ((data_len > 0) && (data_len < sizeof(sysCfg.otaUrl)))
|
||||
strlcpy(sysCfg.otaUrl, (1 == payload) ? OTA_URL : dataBuf, sizeof(sysCfg.otaUrl));
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"OtaUrl\":\"%s\"}"), sysCfg.otaUrl);
|
||||
}
|
||||
else if (!strcmp(type,"SERIALLOG")) {
|
||||
else if (!strcmp_P(type,PSTR("SERIALLOG"))) {
|
||||
if ((data_len > 0) && (payload >= LOG_LEVEL_NONE) && (payload <= LOG_LEVEL_ALL)) {
|
||||
sysCfg.seriallog_level = payload;
|
||||
seriallog_level = payload;
|
||||
|
@ -1150,7 +1154,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"SerialLog\":\"%d (Active %d)\"}"), sysCfg.seriallog_level, seriallog_level);
|
||||
}
|
||||
else if (!strcmp(type,"SYSLOG")) {
|
||||
else if (!strcmp_P(type,PSTR("SYSLOG"))) {
|
||||
if ((data_len > 0) && (payload >= LOG_LEVEL_NONE) && (payload <= LOG_LEVEL_ALL)) {
|
||||
sysCfg.syslog_level = payload;
|
||||
syslog_level = (sysCfg.emulation) ? 0 : payload;
|
||||
|
@ -1158,19 +1162,19 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"SysLog\":\"%d (Active %d)\"}"), sysCfg.syslog_level, syslog_level);
|
||||
}
|
||||
else if (!strcmp(type,"LOGHOST")) {
|
||||
else if (!strcmp_P(type,PSTR("LOGHOST"))) {
|
||||
if ((data_len > 0) && (data_len < sizeof(sysCfg.syslog_host))) {
|
||||
strlcpy(sysCfg.syslog_host, (1 == payload) ? SYS_LOG_HOST : dataBuf, sizeof(sysCfg.syslog_host));
|
||||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"LogHost\":\"%s\"}"), sysCfg.syslog_host);
|
||||
}
|
||||
else if (!strcmp(type,"LOGPORT")) {
|
||||
else if (!strcmp_P(type,PSTR("LOGPORT"))) {
|
||||
if ((data_len > 0) && (payload > 0) && (payload < 32766)) {
|
||||
sysCfg.syslog_port = (1 == payload) ? SYS_LOG_PORT : payload;
|
||||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"LogPort\":%d}"), sysCfg.syslog_port);
|
||||
}
|
||||
else if (!strcmp(type,"IPADDRESS") && (index > 0) && (index <= 4)) {
|
||||
else if (!strcmp_P(type,PSTR("IPADDRESS")) && (index > 0) && (index <= 4)) {
|
||||
if (parseIP(&address, dataBuf)) {
|
||||
sysCfg.ip_address[index -1] = address;
|
||||
// restartflag = 2;
|
||||
|
@ -1178,7 +1182,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
snprintf_P(stemp1, sizeof(stemp1), PSTR(" (%s)"), WiFi.localIP().toString().c_str());
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"IPAddress%d\":\"%s%s\"}"), index, IPAddress(sysCfg.ip_address[index -1]).toString().c_str(), (1 == index) ? stemp1:"");
|
||||
}
|
||||
else if (!strcmp(type,"NTPSERVER") && (index > 0) && (index <= 3)) {
|
||||
else if (!strcmp_P(type,PSTR("NTPSERVER")) && (index > 0) && (index <= 3)) {
|
||||
if ((data_len > 0) && (data_len < sizeof(sysCfg.ntp_server[0]))) {
|
||||
strlcpy(sysCfg.ntp_server[index -1], (!strcmp(dataBuf,"0")) ? "" : (1 == payload) ? (1==index)?NTP_SERVER1:(2==index)?NTP_SERVER2:NTP_SERVER3 : dataBuf, sizeof(sysCfg.ntp_server[0]));
|
||||
for (i = 0; i < strlen(sysCfg.ntp_server[index -1]); i++) {
|
||||
|
@ -1190,7 +1194,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"NtpServer%d\":\"%s\"}"), index, sysCfg.ntp_server[index -1]);
|
||||
}
|
||||
else if (!strcmp(type,"AP")) {
|
||||
else if (!strcmp_P(type,PSTR("AP"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload <= 2)) {
|
||||
switch (payload) {
|
||||
case 0: // Toggle
|
||||
|
@ -1204,7 +1208,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Ap\":\"%d (%s)\"}"), sysCfg.sta_active +1, sysCfg.sta_ssid[sysCfg.sta_active]);
|
||||
}
|
||||
else if (!strcmp(type,"SSID") && (index > 0) && (index <= 2)) {
|
||||
else if (!strcmp_P(type,PSTR("SSID")) && (index > 0) && (index <= 2)) {
|
||||
if ((data_len > 0) && (data_len < sizeof(sysCfg.sta_ssid[0]))) {
|
||||
strlcpy(sysCfg.sta_ssid[index -1], (1 == payload) ? (1 == index) ? STA_SSID1 : STA_SSID2 : dataBuf, sizeof(sysCfg.sta_ssid[0]));
|
||||
sysCfg.sta_active = 0;
|
||||
|
@ -1212,7 +1216,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"SSid%d\":\"%s\"}"), index, sysCfg.sta_ssid[index -1]);
|
||||
}
|
||||
else if (!strcmp(type,"PASSWORD") && (index > 0) && (index <= 2)) {
|
||||
else if (!strcmp_P(type,PSTR("PASSWORD")) && (index > 0) && (index <= 2)) {
|
||||
if ((data_len > 0) && (data_len < sizeof(sysCfg.sta_pwd[0]))) {
|
||||
strlcpy(sysCfg.sta_pwd[index -1], (1 == payload) ? (1 == index) ? STA_PASS1 : STA_PASS2 : dataBuf, sizeof(sysCfg.sta_pwd[0]));
|
||||
sysCfg.sta_active = 0;
|
||||
|
@ -1220,7 +1224,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Password%d\":\"%s\"}"), index, sysCfg.sta_pwd[index -1]);
|
||||
}
|
||||
else if (!grpflg && !strcmp(type,"HOSTNAME")) {
|
||||
else if (!grpflg && !strcmp_P(type,PSTR("HOSTNAME"))) {
|
||||
if ((data_len > 0) && (data_len < sizeof(sysCfg.hostname))) {
|
||||
strlcpy(sysCfg.hostname, (1 == payload) ? WIFI_HOSTNAME : dataBuf, sizeof(sysCfg.hostname));
|
||||
if (strstr(sysCfg.hostname,"%")) {
|
||||
|
@ -1230,7 +1234,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Hostname\":\"%s\"}"), sysCfg.hostname);
|
||||
}
|
||||
else if (!strcmp(type,"WIFICONFIG")) {
|
||||
else if (!strcmp_P(type,PSTR("WIFICONFIG"))) {
|
||||
if ((data_len > 0) && (payload >= WIFI_RESTART) && (payload < MAX_WIFI_OPTION)) {
|
||||
sysCfg.sta_config = payload;
|
||||
wificheckflag = sysCfg.sta_config;
|
||||
|
@ -1245,7 +1249,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"WifiConfig\":\"%d (%s)\"}"), sysCfg.sta_config, stemp1);
|
||||
}
|
||||
}
|
||||
else if (!strcmp(type,"FRIENDLYNAME") && (index > 0) && (index <= 4)) {
|
||||
else if (!strcmp_P(type,PSTR("FRIENDLYNAME")) && (index > 0) && (index <= 4)) {
|
||||
if ((data_len > 0) && (data_len < sizeof(sysCfg.friendlyname[0]))) {
|
||||
if (1 == index) {
|
||||
snprintf_P(stemp1, sizeof(stemp1), PSTR(FRIENDLY_NAME));
|
||||
|
@ -1256,14 +1260,14 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"FriendlyName%d\":\"%s\"}"), index, sysCfg.friendlyname[index -1]);
|
||||
}
|
||||
else if (swt_flg && !strcmp(type,"SWITCHMODE") && (index > 0) && (index <= 4)) {
|
||||
else if (swt_flg && !strcmp_P(type,PSTR("SWITCHMODE")) && (index > 0) && (index <= 4)) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload < MAX_SWITCH_OPTION)) {
|
||||
sysCfg.switchmode[index -1] = payload;
|
||||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"SwitchMode%d\":%d}"), index, sysCfg.switchmode[index-1]);
|
||||
}
|
||||
#ifdef USE_WEBSERVER
|
||||
else if (!strcmp(type,"WEBSERVER")) {
|
||||
else if (!strcmp_P(type,PSTR("WEBSERVER"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload <= 2)) {
|
||||
sysCfg.webserver = payload;
|
||||
}
|
||||
|
@ -1274,20 +1278,20 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Webserver\":\"%s\"}"), getStateText(0));
|
||||
}
|
||||
}
|
||||
else if (!strcmp(type,"WEBPASSWORD")) {
|
||||
else if (!strcmp_P(type,PSTR("WEBPASSWORD"))) {
|
||||
if ((data_len > 0) && (data_len < sizeof(sysCfg.web_password))) {
|
||||
strlcpy(sysCfg.web_password, (!strcmp(dataBuf,"0")) ? "" : (1 == payload) ? WEB_PASSWORD : dataBuf, sizeof(sysCfg.web_password));
|
||||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"WebPassword\":\"%s\"}"), sysCfg.web_password);
|
||||
}
|
||||
else if (!strcmp(type,"WEBLOG")) {
|
||||
else if (!strcmp_P(type,PSTR("WEBLOG"))) {
|
||||
if ((data_len > 0) && (payload >= LOG_LEVEL_NONE) && (payload <= LOG_LEVEL_ALL)) {
|
||||
sysCfg.weblog_level = payload;
|
||||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"WebLog\":%d}"), sysCfg.weblog_level);
|
||||
}
|
||||
#ifdef USE_EMULATION
|
||||
else if (!strcmp(type,"EMULATION")) {
|
||||
else if (!strcmp_P(type,PSTR("EMULATION"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload <= 2)) {
|
||||
sysCfg.emulation = payload;
|
||||
restartflag = 2;
|
||||
|
@ -1296,7 +1300,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
}
|
||||
#endif // USE_EMULATION
|
||||
#endif // USE_WEBSERVER
|
||||
else if (!strcmp(type,"TELEPERIOD")) {
|
||||
else if (!strcmp_P(type,PSTR("TELEPERIOD"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload < 3601)) {
|
||||
sysCfg.tele_period = (1 == payload) ? TELE_PERIOD : payload;
|
||||
if ((sysCfg.tele_period > 0) && (sysCfg.tele_period < 10)) {
|
||||
|
@ -1306,7 +1310,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"TelePeriod\":\"%d%s\"}"), sysCfg.tele_period, (sysCfg.value_units) ? " Sec" : "");
|
||||
}
|
||||
else if (!strcmp(type,"RESTART")) {
|
||||
else if (!strcmp_P(type,PSTR("RESTART"))) {
|
||||
switch (payload) {
|
||||
case 1:
|
||||
restartflag = 2;
|
||||
|
@ -1320,7 +1324,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Restart\":\"1 to restart\"}"));
|
||||
}
|
||||
}
|
||||
else if (!strcmp(type,"RESET")) {
|
||||
else if (!strcmp_P(type,PSTR("RESET"))) {
|
||||
switch (payload) {
|
||||
case 1:
|
||||
restartflag = 211;
|
||||
|
@ -1334,13 +1338,13 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Reset\":\"1 to reset\"}"));
|
||||
}
|
||||
}
|
||||
else if (!strcmp(type,"TIMEZONE")) {
|
||||
else if (!strcmp_P(type,PSTR("TIMEZONE"))) {
|
||||
if ((data_len > 0) && (((payload >= -12) && (payload <= 12)) || (99 == payload))) {
|
||||
sysCfg.timezone = payload;
|
||||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Timezone\":%d}"), sysCfg.timezone);
|
||||
}
|
||||
else if (!strcmp(type,"LEDPOWER")) {
|
||||
else if (!strcmp_P(type,PSTR("LEDPOWER"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload <= 2)) {
|
||||
sysCfg.ledstate &= 8;
|
||||
switch (payload) {
|
||||
|
@ -1357,7 +1361,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"LedPower\":\"%s\"}"), getStateText(bitRead(sysCfg.ledstate, 3)));
|
||||
}
|
||||
else if (!strcmp(type,"LEDSTATE")) {
|
||||
else if (!strcmp_P(type,PSTR("LEDSTATE"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload < MAX_LED_OPTION)) {
|
||||
sysCfg.ledstate = payload;
|
||||
if (!sysCfg.ledstate) {
|
||||
|
@ -1366,7 +1370,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"LedState\":%d}"), sysCfg.ledstate);
|
||||
}
|
||||
else if (!strcmp(type,"CFGDUMP")) {
|
||||
else if (!strcmp_P(type,PSTR("CFGDUMP"))) {
|
||||
CFG_Dump();
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"CfgDump\":\"Done\"}"));
|
||||
}
|
||||
|
@ -1377,7 +1381,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
// Serviced
|
||||
}
|
||||
#ifdef USE_I2C
|
||||
else if (i2c_flg && !strcmp(type,"I2CSCAN")) {
|
||||
else if (i2c_flg && !strcmp_P(type,PSTR("I2CSCAN"))) {
|
||||
i2c_scan(svalue, sizeof(svalue));
|
||||
}
|
||||
#endif // USE_I2C
|
||||
|
@ -1392,7 +1396,7 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
|||
}
|
||||
#endif // USE_IR_REMOTE
|
||||
#ifdef DEBUG_THEO
|
||||
else if (!strcmp(type,"EXCEPTION")) {
|
||||
else if (!strcmp_P(type,PSTR("EXCEPTION"))) {
|
||||
if (data_len > 0) {
|
||||
exception_tst(payload);
|
||||
}
|
||||
|
@ -2353,6 +2357,10 @@ void GPIO_init()
|
|||
#endif // USE_IR_REMOTE
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
extern struct rst_info resetInfo;
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
char log[LOGSZ];
|
||||
|
@ -2413,29 +2421,29 @@ void setup()
|
|||
if (MOTOR == sysCfg.module) {
|
||||
sysCfg.poweronstate = 1; // Needs always on else in limbo!
|
||||
}
|
||||
if (ESP.getResetReason() == "Power on") {
|
||||
if ((resetInfo.reason == REASON_DEFAULT_RST) || (resetInfo.reason == REASON_EXT_SYS_RST)) {
|
||||
if (0 == sysCfg.poweronstate) { // All off
|
||||
power = 0;
|
||||
setRelay(power);
|
||||
}
|
||||
else if (1 == sysCfg.poweronstate) { // All on
|
||||
power = ((0x00FF << Maxdevice) >> 8);
|
||||
power = (1 << Maxdevice) -1;
|
||||
setRelay(power);
|
||||
}
|
||||
else if (2 == sysCfg.poweronstate) { // All saved state toggle
|
||||
power = (sysCfg.power & ((0x00FF << Maxdevice) >> 8)) ^ 0xFF;
|
||||
power = sysCfg.power & ((1 << Maxdevice) -1) ^ 0xFF;
|
||||
if (sysCfg.savestate) {
|
||||
setRelay(power);
|
||||
}
|
||||
}
|
||||
else if (3 == sysCfg.poweronstate) { // All saved state
|
||||
power = sysCfg.power & ((0x00FF << Maxdevice) >> 8);
|
||||
power = sysCfg.power & ((1 << Maxdevice) -1);
|
||||
if (sysCfg.savestate) {
|
||||
setRelay(power);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
power = sysCfg.power & ((0x00FF << Maxdevice) >> 8);
|
||||
power = sysCfg.power & ((1 << Maxdevice) -1);
|
||||
if (sysCfg.savestate) {
|
||||
setRelay(power);
|
||||
}
|
||||
|
|
|
@ -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"];
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
@ -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\"}"));
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
|
|
@ -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];
|
||||
|
@ -212,7 +212,7 @@ 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;
|
||||
|
@ -220,7 +220,7 @@ boolean sl_command(char *type, uint16_t index, char *dataBufUc, uint16_t data_le
|
|||
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
|
||||
|
@ -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
|
||||
|
@ -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\"}"));
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
|
|
@ -532,21 +532,21 @@ 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);
|
||||
|
@ -554,7 +554,7 @@ boolean ws2812_command(char *type, uint16_t index, char *dataBuf, uint16_t data_
|
|||
}
|
||||
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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
|
|
@ -437,105 +437,105 @@ boolean hlw_command(char *type, uint16_t index, char *dataBuf, uint16_t data_len
|
|||
{
|
||||
boolean serviced = true;
|
||||
|
||||
if (!strcmp(type,"POWERLOW")) {
|
||||
if (!strcmp_P(type,PSTR("POWERLOW"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload < 3601)) {
|
||||
sysCfg.hlw_pmin = payload;
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"PowerLow\":\"%d%s\"}"), sysCfg.hlw_pmin, (sysCfg.value_units) ? " W" : "");
|
||||
}
|
||||
else if (!strcmp(type,"POWERHIGH")) {
|
||||
else if (!strcmp_P(type,PSTR("POWERHIGH"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload < 3601)) {
|
||||
sysCfg.hlw_pmax = payload;
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"PowerHigh\":\"%d%s\"}"), sysCfg.hlw_pmax, (sysCfg.value_units) ? " W" : "");
|
||||
}
|
||||
else if (!strcmp(type,"VOLTAGELOW")) {
|
||||
else if (!strcmp_P(type,PSTR("VOLTAGELOW"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload < 501)) {
|
||||
sysCfg.hlw_umin = payload;
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"VoltageLow\":\"%d%s\"}"), sysCfg.hlw_umin, (sysCfg.value_units) ? " V" : "");
|
||||
}
|
||||
else if (!strcmp(type,"VOLTAGEHIGH")) {
|
||||
else if (!strcmp_P(type,PSTR("VOLTAGEHIGH"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload < 501)) {
|
||||
sysCfg.hlw_umax = payload;
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("[\"VoltageHigh\":\"%d%s\"}"), sysCfg.hlw_umax, (sysCfg.value_units) ? " V" : "");
|
||||
}
|
||||
else if (!strcmp(type,"CURRENTLOW")) {
|
||||
else if (!strcmp_P(type,PSTR("CURRENTLOW"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload < 16001)) {
|
||||
sysCfg.hlw_imin = payload;
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"CurrentLow\":\"%d%s\"}"), sysCfg.hlw_imin, (sysCfg.value_units) ? " mA" : "");
|
||||
}
|
||||
else if (!strcmp(type,"CURRENTHIGH")) {
|
||||
else if (!strcmp_P(type,PSTR("CURRENTHIGH"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload < 16001)) {
|
||||
sysCfg.hlw_imax = payload;
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"CurrentHigh\":\"%d%s\"}"), sysCfg.hlw_imax, (sysCfg.value_units) ? " mA" : "");
|
||||
}
|
||||
else if (!strcmp(type,"HLWPCAL")) {
|
||||
else if (!strcmp_P(type,PSTR("HLWPCAL"))) {
|
||||
if ((data_len > 0) && (payload > 0) && (payload < 32001)) {
|
||||
sysCfg.hlw_pcal = (payload > 9999) ? payload : HLW_PREF_PULSE; // 12530
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("(\"HlwPcal\":\"%d%s\"}"), sysCfg.hlw_pcal, (sysCfg.value_units) ? " uS" : "");
|
||||
}
|
||||
else if (!strcmp(type,"HLWUCAL")) {
|
||||
else if (!strcmp_P(type,PSTR("HLWUCAL"))) {
|
||||
if ((data_len > 0) && (payload > 0) && (payload < 32001)) {
|
||||
sysCfg.hlw_ucal = (payload > 999) ? payload : HLW_UREF_PULSE; // 1950
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"HlwUcal\":\"%d%s\"}"), sysCfg.hlw_ucal, (sysCfg.value_units) ? " uS" : "");
|
||||
}
|
||||
else if (!strcmp(type,"HLWICAL")) {
|
||||
else if (!strcmp_P(type,PSTR("HLWICAL"))) {
|
||||
if ((data_len > 0) && (payload > 0) && (payload < 32001)) {
|
||||
sysCfg.hlw_ical = (payload > 2499) ? payload : HLW_IREF_PULSE; // 3500
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"HlwIcal\":\"%d%s\"}"), sysCfg.hlw_ical, (sysCfg.value_units) ? " uS" : "");
|
||||
}
|
||||
#if FEATURE_POWER_LIMIT
|
||||
else if (!strcmp(type,"MAXPOWER")) {
|
||||
else if (!strcmp_P(type,PSTR("MAXPOWER"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload < 3601)) {
|
||||
sysCfg.hlw_mpl = payload;
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"MaxPower\":\"%d%s\"}"), sysCfg.hlw_mpl, (sysCfg.value_units) ? " W" : "");
|
||||
}
|
||||
else if (!strcmp(type,"MAXPOWERHOLD")) {
|
||||
else if (!strcmp_P(type,PSTR("MAXPOWERHOLD"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload < 3601)) {
|
||||
sysCfg.hlw_mplh = (1 == payload) ? MAX_POWER_HOLD : payload;
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"MaxPowerHold\":\"%d%s\"}"), sysCfg.hlw_mplh, (sysCfg.value_units) ? " Sec" : "");
|
||||
}
|
||||
else if (!strcmp(type,"MAXPOWERWINDOW")) {
|
||||
else if (!strcmp_P(type,PSTR("MAXPOWERWINDOW"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload < 3601)) {
|
||||
sysCfg.hlw_mplw = (1 == payload) ? MAX_POWER_WINDOW : payload;
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"MaxPowerWindow\":\"%d%s\"}"), sysCfg.hlw_mplw, (sysCfg.value_units) ? " Sec" : "");
|
||||
}
|
||||
else if (!strcmp(type,"SAFEPOWER")) {
|
||||
else if (!strcmp_P(type,PSTR("SAFEPOWER"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload < 3601)) {
|
||||
sysCfg.hlw_mspl = payload;
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"SafePower\":\"%d%s\"}"), sysCfg.hlw_mspl, (sysCfg.value_units) ? " W" : "");
|
||||
}
|
||||
else if (!strcmp(type,"SAFEPOWERHOLD")) {
|
||||
else if (!strcmp_P(type,PSTR("SAFEPOWERHOLD"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload < 3601)) {
|
||||
sysCfg.hlw_msplh = (1 == payload) ? SAFE_POWER_HOLD : payload;
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"SafePowerHold\":\"%d%s\"}"), sysCfg.hlw_msplh, (sysCfg.value_units) ? " Sec" : "");
|
||||
}
|
||||
else if (!strcmp(type,"SAFEPOWERWINDOW")) {
|
||||
else if (!strcmp_P(type,PSTR("SAFEPOWERWINDOW"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload < 1440)) {
|
||||
sysCfg.hlw_msplw = (1 == payload) ? SAFE_POWER_WINDOW : payload;
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"SafePowerWindow\":\"%d%s\"}"), sysCfg.hlw_msplw, (sysCfg.value_units) ? " Min" : "");
|
||||
}
|
||||
else if (!strcmp(type,"MAXENERGY")) {
|
||||
else if (!strcmp_P(type,PSTR("MAXENERGY"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload < 3601)) {
|
||||
sysCfg.hlw_mkwh = payload;
|
||||
hlw_mkwh_state = 3;
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("{\"MaxEnergy\":\"%d%s\"}"), sysCfg.hlw_mkwh, (sysCfg.value_units) ? " Wh" : "");
|
||||
}
|
||||
else if (!strcmp(type,"MAXENERGYSTART")) {
|
||||
else if (!strcmp_P(type,PSTR("MAXENERGYSTART"))) {
|
||||
if ((data_len > 0) && (payload >= 0) && (payload < 24)) {
|
||||
sysCfg.hlw_mkwhs = payload;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue