update examples

This commit is contained in:
Sergio R. Caprile
2025-06-24 16:26:31 -03:00
parent 074ef5197b
commit f5e2c68c8b
27 changed files with 166 additions and 47 deletions
+2 -2
View File
@@ -156,10 +156,10 @@ static void handle_settings_set(struct mg_connection *c, struct mg_str body) {
settings.log_level = (int) mg_json_get_long(body, "$.log_level", 0);
settings.brightness = mg_json_get_long(body, "$.brightness", 0);
if (s && strlen(s) < MAX_DEVICE_NAME) {
free(settings.device_name);
mg_free(settings.device_name);
settings.device_name = s;
} else {
free(s);
mg_free(s);
}
s_settings = settings; // Save to the device flash
mg_http_reply(c, 200, s_json_header,
+3 -3
View File
@@ -26,9 +26,9 @@ void app_main(void) {
char *ssid = mg_json_get_str(json, "$.ssid");
char *pass = mg_json_get_str(json, "$.pass");
while (!wifi_init(ssid, pass)) (void) 0;
free(ssid);
free(pass);
free((void *) json.buf);
mg_free(ssid);
mg_free(pass);
mg_free((void *) json.buf);
} else {
// If WiFi is not configured, run CLI until configured
MG_INFO(("WiFi is not configured, running CLI. Press enter"));
+2 -2
View File
@@ -157,7 +157,7 @@ static void timer_fn(void *param) {
static void update_string(struct mg_str json, const char *path, char **value) {
char *jval;
if ((jval = mg_json_get_str(json, path)) != NULL) {
free(*value);
mg_free(*value);
*value = strdup(jval);
}
}
@@ -189,7 +189,7 @@ void uart_bridge_fn(struct mg_connection *c, int ev, void *ev_data) {
if (ev == MG_EV_OPEN && c->is_listening) {
struct mg_str config = mg_file_read(&mg_fs_posix, "config.json");
if (config.buf != NULL) config_apply(config);
free(config.buf);
mg_free(config.buf);
s_state.tcp.url = strdup(DEFAULT_TCP);
s_state.websocket.url = strdup(DEFAULT_WEBSOCKET);
s_state.mqtt.url = strdup(DEFAULT_MQTT);
+1 -1
View File
@@ -44,7 +44,7 @@ static void broadcast_mjpeg_frame(struct mg_mgr *mgr) {
mg_send(c, data.buf, data.len);
mg_send(c, "\r\n", 2);
}
free((void *) data.buf);
mg_free((void *) data.buf);
}
static void timer_callback(void *arg) {