I'm using BTStack v1.6.2 in the R.Pi Pico-SDK to connect to a BLE keyboard, the Logitech K380s, and seeing behavior I can't explain.
We are running as a BLE central and call `gap_connect` with the appropriate device address. We see the SM process through the connection states and end up in state 41 (SM_INITIATOR_CONNECTED). At that point my callbacks have set the connection information up and I can send and receive HID messages for ~30 seconds.
After ~30s from the last SM state update to 41, we get the message
> LOG -- sm.c.689: SM timeout
and we're disconnected. If we reconnect it uses the keys stored in TLV and reconnects fine on the next `gap_connect` call, but again, after 30s, we disconnect.
This only seems to happen with the K380S keyboard. Other Logitech and HP keyboards and Microsoft BLE mice all stay connected indefinitely after initial connection
The log is here, on the GitHub issue we've been tracking:
Debug capture log (ignore the SQL extension).
I've looked thru the logged `sm_run: state XXX` transitions and we end with
...SM_PH3_RECEIVE_KEYS->SM_PH3_Y_GET_ENC,->SM_PH3_DISTRIBUTE_KEYS->SM_INITIATOR_CONNECTED
If I go through the code, I see the state `SM_PH3_DISTRIBUTE_KEYS` will only transition to SM_I_C by calling `sm_master_pairing_success` (which sets the connected state) and which calls `sm_done_for_handle` which logs "sm.c.1106: sm: connection 0x40 released setup context" (seen in the posted log) AND stops the SM timer.
But, evidently, the timer is still ongoing because at ~30 seconds from the last key distribution step it fires in the logs.
I'd appreciate any pointers or suggestions. I'm perfectly happy to find it's a bug in my own code, but all that code does is `gap_connect()` and then in the SM callback for SM_EVENT_PAIRING_COMPLETE call `hids_client_connect()`...
Thx,
-EFP3