Android Bluetooth LE Resources

If you are considering developing Bluetooth LE on Android, you should take a look at Stuart Kent’s Android Bluetooth Low Energy Resources on GitHub. He provides lots of links to introductions, videos, libraries, guides, questions on Stack Overflow and example app source code.

If you need more information take a look at the Android section of the BluetoothLE Wiki. If you need to rely on background processing read Don’t Kill My App.

Android 10 Asking for Location Permission

If you have upgraded to Android 10 then you will find you are asked whether particular apps, especially those using maps or Bluetooth, can use Location permission (all the time, only while using the app or Deny). Something like:

You will find that this screen appears, for each app using Location, at a seemingly random time. Why is this? Why do apps you haven’t just started suddenly ask for the permission? What are they doing? How should you answer?

The change of Android location permissions to include ‘only while using the app’ is part of Android 10. For app architectural purposes, some apps get location or Bluetooth scan in an Android Service that runs in background. This Service can be started and stopped by the Android OS according to whether the OS needs resources and also when an app is upgraded. The starting of the Service might cause it to get location or do an initial Bluetooth scan, as part of startup, even though the app isn’t going to use this information. These things used to be transparent but now have the knock on affect of causing the OS to ask for the first-time permission seemingly at a random time.

If, for example in the above BBC Weather app, you need the app to show the latest weather for a location on a widget or otherwise use location-related data in background then select ‘Allow all the time’. Otherwise select ‘Allow only while using the app’. Beware of selecting ‘Deny’ as it’s likely it might cause the app to malfunction in some way.

Our empirical experiences are that Android 10 background restrictions do actually noticeably improve battery life, unlike previous Android ‘Doze’ and App Standby restrictions that seemed to create pain and no gain.

Using Beacons for Race Timing

There’s novel recent research on City Marathon Active Timing System Using Bluetooth Low Energy Technology by Chun-I Sun, Jung-Tang Huang, Shih-Chi Weng and Meng-Fan Chien of Taiwan.

The authors discuss the use of beacons vs RFID and create a system using Received Signal Strength Indicator RSSI and gateways connected to detector mats:

Beacons are carried by athletes. The gateways sync their times via NTP and send data up to a MongoDB database:

An accuracy of ±156 ms was achieved which compares well to the nearest second used to generally record times and resolution accuracy of 0.1s for commercial transponder timing systems.

Latest Nordic Wireless Quarter Magazine Available

Nordic, the manufacturer of the System on a Chip (SoC) in many beacons, has the latest issue of Wireless Quarter Magazine. It showcases the many uses of Nordic SoCs.

News from the world of beacons and Bluetooth LE includes:

  • National Instruments (NI) vibration sensor enables condition monitoring of industrial plant and machinery.
  • IDC research that says commercial and consumer adoption of IoT will drive worldwide annual spending to $1.1 trillion by 2023
  • Brain cells controlled using Bluetooth LE
  • Researchers build millimeter scale Bluetooth LE antenna
  • Quuppa’s direction finding technology used for ice hockey

The Affect of Transmission Power, Advertising Interval and Beacon Placement Density on Location Accuracy

There’s recent research by Gabriele Salvatore de Blasi, José Carlos Rodríguez-Rodríguez, Carmelo R. García and Alexis Quesada-Arencibia of University of Las Palmas de Gran Canaria, Spain on Beacon-Related Parameters of Bluetooth Low Energy: Development of a Semi-Automatic System to Study Their Impact on Indoor Positioning Systems.

The paper starts by giving an overview of fingerprinting. It explains how fingerprinting is time-consuming and labour-intensive. Fingerprinting is affected by:

“Reflection, refraction, path loss, large fluctuations, multipath fading, non-line-of-sight (NLOS) conditions”

A problem is that some environment-related factors change over time, such as changes in hardware/furniture, the presence of people and ambient humidity conditions meaning that fingerprinting isn’t a one-off activity.

The researchers conclude that the highest transmission power (+4 dBm) produces the best location accuracy. However, this uses a lot of battery power. Use of the lowest power (−20 dBm) only worsened the accuracy by 11.8%. Similarly, lowering the density of the beacons by around 50%, the error increase was only about 9.2%. Increasing the advertising interval didn’t have a significant impact on the accuracy.

The affect of beacon orientation was assessed and vertical orientation was found to be best. As expected, introducing a slight electrical noise during the positioning phase did not significantly affect accuracy.

Read about Locating with Beacons

Android 10 Bluetooth Scanning Not Seeing Beacons or Devices

A large number of Bluetooth LE apps don’t work on Android 10 because of a bug in permissions in Android 10 (API 29). This affects nearly all manufacturer apps used for setting up beacons or using Bluetooth LE devices. The only apps that will work are those that have very recently been developed and target Android 10.

Android 10 introduced the requirement to have the ACCESS_FINE_LOCATION permission when targeting (written for) Android 10. Older apps targeting previous versions of Android should not have been affected but, due to a bug, they no longer work.

App developers can make their app work by adding the permission. Note that the permission must also also be prompted for from the user using the request permission mechanism. Alternatively the user can set manually via Settings -> Apps & Notifications -> Your App Name -> Permissions.

If you are a user and need to use a particular app then you will need to use a device having an Android version prior to Android 10. Alternatively, use the iOS app version if possible.

This issue has been has been detected by us on build QP1A.190711.020 and QP1A.191005.007.A1 and is perhaps related to issue 136774949. We expect it to be fixed in the future via an Android OS update.

Using iBeacons with Intelligent Displaying and Alerting Systems

There’s recent research into using iBeacons with intelligent displaying and alerting systems (SICIAD) typically found in public buildings and offices. The paper An Intelligent Low-Power Displaying System with Integrated Emergency Alerting Capability by Marius Vochin, Alexandru Vulpe, Laurentiu Boicescu, Serban Georgica Obreja and George Suciu of the University of Bucharest shows how beacons can be used to determine indoor position of mobile terminals or signalling points of interest.

An Android app uses the beacons to detect location and sends it to the SICIAD system. The researchers concluded that:

“By using an appropriate number of beacons and optimal positions, a relatively precise indoor localization can be obtained with iBeacon technology”

Bluetooth 5 Packet Sniffing

When testing beacons and Bluetooth LE, nRF Connect is usually sufficient. However, if you need deeper analysis of Bluetooth you need to use a packet sniffer.

NCC Group has a new open source sniffer for Bluetooth 5 that also works with Bluetooth 4.x. You need to run the software on a Texas Instruments (TI) CC26x2 board.

The source code and instructions are available on GitHub.