使用bluez 5.4x宣传自定义服务uuid [英] advertise custom service uuid with bluez 5.4x

查看:79
本文介绍了使用bluez 5.4x宣传自定义服务uuid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过BLE编写自定义服务以传输自定义特征.它具有自己的UUID,例如"8E400001-B5A3-F393-E0A9-E50E24DCCA9E".

I am writing a custom service over BLE to transmit custom characteristics. It has it's own UUID such as '8E400001-B5A3-F393-E0A9-E50E24DCCA9E'.

我发现我希望支持的特定android应用(BLE客户端)要求在广告包中包含自定义服务UUID.

I have found that a particular android app (BLE client) I wish to support requires that a custom service UUID is included in the advertising packet.

但是我们的外围设备在debian上通过bluez 5.43运行,我无法弄清楚如何将此UUID放入广告包中.

However our peripheral is running via bluez 5.43 on debian and I cannot figure out how to put this UUID in the advertising packet.

我认为它将是这样的:

hcitool -i hci0 cmd 0x08 0x0008 ....?

推荐答案

我验证了以下命令是否有效(BlueZ ver 5.43,Linux 4.9.0-2-amd64(x86_64)):

I verified the following commands to be working (BlueZ ver 5.43, Linux 4.9.0-2-amd64 (x86_64)):

hcitool -i hci0 cmd 0x08 0x0008 12 11 07 9E CA DC 24 0E E5 A9 E0 93 F3 A3 B5 01 00 40 8E 00 00 00 00 00 00 00 00 00 00 00 00 00

说明:

我假设一切都直到0x0008清除为止,如果没有让我知道或看一下规范中的LE Set Advertising Data Command的说明.0x12是 Advertising_Data_Length ,即紧随其后的有效字节数(直到填充字节).现在,您必须插入 Advertising_Data ,其格式设置与规范的第3卷C部分第11节(图11.1)相同.因此,0x11是AD结构的长度.然后,0x07是AD类型"128位服务类UUID的完整列表"(请参阅​​

I assume everything until 0x0008 is clear, if not let me know or look at the description of the LE Set Advertising Data Command in the spec. 0x12 is Advertising_Data_Length, i.e., the number of useful bytes that comes after (until the padding bytes). Now you have to insert the Advertising_Data, which is formatted as in Vol 3 Part C, Section 11, Fig. 11.1 of the spec. So, 0x11 is the length of the AD Structure. Then, 0x07 is the AD Type "Complete List of 128-bit Service Class UUIDs" (see here). Finally comes the UUID. Notice that everything is little endian.

然后发送LE Set广告参数命令,例如:

Then send the LE Set Advertising Parameters Commands, for example:

hcitool -i hci0 cmd 0x08 0x0006 00 08 00 08 00 00 00 00 00 00 00 00 00 07 00

然后通过发送LE Advertising Enable命令来启用广告:​​

Then enable advertising by sending the LE Advertising Enable command:

hcitool -i hci0 cmd 0x08 0x000A 01

请参见btmon输出此处.

See btmon output here.

这篇关于使用bluez 5.4x宣传自定义服务uuid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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