I'm using nRF52832, soft device 2.0, SDK11 and as a central.
When it happens I'm scanning for peripheral to connect. Usually it's a peripheral advertises at very low rate, ie only a few times per second and with very weak RSSI, ie around -90dbm.
My central device will try to connect to it. Then I have an arbitary timeout because I don't want to wait for too long for really weak signal. When time is up and I haven't received BLE_GAP_EVT_CONNECTED, I'll call sd_ble_gap_connect_cancel() to cancel the connection.
But some time I get NRF_ERROR_INVALID_STATE from the call. If I ignore the error and return to scanning, I'll get soft device fault. What's the reason for the error code? I guess one possibility is it gets connected right when I want to cancel it? How to deal with it?