CloseToMe, an Android BLE library

Using Bluetooth Low Energy Beacons to do contact tracing

Mohsen Mirhoseini
6 min readMay 6, 2020

--

CloseToMe Android BLE library

The idea behind the library

While everyone was in the fight with the COVID-19 pandemic our team was thinking about what can help to the post-pandemic era. The time governments allow people to move out of their caves and get back to their normal life.

The main idea was tracing user close contacts and record that data on the user phone anonymously, a solution totally aligned with GDPR (European Union’s General Data Protection Regulation). The moment a user gets a positive COVID result we broadcast that specific user’s anonymous ID and share it with all the other users to ping those who were in close contact with the sick person.

A week after we started the CoviLights open-source Android application, Google and Apple also agreed and announced a similar idea to provide an API and hopefully, they will release it soon:

However, this won’t stop me from releasing this library which can come handy for other use-cases. Also having in mind that not all Android phones come with the latest Google Play Services and developers in countries under sanctions or limitations may want to do the same by themselves.

How does it work?

The CloseToMe Android library uses Bluetooth Low Energy API to simulate an iBeacon. Needless to any long-lasting painful pairing or bonding and only by advertising a client and scanning for the other clients, we can trace each client anonymously. Beacons can be filtered using their Manufacturer UUID and distinguishable by their Major and Minor which are unsigned short numbers (between 1 and 65535 per each) but this is not enough to have a unique client!

To address this limitation this library can also advertise a user UUID which is unique enough to allow determine clients from each other.

How to integrate the CloseToMe?

--

--

Mohsen Mirhoseini

As an Android developer and tech enthusiast, I publish contents about Android app development. Follow me on Medium and YouTube as "Android Developer Tip".