Release 6.7

This commit is contained in:
Theo Arends 2019-10-24 09:02:33 +02:00
parent 9ad6f71d9e
commit 6ce5b928a1
5 changed files with 40 additions and 29 deletions

View File

@ -220,7 +220,7 @@ enum MonthNamesOptions {Jan=1, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov,
enum HemisphereOptions {North, South}; enum HemisphereOptions {North, South};
enum GetDateAndTimeOptions { DT_LOCAL, DT_UTC, DT_RESTART, DT_ENERGY }; 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}; 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};

View File

@ -524,7 +524,7 @@ void CmndOtaUrl(void)
void CmndSeriallog(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; Settings.flag.mqtt_serial = 0;
SetSeriallog(XdrvMailbox.payload); SetSeriallog(XdrvMailbox.payload);
} }
@ -1075,7 +1075,7 @@ void CmndSerialDelimiter(void)
void CmndSyslog(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); SetSyslog(XdrvMailbox.payload);
} }
Response_P(S_JSON_COMMAND_NVALUE_ACTIVE_NVALUE, XdrvMailbox.command, Settings.syslog_level, syslog_level); Response_P(S_JSON_COMMAND_NVALUE_ACTIVE_NVALUE, XdrvMailbox.command, Settings.syslog_level, syslog_level);

View File

@ -1625,7 +1625,7 @@ void HandleLoggingConfiguration(void)
GetTextIndexed(stemp1, sizeof(stemp1), idx, kLoggingOptions), GetTextIndexed(stemp1, sizeof(stemp1), idx, kLoggingOptions),
GetTextIndexed(stemp2, sizeof(stemp2), dlevel[idx], kLoggingLevels), GetTextIndexed(stemp2, sizeof(stemp2), dlevel[idx], kLoggingLevels),
idx); 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("<option%s value='%d'>%d %s</option>"), WSContentSend_P(PSTR("<option%s value='%d'>%d %s</option>"),
(i == llevel) ? " selected" : "", i, i, (i == llevel) ? " selected" : "", i, i,
GetTextIndexed(stemp1, sizeof(stemp1), i, kLoggingLevels)); GetTextIndexed(stemp1, sizeof(stemp1), i, kLoggingLevels));
@ -2676,7 +2676,7 @@ void CmndWebPassword(void)
void CmndWeblog(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; Settings.weblog_level = XdrvMailbox.payload;
} }
ResponseCmndNumber(Settings.weblog_level); ResponseCmndNumber(Settings.weblog_level);

View File

@ -764,7 +764,7 @@ void CmndMqttPassword(void)
void CmndMqttlog(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; Settings.mqttlog_level = XdrvMailbox.payload;
} }
ResponseCmndNumber(Settings.mqttlog_level); ResponseCmndNumber(Settings.mqttlog_level);

View File

@ -2211,33 +2211,49 @@ char *Evaluate_expression(char *lp,uint8_t and_or, uint8_t *result,JsonObject *
struct T_INDEX ind; struct T_INDEX ind;
uint8_t vtype=0,lastop; uint8_t vtype=0,lastop;
uint8_t res=0; uint8_t res=0;
char *llp=lp;
char *slp;
SCRIPT_SKIP_SPACES SCRIPT_SKIP_SPACES
if (*lp=='(') { if (*lp=='(') {
uint8_t res=0;
uint8_t xand_or=0;
lp++; 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 // check for next and or
SCRIPT_SKIP_SPACES SCRIPT_SKIP_SPACES
if (!strncmp(lp,"or",2)) { if (!strncmp(lp,"or",2)) {
lp+=2; lp+=2;
and_or=1; xand_or=1;
SCRIPT_SKIP_SPACES goto loop;
lp=Evaluate_expression(lp,and_or,result,jo);
} else if (!strncmp(lp,"and",3)) { } else if (!strncmp(lp,"and",3)) {
lp+=3; lp+=3;
and_or=2; xand_or=2;
SCRIPT_SKIP_SPACES goto loop;
lp=Evaluate_expression(lp,and_or,result,jo);
} }
return lp; exit0:
if (!and_or) {
*result=res;
} else if (and_or==1) {
*result|=res;
} else {
*result&=res;
}
goto exit10;
} }
llp=lp;
// compare // compare
dfvar=&fvar; dfvar=&fvar;
glob_script_mem.glob_error=0; glob_script_mem.glob_error=0;
char *slp=lp; slp=lp;
numeric=1; numeric=1;
lp=GetNumericResult(lp,OPER_EQU,dfvar,0); lp=GetNumericResult(lp,OPER_EQU,dfvar,0);
if (glob_script_mem.glob_error==1) { 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]; char str[SCRIPT_MAXSSIZE];
lp=GetStringResult(lp,OPER_EQU,str,jo); lp=GetStringResult(lp,OPER_EQU,str,jo);
if (lastop==OPER_EQUEQU || lastop==OPER_NOTEQU) { if (lastop==OPER_EQUEQU || lastop==OPER_NOTEQU) {
uint8_t res=0;
res=strcmp(cmpstr,str); res=strcmp(cmpstr,str);
if (lastop==OPER_EQUEQU) res=!res; if (lastop==OPER_EQUEQU) res=!res;
if (!and_or) { goto exit;
*result=res;
} else if (and_or==1) {
*result|=res;
} else {
*result&=res;
}
} }
} else { } else {
// numeric // numeric
// evaluate operand // evaluate operand
lp=getop(lp,&lastop); lp=getop(lp,&lastop);
lp=GetNumericResult(lp,OPER_EQU,&fvar1,jo); lp=GetNumericResult(lp,OPER_EQU,&fvar1,jo);
switch (lastop) { switch (lastop) {
case OPER_EQUEQU: case OPER_EQUEQU:
@ -2294,6 +2302,7 @@ char *Evaluate_expression(char *lp,uint8_t and_or, uint8_t *result,JsonObject *
break; break;
} }
exit:
if (!and_or) { if (!and_or) {
*result=res; *result=res;
} else if (and_or==1) { } else if (and_or==1) {
@ -2302,11 +2311,13 @@ char *Evaluate_expression(char *lp,uint8_t and_or, uint8_t *result,JsonObject *
*result&=res; *result&=res;
} }
} }
exit:
exit10:
#if SCRIPT_DEBUG>0 #if SCRIPT_DEBUG>0
char tbuff[128]; char tbuff[128];
sprintf(tbuff,"p1=%d,p2=%d,cmpres=%d line: ",(int32_t)*dfvar,(int32_t)fvar1,*result); sprintf(tbuff,"p1=%d,p2=%d,cmpres=%d,and_or=%d line: ",(int32_t)*dfvar,(int32_t)fvar1,*result,and_or);
toLogEOL(tbuff,lp); toLogEOL(tbuff,llp);
#endif #endif
return lp; return lp;
} }