在 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 00:21:32  来源:igfitidea点击:

Using Bluetooth low energy in linux command line

linuxubuntubluetooth-lowenergybluez

提问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 addbut 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 hcidumpcommand. 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 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 课程,您可以查看其他页面