Original article address
Ibeacons
Ibeacons is a recent topic that allows you to locate in the room and let your phone know where you are in the base station. There are many applications: finding your car in the parking lot, retailers get coupons and location-based special discounts, and even many apps that you can't imagine now.
Ibeacons has many blog posts about ibeacons and how to use it, but from a technical perspective, how they work, deep technology is low-power Bluetooth, etc...
What is Bluetooth with low power consumption?
Bluetooth with low power consumption is part of the Bluetooth 2010 specification released in 4.0. It was launched in Nokia in 2006, but integrated into bluetooth technology, it is a set of protocols different from classic Bluetooth, the device is not backward compatible. Therefore, three types of Bluetooth devices are available: Bluetooth Smart ready in Classic mode and Le (Low Energy) mode. * Smart Bluetooth: only the le mode is supported.
Bluetooth Smart ready
New smartphones (iPhone 4 S +, SG3 +), laptops, tablets, and equipped with Bluetooth 4.0, because it is already a smart Bluetooth transition, beacons, on the other hand, only supports low-power protocols (allowing them to work long enough in a battery scenario), so they implement smart Bluetooth, old devices, for example, peripherals, on-board systems, and old mobile phones generally only support the classic Bluetooth protocol.
Bluetooth with low power consumption focuses on low power consumption. For example, some beacons are under a button battery (the battery is usually not replaced, unless it needs to be replaced when beacon stops working) and can transmit signals for two years. Both low-power Bluetooth and classic Bluetooth use the same spectrum range (2.4 GHz-2.4835 GHz ). Low-Power Bluetooth has a lower transmission rate, although it is not intended to transmit a large amount of data, but to discover and communicate with simple. In the theoretical range, low-power Bluetooth and classic bluetooth signals can reach up to 100 meters.
How to communicate with low-power Bluetooth
Low-Power Bluetooth has two main states: Broadcast and connection.
Broadcast is a one-way discovery mechanism. devices that want to be discovered can transmit packets every 20 ms to 10 seconds. The shorter the time interval, the shorter the battery life, but the faster the device discovers. A data packet can be extended to 47 bytes, which are composed of the following:
* 1-byte header
* 4-byte access address
* 2-39 bytes Broadcast Channel PDU
* 3-byte CRC
Data
For broadcast communication channels, the access address is always 0x8e89bed6. For data channels, each connection is different.
PDU has its own header (two bytes: The load size and its type-whether the device supports connection, etc.) and the actual data load (up to 37 bytes ).
Finally, the first six bytes of the load are the device's MAC address, and the actual data is up to 31 bytes.
Low-Power Bluetooth can operate on a non-connected broadcast mode (all information is included in the broadcast), but they can also allow connections (usually allowed ).
After the device is discovered, you can establish a connection. It is possible to read the services provided by Bluetooth with low power consumption, for each service feature (this is the implementation of the well-known GATT configuration file ). Each feature provides values that can be read or written. For example, a smart thermostat can expose the service to get the current temperature and humidity reading (as a feature service), and another service feature to set the expected temperature. Although beacons does not use a connection, the details are skipped here. If you want to read more low-power Bluetooth connections, Apple's core Bluetooth Guide provides a good overview even if you are not an iOS developer. For more professional technical articles, see ee.
How does beacons use Bluetooth?
Beacons generally use broadcast channels, which are defined by beacon. They transmit data packets at intervals and the data is accepted by devices like smart machines. Therefore, ibeacons is a special application of low-power Bluetooth broadcast, added Special Support for IOS.
If you try to intercept a Bluetooth broadcast package from estimote beacon, you will see the following data:
02 01 06 1A FF 4C 00 02 15 B9 40 7F 30 F5 F8 46 6E AF F9 25 55 6B 57 FE 6D 00 49 00
(Capture the data. If OSX is used, an additional download contains a Bluetooth scan and package log)
The above data already has packets, and the fixed access address, broadcast pdu header, and MAC address are removed. It only has 30 bytes of broadcast data, so it is adapted to the 31-byte limit.
What makes Bluetooth broadcast an ibeacon? The format defined by Apple is as follows:
02 01 06 1A FF 4C 00 02 15: iBeacon prefix (fixed) B9 40 7F 30 F5 F8 46 6E AF F9 25 55 6B 57 FE 6D: proximity UUID (here: Estimote’s fixed UUID) 00 49: major 00 0A: minor C5: 2’s complement of measured TX power
Data
If you want to experiment with beacons without any special devices, follow these steps: If you have a new mobile phone (for example, iPhone 4S + SG3 +) or a Bluetooth 4.0 laptop (retina MacBook ), you can convert the above devices into the sending and receiving ends of ibeacon. For iPhone, refer to the "locate IB" app in the Apple App Store. For MacOS, refer to here, of course, you can also use a circuit board as beacon.
Break down ibeacon data formats
From a fixed ibeacon prefix (02 01 .... 15) What is the meaning of other parts?
UUID (B9... 6D in our example) is used to distinguish your beacons from other identifiers, if, for example, beacons is used to provide special discounts to customers in chain stores. All beacons belong to one chain and should have the same UUID at close distance. Dedicated iPhone applications for chain stores will scan the beacons of the given UUID in the background.
The editor ID (2 bytes, here: 0x0049 (10 hexadecimal 73) is used to group many related beacons, for example, all beacons in the store will have the same primary label, so that the application will know the specific store in which the customer is located.
The secondary label (2 bytes, here: 0x000a, (10 in 10) is used to define an independent beacons. Each beacon will have different labels in the store, so you know where the customer actually is.
Measurement distance
At last, TX power is used to determine the distance from Beacon. How can this be expressed as rough information (near/far/out of range) or as a more precise meter (can be converted to feet?
TX power ), as the signal attenuation expectation, we can further explain that we know the one-meter-long HTTP signal and the current HTTP signal (we get the information together with the received signal), which may have different computing differences, IOS has already created a model. For other platforms, you need to write code. For more information, see here.
Obstacles such as furniture, human or communication congestion can reduce signals, so distance is an estimate.
IOS Integration
IOS and ibeacons bring about some additional integration, so your app can receive notifications. When a beacon appears in a region, it is not only the app runs on the foreground, but also the background. An app can subscribe to the entry/exit time of a region, and then partially wake up, even if it is not yet working. To respond to these events, the app can send a local notification prompting the user to open the app, view in-store prompts (data can be retrieved from the network) or related content.
More accurately, when the mobile phone is inactive, IOS enters the low-power monitoring mode: only the ibacons region is detected to enter and exit. When mobile phones and apps are active, you can enter the search mode to enable the signal strength of your home book and more accurate Distance Estimation.
Note that it takes time for your mobile phone to detect beacon. First, beacons transmits broadcasts intermittently. Second, if your mobile phone is not active, it also detects bluetooth signals at intervals, for beacon to be detected, the two intervals must overlap. In fact, it may take 15 minutes to detect a beacon. For IOS ibeacons, the beacons manufacturer also provides a dedicated SDK to help compile reference based on Beacon. Let's take a look at the example esitmote's IOS sdkandandroid
Next step
The only thing that remains to be done is to develop some beacon-based references.
Link: http://xunyanan.com/blog/2014/03/27/how-do-ibeacons-work/
Written by airan posted at http://xunyanan.com