added CHAR type to the variables

This commit is contained in:
bogd 2024-05-29 15:58:30 +02:00
parent a7417df420
commit 8b8ea9a57f
2 changed files with 11 additions and 1 deletions

View File

@ -43,7 +43,8 @@ typedef enum{
VAR_STRING,
VAR_PASS,
VAR_IPADDR,
VAR_FUNCT
VAR_FUNCT,
VAR_CHAR
} rest_var_types;

View File

@ -623,6 +623,12 @@ esp_err_t SetConfVar(char *name, char *val, rest_var_types *tp)
else
return ESP_ERR_INVALID_ARG;
break;
case VAR_CHAR:
constr = atoi(val);
if (constr < V->minlen || constr > V->maxlen)
return ESP_ERR_INVALID_ARG;
*((uint8_t*) V->ref) = constr;
break;
case VAR_INT:
constr = atoi(val);
if (constr < V->minlen || constr > V->maxlen)
@ -692,6 +698,9 @@ esp_err_t GetConfVar(char *name, char *val, rest_var_types *tp)
case VAR_INT:
itoa(*((int*) V->ref), val, 10);
break;
case VAR_CHAR:
itoa(*((uint8_t*) V->ref), val, 10);
break;
case VAR_STRING:
strcpy(val, (char*) V->ref);
break;