> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ditto.live/llms.txt
> Use this file to discover all available pages before exploring further.

# Bluetooth on Linux

> Install BlueZ package version 5.66 or higher. The BlueZ package is the official Linux stack and provides all the modules you’ll need to enable data sync with Bluetooth Low Energy (LE).

```Shell Shell theme={null}
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev docutils-common -y
wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.72.tar.xz
tar -xf bluez-5.72.tar.xz
cd bluez-5.72
./configure
make
sudo make install
```

### Add support for Linux to iOS connections.

BlueZ 5.51 and above try to automatically read the battery status/service of devices when they connect. However, iOS devices will default prevent BlueZ services from reading the battery service. As a result, BlueZ connection attempts will cause iOS devices to show a pairing prompt constantly. Therefore, we must disable the battery service in BlueZ using the following steps.

1. With your favorite editor, open the bluetooth service file. On Raspberry Pi OS it's located: **/usr/lib/systemd/system/bluetooth.service**, on other versions it may be here: **/etc/systemd/system/bluetooth.target.wants/bluetooth.service**. You will probably need to use su permission to write to this file.

2. Find the line beginning with **ExecStart=** and add **-P battery** to the end. Now the line should look like this:

```Shell Shell theme={null}
ExecStart=/usr/lib/bluetooth/bluetoothd -P battery
```

3\. Save the file

4\. Run `sudo systemctl daemon-reload` and `sudo systemctl restart bluetooth` to apply changes to the Bluetooth service.

5\. By default, connections between dual-mode devices will use `bredr` mode, which is not supported for BLE communication between Linux and macOS. To address this, configure `BlueZ` to operate in LE mode by modifying the configuration file: `/etc/bluetooth/main.conf`. Add or uncomment in the \[General] section to change the setting:

```Shell Shell theme={null}
ControllerMode = le
```

After that, BlueZ should be able to connect to iOS devices without prompting and Ditto Apps should be able to communicate over BT-LE between iOS and Linux.

### Run the following command to set BlueZ' support for multiple advertisements.

```Shell Shell theme={null}
sudo setcap 'cap_net_raw,cap_net_admin+eip' `which hcitool`
```
