Fix config parser silently dropping NFC/flash when touch/buzzer present#6
Open
balloob wants to merge 1 commit into
Open
Fix config parser silently dropping NFC/flash when touch/buzzer present#6balloob wants to merge 1 commit into
balloob wants to merge 1 commit into
Conversation
The TLV config parser's default case jumps to the CRC (offset = configLen - 2) on any unrecognized packet ID, silently dropping every packet that follows. Silabs had no cases for 0x28 (touch_controller), 0x29 (passive_buzzer), or 0x2C (data_extended). The client emits touch/buzzer before flash (0x2B) and NFC (0x2A), so a config containing a touch or buzzer packet made Silabs abort mid-parse and never initialize its NFC + external-flash features. Add skip-by-size handling for these three packet IDs so later packets still parse. Silabs does not consume touch/buzzer (handled by the main MCU) or data_extended (host-only), so skip-by-exact-size is the minimum fix. Sizes cross-checked against Arduino structs.h, the Python config_serializer, and match the client wire format. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012g2e8mr132vcizx92WsgiR
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.
Problem
The TLV config parser advances by a fixed size per packet and, on any unrecognized packet ID, its
defaultcase doesoffset = configLen - 2(jump straight to the CRC) and stops — silently dropping every packet that follows the first unknown one.Silabs implements cases for 0x01, 0x02, 0x04, 0x20, 0x21, 0x23, 0x24, 0x25, 0x26, 0x27, 0x2A (NFC), 0x2B (flash), but has no case for 0x28 (touch_controller), 0x29 (passive_buzzer), or 0x2C (data_extended).
The Python client emits touch/buzzer before flash (0x2B) and NFC (0x2A). So a config that contains a touch or buzzer packet makes Silabs hit
defaultat the touch packet, jump to the CRC, and never parse the flash or NFC packets — silently disabling NFC and external-flash feature init on the device.Fix
Add handling for 0x28, 0x29, and 0x2C so the parser skips past them by their exact wire size (matching the existing 0x26 WiFi skip-by-size pattern), instead of falling into the
defaultabort. Silabs does not consume touch/buzzer (handled by the main MCU) or data_extended (host-only strings), so skip-by-exact-size is the minimal fix that lets the packets after them (flash 0x2B, NFC 0x2A) parse. Thedefaultcase is kept as the last-resort fallback for genuinely unknown IDs.Packet sizes (cross-checked)
struct TouchController(structs.h); Pythonserialize_touch_controller("to 32 bytes")struct PassiveBuzzerConfig(5×u8 + reserved[27]); Pythonserialize_passive_buzzer("to 32 bytes")struct DataExtended(9×32-byte strings); Pythonserialize_data_extended("to 288 bytes")All three sizes match what the client actually serializes onto the wire.
Testing
gcc -fsyntax-onlypasses on the modified parser (local headers are self-contained). The full SLC /arm-none-eabi-gccfirmware build was not available in this environment, so it was not run here.defaultabort never triggered.Related
nRF firmware has the same gap and gets a companion PR.
🤖 Generated with Claude Code
https://claude.ai/code/session_012g2e8mr132vcizx92WsgiR
Companion PR: OpenDisplay/Firmware_NRF#1 (same MJ-8 fix, nRF side — adds 0x2A/0x2B too). Sizes cross-validated: both derived 0x28=32, 0x29=32, 0x2C=288 independently.