diff options
Diffstat (limited to 'main/relay.cpp')
-rw-r--r-- | main/relay.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/main/relay.cpp b/main/relay.cpp new file mode 100644 index 0000000..701701f --- /dev/null +++ b/main/relay.cpp @@ -0,0 +1,29 @@ +#include "esp_check.h" + +#include "relay.h" + +static const char *TAG = "relay"; + +int state = 0; + +char* relay_json(void) +{ + char* resp = NULL; + + int rc = asprintf( + &resp, + "{" + "\"ison\":%s," + "\"has_timer\":false," + "\"timer_started\":0," + "\"timer_duration\":0," + "\"timer_remaining\":0," + "\"source\":\"http\"" + "}", + state ? "true" : "false" + ); + + ESP_RETURN_ON_FALSE(resp && rc, NULL, TAG, "buffer alloc failed"); + + return resp; +} |