为了防止个人理解错误,下面的回答大多都会引用了论坛资料或者链接。
1.如何让设备发起bongding请求
先设置权限BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&dis_init.dis_attr_md.read_perm)
在ios上,除非app试图读取的characteristic收到保护,否则是没有bongding请求发生的。(可参考ble_app_gls例程)
原回答如下:
On iOS, no bonding will occur unless an app tries to read a characteristic that is protected. If you use LightBlue, this app will not do any such reads unless you specifically asks it to. To trigger bonding, you should therefore make sure to navigate the services/characteristics in such way that either a protected read or write is triggered, which again should trigger bonding.
authorization doesn’t have anything to do with bonding, it’s just a way for the application to know and authorize each read/write.
The protection I mean is the one set with the BLE_GAP_CONN_SEC_* macros. If you try to read any characteristic that is set as for example BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(), this will trigger bonding.
2.如何添加用户自己的128bit UUID?
使用sd_ble_uuid_vs_add(param1, param2)函数添加自己的128bit的service或者UUID,6.0的softdevice固件支持添加最多10个128bitUUID。param1是16byte用户uuid, param2存放softdevice分配的UUIDtype, 从BLE_UUID_TYPE_VENDOR_BEGIN(0x02)开始算,总共能添加10条,以后每一条只需要这个vender uuid type就行.
注意,param1的第13,14byte 不用写也行,写了也没用,后面还需添加。
/* 范例 */
ble_uuid128_t uuid_128bits = {0xD0, 0x00, 0x2D, 0x12, 0x1E, 0x4B, 0x0F, 0xA4, 0x99, 0x4