1:material-memory: ZEPHYR PLATFORM 2================================= 3 4Set TX Power on nRF52840 5------------------------ 6 7The Nordic nRF52840 supports Zephyr's vendor specific HCI command for setting TX 8power during advertising, connection, or scanning. With the example [HCI 9USB](https://docs.zephyrproject.org/latest/samples/bluetooth/hci_usb/README.html) 10application, an [nRF52840 11dongle](https://www.nordicsemi.com/Products/Development- 12hardware/nRF52840-Dongle) can be used as a Bumble controller. 13 14To add dynamic TX power support to the HCI USB application, add the following to 15`zephyr/samples/bluetooth/hci_usb/prj.conf` and build. 16 17``` 18CONFIG_BT_CTLR_ADVANCED_FEATURES=y 19CONFIG_BT_CTLR_CONN_RSSI=y 20CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y 21``` 22 23Alternatively, a prebuilt firmware application can be downloaded here: 24[hci_usb.zip](../downloads/zephyr/hci_usb.zip). 25 26Put the nRF52840 dongle into bootloader mode by pressing the RESET button. The 27LED should pulse red. Load the firmware application with the `nrfutil` tool: 28 29``` 30nrfutil dfu usb-serial -pkg hci_usb.zip -p /dev/ttyACM0 31``` 32 33The vendor specific HCI commands to read and write TX power are defined in 34`bumble/vendor/zephyr/hci.py` and may be used as such: 35 36```python 37from bumble.vendor.zephyr.hci import HCI_Write_Tx_Power_Level_Command 38 39# set advertising power to -4 dB 40response = await host.send_command( 41 HCI_Write_Tx_Power_Level_Command( 42 handle_type=HCI_Write_Tx_Power_Level_Command.TX_POWER_HANDLE_TYPE_ADV, 43 connection_handle=0, 44 tx_power_level=-4, 45 ) 46) 47 48if response.return_parameters.status == HCI_SUCCESS: 49 print(f"TX power set to {response.return_parameters.selected_tx_power_level}") 50 51``` 52