Skip to content

Commit

Permalink
[GPIO] Fix mode reported in response to Status command
Browse files Browse the repository at this point in the history
  • Loading branch information
dobrykod committed Oct 12, 2023
1 parent d19f3cf commit a0b567a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/src/Helpers/PortStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a0b567a

Please sign in to comment.