cancel
Showing results for 
Search instead for 
Did you mean: 

Different TX power level for advertising and connection (STM32WB)

msemegen
Associate II

Hi,

is there any option to set different tx power level (aci_hal_set_tx_power_level) when device is connected and is still advertising in background? My goal is to set minimum tx power level for advertising and maximum for connection, when both states are working simultaneously.

Best,

Mateusz

8 REPLIES 8
Remy ISSALYS
ST Employee

Hello,

It's not possible to do this with the basic advertising, but you can use the additional beacon (see ACI_GAP_ADDITIONAL_BEACON_START command) or the extended advertising (see ACI_GAP_ADV_SET_CONFIGURATION command) which allow to set output power in parameter.

In order to have a different tx power level for advertising and for connection, once you are connected to your device, stop the advertising, change the tx power level using aci_hal_set_tx_power_level command and then restart advertising (additional or extended). If you didn't stop the advertising before to change the tx power level, the tx power level will change for advertising and for the connection.

Best Regards

msemegen
Associate II

@Remy ISSALYS  thank You for answer.

How can I stop advertising? After successfully device connection, I cannot stop advertising - aci_gap_set_non_discoverable function returns 12 (I can't find any list of error values description). I'm not using sequencer, so I'm doing it in main program while(true) loop, not in SVCCTL_App_Notification.

Best,

Mateusz

Remy ISSALYS
ST Employee

Hello,

Which type of advertising are you using ? You can find the list of error codes value in STM32WB_BLE_Wireless_Interface.html file. The value 0x12 indicated Invalid HCI Command Parameters.

Best Regards

msemegen
Associate II

Hi!

Before device connection I'm using regular advertising (aci_gap_set_discoverable with aci_gap_update_adv_data).

//EDIT:

return value is 0xC (12 in decimal) - Command Disallowed.

Remy ISSALYS
ST Employee

Hi,

Are you sure your device still advertising once it's connected ? if you try to send the aci_gap_set_non_discoverable command before the connection, is it working ?

Best Regards

msemegen
Associate II

Good point - device automatically stops advertising after connection. How can I prevent this behavior? I set NumOfLinks in SHCI_C2_Ble_Init_Cmd_Packet_t to 2.

//EDIT:

ok, it is not so bad - if advertising stops always after connection_completed, it's ok - I can start new one. But I don't know if it's expected behavior...

Best

Mateusz

Remy ISSALYS
ST Employee

Hello,

If your code is based on STM32CubeWB example, the advertising is stopped after connection. So, in this case if you want to perform another connection, you should restart the advertising.

Best Regards

msemegen
Associate II

Hello,

In this case, my code is not based on any ST sample. The aci_gap_set_non_discoverable function is not called (I set breakpoint there to by 100% sure) - advertasing stops right after connection automatically.