2022-12-30 02:00 AM
I've been experiencing an issue where sporadically the aci_gap_set_discoverable fails to start due to a command disallowed error (similiar to this) on the STM32WB50.
For context: the device goes into sleep mode and wakes-up 100+ times per day. In sleep mode the device advertises in low power mode (min: 546.25ms, max 760 ms). When woken it will advertise in fast mode (min: 20 ms, max 25ms). These parameters perform well.
Before going to sleep mode all active connections are disconnected and this is verified by checking all the link statuses using aci_hal_get_link_status. Once every so many days the device will run into an error that it can't start advertising even though all links appear to be non-active and the advertising parameters are correct.
What additional steps can I take to debug this problem?
FYI, the device is running STM32CubeWB 1.15.0
2023-01-06 12:54 AM
Hello,
Aci_gap_set_discoverable function can return the error code Command Disallowed if an advertising is already running or if the advertising parameters are wrong. When your device is in fast advertising mode, do you reestablish the previous connection or not?
Best Regards
2023-01-23 09:35 AM
Hi Remy,
Thanks for the response. The Aci_gap_set_discoverable returns without error codes. After waking up the device will most likely reestablish connection with the same master as before, but it can also be a different master.
I did some more investigating and it appears a BLE link of the CPU 2 get stuck when disconnecting the masters (aci_gap_terminate). The following sequence is in place:
The interesting part is that once every so many times the aci_gap_terminate command will not result in a hci_disconnection_complete_event and the link disconnecting. Using a BLE sniffer I can see that no packets are sent between master and slave at this point and connection from master side disconnects after supervision timeout has passed.
Additional calls to aci_gap_terminate does not appear to close/terminate the link. I'm validating connection handle and link status using the aci_hal_get_link_status command.Currently I'm resetting the device as soon as I detect this "stuck" link, however this is not very optimal.
Lastly, this behavior does not appear to happen when skipping the fast advertising step in step 2 from the list above.
Best Regards,
Mathieu
2023-01-24 12:41 AM
I accidentally left my reply as a new answer. Please see my message below.
2023-01-24 02:43 AM
Hello,
Did you reproduce this issue if you stay in run mode?
Best Regards
2023-01-24 02:50 AM
Yes. My testing loop to debug this issues skips the whole sleep cycle so:
2023-02-16 06:29 AM
In the end I've decided to simply do a full reset of the hci stack (hci_reset) before going to sleep to make sure none of the links remain in locked condition.