使用堆栈的BlueZ作为外设(广告商) [英] Use BlueZ Stack As A Peripheral (Advertiser)

查看:246
本文介绍了使用堆栈的BlueZ作为外设(广告商)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  • 目标:使用和的BlueZ蓝牙一个加密狗4LE创建通告蓝牙相当于Hello World的外围

  • Goal: Use BlueZ and an Bluetooth 4LE dongle to create a peripheral that advertises the bluetooth equivalent of "Hello World".

我在哪里:目前我已经得到了堆栈的BlueZ设置和下载的,我可以使用HCI工具来认识,看到了蓝牙适配器。我用修修补补hciconfig leadv但我只是不太得到它/理解发生了什么事情。

Where I'm At: I've currently got the BlueZ stack setup and downloaded, I can use the hci tool to recognize and see the Bluetooth dongle. I've tinkered with hciconfig leadv but I'm just not quite getting it/understanding what's going on.

我想帮助我需要:我需要得到它的下一个步骤。如果任何人都可以点我朝着一个很好的资源,走在我通过这个,或者其他什么,这将是非常美联社preciated。如果我需要做额外的腿(搜索)工作,我可以,但我已经冲刷谷歌和SO这个问题的许多不同的衍生物,我能想到的。

What Help I Think I Need: I need to get it to the next step. If anyone can either point me towards a good resource, walk me through this, or anything, It would be much appreciated. If I need to do additional leg(search)work I can but I've scoured Google and SO with as many different derivatives of this question as I can think of.

* I,以及在可能的是iOS开发已经在某些时候这种修修补补希望这个标记作为CoreBluetooth。

*I tagged this as CoreBluetooth as well in hopes that maybe an iOS dev has tinkered with this at some point.

编辑:在回应评论,它看起来稳重陈述我的最终目标是什么。我最终想通过加密狗做广告简单的消息/信号的最简单,挑选了一个iOS设备(CoreBluetooth)上。我已经能够得到的东西运作良好iOS的一侧(吨文档,而不是对事物的Linux方面),但对我来说最难的是让这个适配器设置作为外设。该协议栈的BlueZ是一个可怕的谜我。

In response to a comment, It seems prudent to state what my end goal is. I'd ultimately like to advertise via the dongle the simplest of simple messages/signals and pick that up on an iOS device (CoreBluetooth). I've been able to get the iOS side of things working well (tons of documentation compared to the Linux side of things) but that hard part for me is getting this adapter setup as a peripheral. The BlueZ stack is a terrible enigma for me.

编辑:更多挖后,我最终偶然发现了这个帖子:树莓派蓝牙4.0连接
这使我走向GATT服务器的话题,我将继续奉行这个话题。

After more digging, I eventually stumbled upon this post: Raspberry Pi Bluetooth 4.0 Connection. This has led me toward the topic of a GATT server, I'll continue pursuing this topic.

编辑:好了,所以我对学习的追求下去。在过去的几天我一直潜入更深的HCI *,命令sdptool和gatttool工具。我已经得到了中能设置适配器做广告,hciconfig hci0 leadv的地步。在这一点上,我可以成功地看到适配器,但我实际上并不能读取任何关闭它。我还没有看到友好名称。我会继续在卡车,但一如既往,任何帮助/建议都欢迎。

Alright so my quest for learning goes on. Over the past couple of days I've dived deeper into the hci*, sdptool, and gatttool tools. I've gotten to the point of being able to set the adapter to advertise, "hciconfig hci0 leadv". At this point, I can successfully "see" the adapter, but I cannot actually read anything off of it. I'm not even seeing the friendly name. I'll keep trucking on but as always, any help/suggestions are more than welcome.

编辑:相关链接,蓝牙LE的固体概述有关的iOS。
<一href=\"https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/AboutCoreBluetooth/Introduction.html#//apple_ref/doc/uid/TP40013257-CH1-SW1\">https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/AboutCoreBluetooth/Introduction.html#//apple_ref/doc/uid/TP40013257-CH1-SW1

Relevant Link, solid overview of Bluetooth LE pertaining to iOS. https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/AboutCoreBluetooth/Introduction.html#//apple_ref/doc/uid/TP40013257-CH1-SW1

最后编辑时间:嘿,这个链接介绍如何创建使用树莓派+一个的BlueZ ... iBeacon显示
<一href=\"http://www.wadewegner.com/2014/05/create-an-ibeacon-transmitter-with-the-raspberry-pi/\">http://www.wadewegner.com/2014/05/create-an-ibeacon-transmitter-with-the-raspberry-pi/

LAST Hey all, this link covers how to create an iBeacon using a Raspberry Pi + BlueZ... http://www.wadewegner.com/2014/05/create-an-ibeacon-transmitter-with-the-raspberry-pi/

推荐答案

通过插入你的蓝牙适配器,运行以下命令将告诉你的设备名称,并给它的状态:

With your Bluetooth dongle plugged in, running the following command will tell you the device name and give its state:

$ hciconfig

输出应该是这个样子:

hci0:    Type: BR/EDR  Bus: USB
     BD Address: 00:01:02:aa:bb:cc  ACL MTU: 1021:8  SCO MTU: 64:1
     DOWN
     RX bytes:1000 acl:0 sco:0 events:47 errors:0
     TX bytes:1072 acl:0 sco:0 commands:47 errors:0

这表示该设备被称为hci0处于关闭状态。发出以下命令来把它:

This indicates the device is called hci0 is in a down state. Issue the following command to bring it up:

$ sudo的hciconfig hci0高达

现在它应该看起来像:

$ hciconfig
hci0:   Type: BR/EDR  Bus: USB
     BD Address: 00:01:02:aa:bb:cc  ACL MTU: 1021:8  SCO MTU: 64:1
     UP RUNNING
     RX bytes:1000 acl:0 sco:0 events:47 errors:0
     TX bytes:1072 acl:0 sco:0 commands:47 errors:0

接下来,执行下面的示例命令来配置要发送的广告数据。

Next, execute the following example command to configure the advertising data to be sent.

$ sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 00 00 00 00 c5 00 00 00 00 00 00 00 00 00 00 00 00 00

您可以更改十六进制字节(从1E)发送不同的字节序列为您的广告。其中,从字面上发送ASCII codeS为HELLO WORLD将使用: 48 45 4C 4C 4F 57 4F 52 4C 44 编辑:但你也将有preFIX一个有效的头这条消息,在这里看到的

You can change the hex bytes (starting with 1e) to send different byte sequences for your advertisement. One that literally sends the ASCII codes for "HELLO WORLD" would use: 48 45 4c 4c 4f 57 4f 52 4c 44 ( But you will also have to prefix this message with a valid header, see here.)

现在,请使用以下命令激活加密狗上的广告,这将开始发送直升机世界的数据包。

Now, use the following command to activate advertising on the dongle, this will start sending "Helo World" packets.

$ sudo的hciconfig hci0 leadv 0

编辑:上面的命令,使广告的服务连接。如果你不希望允许的连接,将其更改为 $ sudo的hciconfig hci0 leadv 3

the above command makes the advertised service connectable. If you don't want to allow connections, change it to $ sudo hciconfig hci0 leadv 3

您也可以使用以下命令禁用广告:

You can also disable advertising using the following command:

$ sudo的hciconfig hci0 noleadv

这篇关于使用堆栈的BlueZ作为外设(广告商)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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