在 Raspberry Pi 中对 BLE 服务器和客户端进行编程

Programming a BLE server and a client both in a Raspberry Pi

我想在 Raspberry 中实现 BLE,它将传感器的结果与其特性分开发送,并制作另一个 Raspberry 来获取该数据。

因为提供从传感器读取数据的可能性的语言是用 C、C++ 和 Python 编写的,我一直在搜索 pygattlib, pygatt, pybluez and bluepy 等多个库,但没有结果知道如何发送数据除了有自己的特点。

是否可以选择重现我的请求?

我还阅读了 Apple 和 Google 的 iBeacon 和 Eddystonne 协议,但我的第一点是在两个 Raspberry(服务器和客户端)之间进行通信。

如果您使用的是 rpi,则应预装 Bluez。 Bluez 提供 API 到 D-Bus,您可以使用它来添加 GAP 和 GATT 功能。该文档位于 Bluez 的源代码中。

BLE 广告(GAP 配置文件)文档:https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/advertising-api.txt

BLE 数据传输(GATT 配置文件)文档:https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/gatt-api.txt

当然有例子更容易。他们也在 Bluez 回购中!它们是用 Python 编写的,但应该很容易将其翻译成不同的语言,因为它们只使用 D-Bus。 https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-gatt-server https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-gatt-client https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-advertisement

我会将此标记为答案,因为我可以使用 javascript noble and bleno

中编写的库使其成为可能