Ble development of Android mobile search ibeacon base station
The previous article described the communication between Android phones and ble terminals, and the most common ble terminal should be the ibeacon base station advocated by apple. Ibeacon technology is based on ble. It is characterized by sending messages through broadcasting. Mobile phones can obtain its information without connecting to ibeacon base station. At present, it is mainly used for indoor positioning and marketing information push. It is recognized as ibeacon by carrying specific information in the broadcasting sent by ble. To use ibeacon in IOS, you need to register the UUID and corresponding text profile of ibeacon through passbook. On Android, there is no system level background Bluetooth search service like passbook, which needs to be done by developers themselves. This time, let's talk about Android mobile phone search base station and display ibeacon base station parameters.
It is not difficult to search the ibeacon base station. The core lies in the onlescan (final Bluetooth device, int RSSI, byte [] scanrecord) of Bluetooth adapter. Lescancallback(), and the information identifying ibeacon lies in the scanrecord array. according to https://github.com/RadiusNetworks/android-ibeacon-service/blob/master/src/main/java/com/radiusnetworks/ibeacon/IBeacon.java , identify whether ibeacon depends on the following red characters:
// AirLocate: // 02 01 1a 1a ff 4c 00 02 15 # Apple's fixed iBeacon advertising prefix // e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 # iBeacon profile uuid // 00 00 # major // 00 00 # minor // c5 # The 2's complement of the calibrated Tx Power
At the same time, it should be noted that the UUID of ibeacon has nothing to do with the UUID of ble's service, characteristic and descriptor. Ibeacon's UUID is issued during broadcasting and is a standard defined by apple, while the service, characteristic and descriptor must be obtained after connecting to the ble terminal, which is a ble standard.
The running results of this code are as follows. The changing RSSI can be used to judge the distance, but the txpower of this module is not accurate, so ranging is meaningless:
The code of this article is downloaded from this site, and the code will not be posted. The core code is downloaded from this site.
Interested friends can download the code of this site to test the operation effect, hoping to help you learn Android programming.