Increasing BLE TX Power

185 views
Skip to first unread message

J Ch

unread,
May 24, 2023, 2:49:49 AM5/24/23
to btstack-dev
Hello. Is there an API function that allows me to set BLE TX power above the nominal rate? I see that there is something buried deep in hci.c for extended advertisements, but I don't know how to use it, and I don't know if I can use it for legacy (non-extended) advertisements. Thank you.

Matthias Ringwald

unread,
May 25, 2023, 2:34:04 AM5/25/23
to btsta...@googlegroups.com
Hi Jacob

I haven't played around with LE TX Power. Some Controllers have custom commands for this and it's also not clear what a Controller can support. Which Controller are you working with?

Anyway, I think there a no general 'set tx power' HCI commands, but there's the advertising_tx_power in the HCI_LE_Set_Extended_Advertising_Parameters

If your Controller supports this and if you have enabled support for extended advertising ENABLE_LE_EXTENDED_ADVERTISING,
you can send legacy advertisings with the additional features from the extended.

Here's an example using extended advertising

static const uint8_t adv_sid = 0;
static le_advertising_set_t le_advertising_set;
static uint8_t adv_handle = 0;

static const le_extended_advertising_parameters_t extended_params = {
.advertising_event_properties = 1, // connectable
.primary_advertising_interval_min = 0x4b0, // 750 ms
.primary_advertising_interval_max = 0x4b0, // 750 ms
.primary_advertising_channel_map = 7,
.own_address_type = 0,
.peer_address_type = 0,
.peer_address = { 0 },
.advertising_filter_policy = 0,
.advertising_tx_power = 10, // 10 dBm
.primary_advertising_phy = 1, // LE 1M PHY
.secondary_advertising_max_skip = 0,
.secondary_advertising_phy = 1, // LE 1M PHY
.advertising_sid = adv_sid,
.scan_request_notification_enable = 0,
};

static void setup_advertising() {
gap_extended_advertising_setup(&le_advertising_set, &extended_params, &adv_handle);
gap_extended_advertising_set_adv_data(adv_handle, sizeof(extended_adv_data), extended_adv_data);
gap_extended_advertising_start(adv_handle, 0, 0);
}

Please enable and check the HCI packet log to see if it workied.

Cheers
Matthias


> On 23 May 2023, at 21:09, J Ch <jacob.ch...@gmail.com> wrote:
>
> Hello. Is there an API function that allows me to set BLE TX power above the nominal rate? I see that there is something buried deep in hci.c for extended advertisements, but I don't know how to use it, and I don't know if I can use it for legacy (non-extended) advertisements. Thank you.
>
> --
> You received this message because you are subscribed to the Google Groups "btstack-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to btstack-dev...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/btstack-dev/4d4d404c-3936-4135-8c46-96d5d1a547b7n%40googlegroups.com.

J Ch

unread,
May 25, 2023, 8:38:25 PM5/25/23
to btstack-dev
Thank you for your help!

I am using a Raspberry Pi Pico with the Infineon CYW43439. 

I can confirm that the example you provided compiles without errors and that I can see advertisements, however I am not seeing an increase in Tx power as measured by RSSI from the receiver. I’m holding the receiver close by and in a fixed position so I would expect to see a difference in RSSI between 10 dBm, 0 dBm, and -10 dBm, but I’m not seeing a change. Perhaps the chip doesn’t support it, as you mentioned. Thanks again though!

MatSOBDev

unread,
Mar 9, 2024, 3:56:05 AMMar 9
to btstack-dev
Hi! There a working HCI vendor specific command of: 0x01, 0x26, 0xFC, 0x03, 0xFE, 0x00, 0x09 (last value is TX power) that is used to set BLE (I guess only BLE) adv TX power. It can be sef from -16 to 9 dBm. Higher (or lower) values produces 0x30 error code (I guess) and nothing happens. On the plot from the left: 0, 4, 8, 9 dBm (devices stationary, Pico W programmed via USB serial 1200 baud reset) if I remember correctly:
capture_08032024_012404.jpg
Here is an event after a valid value:
capture_08032024_012411.jpg
Infineon's forum thread about command. I've downloaded vendor codes PDF for CYW4343W, but there was no presence of that command. Here they say it is " transmit power attenuation" so maybe it only can lower TX power from max value baked inside maybe that RAM patch, firmware (.hcd, .cgd, there is plenty of them :D) of a final product design tuning for compliance. Concluding setting 9 dBm is the same as default without doing anything (same RSSI).

Maybe adding a custom gap_advertisements_set_params since it can be used on other CYW chips? Other thing is connection state and command 0x01, 0x26, 0xFC, 0x03, 0x04, 0x00, 0x09 with two bytes 0x0004  connection handl. I don't know for sure, but there might be a way to set TX power per connection.One connection could have higher TX power than the other.

MatSOBDev

