|
| 1 | +.. _bgapi-backend: |
| 2 | + |
| 3 | +Silicon Labs BGAPI backend |
| 4 | +============= |
| 5 | + |
| 6 | +The BGAPI backend of Bleak communicates with any device that implements Silicon Labs "BGAPI" |
| 7 | +Protocol. Classically, this is a Silicon Labs microcontroller, attached via a serial port, |
| 8 | +which has been programmed with some variant of "NCP" (Network Co-Processor) firmware. |
| 9 | + |
| 10 | +This does `not` apply to devices using "RCP" (Radio Co-Processor) firmware, as those only |
| 11 | +expose the much lower level HCI interface. |
| 12 | + |
| 13 | +References: |
| 14 | + * `AN1259: Using the v3.x Silicon Labs Bluetooth Stack in Network Co-Processor Mode <https://www.silabs.com/documents/public/application-notes/an1259-bt-ncp-mode-sdk-v3x.pdf>`_ |
| 15 | + * https://docs.silabs.com/bluetooth/5.0/index |
| 16 | + |
| 17 | +Requirements |
| 18 | +------ |
| 19 | +This backend uses `pyBGAPI <https://pypi.org/project/pybgapi/>`_ to handle the protocol layers. |
| 20 | + |
| 21 | + |
| 22 | +Usage |
| 23 | +----- |
| 24 | +This backend cannot be automatically selected based on system type, so must be manually |
| 25 | +selected, using code such as: |
| 26 | + |
| 27 | +.. code-block:: python |
| 28 | +
|
| 29 | + async with bleak.BleakClient( |
| 30 | + "11:aa:bb:cc:22:33", |
| 31 | + backend=bleak.backends.bgapi.client.BleakClientBGAPI, |
| 32 | + bgapi="/home/karlp/SimplicityStudio/SDKs/gecko-4.2.0/protocol/bluetooth/api/sl_bt.xapi", |
| 33 | + adapter="/dev/ttyACM1", |
| 34 | + ) as client: |
| 35 | + logging.info("Connected to %s", client) |
| 36 | +
|
| 37 | +Pay attention that the ``bgapi`` file must be provided, corresponding to the firmware used on your device. |
| 38 | +These files can be found in the `Silicon Labs Gecko SDK <https://github.com/SiliconLabs/gecko_sdk/>`_ in |
| 39 | +the ``protocol/bluetooth/api`` directory. |
| 40 | + |
| 41 | +Likewise, the ``adapter`` kwarg should be used to specify where the device is attached. |
| 42 | + |
| 43 | +At the time of writing, support for sockets or the Silicon Labs CPC daemon is not tested. |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | +API |
| 48 | +--- |
| 49 | + |
| 50 | +Scanner |
| 51 | +~~~~~~~ |
| 52 | + |
| 53 | +.. automodule:: bleak.backends.bluezdbus.scanner |
| 54 | + :members: |
| 55 | + |
| 56 | +Client |
| 57 | +~~~~~~ |
| 58 | + |
| 59 | +.. automodule:: bleak.backends.bluezdbus.client |
| 60 | + :members: |
| 61 | + |
| 62 | +.. _`asyncio event loop`: https://docs.python.org/3/library/asyncio-eventloop.html |
0 commit comments