Thank you, I did that, but overall pairing seems to be very unreliable. Many times it fails with unspecified reason.
But before that getting into details with pairing, connections have been pretty undeterministic, too. I have a Central which issues a connect to a Peripheral, many times Central comes back with disconnected callback with reason BT_HCI_ERR_CONN_FAIL_TO_ESTAB. So, do you have any recommendations to make connections more reliable ? Any parameters to tweak ? Why would it keep disconnecting with BT_HCI_ERR_CONN_FAIL_TO_ESTAB reason ?
Hi,
Could it be the environment you are testing this in? BT_HCI_ERR_CONN_FAIL_TO_ESTABLISH will happen from time to time. It means the peripheral did not respond to the connect request (only one request is sent per connect attempt) and that the central have to retry. It is normal for this error to happen from time time, but it can also occur quite frequently if there is lots of noise or interference from other nearby sources, for instance, active scanning from other BLE devices.
Yes, it is possible, however, I repeat the test with another MCU vendor and I don't have these connection and pairing issues. So, my question is, what can I change to create a more robust connection and pairing operation ? For example, is there more info on these parameters ? How do they affect connections ? :
I don't think there is much you can do in FW to improve chances for a connection attempt to succeed except for increasing the Radio's TX output power ( example ). Default is 0 dBm and radio is supporting up to +8 dBm. But I'm surprised you don't see this with the other board. Maybe the other board automatically repeats the connection attempt if it fails the first time? A Bluetooth sniffer trace may help show what the problem is.
You are still using 2 Nordic DKs for this test?
I was using one Nordic nRF52840-DK in Peripheral mode and the other unit was another nRF52840-based module DK from another company. So, I switched to two Nordic DKs and connection problems went away, so that's good. But pairing failures are still here, so I've put Nordic nRF52840 dongle with Wireshark capture in between.
It seems like all is going well till when Slave responds with LL_START_ENC_REQ and then I see all packets that are not empty PDU having "Encrypted packet decrypted incorrectly (bad MIC) " error.
Any idea why these bad MIC errors might be happening ?