Android connection and disconnection strange behaviour

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
AnSo_2111241
Level 1
Level 1
Welcome!

Hi to everyone,

Last weeks I've been working on the connection between the bcm20737 and my custom Android app.

For my application I don't need bonding neither passkey or anything which I thought that would make the things easier (this will be relevant later), during my way I discovered what it is to work with BLE + Android, that with some mobile phones everything goes super smooth and with others, usually older mobiles with older Android OS, things turns into a bit of a nightmare, with the majority of them trying some reconnections on the Android side I reach to good connections with the device and good user interactions (Still the user interaction is not as good as with the newer mobiles, any advice in this field will be also really appreciate), the problem came with one mobile, more especificall an old Samsung with Android 5.1 Lollipop, with this mobile even with reconnections connection is taking a lot of minutes.

This mobile is always trying to connect the gatt and almost never calls the service discovery, while in the device side it says that is perfectly connected, eventually all the times that reaches the service discovery function it works flawlessly.

But the problem is not this one, the problem comes now. Tired of trying stuff in the Android side I decided to try example projects of the WICED IDE and see how the mobile and the device behave.  Trying the hello_sensor project I saw that the discovery of services worked flawlessly in the mobile, and after studying the differences I reach the conclusion that the missing point was this specific line.

lesmp_sendSecurityRequest();

With this line the service discovery on the mobile works like a charm, it is incredible.

So, where is the problem? The problem is that with this line the calls from the android app to disconnect the device doesn't work and even if I close the app it stays connected for a couple of minutes, at least on the device side (So it doesn't advertise anymore), also, I don't require any securityrequest in my application cause I don't want to bond the device with the mobile, cause this can cause issues on the android side, and to be totally honest I don't really know what is what this line does.

So if anyone could shed some light in this matter for me I will really appreciate it. Any advise, info about lesmp methods, anything.

Thank you so much and sorry for the long post.

0 Likes
1 Solution
BoonT_56
Employee
Employee
500 likes received 250 likes received 100 likes received

I looked up core specs v4.2 and it stated that this security request from the slave can result in the master doing one of the following three things:

1) encrypt the link

2) initiate pairing

3) reject the request

In hello_sensor app, the "LINK_ENCRYPTION_REQUIRED" was defined in the ble_profile_cfg and that's why a security request is always sent on every connection. You can check whether the device is bonded or not by calling emconninfo_deviceBonded(), something like below:

if (emconninfo_deviceBonded())

{

    ble_trace0("device bonded\n");

}

else

{

     ble_trace0("device not bonded\n");

     lesmp_sendSecurityRequest();

}

return;

View solution in original post

1 Reply