问题
I am looking to send information from my Android device to a micro-controller (such as an Arduino). Using Bluetooth Classic I simply send a byte array of data to the micro-controller, and process the byte array accordingly.
I started reading about Bluetooth Low Energy and I am hearing all this talk about GATT profiles. Why should I create a GATT profile? What is a GATT profile going to do for me in the case of exchanging information from an Android device to a micro-controller?
Thanks in advance!
回答1:
GATT profiles are a way to communicate between Bluetooth central and Peripheral. Lets assume I have an app that reads temperature from a sensor. My current setup is to have the phone act as central, the sensor attached to a bluetooth LE chip as peripheral.
So I communicate to bluetooth LE chip using this profile. In GATT profile declaration in chip, I will be defining a service and two characteristics. Two characteristics being
- Sensor enabler
- Temperature value
Sensor enabler has both read and write permissions, while temperature value has only read permission.
So in your app, whenever you want to read temperature value, you first write 0x01 to enabler characteristic and then read value from temperature value.
To identify the characteristics and services, bluetooth has the concept of UUIDs and handles. UUIDs are globally unique and handles are assigned in the chip.
Services encapsulate the characteristics available. So in a hierarchy you have, Profiles which can multiple services which in turn can have multiple characteristics.
To explain everything in an answer would be too much. Why don't you go through the basics here? I found these documents really useful.
回答2:
The whole concept of Bluetooth Low Energy is to use the less power for transmission between two Bluetooth devices. In order to achieve this one can not use the traditional Bluetooth classic which keeps the channel even though the data transmission is not done. Hence, the concept of ATT/GATT evolved which provides the specifications to transfer the short data packets over BLE link between two Low Energy devices. Due to which when two devices are not communicating then will be as good as stopped. In order to implement the BLE services one has to use these ATT/GATT profiles & protocols.
GATT provides the specification on how a group of attributes(which are nothing but data) are grouped together into meaningful services. It does the common operations of data transfer & storing over ATT by defining its own client-server mechanism. It makes developers life easy by defining whole framework for you & one just need to group these characteristics & services by customizing for developing there profiles & applications.
来源:https://stackoverflow.com/questions/21506237/android-bluetooth-low-energy-gatt-profile