fix(write): named GPIO write values (on/high/true) were silently driving pins LOW (gap-hunt round 2) - #3
Open
SuperInstance wants to merge 1 commit into
Open
Conversation
executeWrite() used String::toInt() to decide the GPIO level. On Arduino, String::toInt() returns 0 for ANY non-numeric input, so 'write <pin> on', 'high', and 'true' silently drove the pin LOW — directly contradicting the documented interface (README + help text both advertise on/off, high/low). Parse the named aliases explicitly before falling back to numeric, matching the contract already implemented (but unused) by parseValue() in CommandParser.cpp. Add a regression test covering all eight aliases plus 0/1; update the README test count.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Gap-hunt pass (goose), independently re-verified by me (rebuilt firmware + test env on the exact pushed commit, hand-traced the fixed logic against the header's documented interface — no real ESP32 hardware is available in this environment, so like round 3's original verification for this repo, this is compile-clean + logic-traced, not device-executed).
Bug:
executeWrite()usedvalueStr.toInt()to decide the GPIO level. On Arduino,String::toInt()returns0for any non-numeric input — sowrite <pin> on,write <pin> high, andwrite <pin> trueall silently drove the pin LOW, directly contradicting the documented interface (both the README and the help text inCommandParser.cppadvertiseon/off,high/lowas valid values). A real, functional bug: any deployment following the repo's own documented usage for named values would get the opposite of the requested pin state.Fix: explicitly parses the named aliases (
on/high/true/1-> HIGH,off/low/false/0-> LOW, case-insensitive) before falling back to numeric parsing — matching the contract already implemented (but previously unused for this path) byparseValue()inCommandParser.cpp.Verification (independently redone):
pio run -e esp32dev(SUCCESS) andpio test -e test --without-uploading --without-testing(compiles clean) myself.0/1: every truthy alias (on,high,true,1) resolves toHIGH, every falsy alias (off,low,false,0) resolves toLOW— matches the new regression test (test_write_named_values) exactly.