From a0b567a04f5fc295d75de8fde2b69b1899e4d53a Mon Sep 17 00:00:00 2001 From: dobry kod <147148803+dobrykod@users.noreply.github.com> Date: Thu, 12 Oct 2023 15:04:56 +0200 Subject: [PATCH] [GPIO] Fix mode reported in response to Status command --- src/src/Helpers/PortStatus.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/src/Helpers/PortStatus.cpp b/src/src/Helpers/PortStatus.cpp index e3b64e2f81..c658bb8bcb 100644 --- a/src/src/Helpers/PortStatus.cpp +++ b/src/src/Helpers/PortStatus.cpp @@ -195,13 +195,14 @@ String getPinStateJSON(bool search, uint32_t key, const String& log, int16_t noS int16_t value = noSearchValue; bool found = false; - if (search) { - const auto it = globalMapPortStatus.find(key); - if (it != globalMapPortStatus.end()) { - mode = it->second.mode; + const auto it = globalMapPortStatus.find(key); + if (it != globalMapPortStatus.end()) { + found = true; + // update mode even if search = false, otherwise it will print mode assigned above + mode = it->second.mode; + // update value only if search = true, otherwise use noSearchValue + if(search) value = it->second.getValue(); - found = true; - } } if (!search || found)