matt7aylor / pygatt-v2

Python wrapper for gatttool (a deprecated tool from BlueZ), BlueZ via pydbus and the BGAPIv1 for accessing Bluetooth LE Devices. Developing pydbus and BGAPIv2 backends.
Other
1 stars 0 forks source link

Creating BGAPIv2 backend #1

Open matt7aylor opened 4 years ago

matt7aylor commented 4 years ago

The bgapi backend in pygatt supports the command set for the BlueGiga devices, these use BGAPI v1 https://www.silabs.com/documents/public/reference-manuals/Bluetooth_Smart_Software-BLE-1.4-API-RM.pdf

We want to create a backend that will support the new Silicon Labs devices that use a newer (incompatible) version of the BGAPI v2 https://docs.silabs.com/bluetooth/latest/ (and maybe in future even the Bluetooth Mesh version of BGAPI https://www.silabs.com/documents/public/reference-manuals/bluetooth-le-and-mesh-software-api-reference-manual.pdf )

The plan for this should be:

matt7aylor commented 4 years ago

Initial test of commands in commit 9225f3ed391917501bfb82fb3feca9528cae0fc2 supports going as far as adapter.get_mac()

import pygatt
import logging 
logging.basicConfig()
logging.getLogger('pygatt').setLevel(logging.DEBUG)
PORT='/dev/pts/10'
adapter = pygatt.BGAPIBackend(serial_port=PORT)
adapter.start()
adapter.get_mac()
mac = adapter.address
matt7aylor commented 4 years ago

A list of all commands/ResponsePacketType used by bgapi v1. We will want to make sure we migrate all these command to their v2 equivalent to reproduce functionality, then we could think about adding extra commands if desired.

In bgapi.py:

In device.py:

EventPacketType expected by pygatt v1. In bgapi.py:

In device.py

matt7aylor commented 4 years ago

Basic support for adapter.scan() as of 1d96cb21a7bc3adbb3b20abdfe5a8e465434a571

matt7aylor commented 4 years ago

Basic connect/disconnect functionality in 0b052a3 . Need to manually change address_type to random for connecting to Thingy52, not sure why dev = adapter.connect('FB:91:81:28:F7:74', address_type=1). No processing of characteristics yet.