Android BLE development-search for iBeacon base stations on Android phones

Source: Internet
Author: User

This article from http://blog.csdn.net/hellogv/, reference must indicate the source!

Last time I talked about communication between Android phones and BLE terminals, and the most common BLE terminal should be the iBeacon base station proposed by Apple. IBeacon is based on BLE. It is characterized by sending messages externally through broadcasting. Mobile phones do not need to connect to the iBeacon base station to obtain its information. Currently, iBeacon is mainly used for indoor positioning and marketing information push, it carries specific information in the broadcast sent by BLE to be identified as iBeacon. When using iBeacon in iOS, you must register iBeacon UUID and the corresponding text description through passbook. on Android, there is no background Bluetooth search service similar to passbook, developers must handle such services by themselves. This time we will talk about searching for base stations and displaying iBeacon base station parameters on Android phones.


It is not difficult to search for an iBeacon base station. The core is the kernel thadapter. LeScanCallback ()OnLeScan(Final effecthdevice device, int Arg, byte [] scanRecord), and the information for identifying iBeacon lies in the scanRecord array. Follow:


// AirLocate:

// 02 01 1a 1a ff 4c 0002 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, note that the UUID of iBeacon is irrelevant to the UUID of BLE Service, Characteristic and Descriptor. The UUID of iBeacon is issued during broadcast and is a standard defined by Apple, the Service, Characteristic, and Descriptor must be connected to the BLE terminal, which is the BLE standard.


The running result of the Code in this article is as follows. The ever-changing body of bsns can be used for distance determination. However, the txPower of this module is not accurate, so ranging is meaningless:

Download: Workshop.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.