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 entryzephyr_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: trueConfiguration variables
Section titled “Configuration variables”- on_numeric_comparison_request (Optional, Automation): An automation to
compare the passkeys shown on the two BLE devices. See
on_numeric_comparison_request.
BLE Server Automation
Section titled “BLE Server Automation”on_numeric_comparison_request
Section titled “on_numeric_comparison_request”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: trueNOTE
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: trueConfiguration variables
Section titled “Configuration variables”- accept (Required, boolean, templatable): Should be
trueif the passkeys displayed on both BLE devices are matching.
Passkey examples
Section titled “Passkey examples”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: trueSecure 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;"