Bluetooth: Peripheral_sc_general
概述
本示例演示了使能 BLE 外围设备角色,和 Peripheral general 示例不同的是, 本示例支持加密流程。 在连接建立后,用户可以在控制台下输入相关的指令以完成配对流程,比如发起安全流程、设置 IO 能力和根据提示,输入配对码。
#define BT_UUID_SERVICE 0xFFF0
#define BT_UUID_CHAR_READ_WRITE 0xFFF1
#define BT_UUID_CHAR_INDCIATE 0xFFF2
#define BT_UUID_CHAR_NOTIFY 0xFFF3
配对指令 (cli commands)
- security:
发起配对流程.
- auth_method:
设置设备输入输出能力,支持display, display and yes/no, input, no-input-no-output, display and input.
- auth_passkey:
给对方设备回复配对码.
- auth_cancel:
取消配对流程.
- auth_passkey_confirm:
确认配对码正确.
- auth_pairing_confirm
确认配对流程.
环境要求
支持 BLE 功能的开发板
编译和烧录
示例位置:
examples/bluetooth/peripheral_sc_general
编译、烧录等操作请参考:[快速入门](https://doc.winnermicro.net/w800/zh_CN/2.1.0rc1/get_started/index.html)
运行结果
[I] (2) main: ver: 0.9.0 build at Sep 12 2024 16:01:42
[I] (24) bt: LE SC enabled
[I] (150) bt: No ID address. App must call settings_load()
[I] (168) bt: Identity: 28:6D:CD:68:D7:99 (public)
[I] (168) bt: HCI: version 4.2 (0x08) revision 0x0709, manufacturer 0x070c
[I] (168) bt: LMP: version 4.2 (0x08) subver 0x0709
[I] (204) sc_peripheral: peripheral indicate service ready
[I] (828) sc_peripheral: Updated MTU: TX: 23 RX: 23 bytes
[I] (830) sc_peripheral: Connected 28:6D:CD:55:E4:57 (public)
[W] (830) bt: Not connected
[I] (830) sc_peripheral: mtu_exchange: Current MTU = 0
[I] (830) sc_peripheral: mtu_exchange: Exchange MTU...
[E] (830) sc_peripheral: mtu_exchange: MTU exchange failed (err -128)
[I] (1118) sc_peripheral: Updated MTU: TX: 247 RX: 247 bytes
[I] (1120) sc_peripheral: Remote pairing features: IO: 0x04, OOB: 0, AUTH: 0x0d, Key: 16, Init Kdist: 0x05, Resp Kdist: 0x07
[I] (1270) sc_peripheral: passkey for 28:6D:CD:55:E4:57 (public): 764892, please confirm it on remote device
[I] (1818) sc_peripheral: LE conn param updated: 28:6D:CD:55:E4:57 (public) int 0x0014 lat 0 to 500
[W] (20600) bt: chan 0x20004128 conn 0x20003c9c handle 0 encrypt 0x01 hci status 0x00
[I] (20602) sc_peripheral: Security changed: 28:6D:CD:55:E4:57 (public) level 4
[I] (20666) sc_peripheral: BONDED with 28:6D:CD:55:E4:57 (public)