The previous article describes the communication between the Android phone and the BLE terminal, while the most common ble terminal should be the ibeacon base station advocated by Apple. Ibeacon technology based on BLE, it is characterized by the broadcast of external messages, mobile phones do not need to connect to the Ibeacon base station can also obtain its information, is mainly used to do indoor positioning and marketing information push, in the BLE issued by the broadcast with specific information to be recognized as ibeacon. Using ibeacon in iOS to go through the Passbook register ibeacon uuid and corresponding text profile, and on Android there is no similar to the passbook of the system-level background Bluetooth Search service, such services need to be done by the developers themselves. This time on the Android phone search base station and display ibeacon base station parameters.
Search Ibeacon base station is not difficult, the core is Bluetoothadapter.lescancallback () Onlescan (final bluetoothdevice device, int rssi, byte[] Scanrecord), and the information that identifies ibeacon is 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 by the following red words:
Airlocate:
1a 1a FF 4c # Apple ' s fixed ibeacon advertising prefix
E2 C5 6d b5 DF fb D2 B0-d0 f5 a7 E0 # ibeacon profile uuid
# major
# minor
C5 # the 2 ' s complement of the calibrated Tx power
Also note that the ibeacon uuid and the BLE service, the characteristic, the descriptor UUID are okay, the ibeacon UUID is broadcast, the standard defined by Apple itself, and the service, Characteristic, descriptor must be connected to the BLE terminal before they get, is the BLE standard.
The results of this code run as follows, changing RSSI can be used to make distance judgments, but this module is not accurate txpower, so ranging is meaningless:
This article code point this site download, the code is not posted out, the core code point this site download.
Interested friends can download the site code to test the effect of the operation, I hope that we learn the Android program has some help.