创建关贸总协定服务器? [英] Creating a Gatt Server?

查看:324
本文介绍了创建关贸总协定服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个更广泛的问题,在这里,所以如果有人可以点我的文档或文章可以解释这一点,这就够了。不用说,一个天的谷歌搜索已无处得到我,我可以使用一个伸出援助之手。

I have a wider range question here, so if someone could point me to a doc or article that could explain this, that would suffice. Needless to say, a days worth of googling has gotten me nowhere, and I could use a helping hand.

我连接到的BeagleBoard 与5.9的BlueZ,我的意图是:

I am connecting to a BeagleBoard with BlueZ 5.9, and my intent is to:


  1. 创建关贸总协定服务器,

  2. 用一些写属性加载它,和

  3. 广告该服务器连接到Android设备。

我创建的Andr​​oid应用程序将连接并运行为中心,呈现3基本完成。我不知道怎么的命令 - 文字的东西类型 - 启动关贸总协定服务器/创建的BeagleBoard的属性。我知道硬件令状大,因此可能我只是有我的术语完全不正确 - 是说,任何帮助将是完成1和2 pciated一个AP $ P $,哪怕仅仅是在正确的方向上推。谢谢!

I've created the Android app that will connect and operate as the central, rendering 3 basically complete. I don't know how the commands - the literal things to type - to initiate a Gatt server / create attributes on the BeagleBoard. I am knew to hardware writ large, so it is possible I just have my terminology completely incorrect - that said, any help would be a appreciated in completing 1 and 2, even if it is just a shove in the right direction. Thanks!

推荐答案

您的术语,主要是正确的。

Your terminology is mainly correct.

通常情况下,GATT数据库具有服务<一个href=\"https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.generic_access.xml\">0x1800 (通用访问)和<一个href=\"https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.generic_attribute.xml\">0x1801 (通用属性)至少的。通用接入服务包含两个强制性的特点:<一href=\"https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.device_name.xml\">Device命名和<一个href=\"https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml\">Appearance.通用属性的服务应该是空的。

Typically, a GATT database has the services 0x1800 (Generic Access) and 0x1801 (Generic Attribute) at least. The Generic Access service contains two mandatory characteristics: Device Name and Appearance. The Generic Attribute service should be empty.

因此​​,最小GATT数据库看起来是这样的:

Therefore, the minimal GATT database looks like this:

Handle  Description
 0000   Service: Generic Access (1800)
 0001   Characteristic: Device Name (2A00, readable)
 0002   Characteristic Value (string)
 0003   Characteristic: Appearance (2A01, readable)
 0004   Characteristic Value (16bit enum)
 0005   Service: Generic Attribute (1801) 

这两个服务后,您可以添加自己的服务。在你的情况,你似乎没有瞄准一个众所周知的服务,让您将创建一个自己的。

After these two services, you can add your own services. In your case, you don't seem to target a well-known service, so you'll create an own one.

首先,使用Mac的命令行中的的uuidgen 工具创建一个128-bit的UUID,例如:

First, create a 128-bit UUID, for example using the uuidgen tool on your Mac's command line

$ uuidgen
DCDF2725-56C8-4235-A4BC-F7951D5C3762

这将是您的服务UUID

This will be your service UUID

 0006   Service: Custom defined Service (DCDF2725-56C8-4235-A4BC-F7951D5C3762)

然后,你提到你想要谈很多可写的特性。所以,让我们创建另一个UUID为那一个。

Then, you mentioned that you want several writeable characteristics. So, let's create another UUID for that one.

$ uuidgen
4C06C6F4-C90D-4C58-8E31-20C8C74FF832

和特性添加到服务

 0007   Characteristic: Custom Characteristic (4C06C...FF832, writeable)
 0008   Characteristic Value (hex, 20 bytes)

您特征值应不超过20个字节,你应该选择写入请求,以保证写入的确认发送到中央。如果你选择写入命令,写道:可以由手机的堆栈或外围设备。

Your characteristic value shouldn't exceed 20 bytes, and you should select "Write Request" to ensure that acknowledgments of writes are sent to the central. If you choose "Write Command", writes may be discarded by either your phone's stack or the peripheral.

您已经定义了这个特点后,你就可以开始进行编码。

After you have defined this characteristic, you are ready to start coding.

我不知道的BeagleBoard SDK,但通常情况下,你通过初始化GATT库和附加模块启动(例如,支持写入,你必须初始化库的第二部分)。

I don't know the BeagleBoard SDK, but typically, you start by initializing the GATT library and additional modules (for example, to support writes, you have to initialize a second part of the library).

这初始化后,您注册GATT数据库。如果您没有用于生成二进制数据一个很好的工具,你可能要他们写自己。这是在蓝牙核心规格4.0版解释。我们希望你能找到,做转变为你的API: - )

After this initialization, you register your GATT database. If you don't have a nice tool for generating the binary data, you may have to write them yourselves. That's explained in the Bluetooth Core Spec V4.0. Let's hope you can find an API that does the transformation for you :-)

在注册成功,你必须设置广告的参数,可以开始做广告(请咨询您的SDK的这个文档和示例,再次)。

When the registration is successful, you'll have to set the advertising parameters and can start advertising (consult your SDK's documentation and samples for this, again).

现在会发生什么事,就是在一段时间后,你会得到一个连接已经建立,后来,你会得到一个给定的句柄的属性请求的回调。然后,你只需要通过看手柄,所提供的值和操作类型来处理请求(读/写)。不要忘了总是响应该请求返回成功值或错误code,否则,你就锁定了蓝牙通信。

What happens now, is that at some time, you will get a callback that a connection has been established, and later, you'll get an attribute request for a given handle. Then, you just have to process the request by looking at the handle, the supplied value and the type of the operation (read / write). Don't forget to always return a success value or an error code in response to the request, as otherwise, you'll lock up the Bluetooth communications.

一般情况下,那些蓝牙芯片总是与异步操作工作。你会发送一个请求,然后要等到请求发送下一个前完成。请记住,在编程时,它可以节省您的时间: - )

Normally, those Bluetooth chips always work with asynchronous operations. You'll send a request, and then have to wait until the request is completed before sending the next one. Remember that when programming, it saves you time :-).

如果你想尝试在Android上首先是因为这对你比较熟悉,可以尝试银河S 4与Android 4.2。它也有一个LE外设模式 - 我没有测试过它的可靠性,虽然。目前最可靠的智能手机堆栈作为LE周边目前在iOS的7 - 所以它可能是值得拿起一部iPod touch,如果它是经济实惠的发挥与它周围

If you want to try on Android first because it's more familiar for you, you can try the Galaxy S 4 with Android 4.2. It also has an LE peripheral mode - I haven't tested its reliability, though. The most reliable smartphone stack at the moment to act as LE peripheral is currently in iOS 7 - so it may be worth picking up an iPod touch if it's affordable to play around with it.

这篇关于创建关贸总协定服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