【问题标题】:Programming a BLE server and a client both in a Raspberry Pi在 Raspberry Pi 中编写 BLE 服务器和客户端
【发布时间】:2019-06-05 13:03:30
【问题描述】:

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

由于提供从传感器读取数据的可能性的语言是用 C、C++ 和 Python 编写的,我一直在搜索多个库,如 pygattlibpygattpybluezbluepy,但没有结果知道如何发送数据加上它们的特性。

是否有任何选项可以重现我的请求?

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

【问题讨论】:

    标签: bluetooth bluetooth-lowenergy raspberry-pi3


    【解决方案1】:

    如果您使用 rpi,您应该预装 Bluez。 Bluez 通过 D-Bus 提供 API,您可以使用它来添加 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 repo 中!它们是用 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

    【讨论】:

    • 感谢您的回答,我了解 Bluez 基本上是因为我一直在研究库和 GATT 功能,但是我没有尝试从中实现它。我还有一个问题,因为在创建 service_manager 之前广告和服务是独立的,这是否意味着我应该创建两个管理器并在那时加入它们?
    【解决方案2】:

    我会将其标记为答案,因为我可以使用用 javascript noblebleno 编写的库来实现它

    【讨论】:

      猜你喜欢
      • 2016-02-08
      • 1970-01-01
      • 1970-01-01
      • 2010-10-31
      • 2023-03-31
      • 2023-01-19
      • 1970-01-01
      • 2011-04-30
      • 2011-07-01
      相关资源
      最近更新 更多