Skip to content

Add Bluetooth Management interface support#55

Merged
colemancda merged 10 commits into
masterfrom
feature/management
Jul 18, 2026
Merged

Add Bluetooth Management interface support#55
colemancda merged 10 commits into
masterfrom
feature/management

Conversation

@colemancda

Copy link
Copy Markdown
Member

Summary

Adds support for the Linux kernel's Bluetooth Management interface (HCI_CHANNEL_CONTROL), the modern API for adapter control, as a new Management module in the BluetoothLinux library:

  • ManagementSocket — actor that opens an HCI control channel socket (not bound to a single controller; commands target a controller by index). send() performs a command and waits for the matching Command Complete or Command Status event, throwing ManagementStatus if the kernel rejects the command; receive() yields kernel event notifications (index added/removed, new settings, device found, and so on).
  • Packet layer — little-endian command and event headers with round-trip encoding, and event notification parsing.
  • Constants — command opcodes (0x0001–0x0047), event codes (0x0001–0x002E), status codes as an Error-conforming enum, and the controller settings bitmask.
  • Typed commands — read version, read controller index list, read controller information (full structure parse including name and class of device), and setters for powered, connectable, fast connectable, bondable, link security, secure simple pairing, low energy, discoverable (mode and timeout), advertising, and local name.

This enables adapter control (power, discoverable, connectable, LE, advertising, naming) without the legacy ioctl path and lays the groundwork for pairing and bonding commands.

Test plan

  • 10 new unit tests covering header round-trips, event and command response parsing (including truncated packet rejection and error status handling), controller information decoding, and settings/name encoding helpers
  • Full test suite passes (50 tests)
  • swift build succeeds with no new warnings
  • Live socket behavior requires Linux with CAP_NET_ADMIN (root)

@colemancda
colemancda merged commit 303e7af into master Jul 18, 2026
1 check passed
@colemancda
colemancda deleted the feature/management branch July 18, 2026 05:32
@colemancda colemancda mentioned this pull request Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant