This article is from http://blog.csdn.net/hellogv/ , the citation must be noted!
The last time we talked about the communication between the Android phone and the BLE terminal, the most common ble terminal should be the ibeacon base station advocated by Apple. Ibeacon technology is based on BLE, which 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 for indoor positioning and marketing information push, in BLE issued by the broadcast with a specific information to be identified as ibeacon. In iOS use ibeacon to go through passbook registered ibeacon UUID and corresponding text profile, and on Android there is no similar passbook this system-level background Bluetooth Search service, such services need to be done by developers themselves. This time talk about Android phone search base station and display ibeacon base station parameters.
Searching the ibeacon base station is not difficult, the core is the Onlescanof Bluetoothadapter.lescancallback () (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 Scarlet Letter:
//airlocate:
//1a 1a ff 4c xx 02 15 # Apple's fixed iBeacon advertising prefix
//E2 C5 6d b5 df fb/d2 B0" D0 f5 A7 "E0 # IBeacon profile uuid
//xx # major
/ /xx # minor
//C5 # the 2 ' s complement of the calibrated Tx Power
Also note that the UUID of the ibeacon and ble Service, characteristic, descriptor uuid is okay, ibeacon UUID is broadcast when issued, is the standard defined by Apple itself, and Service, characteristic, descriptor must be connected to the BLE terminal to get, is the BLE standard.
This code runs the result as follows, constantly changing Rssi can be used to do distance judgment, but this module txpower is not very accurate, so the range is meaningless:
This code can be downloaded here: http://download.csdn.net/detail/hellogv/7269127, the code is not posted out, the core code is changed from https://github.com/RadiusNetworks/ Android-ibeacon-service.
Android BLE developed Android phone search ibeacon base Station