feat: replace JSON BLE protocol with compact binary encoding#3
Merged
spectrachrome merged 5 commits intomainfrom Feb 23, 2026
Merged
feat: replace JSON BLE protocol with compact binary encoding#3spectrachrome merged 5 commits intomainfrom
spectrachrome merged 5 commits intomainfrom
Conversation
22-byte state snapshots (down from ~300 JSON), 1-4 byte commands, 1-byte acks. Eliminates serde, serde_json_core, and heapless deps.
Triggers red, green, blue, or white at full intensity, bypassing all post-processing. Uses wall-clock deadline instead of frame counting to avoid SPI write overhead inflating the duration.
Prevents phantom strobe on the bench when no TX is powered on. The FC reports default RC channel values (~1500) that passed the AUX7 > 1250 threshold. Also adds ±10 deadband to TX link detection and drains stale UART bytes before each MSP_RC poll.
Merge main branch into ble_binary_protocol, incorporating: - AUX strobe gated on armed/arming-allowed flight mode - TX link detection with ±10 deadband (replaces exact 1500 comparison) - UART drain before MSP_RC polls to prevent desync - BLE RX command logging adapted for binary protocol
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.
Summary
(spec:
docs/binary_protocol.md) — state snapshots shrink from ~300 bytes/ ~15 BLE packets down to 22 bytes (1–2 packets)
0x00OK /0xE0parse error /0xE1range error), replacing verbose JSONround-trips
TestPatterncommand (0xF0) that triggers a 5-second solid-colorepisode (red/green/blue/white) at full intensity, bypassing all
post-processing — useful for verifying LED wiring and color order
GetVersioncommand (0x02) returning protocol version + firmwaresemver (5 bytes)
serde,serde_json_core, andheaplesscrate dependencies(saves ~15 KB flash)
What changed
src/ble.rshandle_binary_command), state encoder (22-byte snapshot), version encoder, constants for all command/response IDs, unit testssrc/bin/main.rsble_handle_message, wall-clock test pattern deadline, BLE RX loggingsrc/state.rsTEST_PATTERNsignal for inter-task test patternCargo.tomlserde,serde_json_core,heaplessdocs/binary_protocol.mdProtocol at a glance
App → Device (commands):
0x01 GetState → 22-byte state snapshot
0x02 GetVersion → 5-byte version response
0x10..0x1D Setters → 1-byte ack (0x00 OK)
0xF0 TestPattern → 1-byte ack, 5s solid color episode
Device → App (responses):
0x00 OK
0x01 + 21B State snapshot
0x02 + 4B Version (protocol v1, fw semver)
0xE0 Parse error
0xE1 Range error
Test plan
GetState(0x01)returns 22 bytes starting with
0x01 0x01GetVersion(0x02) — verify 5-byte response02 01 00 01 00SetBrightness(10 80) — verify00ack, thenGetStateshows updated brightness
TestPatternred (F0 00) — verify 5-second solid red, returnsto normal pattern
12 00for FPS=0) — verifyE1rangeerror
connected)