Skip to content
Get started

Zephyr BLE Server

The zephyr_ble_server component enables a Bluetooth Low Energy GATT server on devices running the Zephyr RTOS. It supports secure pairing flows, including the Numeric Comparison passkey confirmation model defined in the Bluetooth specification.

# Example configuration entry
zephyr_ble_server:
on_numeric_comparison_request:
then:
- logger.log:
format: "Compare this passkey with the one on your BLE device: %06d"
args: [passkey]
- ble_server.numeric_comparison_reply:
accept: true

This automation is triggered when a numeric comparison is requested by the BLE device.

zephyr_ble_server:
on_numeric_comparison_request:
then:
- logger.log:
format: "Compare this passkey with the one on your BLE device: %06d"
args: [passkey]
- ble_server.numeric_comparison_reply:
accept: true

NOTE

The BLE server also comes up when the device is in safe mode, so a device stuck in a boot loop can still be updated over BLE. This automation does not run while the device is in safe mode, so the device then rejects every new pairing request. Computers that are already paired (bonded) with the device can still connect.

ble_server.numeric_comparison_reply Action

Section titled “ble_server.numeric_comparison_reply Action”

This action triggers an authentication attempt after a numeric comparison.

Example usage:

on_...:
then:
- ble_server.numeric_comparison_reply:
accept: true
  • accept (Required, boolean, templatable): Should be true if the passkeys displayed on both BLE devices are matching.

Secure connection with numeric comparison accepted automatically:

zephyr_ble_server:
on_numeric_comparison_request:
then:
- logger.log:
format: "Compare this passkey with the one on your BLE device: %06d"
args: [passkey]
- ble_server.numeric_comparison_reply:
accept: true

Secure connection with numeric comparison accepted via a lambda:

zephyr_ble_server:
on_numeric_comparison_request:
then:
- logger.log:
format: "Compare this passkey with the one on your BLE device: %06d"
args: [passkey]
- ble_server.numeric_comparison_reply:
accept: !lambda "return true;"