简体   繁体   English

如何使用 C 程序通过 Linux 与 BLE 设备交互?

[英]How to interact with BLE devices through Linux using C programs?

I am fairly new to the BLE world.我对 BLE 世界还很陌生。 Assuming I have a BLE device Eg: A heart rate monitor, How do I interact with that BLE device using C code.假设我有一个 BLE 设备 例如:心率监测器,我如何使用 C 代码与该 BLE 设备交互。

I am able to see the Heart rate data using the command line tool 'bluetoothctl'.我可以使用命令行工具“bluetoothctl”查看心率数据。 If I want connect to the same device through C code and see the Notified data, how do I go about it?如果我想通过 C 代码连接到同一设备并查看通知数据,我该如何 go 关于它?

Though some codes on the Internet and GitHub helped me to scan for the device, I do not have any idea on how to connect to the device, read the GATT characteristics of the BLE device.虽然网上的一些代码和 GitHub 帮助我扫描了设备,但我不知道如何连接到设备,阅读 BLE 设备的 GATT 特性。 I'd even appreaciate it if anyone points me to the API documentations of BlueZ, I literally have no clue what the programs are all about.如果有人将我指向 BlueZ 的 API 文档,我什至会欣赏它,我真的不知道这些程序的全部内容。 Any assistance would be of great help.任何帮助都会有很大帮助。

The preferred API for BlueZ uses the D-Bus bindings. BlueZ 的首选 API 使用 D-Bus 绑定。 The documentation for those APIs are at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc这些 API 的文档位于: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc

There are Python examples of how to use the D-Bus API at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test There are Python examples of how to use the D-Bus API at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test

bluetoothctl is written in C and the source is available at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/client bluetoothctl用 C 编写,源代码位于: https://git.kernel.org/pub/scm/bluetooth/bluez

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM