W801 BLE 和手机再次配对失败

发布于 2022-06-30 13: 50: 23

编译 W801 的固件代码 (没记错是 wm_sdk_w80x_20211115. zip) , 然后烧录固件到 W801.

在串口调试助手输入:
t-bt-on
t-ble-adv (1)
蓝牙启动成功, 并正常发送广播报文

手机打开蓝牙并扫描到 W801. 点击配对成功.

然后, 手机端将配对好的 W801 设备删除, 板子也重新上电 (排除干扰) .

串口助手丽依次输入 t-bt-on, t-ble-adv (1) , 手机端还是能扫描到 W801 设备. 但是
点击配对时却失败, 串口终端内容是这样的:

[WM_I]  0: 00: 01. 288  adapter status = bt_state_on
[WM_I]  0: 00: 01. 294  init base application
[WM_I]  0: 00: 06. 968  ### tls_ble_demo_adv type=1
[WM_I]  0: 00: 06. 974  Starting advertising
GAP procedure initiated:  advertise;  disc_mode=2 direct_addr_type=0 direct_addr=00: 00: 00: 00: 00: 00 adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=64 adv_itvl_max=64
[WM_I]  0: 00: 11. 806  gap_event,  [BLE_GAP_EVENT_CONNECT]
[WM_I]  0: 00: 12. 068  gap_event,  [BLE_GAP_EVENT_REPEAT_PAIRING]
[WM_I]  0: 00: 45. 070  gap_event,  [BLE_GAP_EVENT_DISCONNECT]

是不是这个 BLE_GAP_EVENT_REPEAT_PAIRING 没处理好? 源码没有改动, 只是编译后烧录到板子上.

查看更多

关注者
0
被浏览
1. 2k
1 个回答
haoronMango
haoronMango 2022-07-02
这家伙很懒, 什么也没写!

OK, 我们做个记录
https: //github. com/h2zero/NimBLE-Arduino/issues/116

case BLE_GAP_EVENT_REPEAT_PAIRING: 
    /* We already have a bond with the peer,  but it is attempting to
     * establish a new secure link.   This app sacrifices security for
     * convenience:  just throw away the old bond and accept the new link. 
     */
    /* Delete the old bond.  */
    rc = ble_gap_conn_find (event- repeat_pairing. conn_handle,  &desc) ; 
    assert (rc == 0) ; 
    ble_store_util_delete_peer (&desc. peer_id_addr) ; 
    
    TLS_BT_APPL_TRACE_DEBUG ("! ! ! BLE_GAP_EVENT_REPEAT_PAIRING\r\n") ; 
    return BLE_GAP_REPEAT_PAIRING_RETRY; 

搜索后发现, 原来是要删除原来的配对信息 (持久化存储) . 然后再 wm_ble_server_api_demo. c 里是有个 case 处理的. 但是 wm_ble_gap. c 里没有. 所以发送广播时就酱紫.

撰写答案

请登录后再发布答案, 点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览