1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#include "param.h"
#include "http_server.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void cmd_handle(uint8_t)(const char* attr, sockbuf_t* sockbuf, uint8_t* ptr)
{
int tmp = (int)(*ptr);
cmd_handle(int)(attr, sockbuf, &tmp);
*ptr = (uint8_t)tmp;
}
size_t serialize_to_json(uint8_t)(
char** out, size_t len, const char* attr, const char* dn, uint8_t value)
{
size_t newlen = snprintf(
*out,
len,
"\"%s\":{\"type\":\"uint8_t\",\"value\":\"%u\",\"disp\":\"%s\"}",
attr,
(unsigned int)value,
dn);
*out += newlen;
return len - newlen;
}
#define TAG "param_u8"
void http_handle(uint8_t)(httpd_req_t* req, uint8_t* val)
{
int tmp = (int)(*val);
http_handle(int)(req, &tmp);
*val = (uint8_t)tmp;
}
void print(uint8_t)(sockbuf_t* sockbuf, const char* attr, uint8_t val)
{
char buf[128];
snprintf(buf, sizeof(buf), "%s: %u :: uint8_t\n", attr, (unsigned int)val);
sockbuf_write(sockbuf, buf);
}
|