fix(dbus): normalize peripheral id at every public entry point#81
Merged
Conversation
Replaces undocumented prose-only requirement with a machine-readable version range so Renovate/Dependabot/`npm ls` can track supported versions. Marked optional so npm doesn't auto-install on Mac/Win. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
BlueZ emits MAC addresses in uppercase colon form (AA:BB:CC:DD:EE:FF), while noble's canonical peripheral id is the colon-stripped lowercase form (aabbccddeeff). External callers may pass any of: canonical id, uppercase id, mixed-case id, or uppercase/lowercase/mixed colon-MAC form. Add a small `normalizeId` helper and apply it at the top of every public method that accepts a peripheralUuid (connect, disconnect, cancelConnect, updateRssi, discoverServices, discoverIncludedServices, discoverCharacteristics, read, write, broadcast, notify, discoverDescriptors, readValue, writeValue, readHandle, writeHandle). Internal lookups now match regardless of the casing/separator the caller used, and emitted events always carry the canonical id. Null/undefined ids are passed through unchanged so existing "unknown peripheral" code paths still kick in instead of throwing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
🎉 This PR is included in version 2.5.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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
peripheralUuidto the canonical noble id form (lowercase, no colons) at every public method on the D-Bus bindingsaabbccddeeff,AABBCCDDEEFF,AaBbCcDdEeFf,AA:BB:CC:DD:EE:FF,aa:bb:cc:dd:ee:ff,Aa:Bb:Cc:Dd:Ee:Ff— all map toaabbccddeeffnull/undefinedpass through unchanged so existing "unknown peripheral" no-op paths still workWhy
BlueZ emits MAC addresses uppercase with colons (
AA:BB:CC:DD:EE:FF) and uses uppercase underscored form in object paths (/org/bluez/hci0/dev_AA_BB_CC_DD_EE_FF). Internally we already lowercase to build the noble id (aabbccddeeff) and look devices up in aMapkeyed by that canonical form. But there was no input normalization — if a user passed an uppercase id or a colon-separated MAC (which is plausible if they have an address hardcoded in config), every internal_devices.get(id)lookup would silently miss and the call would no-op or fall into an error path.This change makes the binding lenient about input shape and strict about output shape (canonical id everywhere in events).
Methods covered
connect,cancelConnect,disconnect,updateRssi,discoverServices,discoverIncludedServices,discoverCharacteristics,read,write,broadcast,notify,discoverDescriptors,readValue,writeValue,readHandle,writeHandle.Test plan
npx jest— 17 suites, 673 tests pass (+19 new normalization tests, parametrized across 6 input variants fordiscoverServices/read/readHandleplus a null-safety test)npm run lint— cleanperipheral.connect()and confirm BlueZ paths still resolve🤖 Generated with Claude Code