This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

No disconnect event after bond on Android

Hello,

To reproduce this problem I use these steps:

  1. Bond to NRF51822 using Android 6.0.1 and latest nRF Connect version;
  2. After successful bond, connect to NRF51822;
  3. Use "DISCONNECT" button in nRF Connect application;

After these steps my application does not get BLE_GAP_EVT_DISCONNECTED event. As a consequence it does not advertise.

I am using custom board with NRF51822, S130 v2.0.1, SDK v12.1.0. My application has a custom profile. Note: problem is also reproducible with ble_app_hrs_freertos example.

Some insights:

  1. If I repeat connect/disconnect action from nRF Connect for few times I eventually get BLE_GAP_EVT_DISCONNECTED with reason BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION. After that I get disconnect events in application on every disconnect from android.
  2. If I turn off bluetooth on mobile phone or reset NRF51822 after bond, I receive disconnect event later on;
  3. This behaviour does not reproduce with S110 and SDK v10;
  4. This behavior does not reproduce with android version 5.0;
Parents
  • One comment. Does it disconnect when you close the device tab in nRF Connect? Clicking Disconnect button will not call gatt.close() method (to allow clearing device cache when device is disconnected), but closing the tab will. Aldo, make sure you don't have any other app that opened the GATT server running in background as it might have connected to your device. Then disconnect button will only disconnect your app, not the physical link. To make sure the device disconnected no matter how many apps are connected (or as a workaround in case of a bug) send a command to it and disconnect from peripheral side as suggested below.

Reply
  • One comment. Does it disconnect when you close the device tab in nRF Connect? Clicking Disconnect button will not call gatt.close() method (to allow clearing device cache when device is disconnected), but closing the tab will. Aldo, make sure you don't have any other app that opened the GATT server running in background as it might have connected to your device. Then disconnect button will only disconnect your app, not the physical link. To make sure the device disconnected no matter how many apps are connected (or as a workaround in case of a bug) send a command to it and disconnect from peripheral side as suggested below.

Children
No Data
Related