unread,
Mar 9, 2024, 5:21:47 AMMar 9
to btstack-dev
I was using Pico SDK driver to send HCI command, now with BTstack:

uint8_t buf[6] = {0x26, 0xFC, 0x03, 0xFE, 0x00, 0xF0};
hci_send_cmd_packet(buf, 6);

Easier and cleaner. But is it safe to use it outside of the stack "loop-interrupt"? Eg. HCI traffic collision and stuff. Now HCI dump looks like that:

capture_09032024_111657.jpg

MatSOBDev

unread,
Mar 9, 2024, 4:18:15 PMMar 9
to btstack-dev
Silly mistake, 0x10 doesn't equalt to 10. So:

hci_send_cmd_packet((uint8_t []){0x26, 0xFC, 0x03, 0xFE, 0x00, 12}, 6);

sets TX power successfully to... 10 dBm (?) I guess... My phone was unreliable, and RSSI was fluctuating so used two Pico W's instead - one only advertising, one - only passively scanning. Still not perfect, but ok. Whitelist was enabled. Setting value to: 12, 11, 10 equals to default value. Now decimal 13 was producing 0x30 EVT error code. So I guess default and max value is 10 dBm. No wonder, that's ETSI max for BLE. An other clue was from playing with CyBluetool and "Write_Tx_Power_Table" and "LE_Read_Advertising_Channel_Tx_Power" commands. First one with argument "is LE" set to true and "Chip Max Tx Power" set to 12 returned 0x0A (10). Values lower than 0x0A was changing it to that new value. But with lower value set, changing TX power to higher that in that power table was successful (by RSSI). "LE_Read_Advertising_Channel_Tx_Power" was producing 0x0C (12) even when not messing with TX power, weird but RSSI kinda says it is not 12. Sooooo, it I guess it is 10 dBm now by default without doing nothing. Lower values are possible to set. But still there is some trick up the sleeve :D

J Ch

unread,
Mar 11, 2024, 11:46:38 AMMar 11
to btstack-dev
Very interesting. Are you running this on the stack that's included in the official Pico W SDK? Or did you make an update to the CYW4343W blob?

Matthias Ringwald

unread,
Mar 12, 2024, 2:38:51 AMMar 12
to btsta...@googlegroups.com
Hi MatSOBDev

For sending custom commands, please see https://bluekitchen-gmbh.com/btstack/#protocols/%23hci-host-controller-interface
If you're missing specific vendor commands for Broadcom/Infineon/Cypress, you can add them as hci_bcm_...., see hci_cmd.h

In general, I don't think that you can increase the TX power, which is either limited by regulations (configured in .hcd or similar) or hardware.

Best regards
Matthias

> On 9 Mar 2024, at 11:21, MatSOBDev <mats...@gmail.com> wrote:
>
> I was using Pico SDK driver to send HCI command, now with BTstack:
>
> uint8_t buf[6] = {0x26, 0xFC, 0x03, 0xFE, 0x00, 0xF0};
> hci_send_cmd_packet(buf, 6);
>
> Easier and cleaner. But is it safe to use it outside of the stack "loop-interrupt"? Eg. HCI traffic collision and stuff. Now HCI dump looks like that:
>
> <capture_09032024_111657.jpg>
>
> sobota, 9 marca 2024 o 09:56:05 UTC+1 MatSOBDev napisał(a):
> Hi! There a working HCI vendor specific command of: 0x01, 0x26, 0xFC, 0x03, 0xFE, 0x00, 0x09 (last value is TX power) that is used to set BLE (I guess only BLE) adv TX power. It can be sef from -16 to 9 dBm. Higher (or lower) values produces 0x30 error code (I guess) and nothing happens. On the plot from the left: 0, 4, 8, 9 dBm (devices stationary, Pico W programmed via USB serial 1200 baud reset) if I remember correctly:
> Here is an event after a valid value:
>
> To view this discussion on the web visit https://groups.google.com/d/msgid/btstack-dev/f237fc7a-9a09-429c-ac83-73df307ec1c8n%40googlegroups.com.
> <capture_09032024_111657.jpg>

MatSOBDev

unread,
Mar 19, 2024, 5:45:08 PMMar 19
to btstack-dev
Everything's vanilla. For legacy advertisements, it is also possible to control (not to increase unfortunately, but chip is maxed out anyway by  default I guess) TX power tied to the advertisement using multiple advertisements vendor opcode (it is a set of instructions designed for Android). So there could be 9 adv running in total controlled by the hardware. 1 standard spec, 8 multiple Android ones. And every one from that 8 ones, can have different TX power. And answering my question from the past, there are also more advanced filtering options that I used in Android before, not only standard whitelist by MAC. You can play AIROC™ Bluetooth® Test and Debug Tool from Infineon, everything's there, just attach some serial USB to pretend to be a legit chip :P It only needs to read serial output from PC.
Reply all
Reply to author
Forward
0 new messages