Zephyr BLE Server
zephyr_ble_server 组件在运行
Zephyr RTOS 的设备上启用蓝牙低功耗 GATT 服务器。它支持安全配对流程,包括蓝牙规范中定义的 数字比较 密码
确认模型。
# 示例配置条目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- on_numeric_comparison_request (可选, Automation): 一个用于
比较两台 BLE 设备上显示的密码的自动化。参见
on_numeric_comparison_request。
BLE 服务器自动化
Section titled “BLE 服务器自动化”on_numeric_comparison_request
Section titled “on_numeric_comparison_request”当 BLE 设备请求数字比较时,将触发此自动化。
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: trueble_server.numeric_comparison_reply 动作
Section titled “ble_server.numeric_comparison_reply 动作”此动作在数字比较后触发一次身份验证尝试。
使用示例:
on_...: then: - ble_server.numeric_comparison_reply: accept: true- accept (必选, boolean, 可模板化): 如果两台
BLE 设备上显示的密码匹配,应为
true。
自动接受数字比较的安全连接:
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通过 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;"