Finding Bluetooth low energy with python

后端 未结 2 961
予麋鹿
予麋鹿 2021-02-02 03:18

Is it possible for this code to be modified to include Bluetooth Low Energy devices as well? https://code.google.com/p/pybluez/source/browse/trunk/examples/advanced/inquiry-wit

2条回答
  •  孤街浪徒
    2021-02-02 03:44

    You could also try pygattlib. It can be used to discover devices, and (currently) there is a basic support for reading/writing characteristics. No RSSI for now.

    You could discover using the following snippet:

    from gattlib import DiscoveryService
    
    service = DiscoveryService("hci0")
    devices = service.discover(2)
    

    DiscoveryService accepts the name of the device, and the method discover accepts a timeout (in seconds) for waiting responses. devices is a dictionary, with BL address as keys, and names as values.

    pygattlib is packaged for Debian (or Ubuntu), and also available as a pip package.

提交回复
热议问题