From 6ce5b928a1a1034d03484d00c52f8b2e1c81b7d1 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 24 Oct 2019 09:02:33 +0200 Subject: [PATCH] Release 6.7 --- sonoff/sonoff.h | 2 +- sonoff/support_command.ino | 4 +-- sonoff/xdrv_01_webserver.ino | 4 +-- sonoff/xdrv_02_mqtt.ino | 2 +- sonoff/xdrv_10_scripter.ino | 57 +++++++++++++++++++++--------------- 5 files changed, 40 insertions(+), 29 deletions(-) diff --git a/sonoff/sonoff.h b/sonoff/sonoff.h index 40b3dcb98..9dd173167 100644 --- a/sonoff/sonoff.h +++ b/sonoff/sonoff.h @@ -220,7 +220,7 @@ enum MonthNamesOptions {Jan=1, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, enum HemisphereOptions {North, South}; enum GetDateAndTimeOptions { DT_LOCAL, DT_UTC, DT_RESTART, DT_ENERGY }; -enum LoggingLevels {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE, LOG_LEVEL_ALL}; +enum LoggingLevels {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE}; enum WifiConfigOptions {WIFI_RESTART, EX_WIFI_SMARTCONFIG, WIFI_MANAGER, EX_WIFI_WPSCONFIG, WIFI_RETRY, WIFI_WAIT, WIFI_SERIAL, WIFI_MANAGER_RESET_ONLY, MAX_WIFI_OPTION}; diff --git a/sonoff/support_command.ino b/sonoff/support_command.ino index 4704e14e1..fdf65ecf7 100644 --- a/sonoff/support_command.ino +++ b/sonoff/support_command.ino @@ -524,7 +524,7 @@ void CmndOtaUrl(void) void CmndSeriallog(void) { - if ((XdrvMailbox.payload >= LOG_LEVEL_NONE) && (XdrvMailbox.payload <= LOG_LEVEL_ALL)) { + if ((XdrvMailbox.payload >= LOG_LEVEL_NONE) && (XdrvMailbox.payload <= LOG_LEVEL_DEBUG_MORE)) { Settings.flag.mqtt_serial = 0; SetSeriallog(XdrvMailbox.payload); } @@ -1075,7 +1075,7 @@ void CmndSerialDelimiter(void) void CmndSyslog(void) { - if ((XdrvMailbox.payload >= LOG_LEVEL_NONE) && (XdrvMailbox.payload <= LOG_LEVEL_ALL)) { + if ((XdrvMailbox.payload >= LOG_LEVEL_NONE) && (XdrvMailbox.payload <= LOG_LEVEL_DEBUG_MORE)) { SetSyslog(XdrvMailbox.payload); } Response_P(S_JSON_COMMAND_NVALUE_ACTIVE_NVALUE, XdrvMailbox.command, Settings.syslog_level, syslog_level); diff --git a/sonoff/xdrv_01_webserver.ino b/sonoff/xdrv_01_webserver.ino index 1f3fc3733..40b3bab83 100644 --- a/sonoff/xdrv_01_webserver.ino +++ b/sonoff/xdrv_01_webserver.ino @@ -1625,7 +1625,7 @@ void HandleLoggingConfiguration(void) GetTextIndexed(stemp1, sizeof(stemp1), idx, kLoggingOptions), GetTextIndexed(stemp2, sizeof(stemp2), dlevel[idx], kLoggingLevels), idx); - for (uint32_t i = LOG_LEVEL_NONE; i < LOG_LEVEL_ALL; i++) { + for (uint32_t i = LOG_LEVEL_NONE; i <= LOG_LEVEL_DEBUG_MORE; i++) { WSContentSend_P(PSTR("%d %s"), (i == llevel) ? " selected" : "", i, i, GetTextIndexed(stemp1, sizeof(stemp1), i, kLoggingLevels)); @@ -2676,7 +2676,7 @@ void CmndWebPassword(void) void CmndWeblog(void) { - if ((XdrvMailbox.payload >= LOG_LEVEL_NONE) && (XdrvMailbox.payload <= LOG_LEVEL_ALL)) { + if ((XdrvMailbox.payload >= LOG_LEVEL_NONE) && (XdrvMailbox.payload <= LOG_LEVEL_DEBUG_MORE)) { Settings.weblog_level = XdrvMailbox.payload; } ResponseCmndNumber(Settings.weblog_level); diff --git a/sonoff/xdrv_02_mqtt.ino b/sonoff/xdrv_02_mqtt.ino index edc844448..50f66c8ce 100644 --- a/sonoff/xdrv_02_mqtt.ino +++ b/sonoff/xdrv_02_mqtt.ino @@ -764,7 +764,7 @@ void CmndMqttPassword(void) void CmndMqttlog(void) { - if ((XdrvMailbox.payload >= LOG_LEVEL_NONE) && (XdrvMailbox.payload <= LOG_LEVEL_ALL)) { + if ((XdrvMailbox.payload >= LOG_LEVEL_NONE) && (XdrvMailbox.payload <= LOG_LEVEL_DEBUG_MORE)) { Settings.mqttlog_level = XdrvMailbox.payload; } ResponseCmndNumber(Settings.mqttlog_level); diff --git a/sonoff/xdrv_10_scripter.ino b/sonoff/xdrv_10_scripter.ino index 3e1487b64..e4610c830 100644 --- a/sonoff/xdrv_10_scripter.ino +++ b/sonoff/xdrv_10_scripter.ino @@ -2211,33 +2211,49 @@ char *Evaluate_expression(char *lp,uint8_t and_or, uint8_t *result,JsonObject * struct T_INDEX ind; uint8_t vtype=0,lastop; uint8_t res=0; + char *llp=lp; + char *slp; SCRIPT_SKIP_SPACES - if (*lp=='(') { + uint8_t res=0; + uint8_t xand_or=0; lp++; - lp=Evaluate_expression(lp,and_or,result,jo); - lp++; + +loop: + SCRIPT_SKIP_SPACES + lp=Evaluate_expression(lp,xand_or,&res,jo); + if (*lp==')') { + lp++; + goto exit0; + } // check for next and or SCRIPT_SKIP_SPACES if (!strncmp(lp,"or",2)) { lp+=2; - and_or=1; - SCRIPT_SKIP_SPACES - lp=Evaluate_expression(lp,and_or,result,jo); + xand_or=1; + goto loop; } else if (!strncmp(lp,"and",3)) { lp+=3; - and_or=2; - SCRIPT_SKIP_SPACES - lp=Evaluate_expression(lp,and_or,result,jo); + xand_or=2; + goto loop; } - return lp; +exit0: + if (!and_or) { + *result=res; + } else if (and_or==1) { + *result|=res; + } else { + *result&=res; + } + goto exit10; } + llp=lp; // compare dfvar=&fvar; glob_script_mem.glob_error=0; - char *slp=lp; + slp=lp; numeric=1; lp=GetNumericResult(lp,OPER_EQU,dfvar,0); if (glob_script_mem.glob_error==1) { @@ -2252,23 +2268,15 @@ char *Evaluate_expression(char *lp,uint8_t and_or, uint8_t *result,JsonObject * char str[SCRIPT_MAXSSIZE]; lp=GetStringResult(lp,OPER_EQU,str,jo); if (lastop==OPER_EQUEQU || lastop==OPER_NOTEQU) { - uint8_t res=0; res=strcmp(cmpstr,str); if (lastop==OPER_EQUEQU) res=!res; - if (!and_or) { - *result=res; - } else if (and_or==1) { - *result|=res; - } else { - *result&=res; - } + goto exit; } } else { // numeric // evaluate operand lp=getop(lp,&lastop); - lp=GetNumericResult(lp,OPER_EQU,&fvar1,jo); switch (lastop) { case OPER_EQUEQU: @@ -2294,6 +2302,7 @@ char *Evaluate_expression(char *lp,uint8_t and_or, uint8_t *result,JsonObject * break; } +exit: if (!and_or) { *result=res; } else if (and_or==1) { @@ -2302,11 +2311,13 @@ char *Evaluate_expression(char *lp,uint8_t and_or, uint8_t *result,JsonObject * *result&=res; } } -exit: + + +exit10: #if SCRIPT_DEBUG>0 char tbuff[128]; - sprintf(tbuff,"p1=%d,p2=%d,cmpres=%d line: ",(int32_t)*dfvar,(int32_t)fvar1,*result); - toLogEOL(tbuff,lp); + sprintf(tbuff,"p1=%d,p2=%d,cmpres=%d,and_or=%d line: ",(int32_t)*dfvar,(int32_t)fvar1,*result,and_or); + toLogEOL(tbuff,llp); #endif return lp; }