Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1c2ea6f

Browse files
committedJan 6, 2023
backends:bgapi: initial documentation.
Adds a feature to the changelog and some initial notes on the specifics of this backend. Signed-off-by: Karl Palsson <karlp@etactica.com>
1 parent 535ddf0 commit 1c2ea6f

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed
 

‎CHANGELOG.rst

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Added
1818
* Added ``BleakScanner.find_device_by_name()`` class method.
1919
* Added optional command line argument to use debug log level to all applicable examples.
2020
* Make sure the disconnect monitor task is properly cancelled on the BlueZ client.
21+
* Added new backend, for Silicon Labs NCP devices implementing BGAPI
2122

2223
Changed
2324
-------

‎docs/backends/bgapi.rst

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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

‎docs/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Features
3939
* Supports Windows 10, version 16299 (Fall Creators Update) or greater
4040
* Supports Linux distributions with BlueZ >= 5.43 (See :ref:`linux-backend` for more details)
4141
* OS X/macOS support via Core Bluetooth API, from at least OS X version 10.11
42+
* Supports any os via Silicon Labs NCP devices. (See :ref:`bgapi-backend` for more details)
4243

4344
Bleak supports reading, writing and getting notifications from
4445
GATT servers, as well as a function for discovering BLE devices.

0 commit comments

Comments
 (0)
Please sign in to comment.