diff --git a/wifi-subsys/components/uart/CMakeLists.txt b/wifi-subsys/components/uart/CMakeLists.txt index 88ffaf43f..ab2dcc004 100644 --- a/wifi-subsys/components/uart/CMakeLists.txt +++ b/wifi-subsys/components/uart/CMakeLists.txt @@ -1,2 +1,2 @@ file(GLOB_RECURSE SOURCES src/*.c) -idf_component_register(SRCS ${SOURCES} INCLUDE_DIRS src ../../main REQUIRES network tools protocols) +idf_component_register(SRCS ${SOURCES} INCLUDE_DIRS src ../../main REQUIRES network json tools protocols) diff --git a/wifi-subsys/components/uart/src/subsys_uart.c b/wifi-subsys/components/uart/src/subsys_uart.c index 65d4d8ec5..d646caf57 100644 --- a/wifi-subsys/components/uart/src/subsys_uart.c +++ b/wifi-subsys/components/uart/src/subsys_uart.c @@ -20,6 +20,7 @@ * @author xkevin190 */ #include +#include #include "subsys_uart.h" #include "driver/gpio.h" @@ -100,12 +101,16 @@ void received_sensor_data(uint8_t *values, size_t len) { decode(values, "temp", &val_received, len); ESP_LOGI(__func__, "%d ", val_received); + cJSON* root = cJSON_CreateObject(); + cJSON_AddNumberToObject(root, "temp", val_received); + char* payload = cJSON_Print(root); + http_request_t request; request.method = HTTP_METHOD_POST; - request.content_type = HTTPS_CONTENT_CBOR; + request.content_type = HTTPS_CONTENT_JSON; memcpy(request.url, "https://cloud.mesh4all.org", sizeof("https://cloud.mesh4all.org")); - memcpy(request.body, values, len); + memcpy(request.body, payload, strlen(payload) + 1); request.callback = &callback; http_client(&request); }