cancel
Showing results for 
Search instead for 
Did you mean: 

Using BLE can you advertise indefinitely?

WThal.1
Associate II

Hi,

I want to be able to advertise continuously (without timeout). Is it possible? I use CubeMX, is there any setting to allow this? or once the files are generated, what line can I comment out to achieve this behaviour? I have tried commenting out the line below from app_ble.c (around line 493) but no luck. Thanks.

 HW_TS_Create(CFG_TIM_PROC_ID_ISR, &(BleApplicationContext.Advertising_mgr_timer_Id), hw_ts_SingleShot, Adv_Cancel_Req);

4 REPLIES 4
Remi QUINTIN
ST Employee

Do you mean advertising without setting any connection like a beacon?

Once the advertising phase is started, there is no way to stop it it except calling the ACI_GAP_TERMINATE function. This function may be called inside the callback resulting from a elapsed timer (Timeout)

Commenting the call to ACI_GAP_TERMINATE function may be the right way in your case.

Remi QUINTIN
ST Employee

In fact the function to call to stop the advertising phase (launched via the call to aci_gap_set_discoverable function) is aci_gap_set_non_discoverable.

So you should search for this aci_gap_set_non_discoverable function in your code.

WThal.1
Associate II

Thanks Remi. I have found aci_gap_set_non_discoverable twice and I had an led to switch ON when this function is reached but it looks like it never gets there. Somehow there is something else somewhere terminating the advertising. Is it possible that there is another timeout that actually shuts down the STM32WB after inactivity? By the way this is the p2p server example in the firmware library so I haven't added any other code.

WThal.1
Associate II

Sorry, it's working now. I didn't realise I put some extra code to debug the advertising issue. It seems that adding code without using the Scheduler made the STM32WB crash. Thanks.