What is Bluetooth LINE Service Advertising?

We recently started selling beacons that can advertise LINE. This post explains LINE advertising with information on the packet format.

LINE Beacons are used with the LINE messenger service that allows users to send text, video, and voice messages on smartphones and the PC. It’s currently available in Japan, Taiwan, Thailand, and Indonesia. LINE have iOS and Android developer APIs that allow you to hook into the LINE service and include LINE services in your app. The LINE beacon allows your LINE code, called a bot, to receive beacon webhook events whenever a LINE user enters the proximity of a beacon. The beacons allow you to customise your bot app to interact with users in specific contexts. There’s also a beacon banner feature, available for corporate users, that causes a banner to appear in the LINE messenger app when it comes close to a LINE beacon.

LINE Bluetooth Advertising
LINE Bluetooth Advertising

Unlike iBeacon, LINE Beacon packets have a secure message field to prevent packet tampering and replay attacks. The secure data is 7 bytes long containing a message authentication code, timestamp and battery level. Secure messages are sent to the LINE platform for verification.

Generating LINE advertising
Generating LINE Advertising

LINE recommend LINE beacon packets be sent at a very high rate of every 152ms. In addition, LINE recommend advertising iBeacon (UUID D0D2CE24-9EFC-11E5-82C4-1C6A7A17EF38, Major 0x4C49, Mino 0x4E45) to notify iOS devices that the LINE Beacon device is nearby. This is because an iOS app can only see iBeacons when in background and LINE beacons can’t wake an app.

We observe that the high advertising rate and concurrent iBeacon advertising aren’t battery friendly and the beacon battery isn’t going to last long.

There’s more information on the LINE developer site on using beacons and the LINE packet format.

Making More Sense of Bluetooth Advertising Scans

When working with Bluetooth beacons and/or gateways and looking at raw Bluetooth data it can often become confusing which device is which. When setting up beacons using manufacturers’ apps, it’s a common occurrence for our customers to mistakenly connect to smartphones or fitness trackers rather than a beacon and wonder why the connection doesn’t work.

RaMBLE is a useful Android app that helps decode the Bluetooth devices around you. It attempts to classify devices so you can identify them:

The scanning runs in background and also logs advertising so that the data can be exported for analysis.

Nordic Android Library

A new version of Nordic Semiconductor’s Android BLE library has been released. Nordic is the manufacturer of the system on a chip (SoC) inside some Bluetooth devices. Connecting to these devices, as opposed to just scanning for their advertising data, can be very tricky and there are lots of different ways of doing things depending on the Android version and workarounds based on specific situations. Nordic’s Android library aims to solve these problems and claims it “makes working with Bluetooth LE on Android a pleasure”. The library uses standard Bluetooth and hence works for all Android Bluetooth development, not just Nordic’s devices.

The new Android BLE Library v2.2.0 adds GATT server support and tidies up the callback mechanism. GATT server is where the Android device itself can be connected to from another device as opposed to Android initiating the connection. Note that this library is all about Bluetooth GATT connections. Connections are rare in the BLE World as most information is obtained through non-connected scanning for Bluetooth advertising. Connections tend to be used for settings or where you need higher or larger throughput than advertising can provide.

Note that the library doesn’t include scanning which is required before you can connect. Nordic provides a separate scanning library.

Also be aware that these libraries are relatively large. When we used them they took us over the Android 64K method limit thus complicating development slightly. Also, the later versions have dependencies on AndroidX. Finally, while the libraries hide the complications of Android development, this can be good and bad. When problems happen, as they always do with Bluetooth GATT, if you didn’t write the workarounds in the first place, debugging and fixing can be difficult.

Android Apps Not Scanning

As more and more devices are being shipped with Android 10 we are increasing getting reports of problems with beacon apps built for previous versions of Android. We mentioned this issue back in October last year.

To compound the problem, many popular Chinese manufacturers such as Oppo, Huawei and Xiaomi also now using Android 10 in their forked versions of Android. Not only are these manufacturers inheriting the Android 10 problem but their devices also suffer from problems running services, such as Bluetooth scanning, in background. The problem is that these manufacturers also add their own additional background throttling (and killing) mechanisms into the OS that make Bluetooth unreliable. The site dontkillmyapp documents the known problems and some workarounds for various forks of Android.

If you think you might be a victim of these issues, try using another, perhaps older, Android smartphone to isolate the problem.

Bluetooth Beacons Study Guide

Bluetooth SIG have updated their Introduction to Bluetooth Beacons. It provides advice and examples how to use beacons from iOS, Android and Raspberry Pi using the respective Bluetooth APIs.

The examples show how to scan for AltBeacon which is unusual because most people will want to scan for iBeacon because AltBeacon is sent by very few beacons. This is less of a problem on Android and Raspberry Pi where slightly modified code can be used. However, on iOS, the suggested APIs won’t work for iBeacon because Apple removes the iBeacon data from the Bluetooth scan response data to force you to use the iBeacon specific APIs which aren’t mentioned in the guide.

iBeacons for Android, iBeacons for iOS

We often gets asked what are the best beacons for iOS and/or Android. As mentioned in our post on Which Beacons Are The Most Compatible, all beacons, whether iBeacon or Eddystone, are compatible with iOS and Android.

The universal compatibility comes about because all beacons are slight derivations of a few standard circuit designs and firmware provided by Texas Instruments, Dialog and Nordic who produce the System On a Chip (SoC) inside beacons.

Instead, you should be looking at more physical aspects such as battery size, battery life, range, on-off buttons, waterproofing and included sensors.

View iBeacons