ARMmbed / mbed-os-example-ble

BLE demos using mbed OS and mbed cli
Apache License 2.0
134 stars 118 forks source link

SM example: defer setLinkSecurity. #264

Closed pan- closed 3 years ago

pan- commented 5 years ago

There's an issue with current mbed-os codebase where the security manager is notified of the existence of a new connection after the user event handler. This prevent correct execution of setLinkSecurity in the connection event handler.

A simple workaround i to defer execution of setLinkSecurity after the execution the user event handler.

pan- commented 5 years ago

See #257 @AGlass0fMilk @loverdeg-ep @paul-szczepanek-arm

AGlass0fMilk commented 5 years ago

@pan- How was this fix tested? I am still not able to connect using the LightBlue app on my phone.

I no longer get a security manager error but I get a "Advertising timed out - aborting" message along with the cyclical connect/disconnect. See the example output below:

 PERIPHERAL 

f9:91:38:7f:c9:c8
Please connect to device
Connected to peer: 52:88:63:c6:53:1d
Advertising timed out - aborting

 CENTRAL 

Diconnected

 PERIPHERAL 

f9:91:38:7f:c9:c8                                                               
Please connect to device                                                        
Connected to peer: 52:88:63:c6:53:1d                                            
Advertising timed out - aborting                                                

 CENTRAL                                                                        

Diconnected                                                                     

 PERIPHERAL                                                                     

f9:91:38:7f:c9:c8                                                               
Please connect to device
AGlass0fMilk commented 5 years ago

@paul-szczepanek-arm This patch doesn't fix the issue... see my PR #265

It still needs work after that even.

paul-szczepanek-arm commented 5 years ago

This is an improvement on the situation. We're looking into the other issues.

pan- commented 5 years ago

@AGlass0fMilk I'm out of the office with limited access to boards. I tried this patch on ST BlueNRG but not yet on NRF52840. Thanks for raising another PR to fix the issue on NRF. I will try it early next week.

We will try to land fixes into ble implementation rather than workaround in the example when there's time for it.

40Grit commented 4 years ago

@ranshe

paul-szczepanek-arm commented 3 years ago

sm fixed in the meantime