fixed type of content returned from rest api

This commit is contained in:
Bogdan Pilyugin 2023-07-28 16:36:15 +02:00
parent 5b4b779ae1
commit 581e2a6ad5
3 changed files with 12 additions and 3 deletions

View File

@ -41,6 +41,7 @@ HTTP_IO_RESULT HTTPPostSysAPI(httpd_req_t *req, char *PostData)
M.outputDataBuffer = respbuf;
M.outputDataLength = EXPECTED_MAX_DATA_RESPONSE_SIZE;
SysServiceDataHandler(&M);
httpd_resp_set_type(req, "application/json");
httpd_resp_sendstr(req, respbuf);
free(respbuf);
return HTTP_IO_DONE_API;

View File

@ -27,7 +27,14 @@
extern SYS_CONFIG SysConfig;
static void get_time(char *argres)
static void funct_addone(char *argres)
{
int arg = atoi(argres);
arg *= 2;
itoa(arg, argres, 10);
}
static void funct_time(char *argres)
{
time_t now;
time(&now);
@ -40,7 +47,8 @@ const rest_var_t ConfigVariables[] =
{ 1, "otaurl", &SysConfig.OTAURL, VAR_STRING, 3, 128 },
{ 2, "ledenab", &SysConfig.Flags1.bIsLedsEnabled, VAR_BOOL, 0, 1 },
{ 3, "otaint", &SysConfig.OTAAutoInt, VAR_INT, 0, 65535 },
{ 4, "time", &get_time, VAR_FUNCT, 0, 65535 }
{ 4, "time", &funct_time, VAR_FUNCT, 0, 65535 },
{ 5, "addone", &funct_addone, VAR_FUNCT, 0, 65535 }
};

View File

@ -44,7 +44,7 @@
"msgid":123456789,
"time":"2023-06-03T12:25:24+00:00",
"msgtype":2,
"payloadtype":1
"payloadtype":1,
"payload":{
"variables":[{"name":"netname","val":""},
{"name":"otaurl","val":""},