dashboard: prioritize relay commands over status polling

This commit is contained in:
2026-06-15 15:27:49 -06:00
parent b93edc248d
commit 5d93ee5d3a
2 changed files with 9 additions and 4 deletions
@@ -1,6 +1,6 @@
#pragma once
static const char *DASHBOARD_VERSION = "0.1.71-shift-fuel-left";
static const char *DASHBOARD_VERSION = "0.1.73-relay-command-priority";
// Update these if your Cargo ESP AP credentials are different.
static const char *CARGO_WIFI_SSID = "OverlandController";
@@ -56,6 +56,7 @@ static unsigned long last_status_poll_ms = 0;
static unsigned long last_metadata_poll_ms = 0;
static bool api_request_in_progress = false;
static unsigned long last_relay_command_ms = 0;
static bool fast_status_refresh_requested = false;
static bool metadata_refresh_requested = true;
static bool was_wifi_connected = false;
@@ -351,7 +352,7 @@ static void set_label_text_if_changed(lv_obj_t *label, String &last_text, const
static void request_fast_status_refresh()
{
fast_status_refresh_requested = true;
fast_status_refresh_requested = false;
}
static void create_overland_overview_screen();
@@ -481,6 +482,8 @@ static bool post_relay_state(const String &relay_id, bool state)
HTTPClient http;
http.setTimeout(1200);
http.begin(CARGO_API_RELAY_SET_URL);
http.setReuse(false);
http.addHeader("Connection", "close");
http.addHeader("Content-Type", "application/json");
unsigned long start_ms = millis();
@@ -605,7 +608,7 @@ static void update_system_status_label()
if (wifi_connected && !was_wifi_connected) {
was_wifi_connected = true;
fast_status_refresh_requested = true;
fast_status_refresh_requested = false;
metadata_refresh_requested = true;
last_status_poll_ms = 0;
last_metadata_poll_ms = 0;
@@ -1051,8 +1054,10 @@ static bool fetch_status_fields(const char *url, const char *label)
unsigned long start_ms = millis();
HTTPClient http;
http.setTimeout(900);
http.setTimeout(300);
http.begin(url);
http.setReuse(false);
http.addHeader("Connection", "close");
int code = http.GET();
status_model.http_code = code;