Reference: http://www.cnblogs.com/savagemorgan/p/3722657.htmlAndroid4.3 bluetooth BLE Preliminary
http://www.cnblogs.com/zdz8207/category/434664.html Talk about months since the development of android bluetooth 4.0 BLE feel for low power applications
http://item.taobao.com/item.htm?spm=a1z09.2.9.13.5EVeNE&id=36373854308&_u=hfm125r918e&qq-pf-to= pcqq.c2c#userconsent# Bluetooth module
http://blog.csdn.net/jimoduwu/article/details/21604215Android BLE Bluetooth Low power tutorial, Realization of Central Bluetoothgatt and peripheral bluetoothgattserver
http://blog.csdn.net/woshasanguo/article/details/41082395android ble bluetooth development solution (good writing)
?
- First you need to understand some concepts
Bluetooth 2.0 vs Bluetooth 4.0, the main difference is that the protocol has changed, the 4.0 main power saving strategy, compared with other, this is more power-saving. Moreover, the pit is not this, the most pit is Bluetooth 2 can only with Bluetooth 2.0 communication, Bluetooth 4.0 and Bluetooth 4.0 communication.
The protocol is different and cannot communicate directly.
In the development of mobile phone and SCM through the process of Bluetooth communication, we have to know, in fact, mobile phones and microcontroller is the same, 2.0 of Bluetooth can not be the same as 4.0 Bluetooth communication.
Another thing is, mobile phone, Bluetooth communication is generally used in the system to develop the app, rather than with our own development of the app, this is because the phone does not have root, can not use the mobile phone app to communicate with each other.
So, now on the market are, mobile phone Bluetooth 4.0 and the module Bluetooth 4.0 communication.
- Bluetooth Related concepts:
GATT, ATT: Both are the protocol specification for small data transfer between BLE and are common.
Characteristic: Data type, which includes a description of value and 0 to more value.
Descriptor: Description of the above, such as range, unit of measurement, etc.
A collection of service:characteristic, such as a service may contain multiple ch, and one ch may also contain multiple des.
?
?
3, the transmission of data problems:
Be sure to understand the flow of data to the problem:
Program Structure:
In the devicescanactivity, how does the data return? The data is passed through the intent to this here.
In Devicecontrolactivity, the data is this:
After the various callbacks, the data in the device, we are now the purpose is to send data, to send the data is needed
Mnotifycharacteristic
How does it get:
?
?
?
?
?
From top to bottom, we can see that what we want to get is actually mdeviceaddress, and this has been achieved. You just need to find it from the bottom up.
mBluetoothLeService
?
- Concept or concept
BLEdivided into three partsService,characteristic,Descriptor, these three parts are made up ofUUIDas a unique identifier. a Bluetooth4.0The terminal can contain multipleService, aServicecan contain multiplecharacteristic, acharacteristiccontains aValueand multipleDescriptor, aDescriptorcontains aValue.
?
?
The second chunk, the analysis is a little complicated.
Each of the above sections has a unique UUID, and the UUID is fixed for a fixed device, but with so many devices, how do we determine the device?
As shown in the following:
The above is useful for a fixed device, but it is hard to say for a device that is not fixed.
?
In other words, GATT is different for some of the same devices, and the Services,character,descriptor under GATT have the same UUID.
The GATT is obtained through the device Mac, and its function is Connectgatt.
One Equipment one GATT, change equipment will change GATT.
In fact, we can also do the following, a device corresponding to multiple services, a service may correspond to multiple characteristic, the same services (service) of the same device
The same as the UUID of the property (characteristic).
?
Bluetooth Development Summary 1