2020-08-29 04:15:16 +10:00
---
title: Bluetooth Behavior
sidebar_label: Bluetooth
---
## Summary
The bluetooth behavior allows management of various settings and states related to the bluetooth connection(s)
2020-09-09 13:26:00 +10:00
between the keyboard and the host. By default, ZMK supports five "profiles" for selecting which bonded host
computer/laptop/keyboard should receive the keyboard input; many of the commands here operation on those profiles.
2020-08-29 04:15:16 +10:00
## Bluetooth Command Defines
Bluetooth command defines are provided through the [`dt-bindings/zmk/bt.h` ](https://github.com/zmkfirmware/zmk/blob/main/app/include/dt-bindings/zmk/bt.h ) header,
which is added at the top of the keymap file:
```
#include <dt-bindings/zmk/bt.h>
```
2020-09-14 12:20:25 +10:00
This will allow you to reference the actions defined in this header such as `BT_CLR_CMD` .
2020-08-29 04:15:16 +10:00
Here is a table describing the command for each define:
2020-09-14 12:20:25 +10:00
| Define | Action |
| ------------ | ---------------------------------------------------------------------------------------------- |
| `BT_CLR_CMD` | Clear bond information between the keyboard and host for the selected profile [^1] |
| `BT_NXT_CMD` | Switch to the next profile, cycling through to the first one when the end is reached. |
| `BT_PRV_CMD` | Switch to the previous profile, cycling through to the last one when the beginning is reached. |
| `BT_SEL_CMD` | Select the 0-indexed profile by number. |
2020-08-29 04:15:16 +10:00
2020-09-09 13:26:00 +10:00
Because at least one bluetooth commands takes an additional parameter, it is recommended to use
the following aliases in your keymap to avoid having to specify an ignored second parameter:
2020-08-29 04:15:16 +10:00
2020-09-14 12:20:25 +10:00
| Define | Action |
| -------- | -------------------------------------------------------------------------------- |
| `BT_CLR` | Alias for `BT_CLR_CMD 0` to clear the current profile's bond to the current host |
| `BT_NXT` | Alias for `BT_NXT_CMD 0` to select the next profile |
| `BT_PRV` | Alias for `BT_PRV_CMD 0` to select the previous profile |
| `BT_SEL` | Alias for `BT_SEL_CMD` to select the given profile, e.g. `&bt BT_SEL 1` |
2020-08-29 04:15:16 +10:00
## Bluetooth Behavior
The bluetooth behavior completes an bluetooth action given on press.
### Behavior Binding
- Reference: `&bt`
2020-09-14 12:20:25 +10:00
- Parameter #1: The bluetooth command define, e.g. `BT_CLR_CMD`
2020-09-02 13:22:30 +10:00
- Parameter #2: (Reserved for future bluetooth command types)
2020-08-29 04:15:16 +10:00
### Examples
2020-09-09 13:26:00 +10:00
1. Behavior binding to clear the paired host for the selected profile:
2020-08-29 04:15:16 +10:00
```
2020-09-14 12:20:25 +10:00
& bt BT_CLR
2020-08-29 04:15:16 +10:00
```
2020-09-09 13:26:00 +10:00
1. Behavior binding to select the next profile:
```
2020-09-14 12:20:25 +10:00
& bt BT_NXT
2020-09-09 13:26:00 +10:00
```
1. Behavior binding to select the previous profile:
```
2020-09-14 12:20:25 +10:00
& bt BT_NXT
2020-09-09 13:26:00 +10:00
```
1. Behavior binding to select the 2nd profile (passed parameters are [zero based ](https://en.wikipedia.org/wiki/Zero-based_numbering )):
```
2020-09-14 12:20:25 +10:00
& bt BT_SEL 1
2020-09-09 13:26:00 +10:00
```