dashboard: prioritize relay commands over status polling
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#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.
|
// Update these if your Cargo ESP AP credentials are different.
|
||||||
static const char *CARGO_WIFI_SSID = "OverlandController";
|
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 unsigned long last_metadata_poll_ms = 0;
|
||||||
|
|
||||||
static bool api_request_in_progress = false;
|
static bool api_request_in_progress = false;
|
||||||
|
static unsigned long last_relay_command_ms = 0;
|
||||||
static bool fast_status_refresh_requested = false;
|
static bool fast_status_refresh_requested = false;
|
||||||
static bool metadata_refresh_requested = true;
|
static bool metadata_refresh_requested = true;
|
||||||
static bool was_wifi_connected = false;
|
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()
|
static void request_fast_status_refresh()
|
||||||
{
|
{
|
||||||
fast_status_refresh_requested = true;
|
fast_status_refresh_requested = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void create_overland_overview_screen();
|
static void create_overland_overview_screen();
|
||||||
@@ -481,6 +482,8 @@ static bool post_relay_state(const String &relay_id, bool state)
|
|||||||
HTTPClient http;
|
HTTPClient http;
|
||||||
http.setTimeout(1200);
|
http.setTimeout(1200);
|
||||||
http.begin(CARGO_API_RELAY_SET_URL);
|
http.begin(CARGO_API_RELAY_SET_URL);
|
||||||
|
http.setReuse(false);
|
||||||
|
http.addHeader("Connection", "close");
|
||||||
http.addHeader("Content-Type", "application/json");
|
http.addHeader("Content-Type", "application/json");
|
||||||
|
|
||||||
unsigned long start_ms = millis();
|
unsigned long start_ms = millis();
|
||||||
@@ -605,7 +608,7 @@ static void update_system_status_label()
|
|||||||
|
|
||||||
if (wifi_connected && !was_wifi_connected) {
|
if (wifi_connected && !was_wifi_connected) {
|
||||||
was_wifi_connected = true;
|
was_wifi_connected = true;
|
||||||
fast_status_refresh_requested = true;
|
fast_status_refresh_requested = false;
|
||||||
metadata_refresh_requested = true;
|
metadata_refresh_requested = true;
|
||||||
last_status_poll_ms = 0;
|
last_status_poll_ms = 0;
|
||||||
last_metadata_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();
|
unsigned long start_ms = millis();
|
||||||
|
|
||||||
HTTPClient http;
|
HTTPClient http;
|
||||||
http.setTimeout(900);
|
http.setTimeout(300);
|
||||||
http.begin(url);
|
http.begin(url);
|
||||||
|
http.setReuse(false);
|
||||||
|
http.addHeader("Connection", "close");
|
||||||
int code = http.GET();
|
int code = http.GET();
|
||||||
|
|
||||||
status_model.http_code = code;
|
status_model.http_code = code;
|
||||||
|
|||||||
Reference in New Issue
Block a user