forked from sfeakes/AqualinkD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
json_messages.h
117 lines (93 loc) · 4.22 KB
/
json_messages.h
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#ifndef JSON_MESSAGES_H_
#define JSON_MESSAGES_H_
//FUNCTION PROTOTYPES
//#define JSON_LABEL_SIZE 300
//#define JSON_BUFFER_SIZE 4000
//#define JSON_STATUS_SIZE 1024
#define JSON_LABEL_SIZE 600
#define JSON_BUFFER_SIZE 5120
#define JSON_STATUS_SIZE 2048
#define JSON_MQTT_MSG_SIZE 100
#define JSON_ON "on"
#define JSON_OFF "off"
#define JSON_FLASH "flash"
#define JSON_ENABLED "enabled"
#define JSON_FAHRENHEIT "f"
#define JSON_CELSIUS "c"
#define JSON_UNKNOWN "u"
#define JSON_OK "ok"
#define JSON_LOW "low"
#define JSON_PROGRAMMING "Programming"
#define JSON_SERVICE "Service Mode"
#define JSON_TIMEOUT "Timeout Mode"
#define JSON_READY "Ready"
struct JSONkeyvalue{
char *key;
char *value;
};
struct JSONwebrequest {
struct JSONkeyvalue first;
struct JSONkeyvalue second;
struct JSONkeyvalue third;
};
struct JSONkvptr {
struct JSONkeyvalue kv[4];
};
const char* getAqualinkDStatusMessage(struct aqualinkdata *aqdata);
int build_aqualink_status_JSON(struct aqualinkdata *aqdata, char* buffer, int size);
int build_aux_labels_JSON(struct aqualinkdata *aqdata, char* buffer, int size);
bool parseJSONwebrequest(char *buffer, struct JSONwebrequest *request);
bool parseJSONrequest(char *buffer, struct JSONkvptr *request);
int build_mqtt_status_JSON(char* buffer, int size, int idx, int nvalue, float setpoint/*char *svalue*/);
bool parseJSONmqttrequest(const char *str, size_t len, int *idx, int *nvalue, char *svalue);
int build_aqualink_error_status_JSON(char* buffer, int size, char *msg);
int build_mqtt_status_message_JSON(char* buffer, int size, int idx, int nvalue, char *svalue);
//int build_device_JSON(struct aqualinkdata *aqdata, int programable_switch, char* buffer, int size, bool homekit);
//int build_device_JSON(struct aqualinkdata *aqdata, int programable_switch1, int programable_switch2, char* buffer, int size, bool homekit);
int build_device_JSON(struct aqualinkdata *aqdata, char* buffer, int size, bool homekit);
#endif /* JSON_MESSAGES_H_ */
/*
{\"type\": \"status\",\"version\": \"8157 REV MMM\",\"date\": \"09/01/16 THU\",\"time\": \"1:16 PM\",\"temp_units\": \"F\",\"air_temp\": \"96\",\"pool_temp\": \"86\",\"spa_temp\": \" \",\"battery\": \"ok\",\"pool_htr_set_pnt\": \"85\",\"spa_htr_set_pnt\": \"99\",\"freeze_protection\": \"off\",\"frz_protect_set_pnt\": \"0\",\"leds\": {\"pump\": \"on\",\"spa\": \"off\",\"aux1\": \"off\",\"aux2\": \"off\",\"aux3\": \"off\",\"aux4\": \"off\",\"aux5\": \"off\",\"aux6\": \"off\",\"aux7\": \"off\",\"pool_heater\": \"off\",\"spa_heater\": \"off\",\"solar_heater\": \"off\"}}
{\"type\": \"aux_labels\",\"aux1_label\": \"Cleaner\",\"aux2_label\": \"Waterfall\",\"aux3_label\": \"Spa Blower\",\"aux4_label\": \"Pool Light\",\"aux5_label\": \"Spa Light\",\"aux6_label\": \"Unassigned\",\"aux7_label\": \"Unassigned\"}
{"type": "status","version": "8157 REV MMM","date": "09/01/16 THU","time": "1:16 PM","temp_units": "F","air_temp": "96","pool_temp": "86","spa_temp": " ","battery": "ok","pool_htr_set_pnt": "85","spa_htr_set_pnt": "99","freeze_protection": "off","frz_protect_set_pnt": "0","leds": {"pump": "on","spa": "off","aux1": "off","aux2": "off","aux3": "off","aux4": "off","aux5": "off","aux6": "off","aux7": "off","pool_heater": "off","spa_heater": "off","solar_heater": "off"}}
{"type": "aux_labels","aux1_label": "Cleaner","aux2_label": "Waterfall","aux3_label": "Spa Blower","aux4_label": "Pool Light","aux5_label": "Spa Light","aux6_label": "Unassigned","aux7_label": "Unassigned"}
{
"type":"aux_labels",
"aux1_label":"Cleaner",
"aux2_label":"Waterfall",
"aux3_label":"Spa Blower",
"aux4_label":"Pool Light",
"aux5_label":"Spa Light",
"aux6_label":"Unassigned",
"aux7_label":"Unassigned"
}
{
"type":"status",
"version":"8157 REV MMM",
"date":"09/01/16 THU",
"time":"1:16 PM",
"temp_units":"F",
"air_temp":"96",
"pool_temp":"86",
"spa_temp":" ",
"battery":"ok",
"pool_htr_set_pnt":"85",
"spa_htr_set_pnt":"99",
"freeze_protection":"off",
"frz_protect_set_pnt":"0",
"leds":{
"pump":"on",
"spa":"off",
"aux1":"off",
"aux2":"off",
"aux3":"off",
"aux4":"off",
"aux5":"off",
"aux6":"off",
"aux7":"off",
"pool_heater":"off",
"spa_heater":"off",
"solar_heater":"off"
}
}
*/