How to setting TX power through HCI command?

Hi Sir,

We reference example "/nrf/samples/bluetooth/hci_uart" and test on nRF52833.

Now we want to set the Tx power by sending appropriate HCI commands from the host.

We tried the below command but got an error.

"hcitool -a hci0 inqtpl 4"

Can't set inquiry transmit power level on hci0: Input/output error (5)

Could you share the command for how to set the TX power level?

Thank you.

BRs, Han

Parents
  • Hi,

    When using hcitool note that inq and tpl are two different commands.
    hcitool should be used with -i option.
    Full command would look like this hcitool [-i <hciX>] [command [command_parameters]]
    inq - used for inquiries of remote devices
    tpl - command used for displaying transmit power level
    In your case, this would be hcitool -i hci0 tpl <bdaddr> [type]

    If you want to use inqtpl command then consider using hciconfig:
    hciconfig inqtpl 4 - sets the inquiry transmit power level to 4
    hciconfig inqtpl    - gets the inquiry transmit power level

    Best regards,
    Dejan

  • Hi Dejan,

    I follow the command but got the error as below.

    sudo hciattach -s 115200 /dev/ttyACM1 any 115200 noflow nosleep

    sudo hciconfig inqtpl 4

    I also tried "hcitool".

    sudo hcitool -i hci0 tpl 00:00:00:00:00:00 4

    Does any step go wrong?

    Thank you.

    BRs, Han

  • Hi,

    The ogf part of the opcode has 6 bits and it denotes the opcode group field. In your case 0x3f is reserved for vendor specific command. The ocf part has 10 bits and it is known as opcode command field. A Command Complete HCI Event specifies the corresponding Vendor specific debug command opcode. For more information, please refer to the bluetooth specification.

    One good explanation of the hcitool command output can be found here

    Setting the transmit power value is vendor specific command. Please check hci_zephyr and hci_softdevice.

    There is also an example in zephyr\samples\bluetooth\hci_pwr_ctrl.

    Best regards,
    Dejan

  • Hi, 

    As said previously, please note that hcitool is deprecated in BlueZ and should not be used anymore. Instead, you should use bluetoothctl tool.

    For BlueZ related questions, please consider joining BlueZ mailing list.

    Best regards,
    Dejan

  • Hi Dejans,

    Unfortunately, I cannot set the tx power from "Write Tx Power Level" and also from bluetoothctl command.

    Below is the test result.

    Sorry that I'm not familiar w/ hci tool, could you share the hint which step or concept I missed.

    1. Write TX power, but got fail return "unknow hci command".

        sudo hciattach -s 115200 /dev/ttyACM0 any 115200 noflow nosleep

        sudo hciconfig hci0 up // bring up device

        sudo hciconfig hci0

        sudo hcitool -i hci0 cmd 0x3f 0x000e 0x00 0x6461 4 //set tx power level 4

        sudo hcitool -i hci0 cmd 0x3f 0x000e 0x02 0x6461 4

    2. bluetoothctl

    I tried to use "bluetootlctl", but i cannot find the parameter for tx power level setting from help.

    Does the command of tx power level has been hidden? or this is a sub command?

    Thank you.

    BRs, Hanyu

  • Hi,

    Setting TX power level is a vendor specific command and you should consider other channels for more help.
    Have you been able to join BlueZ mailing list (or some other channel related to BlueZ) as suggested previously? Have you got any advices there?

    Best regards,
    Dejan

  • Hi Dejan,

    I summarize the result and it works on my side.

    Example: /1.8.0/nrf/samples/bluetooth/hci_uart

    1. Add the below setting on "prj.conf" and re-build the project.

    CONFIG_BT_HCI_VS=y

    CONFIG_BT_HCI_VS_EXT=y

    CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y

    CONFIG_BT_HCI_RAW_CMD_EXT=y

    CONFIG_BT_CTLR_SET_HOST_FEATURE=y

    2. Use the below command to bring up

    sudo hciattach -s 115200 /dev/ttyACM0 any 115200 noflow nosleep

    sudo hciconfig hci0 up

    3. use the below command to set the TX power "-8 dBm"

    sudo hcitool -i hci0 cmd 0x3f 0x000e 0x00 0x00 0x00 -8

    4. use the below command to read the TX power

    sudo hcitool -i hci0 cmd 0x3f 0x000f 0x00 0x00 0x00

    5. Test w/ "bluetoothctl"

    sudo  bluetoothctl # run bluetoothctl tool

    menu advertise     # enter sub-menu "advertise"

    name AABB          # set device name "AABB"

    back                      # back to the main menu

    advertiser on         # start advertising and check the RSSI w/ nRF connect APP 

    advertiser off         # stop advertising.

    Thank you.

    BRs, Hanyu

Reply
  • Hi Dejan,

    I summarize the result and it works on my side.

    Example: /1.8.0/nrf/samples/bluetooth/hci_uart

    1. Add the below setting on "prj.conf" and re-build the project.

    CONFIG_BT_HCI_VS=y

    CONFIG_BT_HCI_VS_EXT=y

    CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y

    CONFIG_BT_HCI_RAW_CMD_EXT=y

    CONFIG_BT_CTLR_SET_HOST_FEATURE=y

    2. Use the below command to bring up

    sudo hciattach -s 115200 /dev/ttyACM0 any 115200 noflow nosleep

    sudo hciconfig hci0 up

    3. use the below command to set the TX power "-8 dBm"

    sudo hcitool -i hci0 cmd 0x3f 0x000e 0x00 0x00 0x00 -8

    4. use the below command to read the TX power

    sudo hcitool -i hci0 cmd 0x3f 0x000f 0x00 0x00 0x00

    5. Test w/ "bluetoothctl"

    sudo  bluetoothctl # run bluetoothctl tool

    menu advertise     # enter sub-menu "advertise"

    name AABB          # set device name "AABB"

    back                      # back to the main menu

    advertiser on         # start advertising and check the RSSI w/ nRF connect APP 

    advertiser off         # stop advertising.

    Thank you.

    BRs, Hanyu

Children
Related