-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #264 from xkevin190/wifi-subsys-modifications
wifi-subsys: added cJSON and changed cbor to json in the https-request
- Loading branch information
Showing
2 changed files
with
8 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
* @author xkevin190 <[email protected]> | ||
*/ | ||
#include <string.h> | ||
#include <cJSON.h> | ||
|
||
#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); | ||
} | ||
|