Move hub Bluetooth size optimization - #503
Open
dlech wants to merge 2 commits into
Open
Conversation
The two functions are identical: both read a 3 byte response with a status and a handle. Follow the existing hci_le_command_end alias pattern and keep only one copy. The linker was already merging the two, so this does not change the binary.
Most HCI commands that the Move Hub sends have parameters that are all fixed at compile time, but each call site paid for runtime packing via the aci_*_begin functions plus two protothread checkpoints to wait for the transport and for command completion. Store those commands as complete const parameter blobs instead and send them through a shared child protothread, so each site is a single checkpoint. A shared child state is safe because at most one HCI command exchange is in flight at a time, which the global hci_command_complete flag already assumes. Also derive the advertising scan response from a const template with only the hub name appended at runtime, introduce a static initializer for the Device Information Service PnP ID so the GATT characteristic value can live in flash instead of being packed on the fly, and share the duplicated stop-scanning failure path in scan and connect. The command blobs were verified byte for byte against the output of the original packing code. This saves around 350 bytes on the Move Hub.
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.
Making the code more efficient size-wise to get another 350 bytes or so for other things.