source code migrating from gitlab

This commit is contained in:
2026-05-15 15:51:41 -04:00
commit 6cf9a21574
28 changed files with 2960 additions and 0 deletions
@@ -0,0 +1,45 @@
#include "json/json_convert.h"
#include <cJSON.h>
#include <esp_log.h>
char *createJSON(float fahr, float cel, float hum) {
char *json = NULL;
cJSON *fahrenheit = NULL;
cJSON *celsius = NULL;
cJSON *humidity = NULL;
cJSON *data = cJSON_CreateObject();
if (!data) {
return NULL;
}
fahrenheit = cJSON_CreateNumber(fahr);
if (!fahrenheit) {
cJSON_Delete(data);
return NULL;
}
cJSON_AddItemToObject(data, "fahrenheit", fahrenheit);
celsius = cJSON_CreateNumber(cel);
if (!celsius) {
ESP_LOGE("JSON", "Failed to create celsius JSON");
cJSON_Delete(data);
return NULL;
}
cJSON_AddItemToObject(data, "celsius", celsius);
humidity = cJSON_CreateNumber(hum);
if (!humidity) {
cJSON_Delete(data);
return NULL;
}
cJSON_AddItemToObject(data, "humidity", humidity);
json = cJSON_Print(data);
return json;
}