BLE connection to Android mobile phone

Hi,

I'm using NRF52840 to connect to an Android mobile phone.

The application scans for advertisement and when the NRF device starts advertising - connection is established.

The problem is that after bonding - connection isn't always established when advertising starts. Only when the application is open on Android mobile phone, everything works.

Is there any definition on NRF device that can solve that problem? To make sure the Android will connect on every advertisement after bonding?

Thanks!

Parents
  • Hello,

    The automatic connection can be established in several ways. After bonding, the device could advertise directly, which should trigger Android reconnecting to the device. But then, you should have an app ready to take over the connection. For HID profiles, like keyboard and mouse, that is not needed, as it's supported natively since KitKat. Other profiles need to have an app, and the app need to be running or woken up by the system.

    On Android O and newer, you may scan with PendingIntent, which will allow your app not to have any long running service. When the device is found, the system can wake up your app by calling a broadcast, or perhaps starting a service, that should connect to the device.

    You may also use a background service that does the scanning, but those may be killed if the service is not displaying a notification (isn't promoted to foreground service). Have a look at https://developer.android.com/about/versions/oreo/background.

    Nordic offers Android Scanner Compat Library which can emulate scanning with PendingIntent for older platforms, but we highly recommend setting minSdk to Android O, as this is way more battery efficient than what the compat library can deliver.

Reply
  • Hello,

    The automatic connection can be established in several ways. After bonding, the device could advertise directly, which should trigger Android reconnecting to the device. But then, you should have an app ready to take over the connection. For HID profiles, like keyboard and mouse, that is not needed, as it's supported natively since KitKat. Other profiles need to have an app, and the app need to be running or woken up by the system.

    On Android O and newer, you may scan with PendingIntent, which will allow your app not to have any long running service. When the device is found, the system can wake up your app by calling a broadcast, or perhaps starting a service, that should connect to the device.

    You may also use a background service that does the scanning, but those may be killed if the service is not displaying a notification (isn't promoted to foreground service). Have a look at https://developer.android.com/about/versions/oreo/background.

    Nordic offers Android Scanner Compat Library which can emulate scanning with PendingIntent for older platforms, but we highly recommend setting minSdk to Android O, as this is way more battery efficient than what the compat library can deliver.

Children
No Data
Related