From 8b8ea9a57f843bb7b07682b367e7d9991d616f25 Mon Sep 17 00:00:00 2001 From: bogd Date: Wed, 29 May 2024 15:58:30 +0200 Subject: [PATCH] added CHAR type to the variables --- include/SysConfiguration.h | 3 ++- src/RestApiHandler.c | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/SysConfiguration.h b/include/SysConfiguration.h index 3ab5f78..8eca5fc 100644 --- a/include/SysConfiguration.h +++ b/include/SysConfiguration.h @@ -43,7 +43,8 @@ typedef enum{ VAR_STRING, VAR_PASS, VAR_IPADDR, - VAR_FUNCT + VAR_FUNCT, + VAR_CHAR } rest_var_types; diff --git a/src/RestApiHandler.c b/src/RestApiHandler.c index 973ea53..16125c2 100644 --- a/src/RestApiHandler.c +++ b/src/RestApiHandler.c @@ -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;