state information

This commit is contained in:
2026-09-15 20:51:07 +02:00
parent 1d42228ab0
commit a1dae20cbf
8 changed files with 38 additions and 27 deletions
+6 -5
View File
@@ -106,23 +106,24 @@ char* ygg_send_post(const char *url, char *post_data) {
int ygg_get_sensor_id(const char *sensor_name,
const char *url);
void ygg_send_sensor_redouts(float temp, float press, float hum) {
void ygg_send_sensor_readouts(const char *sensor_name,
ygg_sensor_readout readout) {
char post_data[64];
int sensor_id = ygg_get_sensor_id("super_hiper_bmp280", "http://192.168.0.236:5000");
int sensor_id = ygg_get_sensor_id(sensor_name, "http://192.168.0.236:5000");
char url[128];
snprintf(url, sizeof(url),
"http://192.168.0.236:5000/api/sensors/%d/readouts", sensor_id);
snprintf(post_data, sizeof(post_data),
"{\"type\":\"temperature\", \"value\":%.2f}", temp);
"{\"type\":\"temperature\", \"value\":%.2f}", readout.temperature);
ygg_send_post(url, post_data);
snprintf(post_data, sizeof(post_data),
"{\"type\":\"pressure\", \"value\":%.2f}", press);
"{\"type\":\"pressure\", \"value\":%.2f}", readout.pressure);
ygg_send_post(url, post_data);
snprintf(post_data, sizeof(post_data),
"{\"type\":\"humidity\", \"value\":%.2f}", hum);
"{\"type\":\"humidity\", \"value\":%.2f}", readout.humidity);
ygg_send_post(url, post_data);
}