在 linux 命令行中使用低功耗蓝牙
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17835469/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using Bluetooth low energy in linux command line
提问by V-Xtreme
I am working on using the Bluetooth low energy modem with Linux. I am using the command line option for that i.e. hcitool
. I am able to the find the devices using the command: $ hcitool scan
我正在研究在 Linux 上使用蓝牙低功耗调制解调器。我正在使用命令行选项,即hcitool
. 我可以使用以下命令找到设备:$ hcitool scan
It is working fine for me, also I am able to broadcast my device using :
它对我来说很好用,我也可以使用以下方法广播我的设备:
sudo hciconfig hci0 leadv
It is also working fine. But I want to add the services and characteristic to the modem device which can be detected by other device. I have tried sdptool add
but it is not working for me. Does anyone know how to add the services and characteristics to the peripheral using the command line tools in ubuntu?
它也工作正常。但是我想将服务和特性添加到其他设备可以检测到的调制解调器设备中。我试过了,sdptool add
但它对我不起作用。有谁知道如何使用 ubuntu 中的命令行工具向外围设备添加服务和特性?
Edit:My modem is broadcasting but not able to explore the services and characteristic to the other BLE device. Now I am able to set the name of device using hcio name command
编辑:我的调制解调器正在广播,但无法探索其他 BLE 设备的服务和特性。现在我可以使用设置设备的名称hcio name command
Edit:Now I am able to render the services and characteristic, by simultaneously running sudo hcidump
command. But I am not able to track from where I am getting those services and characteristics. One definite observation is those services are rendering from the machine.
编辑:现在我可以通过同时运行sudo hcidump
命令来呈现服务和特征。但是我无法跟踪我从哪里获得这些服务和特征。一个明确的观察结果是这些服务是由机器提供的。
采纳答案by nopsoft
SDP is absent in BLE. Broadcast/advertise frame and GATT client/server are used instead.
BLE 中没有 SDP。改为使用广播/广告帧和 GATT 客户端/服务器。
Several links:
几个链接:
- BlueZ gatttool: command line tool to run common GATT procedures
- BlueZ GATT's ready profiles
- hint: DBUS
- GATT and DBUS example
- How can I connect to the FitBit Zip over Bluetooth 4.0 LE on Linux with bluez?
- Bluetooth Low Energy: listening for notifications/indications in linux
- http://comments.gmane.org/gmane.linux.bluez.kernel/29547
回答by Ottavio Campana
I used to broadcast BT services by following this article. This page not only shouws you how to advertise a profile, but also gives you an example on how to implement the HSP profile.
我曾经通过关注这篇文章来广播 BT 服务。此页面不仅向您展示了如何宣传个人资料,而且还为您提供了有关如何实施 HSP 个人资料的示例。
To know the bt class you need to announce, you can check this other page.
要了解您需要宣布的 bt 课程,您可以查看其他页面。