zephyr-cp/_bleio: don't let an unsupported Tx power command block advertising - #11231
Closed
mikeysklar wants to merge 1 commit into
Closed
zephyr-cp/_bleio: don't let an unsupported Tx power command block advertising#11231mikeysklar wants to merge 1 commit into
mikeysklar wants to merge 1 commit into
Conversation
…ertising
common_hal_bleio_adapter_start_advertising() called set_tx_power()
unconditionally before bt_le_adv_start(). That sends
BT_HCI_OP_VS_WRITE_TX_POWER_LEVEL (0xfc0e), a Zephyr vendor-specific
command rather than a Bluetooth spec one. Controllers that do not
implement Zephyr's VS extensions reject it, and the resulting error
aborted start_advertising() before advertising was ever started, so
those controllers could not advertise at all.
On a SiWx917-DK2605A, which has its own vendor command at 0xfc06 for RF
power:
<wrn> bt_hci_core: opcode 0xfc0e status 0x01 (Unknown HCI Command)
OSError: [Errno 5] Input/output error
Split the command into a non-raising _try_set_tx_power(). The public
common_hal_bleio_adapter_set_tx_power() still raises, so an explicit
adapter.tx_power assignment fails loudly, but start_advertising() treats
it as best-effort and continues.
mikeysklar
force-pushed
the
zephyr-bleio/tx-power
branch
from
August 23, 2026 16:17
92e5c69 to
b2dbd56
Compare
Collaborator
Author
|
Closing, this is already in #11226 as bleio_adapter_set_tx_power_noraise(). Same fix, same reason. For what it is worth, the VS command rejection (opcode 0xfc0e, status 0x01) and advertising working once it is best-effort are both confirmed on a SiWx917-DK2605A, so that part of #11226 holds on a non-Nordic controller. |
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.
What
start_advertising()on zephyr-cp could not advertise at all on a controller that does not implement Zephyr's vendor-specific Tx power command. It now treats the Tx power write as best-effort and advertises anyway. An explicitadapter.tx_power = nstill raises on failure.Why
common_hal_bleio_adapter_start_advertising()callsset_tx_power()unconditionally beforebt_le_adv_start(). That sendsBT_HCI_OP_VS_WRITE_TX_POWER_LEVEL(0xfc0e), a Zephyr vendor-specific HCI command rather than a Bluetooth spec one. A controller without Zephyr's VS extensions rejects it, the call returns-EIO, andstart_advertising()raised before it ever reachedbt_le_adv_start().On a SiWx917-DK2605A (Zephyr board
siwx917_dk2605a), whose controller has its own vendor command at0xfc06for RF power:This affects any controller lacking Zephyr's VS HCI commands, not only that one. The shared-bindings default is
tx_power=0, so everyadafruit_bleprogram hits this path on everystart_advertising().The fix splits the command into a non-raising
_try_set_tx_power().common_hal_bleio_adapter_set_tx_power()still raises, so a deliberate Tx power assignment fails loudly.start_advertising()calls the non-raising form and continues at the controller default. There is no log line on rejection because it would print on everystart_advertising()on such a controller.Hardware tested
OSError: [Errno 5]fromstart_advertising(), zero scanner hits. After: the board advertises and is discoverable by name from an external BLE scanner. That test was done at the end of July on the SiWx917 bring-up tree; the change has been rebased onto currentmainand recompiled, not re-run on hardware today.adafruit_feather_nrf52840_zephyr: build only, on currentmainwith this change. Not run on an nRF52840.Not tested: a controller that implements the VS command. The only behaviour change for those is that a failure of the command no longer aborts advertising.
Scope
This is older work from the SiWx917 bring-up. An LLM review pass over the zephyr-cp
_bleiowork in progress flagged it as relevant to the BLE workflow effort, so it is being filed now on its own rather than waiting for the SiWx917 board PR (#11218). It does not depend on that PR.AI assistance
Written with Claude Code. I verified the failure and the fix on the DK2605A myself, reviewed the diff by hand, and confirmed the rebased change compiles for
adafruit_feather_nrf52840_zephyron currentmain.