From 9d94f710f7b00d109bf6f6ee57996f43bce5c67f Mon Sep 17 00:00:00 2001 From: Luke Hoersten Date: Fri, 17 Jul 2026 18:56:03 -0500 Subject: main: code-review fixes — brightness units, OTA stall cap, stats + locking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - display: s_last_pwm cached the raw 0-100 percentage at init but display_wake writes it straight to REG_PWM (0-255 duty) — first wake ran visibly dim until a /config brightness change. Shared pct_to_duty helper now converts in both paths. - http_api: cap consecutive OTA recv timeouts (a stalled client spun forever holding s_ota_in_progress, wedging OTA until reboot); cap viewport name at 54 chars so viewport- fits the 63-byte mDNS label; log mdns_service_refresh failures; /state builds JSON from a snapshot instead of holding the state lock across ~25 cJSON allocs; respond_400 delegates to respond_status. - stream_server: bytes_in_window now counts painted frames only (frames discarded while asleep inflated the first post-wake window's MB/s, avg-jpeg and chunk/wire averages; recv_bytes folded in); so_rcvbuf carried into the stats snapshot under the mux; drop dead HEADER_BYTES; merge read_body_instrumented into read_n. - state_machine: transition mutex serializes concurrent wake/sleep (display side-effects ran after the state lock dropped, so racing callers could leave the backlight contradicting st->state); wake-path placeholder paint now takes the decoder lock like the stream path (concurrent esp_lcd_panel_draw_bitmap from two tasks isn't safe). - local_screens: overlay paint takes the decoder lock too; check the overlay timer create; panel dims from viewport_state.h. - jpeg_decoder: try_lock before init returns busy instead of passing a NULL semaphore to xSemaphoreTake. - net_eth: clear cached IP string on link down (stale /state + info). - dead code: display_present_bgr888, TOUCH_FT5426_ADDR, touch s_task, JPEG_DECODER_MAX_OUTPUT_BYTES; doc drift in nvs_config.h / jpeg_decoder.h / app_main flag legend. --- main/ota.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'main/ota.c') diff --git a/main/ota.c b/main/ota.c index 3924dca..ee636da 100644 --- a/main/ota.c +++ b/main/ota.c @@ -29,6 +29,9 @@ void ota_arm_healthy_timer(void) .callback = &healthy_cb, .name = "ota_healthy", }; + // The handle is deliberately never deleted: one ~50-byte allocation + // per boot, and deleting from inside the callback would race the + // dispatcher. esp_timer_handle_t t = NULL; if (esp_timer_create(&args, &t) != ESP_OK) return; esp_timer_start_once(t, OTA_HEALTHY_DELAY_US); -- cgit v1.2.3