安卓:蓝牙低耗能GATT简介蓝牙、简介、GATT

2023-09-07 22:52:44 作者:㎜ 输过,但是从未怕过

我期待从我的Andr​​oid设备将信息发送到微控制器(例如一个Arduino)。使用蓝牙经典,我只是发送数据的字节数组到微控制器,并相应地处理字节数组。

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.

我开始阅读关于蓝牙低耗能和我听到这一切谈GATT的配置文件。我为什么要创建一个配置文件关贸总协定?什么是关贸总协定的个人资料去为我从Android设备到微控制器交换信息的情况下怎么办?

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?

在此先感谢!

推荐答案

GATT配置文件是蓝牙中枢和外周之间进行通信的方式。让我们假设我有一个应用程序从一个传感器读取温度。我目前的设置是让手机充当核心,连接到蓝牙LE芯片作为外围的传感器。

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.

所以我沟通使用该配置蓝牙LE芯片。在芯片GATT文件声明,我将定义一个服务,两个特点。两个特点是

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 has both read and write permissions, while temperature value has only read permission.

因此​​,在您的应用程序,只要你想读温度值,你先写0×01,从温度值推动者特点,然后读值。

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.

要确定的特性和服务,蓝牙具有的UUID和手柄的概念。的UUID是全球唯一的句柄在芯片分配。

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.