Hello,
I've recently been investigating a problem on a CC2640R2F project where we're getting intermittent pairing problems with certain Android devices. I've replicated the problem using the blestack simple_peripheral example included with SimpleLink SDK v3.20. It looks like this issue was raised previously (see related question).
To align simple_peripheral to the target settings on my project, I have modified simple_peripheral.c as follows (starting at line 560):
// Don't send a pairing request after connecting; the peer device must // initiate pairing uint8_t pairMode = GAPBOND_PAIRING_MODE_WAIT_FOR_REQ; // Use authenticated pairing: require passcode. uint8_t mitm = FALSE; // JW - modified for 'Just Works' authentication // This device only has display capabilities. Therefore, it will display the // passcode during pairing. However, since the default passcode is being // used, there is no need to display anything. uint8_t ioCap = GAPBOND_IO_CAP_NO_INPUT_NO_OUTPUT; // JW - modified for 'Just Works' authentication // Request bonding (storing long-term keys for re-encryption upon subsequent // connections without repairing) uint8_t bonding = TRUE; // Whether to replace the least recently used entry when bond list is full, // and a new device is bonded. // Alternative is pairing succeeds but bonding fails, unless application has // manually erased at least one bond. uint8_t replaceBonds = FALSE; // JW - added to enforce LE Secure Connections. uint8_t secureConnection = GAPBOND_SECURE_CONNECTION_ONLY; GAPBondMgr_SetParameter(GAPBOND_PAIRING_MODE, sizeof(uint8_t), &pairMode); GAPBondMgr_SetParameter(GAPBOND_MITM_PROTECTION, sizeof(uint8_t), &mitm); GAPBondMgr_SetParameter(GAPBOND_IO_CAPABILITIES, sizeof(uint8_t), &ioCap); GAPBondMgr_SetParameter(GAPBOND_BONDING_ENABLED, sizeof(uint8_t), &bonding); GAPBondMgr_SetParameter(GAPBOND_LRU_BOND_REPLACEMENT, sizeof(uint8_t), &replaceBonds); GAPBondMgr_SetParameter(GAPBOND_SECURE_CONNECTION, sizeof(uint8_t), &secureConnection); // JW - added
I have tried this code out with a Samsung Galaxy A10 and a Moto E6 Plus, using the nRF Connect app for triggering bonding operations.
The Galaxy A10 bonds within 1 second.
The Moto E6 Plus normally takes around 20 seconds for all pairing packets to be exchanged, with another 20 seconds before bonding is reported by the app and simple_peripheral terminal.
Occasionally, the Moto E6 pairing packets are exchanged quickly, but there is still a 20 second delay before bonding is reported.
I have tried this with SimpleLink SDK versions 1.50 and 4.10 and get the same result.
If I compile the Stack project included with simple_peripheral with SC_HOST_DEBUG - turning on support for Bluetooth debug keys - both phones bond within 1 second.
If I make the same modification to the blestack5 simple_peripheral example, both phones bond within 1 second. Note that Bluetooth debug keys were not enabled in this case and I was using SimpleLink SDK v3.20.
I'd be grateful for any suggestions on how to fix/workaround this issue.
Thanks,
John
