mbed-os-example-ble: Security Manager example broken for nRF52840_DK

Hi,

While attempting to build and test the BLE_SM example on the nRF52840_DK target, my phone is able to connect but the Mbed-OS device encounters an error when attempting to upgrade the link’s security. The following debug output is shown:

 PERIPHERAL                                                                     
                                                                                
[XXXXXXXX]                                                              
Please connect to device                                                        
Connected to peer [XXXXXXX]                                        
Error during SM::setLinkSecurity 4                                              
Advertising timed out - aborting 

The SM:setLinkSecurity call is returning BLE_ERROR_INVALID_PARAM at this line:

https://github.com/ARMmbed/mbed-os/blob/033fffea8406fc32b4a19d92d76912c86b010f86/features/FEATURE_BLE/source/generic/GenericSecurityManager.tpp#L367-L370

get_control_blocks loops through a number of connection control blocks trying to find the one given by the caller. None of the control blocks are in the connected state yet – so the call fails to find the control block and thus the security manager returns Invalid Parameter.

My theory is that the internal state hasn’t been updated before the stack’s onConnectionComplete handler is called.

I’m going to try and delay the link security upgrade by deferring to the example’s event queue for a few milliseconds. I’ll post back with my findings…

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 16 (10 by maintainers)

Most upvoted comments

I’ll talk to the team to check this issue.

@0xc0170 This falls under the category of defect I believe