Raspberry Pi:与Bluepy的BLE配对因“ Just works”配对而失败

时间:2019-05-19 18:37:41

标签: python bluetooth-lowenergy raspberry-pi3

BluePy连接问题:

我将RPI用作中央设备,我需要将RPI连接到使用“ Just Works-Pair”通过Bluepy配对设备的外围设备。与该外围设备的连接失败,但是对于没有配对的外围设备,连接成功。

使用外围设备类时,它检测到设备,但无法获得服务。但是,对于没有配对要求的设备,上述所有操作均会成功。

from bluepy import btle

device = btle.Peripheral("XX:XX:XX:XX:XX:XX")
print device

services = device.getServices()
for s in services:
    print services

运行时日志:

python k_ble_demo.py

<bluepy.btle.Peripheral instance at 0x769fd530>
^CTraceback (most recent call last):
  File "k_ble_demo.py", line 6, in <module>
    services = device.getServices()
  File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 481, in getServices
    return self.services
  File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 477, in services
    self._serviceMap = self.discoverServices()
  File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 459, in discoverServices
    rsp = self._getResp('find')
  File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 407, in _getResp
    resp = self._waitResp(wantType + ['ntfy', 'ind'], timeout)
  File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 347, in _waitResp
    rv = self._helper.stdout.readline()
KeyboardInterrupt

我希望连接能够成功进行,并且每次执行时都会列出服务。

0 个答案:

没有答案