feat: Ble_manager - add wireless.bluetooth.channel Focus command (host-side BT channel switching) - #34
Open
Cylindrix wants to merge 1 commit into
Open
Conversation
Adds a Focus API command to read the active Bluetooth channel and to switch to another channel from the host. The switch reuses the exact procedure the number keys run in pairing mode, extracted unchanged into BleManager::change_channel() and shared by both paths. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Motivation
Multi-host users (keyboard paired to a PC and a laptop, KVM-style setups) currently have no way to switch the active Bluetooth channel from the host. The only path is the physical sequence: Bluetooth pairing key, then a number key. That sequence cannot be automated:
wireless.bluetooth.*handlers inBle_manager.cppare commented out).macros.triggergets as far as opening pairing mode, but the channel keys are matched by physical coordinate (coord.row/coord.col) inkbdif_key_event_process, so a macro-played digit is ignored. (Verified on a Raise 2, firmware v1.4.1.)This PR adds one Focus command so hosts and Bazecor can do it directly:
Implementation
BleManager::change_channel(uint8_t index_channel); the key handler now calls it. No behavioral change to the existing key path.kbdif_command_event_cb(previously a commented-out sketch) now delegates to a newkbdif_command_event_processinstance method, mirroring howkbdif_key_event_cbdelegates, and implements the command following the pattern ofRadioManager::kbdif_command_event_cb(wireless.rf.*).BLE_CONNECTIONS_COUNT, and the switch only runs whenble_innited()andFirmwareVersion::keyboard_is_wireless(). Switching to the already-active channel is a no-op.One expected quirk, noted in a comment: when the requesting host is connected over Bluetooth on the channel being switched away from, the link drops mid-procedure, so that host may never receive the Focus reply. The switch itself completes.
Testing
I could not compile this: the build depends on the private
kaleidoscope_adaptersubmodule (see #33), so external contributors cannot build the firmware. The change is a mechanical extraction plus a handler modeled closely on the workingwireless.rf.*handler, but it has not been flashed or run. I have a Raise 2 (ANSI, wireless) and I am happy to test a build or a beta release that includes this and report back.🤖 Generated with Claude Code