From fae30398b27c9e5ec41bbc8daaaabb7c254b9fb3 Mon Sep 17 00:00:00 2001 From: Martin Date: Sun, 3 Sep 2023 09:26:36 -0400 Subject: [PATCH] Added a client transfer context for use by the control marshaling function --- src/ESPUIclient.cpp | 4 ++-- src/ESPUIclient.h | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ESPUIclient.cpp b/src/ESPUIclient.cpp index 9b7d561..62644a8 100644 --- a/src/ESPUIclient.cpp +++ b/src/ESPUIclient.cpp @@ -307,7 +307,7 @@ uint32_t ESPUIclient::prepareJSONChunk(uint16_t startindex, JsonObject item = items.createNestedObject(); elementcount++; - control->MarshalControl(item, InUpdateMode); + control->MarshalControl(item, InUpdateMode, ClientTransferContext); if (rootDoc.overflowed()) { @@ -315,6 +315,7 @@ uint32_t ESPUIclient::prepareJSONChunk(uint16_t startindex, if (1 == elementcount) { Serial.println(String(F("ERROR: prepareJSONChunk: Control ")) + String(control->id) + F(" is too large to be sent to the browser.")); + // Serial.println(String(F("ERROR: prepareJSONChunk: value: ")) + control->value); rootDoc.clear(); item = items.createNestedObject(); control->MarshalErrorMessage(item); @@ -330,7 +331,6 @@ uint32_t ESPUIclient::prepareJSONChunk(uint16_t startindex, } // exit the loop control = nullptr; - } else { diff --git a/src/ESPUIclient.h b/src/ESPUIclient.h index 5a34699..6a67fda 100644 --- a/src/ESPUIclient.h +++ b/src/ESPUIclient.h @@ -17,6 +17,12 @@ public: ReloadNeeded = 3, }; + struct ClientTransferContext_t + { + void *control = nullptr; + uint16_t Offset = 0; + }; + protected: // bool HasBeenNotified = false; // Set when a notification has been sent and we are waiting for a reply // bool DelayedNotification = false; // set if a delayed notification is needed @@ -39,7 +45,8 @@ protected: fsm_EspuiClient_state* pCurrentFsmState = &fsm_EspuiClient_state_Idle_imp; time_t EspuiClientEndTime = 0; - + ClientTransferContext_t ClientTransferContext; + // bool NeedsNotification() { return pCurrentFsmState != &fsm_EspuiClient_state_Idle_imp; } bool CanSend();