formatting and linting automation

Squashed commits:
[cd479ba] formatting and linting automation
[7fbfabb] formatting and linting automation
[c4f9505] fix after rebase
[f506ad4] rename job
[441d517] update doc (+7 squashed commits)
[2e1b416] fix invoke and github action
[6ae5bb4] doc for git blame
[44b5461] add GitHub action
[b07474f] add docs
[4cd9a6f] more linter fixes
[db71901] wip
[540dc88] wip
This commit is contained in:
Gilles Boccon-Gibod
2022-12-10 09:29:51 -08:00
parent 80fe2ea422
commit c2959dadb4
140 changed files with 2632 additions and 1346 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
API EXAMPLES
============
============
+1 -1
View File
@@ -1,2 +1,2 @@
API DEVELOPER GUIDE
===================
===================
-1
View File
@@ -16,4 +16,3 @@ Bumble Python API
### HCI_Disconnect_Command
::: bumble.hci.HCI_Disconnect_Command
+1 -1
View File
@@ -1,2 +1,2 @@
GOLDEN GATE BRIDGE
==================
==================
@@ -28,5 +28,3 @@ a host that send custom HCI commands that the controller may not understand.
(through which the communication with other virtual controllers will be mediated).
NOTE: this assumes you're running a Link Relay on port `10723`.
-1
View File
@@ -11,4 +11,3 @@ These include:
* [Golden Gate Bridge](gg_bridge.md) - a bridge between GATT and UDP to use with the Golden Gate "stack tool"
* [Show](show.md) - Parse a file with HCI packets and print the details of each packet in a human readable form
* [Link Relay](link_relay.md) - WebSocket relay for virtual RemoteLink instances to communicate with each other.
@@ -31,4 +31,3 @@ The WebSocket path used by a connecting client indicates which virtual "chat roo
It is possible to connect to a "chat room" in a relay as an observer, rather than a virtual controller. In this case, a text-based console can be used to observe what is going on in the "chat room". Tools like [`wscat`](https://github.com/websockets/wscat#readme) or [`websocat`](https://github.com/vi/websocat) can be used for that.
Example: `wscat --connect ws://localhost:10723/test`
+5 -5
View File
@@ -3,8 +3,8 @@ USB PROBE TOOL
This tool lists all the USB devices, with details about each device.
For each device, the different possible Bumble transport strings that can
refer to it are listed.
If the device is known to be a Bluetooth HCI device, its identifier is printed
refer to it are listed.
If the device is known to be a Bluetooth HCI device, its identifier is printed
in reverse colors, and the transport names in cyan color.
For other devices, regardless of their type, the transport names are printed
in red. Whether that device is actually a Bluetooth device or not depends on
@@ -30,7 +30,7 @@ When running from the source distribution:
$ python3 apps/usb-probe.py
```
or
or
```
$ python3 apps/usb-probe.py --verbose
@@ -38,7 +38,7 @@ $ python3 apps/usb-probe.py --verbose
!!! example
```
$ python3 apps/usb_probe.py
$ python3 apps/usb_probe.py
ID 0A12:0001
Bumble Transport Names: usb:0 or usb:0A12:0001
@@ -47,4 +47,4 @@ $ python3 apps/usb-probe.py --verbose
Subclass/Protocol: 1/1 [Bluetooth]
Manufacturer: None
Product: USB2.0-BT
```
```
+1 -1
View File
@@ -1,2 +1,2 @@
CONTROLLER
==========
==========
+1 -1
View File
@@ -1,2 +1,2 @@
GATT
====
====
+1 -1
View File
@@ -1,2 +1,2 @@
HOST
====
====
@@ -1,2 +1,2 @@
SECURITY MANAGER
================
================
+43
View File
@@ -0,0 +1,43 @@
CODE STYLE
==========
The Python code style used in this project follows the [Black code style](https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html).
# Formatting
For now, we are configuring the `black` formatter with the option to leave quotes unchanged.
The preferred quote style is single quotes, which isn't a configurable option for `Black`, so we are not enforcing it. This may change in the future.
## Ignoring Commit for Git Blame
The adoption of `Black` as a formatter came in late in the project, with already a large code base. As a result, a large number of files were changed in a single commit, which gets in the way of tracing authorship with `git blame`. The file `git-blame-ignore-revs` contains the commit hash of when that mass-formatting event occurred, which you can use to skip it in a `git blame` analysis:
!!! example "Ignoring a commit with `git blame`"
```
$ git blame --ignore-revs-file .git-blame-ignore-revs
```
# Linting
The project includes a `pylint` configuration (see the `pyproject.toml` file for details).
The `pre-commit` checks only enforce that there are no errors. But we strongly recommend that you run the linter with warnings enabled at least, and possibly the "Refactor" ('R') and "Convention" ('C') categories as well.
To run the linter, use the `project.lint` invoke command.
!!! example "Running the linter with default options"
With the default settings, Errors and Warnings are enabled, but Refactor and Convention categories are not.
```
$ invoke project.lint
```
!!! example "Running the linter with all categories"
```
$ invoke project.lint --disable=""
```
# Editor/IDE Integration
## Visual Studio Code
The project includes a `.vscode/settings.json` file that specifies the `black` formatter and enables an editor ruler at 88 columns.
You may want to configure your own environment to "format on save" with `black` if you find that useful. We are not making that choice at the workspace level.
@@ -0,0 +1,11 @@
CONTRIBUTING TO THE PROJECT
===========================
To contribute some code to the project, you will need to submit a GitHub Pull Request (a.k.a PR). Please familiarize yourself with how that works (see [GitHub Pull Requests](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests))
You should follow the project's [code style](code_style.md), and pre-check your code before submitting a PR. The GitHub project is set up with some [Actions](https://github.com/features/actions) that will check that a PR passes at least the basic tests and complies with the coding style, but it is still recommended to check that for yourself before submitting a PR.
To run the basic checks (essentially: running the tests, the linter, and the formatter), use the `project.pre-commit` `invoke` command, and address any issues found:
```
$ invoke project.pre-commit
```
@@ -1,11 +1,11 @@
PYTHON ENVIRONMENTS
===================
When you don't want to install Bumble in your main/default python environment,
When you don't want to install Bumble in your main/default python environment,
using a virtual environment, where the package and its dependencies can be
installed, isolated from the rest, may be useful.
There are many flavors of python environments and dependency managers.
There are many flavors of python environments and dependency managers.
This page describes a few of the most common ones.
@@ -16,7 +16,7 @@ Visit the [`venv` documentation](https://docs.python.org/3/library/venv.html) pa
## Pyenv
`pyenv` lets you easily switch between multiple versions of Python. It's simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well.
`pyenv` lets you easily switch between multiple versions of Python. It's simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well.
Visit the [`pyenv` site](https://github.com/pyenv/pyenv) for instructions on how to install
and use `pyenv`
@@ -25,10 +25,10 @@ and use `pyenv`
Conda is a convenient package manager and virtual environment.
The file `environment.yml` is a Conda environment file that you can use to create
a new Conda environment. Once created, you can simply activate this environment when
working with Bumble.
working with Bumble.
Visit the [Conda site](https://docs.conda.io/en/latest/) for instructions on how to install
and use Conda.
A few useful commands:
A few useful commands:
### Create a new `bumble` Conda environment
```
+1 -1
View File
@@ -69,4 +69,4 @@ An app that connects to an RFComm server and bridges the RFComm channel to a loc
An app that implements an RFComm server and, when a connection is received, bridges the channel to a local TCP socket
## `run_scanner.py`
An app that scan for BLE devices and print the advertisements received.
An app that scan for BLE devices and print the advertisements received.
+11 -9
View File
@@ -5,18 +5,18 @@ GETTING STARTED WITH BUMBLE
You need Python 3.8 or above. Python >= 3.9 is recommended, but 3.8 should be sufficient if
necessary (there may be some optional functionality that will not work on some platforms with
python 3.8).
python 3.8).
Visit the [Python site](https://www.python.org/) for instructions on how to install Python
for your platform.
for your platform.
Throughout the documentation, when shell commands are shown, it is assumed that you can
invoke Python as
```
$ python
```
If invoking python is different on your platform (it may be `python3` for example, or just `py` or `py.exe`),
If invoking python is different on your platform (it may be `python3` for example, or just `py` or `py.exe`),
adjust accordingly.
You may be simply using Bumble as a module for your own application or as a dependency to your own
You may be simply using Bumble as a module for your own application or as a dependency to your own
module, or you may be working on modifying or contributing to the Bumble module or example code
itself.
@@ -65,15 +65,17 @@ $ python -m pip install git+https://github.com/google/bumble.git@27c0551
# Working On The Bumble Code
When you work on the Bumble code itself, and run some of the tests or example apps, or import the
module in your own code, you typically either install the package from source in "development mode" as described above, or you may choose to skip the install phase.
module in your own code, you typically either install the package from source in "development mode" as described above, or you may choose to skip the install phase.
If you plan on contributing to the project, please read the [contributing](development/contributing.md) section.
## Without Installing
If you prefer not to install the package (even in development mode), you can load the module directly from its location in the project.
If you prefer not to install the package (even in development mode), you can load the module directly from its location in the project.
A simple way to do that is to set your `PYTHONPATH` to
point to the root project directory, where the `bumble` subdirectory is located. You may set
`PYTHONPATH` globally, or locally with each command line execution (on Unix-like systems).
Example with a global `PYTHONPATH`, from a unix shell, when the working directory is the root
Example with a global `PYTHONPATH`, from a unix shell, when the working directory is the root
directory of the project.
```bash
@@ -96,11 +98,11 @@ $ PYTHONPATH=. python examples/run_advertiser.py examples/device1.json serial:/d
```
# Where To Go Next
Once you've installed or downloaded Bumble, you can either start using some of the
Once you've installed or downloaded Bumble, you can either start using some of the
[Bundled apps and tools](apps_and_tools/index.md), or look at the [examples](examples/index.md)
to get a feel for how to use the APIs, and start writing your own applications.
Depending on the use case you're interested in exploring, you may need to use a physical Bluetooth
controller, like a USB dongle or a board with a Bluetooth radio. Visit the [Hardware page](hardware/index.md)
for more information on using a physical radio, and/or the [Transports page](transports/index.md) for more
for more information on using a physical radio, and/or the [Transports page](transports/index.md) for more
details on interfacing with either hardware modules or virtual controllers over various transports.
+6 -6
View File
@@ -1,18 +1,18 @@
HARDWARE
========
The Bumble Host connects to a controller over an [HCI Transport](../transports/index.md).
To use a hardware controller attached to the host on which the host application is running, the transport is typically either [HCI over UART](../transports/serial.md) or [HCI over USB](../transports/usb.md).
On Linux, the [VHCI Transport](../transports/vhci.md) can be used to communicate with any controller hardware managed by the operating system. Alternatively, a remote controller (a phyiscal controller attached to a remote host) can be used by connecting one of the networked transports (such as the [TCP Client transport](../transports/tcp_client.md), the [TCP Server transport](../transports/tcp_server.md) or the [UDP Transport](../transports/udp.md)) to an [HCI Bridge](../apps_and_tools/hci_bridge) bridging the network transport to a physical controller on a remote host.
The Bumble Host connects to a controller over an [HCI Transport](../transports/index.md).
To use a hardware controller attached to the host on which the host application is running, the transport is typically either [HCI over UART](../transports/serial.md) or [HCI over USB](../transports/usb.md).
On Linux, the [VHCI Transport](../transports/vhci.md) can be used to communicate with any controller hardware managed by the operating system. Alternatively, a remote controller (a phyiscal controller attached to a remote host) can be used by connecting one of the networked transports (such as the [TCP Client transport](../transports/tcp_client.md), the [TCP Server transport](../transports/tcp_server.md) or the [UDP Transport](../transports/udp.md)) to an [HCI Bridge](../apps_and_tools/hci_bridge) bridging the network transport to a physical controller on a remote host.
In theory, any controller that is compliant with the HCI over UART or HCI over USB protocols can be used.
In theory, any controller that is compliant with the HCI over UART or HCI over USB protocols can be used.
HCI over USB is very common, implemented by a number of commercial Bluetooth dongles.
HCI over USB is very common, implemented by a number of commercial Bluetooth dongles.
It is also possible to use an embedded development board, running a specialized application, such as the [`HCI UART`](https://docs.zephyrproject.org/latest/samples/bluetooth/hci_uart/README.html) and [`HCI USB`](https://docs.zephyrproject.org/latest/samples/bluetooth/hci_usb/README.html) demo applications from the [Zephyr project](https://www.zephyrproject.org/), or the [`blehci`](https://mynewt.apache.org/latest/tutorials/ble/blehci_project.html) application from [mynewt/nimble](https://mynewt.apache.org/)
Some specific USB dongles and embedded boards that are known to work include:
* [Nordic nRF52840 DK board](https://www.nordicsemi.com/Products/Development-hardware/nrf52840-dk) with the Zephyr `HCI UART` application
* [Nordic nRF52840 DK board](https://www.nordicsemi.com/Products/Development-hardware/nrf52840-dk) with the mynewt `blehci` application
* [Nordic nrf52840 dongle](https://www.nordicsemi.com/Products/Development-hardware/nRF52840-Dongle) with the Zephyr `HCI USB` application
File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 113 KiB

After

Width:  |  Height:  |  Size: 113 KiB

-1
View File
@@ -163,4 +163,3 @@ Future features to be considered include:
* Bindings for languages other than Python
* RPC interface to expose most of the API for remote use
* (...suggest anything you want...)
+6 -7
View File
@@ -2,13 +2,13 @@
===================================
Using Bumble with Android is not about running the Bumble stack on the Android
OS itself, but rather using Bumble with the Bluetooth support of the Android
OS itself, but rather using Bumble with the Bluetooth support of the Android
emulator.
The two main use cases are:
* Connecting the Bumble host stack to the Android emulator's virtual controller.
* Using Bumble as an HCI bridge to connect the Android emulator to a physical
* Using Bumble as an HCI bridge to connect the Android emulator to a physical
Bluetooth controller, such as a USB dongle
!!! warning
@@ -17,7 +17,7 @@ The two main use cases are:
version of the emulator you are using.
You will need version 31.3.8.0 or later.
The Android emulator supports Bluetooth in two ways: either by exposing virtual
The Android emulator supports Bluetooth in two ways: either by exposing virtual
Bluetooth controllers to which you can connect a virtual Bluetooth host stack, or
by exposing an way to connect your own virtual controller to the Android Bluetooth
stack via a virtual HCI interface.
@@ -25,7 +25,7 @@ Both ways are controlled via gRPC requests to the Android emulator.
## Launching the Emulator
If the version of the emulator you are running does not yet support enabling
If the version of the emulator you are running does not yet support enabling
Bluetooth support by default or automatically, you must launch the emulator from
the command line.
@@ -43,7 +43,7 @@ communicate link layer packets between them, thus creating a virtual radio netwo
Configuring a Bumble Device instance to use Root Canal as a virtual controller
allows that virtual device to communicate with the Android Bluetooth stack, and
through it with Android applications as well as system-managed profiles.
To connect a Bumble host stack to a Root Canal virtual controller instance, use
To connect a Bumble host stack to a Root Canal virtual controller instance, use
the bumble `android-emulator` transport in `host` mode (the default).
!!! example "Run the example GATT server connected to the emulator"
@@ -78,7 +78,7 @@ To connect a virtual controller to the Android Bluetooth stack, use the bumble `
## Other Tools
The `show` application that's included with Bumble can be used to parse and pretty-print the HCI packets
from an Android HCI "snoop log" (see [this page](https://source.android.com/devices/bluetooth/verifying_debugging)
from an Android HCI "snoop log" (see [this page](https://source.android.com/devices/bluetooth/verifying_debugging)
for details on how to obtain HCI snoop logs from an Android device).
Use the `--format snoop` option to specify that the file is in that specific format.
@@ -86,4 +86,3 @@ Use the `--format snoop` option to specify that the file is in that specific for
```shell
$ bumble-show --format snoop btsnoop_hci.log
```
+12 -14
View File
@@ -13,8 +13,8 @@ The 3 main types of physical Bluetooth controllers are:
!!! tip "Conflicts with the kernel and BlueZ"
If your use a USB dongle that is recognized by your kernel as a supported Bluetooth device, it is
likely that the kernel driver will claim that USB device and attach it to the BlueZ stack.
If you want to claim ownership of it to use with Bumble, you will need to set the state of the corresponding HCI interface as `DOWN`.
likely that the kernel driver will claim that USB device and attach it to the BlueZ stack.
If you want to claim ownership of it to use with Bumble, you will need to set the state of the corresponding HCI interface as `DOWN`.
HCI interfaces are numbered, starting from 0 (i.e `hci0`, `hci1`, ...).
For example, to bring `hci0` down:
@@ -36,7 +36,7 @@ See the [USB Transport page](../transports/usb.md) for general information on ho
!!! tip "USB Permissions"
By default, when running as a regular user, you won't have the permission to use
arbitrary USB devices.
You can change the permissions for a specific USB device based on its bus number and
You can change the permissions for a specific USB device based on its bus number and
device number (you can use `lsusb` to find the Bus and Device numbers for your Bluetooth
dongle).
@@ -69,9 +69,9 @@ You can bring a HCI controller `UP` or `DOWN` with `hciconfig hci<X> up` and `hc
By default, when running as a regular user, you won't have the permission to use
an HCI socket to a Bluetooth controller (you may see an exception like `PermissionError: [Errno 1] Operation not permitted`).
If you want to run without using `sudo`, you need to manage the capabilities by adding the appropriate entries in `/etc/security/capability.conf` to grant a user or group the `cap_net_admin` capability.
If you want to run without using `sudo`, you need to manage the capabilities by adding the appropriate entries in `/etc/security/capability.conf` to grant a user or group the `cap_net_admin` capability.
See [this manpage](https://manpages.ubuntu.com/manpages/bionic/man5/capability.conf.5.html) for details.
Alternatively, if you are just experimenting temporarily, the `capsh` command may be useful in order
to execute a single command with enhanced permissions, as in this example:
@@ -80,7 +80,7 @@ You can bring a HCI controller `UP` or `DOWN` with `hciconfig hci<X> up` and `hc
$ sudo capsh --caps="cap_net_admin+eip cap_setpcap,cap_setuid,cap_setgid+ep" --keep=1 --user=$USER --addamb=cap_net_admin -- -c "<path/to/executable> <executable-args>"
```
Where `<path/to/executable>` is the path to your `python3` executable or to one of the Bumble bundled command-line applications.
!!! tip "List all available controllers"
The command
```
@@ -94,22 +94,22 @@ You can bring a HCI controller `UP` or `DOWN` with `hciconfig hci<X> up` and `hc
pi@raspberrypi:~ $ hciconfig
hci1: Type: Primary Bus: USB
BD Address: 00:16:A4:5A:40:F2 ACL MTU: 1021:8 SCO MTU: 64:1
DOWN
DOWN
RX bytes:84056 acl:0 sco:0 events:51 errors:0
TX bytes:1980 acl:0 sco:0 commands:90 errors:0
hci0: Type: Primary Bus: UART
BD Address: DC:A6:32:75:2C:97 ACL MTU: 1021:8 SCO MTU: 64:1
DOWN
DOWN
RX bytes:68038 acl:0 sco:0 events:692 errors:0
TX bytes:20105 acl:0 sco:0 commands:843 errors:0
```
!!! tip "Disabling `bluetoothd`"
When the Bluetooth daemon, `bluetoothd`, is running, it will try to use any HCI controller attached to the BlueZ stack, automatically. This means that whenever an HCI socket transport is released, it is likely that `bluetoothd` will take it over, so you will get a "device busy" condition (ex: `OSError: [Errno 16] Device or resource busy`). If that happens, you can always use
When the Bluetooth daemon, `bluetoothd`, is running, it will try to use any HCI controller attached to the BlueZ stack, automatically. This means that whenever an HCI socket transport is released, it is likely that `bluetoothd` will take it over, so you will get a "device busy" condition (ex: `OSError: [Errno 16] Device or resource busy`). If that happens, you can always use
```
$ hciconfig hci0 down
```
```
(or `hci<X>` with `<X>` being the index of the controller device you want to use), but a simpler solution is to just stop the `bluetoothd` daemon, with a command like:
```
$ sudo systemctl stop bluetooth.service
@@ -181,13 +181,13 @@ With the [VHCI transport](../transports/vhci.md) you can attach a Bumble virtual
```
python3 examples/run_controller.py F6:F7:F8:F9:FA:FB examples/device1.json vhci
```
You should see a 'Virtual Bus' controller. For example:
```
$ hciconfig
hci0: Type: Primary Bus: Virtual
BD Address: F6:F7:F8:F9:FA:FB ACL MTU: 27:64 SCO MTU: 0:0
UP RUNNING
UP RUNNING
RX bytes:0 acl:0 sco:0 events:43 errors:0
TX bytes:274 acl:0 sco:0 commands:43 errors:0
```
@@ -204,5 +204,3 @@ With the [VHCI transport](../transports/vhci.md) you can attach a Bumble virtual
### Using a Simulated UART HCI
### Bridge to a Remote Controller
-1
View File
@@ -11,4 +11,3 @@ To do that, use the following command:
sudo nvram bluetoothHostControllerSwitchBehavior="never"
```
A reboot shouldn't be necessary after that. See [Tech Note 2295](https://developer.apple.com/library/archive/technotes/tn2295/_index.html)
+1 -1
View File
@@ -7,7 +7,7 @@ USB HCI
To use a Bluetooth USB dongle on Windows, you need a USB dongle that does not require a vendor Windows driver (the dongle will be used directly through the [`WinUSB`](https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/winusb) driver rather than through a vendor-supplied Windows driver).
In order to use the dongle, the `WinUSB` driver must be assigned to the USB device. It is likely that, by default, when you first plug in the dongle, it will be recognized by Windows as a Bluetooth USB device, and Windows will try to use it with its native Bluetooth stack. You will need to switch the driver, which can be done easily with the [Zadig tool](https://zadig.akeo.ie/).
In the Zadig tool, select your USB dongle device, and associate it with WinUSB.
In the Zadig tool, select your USB dongle device, and associate it with WinUSB.
Once the WinUSB driver is correctly assigned to your device, you can confirm that by checking the settings with the Windows Device Manager control panel. Your device should appear under "Universal Serial Bus Device" (not under "Bluetooth"), and inspecting the driver details, you should see `winusb.sys` in the list of driver files.
![USB Driver Details](winusb_driver.png)
@@ -6,17 +6,17 @@ The Android emulator transport either connects, as a host, to a "Root Canal" vir
## Moniker
The moniker syntax for an Android Emulator transport is: `android-emulator:[mode=<host|controller>][<hostname>:<port>]`, where
the `mode` parameter can specify running as a host or a controller, and `<hostname>:<port>` can specify a host name (or IP address) and TCP port number on which to reach the gRPC server for the emulator.
the `mode` parameter can specify running as a host or a controller, and `<hostname>:<port>` can specify a host name (or IP address) and TCP port number on which to reach the gRPC server for the emulator.
Both the `mode=<host|controller>` and `<hostname>:<port>` parameters are optional (so the moniker `android-emulator` by itself is a valid moniker, which will create a transport in `host` mode, connected to `localhost` on the default gRPC port for the emulator).
!!! example Example
`android-emulator`
`android-emulator`
connect as a host to the emulator on localhost:8554
!!! example Example
`android-emulator:mode=controller`
`android-emulator:mode=controller`
connect as a controller to the emulator on localhost:8554
!!! example Example
`android-emulator:localhost:8555`
`android-emulator:localhost:8555`
connect as a host to the emulator on localhost:8555
+2 -2
View File
@@ -8,5 +8,5 @@ This is typically used to open a PTY, or unix driver, not for real files.
The moniker for a File transport is `file:<path>`
!!! example
`file:/dev/ttys001`
Opens the pseudo terminal `/dev/ttys001` as a transport
`file:/dev/ttys001`
Opens the pseudo terminal `/dev/ttys001` as a transport
+2 -2
View File
@@ -10,8 +10,8 @@ An HCI Socket can send/receive HCI packets to/from a Bluetooth HCI controller ma
The moniker for an HCI Socket transport is either just `hci-socket` (to use the default/first Bluetooth controller), or `hci-socket:<index>` where `<index>` is the 0-based index of a Bluetooth controller device.
!!! example
`hci-socket`
`hci-socket`
Use an HCI socket to the first Bluetooth controller (`hci0 on Linux`)
!!! tip "On Linux"
See the [Linux Platform](../platforms/linux.md) page for details on how to use HCI sockets on Linux
See the [Linux Platform](../platforms/linux.md) page for details on how to use HCI sockets on Linux
+1 -1
View File
@@ -8,5 +8,5 @@ The moniker syntax for a PTY transport is: `pty[:path]`.
Where `path`, is used, is the path name where a symbolic link to the PTY will be created for convenience (the link will be removed when the transport is closed or when the process exits).
!!! example
`pty:virtual_hci`
`pty:virtual_hci`
Creates a PTY entry and a symbolic link, named `virtual_hci`, linking to the PTY
+1 -1
View File
@@ -8,5 +8,5 @@ The moniker syntax for a serial transport is: `serial:<device-path>[,<speed>]`
When `<speed>` is omitted, the default value of 1000000 is used
!!! example
`serial:/dev/tty.usbmodem0006839912172,1000000`
`serial:/dev/tty.usbmodem0006839912172,1000000`
Opens the serial port `/dev/tty.usbmodem0006839912172` at `1000000`bps
+2 -2
View File
@@ -7,5 +7,5 @@ The TCP Client transport uses an outgoing TCP connection to a host:port address.
The moniker syntax for a TCP client transport is: `tcp-client:<remote-host>:<remote-port>`
!!! example
`tcp-client:127.0.0.1:9001`
Connects to port 9001 on the local host
`tcp-client:127.0.0.1:9001`
Connects to port 9001 on the local host
+3 -3
View File
@@ -5,9 +5,9 @@ The TCP Client transport uses an incoming TCP connection to a host:port address.
## Moniker
The moniker syntax for a TCP server transport is: `tcp-server:<local-host>:<local-port>`
where `<local-host>` may be the address of a local network interface, or `_` to accept
where `<local-host>` may be the address of a local network interface, or `_` to accept
connections on all local network interfaces.
!!! example
`tcp-server:_:9001`
Waits for and accepts connections on port `9001`
`tcp-server:_:9001`
Waits for and accepts connections on port `9001`
+1 -1
View File
@@ -7,5 +7,5 @@ The UDP transport is a UDP socket, receiving packets on a specified port number,
The moniker syntax for a UDP transport is: `udp:<local-host>:<local-port>,<remote-host>:<remote-port>`.
!!! example
`udp:0.0.0.0:9000,127.0.0.1:9001`
`udp:0.0.0.0:9000,127.0.0.1:9001`
UDP transport where packets are received on port `9000` and sent to `127.0.0.1` on port `9001`
+2 -2
View File
@@ -10,5 +10,5 @@ The VHCI transport allows attaching a virtual controller to the Bluetooth stack
The moniker for a VHCI transport is either just `vhci` (to use the default VHCI device path at `/dev/vhci`), or `vhci:<path>` where `<path>` is the path of a VHCI device.
!!! example
`vhci`
Attaches a virtual controller transport to `/dev/vhci`
`vhci`
Attaches a virtual controller transport to `/dev/vhci`
+1 -1
View File
@@ -7,5 +7,5 @@ The UDP transport is a UDP socket, receiving packets on a specified port number,
The moniker syntax for a UDP transport is: `udp:<local-host>:<local-port>,<remote-host>:<remote-port>`.
!!! example
`udp:0.0.0.0:9000,127.0.0.1:9001`
`udp:0.0.0.0:9000,127.0.0.1:9001`
UDP transport where packets are received on port `9000` and sent to `127.0.0.1` on port `9001`
+1 -1
View File
@@ -7,5 +7,5 @@ The UDP transport is a UDP socket, receiving packets on a specified port number,
The moniker syntax for a UDP transport is: `udp:<local-host>:<local-port>,<remote-host>:<remote-port>`.
!!! example
`udp:0.0.0.0:9000,127.0.0.1:9001`
`udp:0.0.0.0:9000,127.0.0.1:9001`
UDP transport where packets are received on port `9000` and sent to `127.0.0.1` on port `9001`
+1 -1
View File
@@ -11,4 +11,4 @@ Write a python application (ex: a GATT client that will connect to a hear rate s
| Python || Host |<-- HCI -->| Controller |{...radio...}| Device |
| App || | Transport | | | |
+--------++--------+ +------------+ +-----------+
```
```
+1 -1
View File
@@ -11,4 +11,4 @@ Connect a native Bluetooth application, running on a host with Bluetooth stack t
| Bluetooth |<-- HCI -->| Virtual |<== Local or ==>| Virtual || Host || Python |
| App | Transport | Controller | Remote | Controller || || App |
+-----------+ +------------+ Link +------------++--------++--------+
```
```
+1 -1
View File
@@ -11,4 +11,4 @@ Connect an emulated Bluetooth device (ex: an Android emulator, or an embedded de
| Bluetooth |<-- HCI -->| Virtual |<== Local or ==>| Virtual || Host || Python |
| Device | Transport | Controller | Remote | Controller || || App |
+-----------+ +------------+ Link +------------++--------++--------+
```
```
+2 -2
View File
@@ -6,9 +6,9 @@ USE CASE 4
Connect two emulated Bluetooth device (ex: an Android emulator, or an embedded device emulator) to each other
```
+-----------+ +------------+ +------------+ +-----------+
+-----------+ +------------+ +------------+ +-----------+
| Emulated | | Bumble | Bumble | Bumble | | Emulated |
| Bluetooth |<-- HCI -->| Virtual |<== Local or ==>| Virtual |<-- HCI -->| Bluetooth |
| Device | Transport | Controller | Remote | Controller | Transport | Device |
+-----------+ +------------+ Link +------------+ +-----------+
```
```
+1 -1
View File
@@ -17,4 +17,4 @@ Write several python applications (ex: a GATT client that will connect to a hear
| Python || Host || Controller |<--+ +-->| Controller || Host || Python |
| App || || | | || || App |
+--------++--------++------------+ +------------++--------++--------+
```
```
+2 -2
View File
@@ -6,9 +6,9 @@ USE CASE 6
It can be useful to connect an emulated device (like a phone simulator, or an emulated embedded device) to a physical controller in order to connect to other Bluetooth devices. By doing this via a Bumble HCI bridge, it becomes easy to inspect the HCI packets exchanged with the controller, and possibly filter/change them if needed (for example to support vendor-specific HCI extensions).
```
+-----------+ +--------+ +------------+ +-----------+
+-----------+ +--------+ +------------+ +-----------+
| Emulated | | Bumble | | Physical | | Bluetooth |
| Bluetooth |<-- HCI -->| HCI |<-- HCI -->| Controller |{...radio...}| Device |
| Device | Transport | Bridge | Transport | | | |
+-----------+ +--------+ +------------+ +-----------+
```
```