Hello,
I am implementing advertising control on the KW47.
To stop advertising, I use Gap_StopAdvertising(). However, there are cases where I would like to start advertising again before receiving the gAdvertisingStateChanged_c event after issuing the stop request.
In this situation, is it safe to call Gap_StartAdvertising() while the Gap_StopAdvertising() operation is still in progress?
Specifically, which of the following sequences is recommended?
---
Gap_StopAdvertising()
↓
Wait for gAdvertisingStateChanged_c
↓
Gap_StartAdvertising()
----
or
---
Gap_StopAdvertising()
↓
Gap_StartAdvertising()
---
Does the SDK handle the state transition internally, or is it necessary to wait for the gAdvertisingStateChanged_c event that indicates advertising has stopped before calling Gap_StartAdvertising()?
Thank you for your support.
Best regards.
Hello @hyama,
Could you provide a more context on the scenario where you would like to restart advertising before receiving the gAdvertisingStateChanged_c event?
The recommended approach is to wait for the gAdvertisingStateChanged_c event to verify that the advertising state transition has completed successfully. While Gap_StopAdvertising() initiates the procedure, the callback confirms the result of the operation. For example, instead of receiving a gAdvertisingStateChanged_c event, the application may receive a gAdvertisingCommandFailed_c event indicating that the requested operation could not be completed.
BR
Habib
Thank you for the clarification.
We asked this question because we expected the SDK might internally handle the stop and start requests in sequence, even if Gap_StartAdvertising() was called before receiving the gAdvertisingStateChanged_c event.
Since waiting for the gAdvertisingStateChanged_c event is the recommended approach, we will modify our implementation accordingly.
Thank you for your support.