Clean up RPC response.
- Refactor mqtt_publish_stat() to take va_list - Make publish_stat format its response with json_vprintf() so it is valid JSON. - Call publish_stat in channel_set, the only place where the GPIO state changes - Return (valid) JSON response in all RPCs
This commit is contained in:
@ -27,7 +27,6 @@ uint8_t channel_idx_by_gpio(int gpio);
|
||||
void channel_set(int idx, bool state);
|
||||
bool channel_get(int idx);
|
||||
int channel_get_total();
|
||||
void channel_report(int idx, char *msg, int msg_len);
|
||||
void channel_handler(int gpio, void *arg);
|
||||
|
||||
#endif // __MAIN_H
|
||||
|
@ -9,6 +9,6 @@
|
||||
#define MQTT_TOPIC_BROADCAST_STAT "/mongoose/broadcast/stat"
|
||||
|
||||
void mqtt_init();
|
||||
void mqtt_publish_stat(const char *stat, const char *msg);
|
||||
void mqtt_publish_stat(const char *stat, const char *fmt, ...);
|
||||
|
||||
#endif // __MQTT_H
|
||||
|
Reference in New Issue
Block a user