Skip to content
README.md 3.5 KiB
Newer Older
Yoan Picchi's avatar
Yoan Picchi committed

# Babblesim tools
Yoan Picchi's avatar
Yoan Picchi committed

## Dependencies

- Python 3 with virtual environment and pip
- curl
- git
- CMake (3.20 at minimum)
- GCC or Clang with multilib support
If you're running an debian derivative you may use the command line below:
Yoan Picchi's avatar
Yoan Picchi committed

```sh
apt-get -y install python3 python3-venv python3-pip curl git cmake gcc-multilib
```
Yoan Picchi's avatar
Yoan Picchi committed

Note that CMake 3.20 at minimum is required to build zephyr.
If you're running an older distro check (Kitware's website)[https://apt.kitware.com/] for details on how to add a
PPA with a newer cmake.
Yoan Picchi's avatar
Yoan Picchi committed

## Components
Yoan Picchi's avatar
Yoan Picchi committed

babblesim - simulation which connects the controllers together.
hci-ip-bridge - a relay listening on an IP socket to forward HCI traffic to an HCI interface.
zephyr-controller - used to build a controller part of the BLE stack that waits for you to connect your host stack to.
Yoan Picchi's avatar
Yoan Picchi committed

## How to build
Yoan Picchi's avatar
Yoan Picchi committed

Run the top level build script:
Yoan Picchi's avatar
Yoan Picchi committed

```sh
./build.sh
Yoan Picchi's avatar
Yoan Picchi committed
```

## How to run
Yoan Picchi's avatar
Yoan Picchi committed

### Running Babblesim
Yoan Picchi's avatar
Yoan Picchi committed


The run.sh script is setup to run with two UART HCI connected controllers.
If you want to run a different set of controllers you may run babblesim yourself instead of running the script.
Yoan Picchi's avatar
Yoan Picchi committed

Run the top level run script as sudo:
Yoan Picchi's avatar
Yoan Picchi committed

```sh
sudo ./run.sh
Yoan Picchi's avatar
Yoan Picchi committed
```

Babblesim is now connected to two controllers waiting for host stacks to connect to them.
Yoan Picchi's avatar
Yoan Picchi committed

Take note of the pseudotty used, eg: ```UART_0 connected to pseudotty: /dev/pts/5```
Yoan Picchi's avatar
Yoan Picchi committed

Leave it running and open a new terminal.

Use the pseudotty you got from babblesim to attach an HCI interface to a TTY.
Yoan Picchi's avatar
Yoan Picchi committed

```sh
sudo btattach -P h4 -B /dev/pts/5 -S 1000000
Yoan Picchi's avatar
Yoan Picchi committed
```

Take note of the device ID, eg: ```Device index 1 attached```
Yoan Picchi's avatar
Yoan Picchi committed

This will match the HCI interface ID you can later use to connect to using your host stack (`HCI1` in this case).
Yoan Picchi's avatar
Yoan Picchi committed

#### Monitoring HCI traffic
Yoan Picchi's avatar
Yoan Picchi committed

If you want to be sure the `btattach` is complete you may monitor the traffic in another terminal with:
Yoan Picchi's avatar
Yoan Picchi committed


```sh
sudo btmon
```
Yoan Picchi's avatar
Yoan Picchi committed

### Connecting Host stacks to Controllers
Yoan Picchi's avatar
Yoan Picchi committed

Controllers are now waiting for host stacks to connect to them over HCI.
Yoan Picchi's avatar
Yoan Picchi committed

#### HCI over IP socket
Yoan Picchi's avatar
Yoan Picchi committed

You can use hci-bridge to connect your host over a ip socket transport.
Yoan Picchi's avatar
Yoan Picchi committed

The first parameter parameter is the device ID you previously obtained from running btattach.
Yoan Picchi's avatar
Yoan Picchi committed

sudo __build/bin/hci-ip-bridge 1
Yoan Picchi's avatar
Yoan Picchi committed

The bridge is listening on a socket bound to loopback and port 51051.
Yoan Picchi's avatar
Yoan Picchi committed

Leave the terminal running and observe the traffic when you connect to it over the IP socket.
Yoan Picchi's avatar
Yoan Picchi committed

#### Other host stacks
Yoan Picchi's avatar
Yoan Picchi committed

Any host stack can connect to the created HCI interfaces.
You may for example use bleak to write python scripts which will connect to the controllers running in babblesim.
Yoan Picchi's avatar
Yoan Picchi committed

# License and contributions

The software is provided under the Apache-2.0 license. All contributions to software and documents are licensed by contributors under the same license model as the software/document itself (ie. inbound == outbound licensing). Open IoT SDK may reuse software already licensed under another license, provided the license is permissive in nature and compatible with Apache v2.0.

Folders containing files under different permissive license than Apache 2.0 are listed in the LICENSE file.

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for more information.

## Security issues reporting

If you find any security vulnerabilities, please do not report it in the GitLab issue tracker. Instead, send an email to the security team at arm-security@arm.com stating that you may have found a security vulnerability in the Open IoT SDK.

More details can be found at [Arm Developer website](https://developer.arm.com/support/arm-security-updates/report-security-vulnerabilities).