【问题标题】:How is StartNofity invoked in Python BLE implementation?在 Python BLE 实现中如何调用 StartNofity?
【发布时间】:2021-03-20 02:44:31
【问题描述】:

环境:Ubuntu 20.04,Python

我的 BLE gatt 服务器实现大致基于此处的示例 - https://github.com/Douglas6/cputemp

这是我的相关代码:

class RxCharacteristic(Characteristic):
   def __init__(self, service):
      self.notifying = False
      Characteristic.__init__(self, RXCHARID,
                            ['read', 'notify'], service)

   def ReadValue(self, options):
      value = []
      return value

   def StartNotify(self):
      if self.notifying:
        return
      print('Notifying...')
      self.notifying = True

当一个 BLE 特性以“notify”属性发布时,我的理解是 StartNotify/StopNotify 方法会被自动调用。我猜这发生在客户端连接/断开连接时。

就我而言,当我从“nRF Connect”Android 应用程序测试我的连接性时,我没有看到 StartNotify 被调用。

我想知道是什么触发了 StartNotify/StopNotify 方法的调用。为什么我没有看到它被调用?问候。

【问题讨论】:

    标签: bluetooth-lowenergy dbus


    【解决方案1】:

    您需要在 nRF Connect 应用中启用通知。执行此操作的是应用程序中的多个向下箭头:

    然后蓝牙守护程序将调用StartNotify D-Bus 方法,在链接示例中表示thisthis

    您可以通过以下方式监控 D-Bus 调用:

    sudo busctl monitor org.bluez

    【讨论】:

    • 非常感谢您的帮助。出于某种原因,nRF Connect 应用程序中的按钮出现和消失的速度非常快,甚至在我点击它们之前。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-20
    • 2022-06-12
    • 2021-10-20
    • 1970-01-01
    • 1970-01-01
    • 2016-04-02
    • 2014-12-16
    相关资源
    最近更新 更多