设备:esp32s3
主设备:S21,android
源:example_ble_sec_gatts_demo
编辑代码:
代码:
sta
tic esp_ble_adv_params_t heart_rate_adv_params = {
.adv_int_min = 0x100,
.adv_int_max = 0x100,
.adv_type = ADV_TYPE_IND,
.own_addr_type =BLE_ADDR_TYPE_PUBLIC, // edit_1
.channel_map = ADV_CHNL_ALL,
.adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY,
};
own_addr_type 更改为 public 以进行自动连接
代码:
case ESP_GATTS_CONNECT_EVT:
ESP_LOGI(GATTS_TABLE_TAG, "ESP_GATTS_CONNECT_EVT");
/* start security connect with peer device when receive the connect event sent by the master */
esp_ble_set_encryption(param->connect.remote_bda, ESP_BLE_SEC_ENCRYPT); //edit_2
break;
代码:
esp_ble_auth_req_t auth_req = ESP_LE_AUTH_REQ_SC_BOND; //edit_3
我想我已经准备好在我的设备之间自动连接了。
当我第一次连接到esp32s3时,它连接成功了。
然后,我关闭 esp32s3 并在断开连接后打开连接。
此时esp32s3反复在连接和断开之间。
终端在日志下方显示我
I (4061) SEC_GATTS_DEMO: 7a 31 08 03 9d 36
W (4131) BT_HCI: hcif disc complete: hdl 0x1, rsn 0x3d
I (4131) SEC_GATTS_DEMO: ESP_GATTS_DISCONNECT_EVT, 断开原因 0x3d
I (4141) SEC_GATTS_DEMO4: advertising start
( advertising start) ) SEC_GATTS_DEMO: ESP_GATTS_CONNECT_EVT
I (4871) SEC_GATTS_DEMO: remote BD_ADDR: 7a3108039d36
I (4871) SEC_GATTS_DEMO: address type = 1
I (4871) SEC_GATTS_DEMO: pair status = success
I (4871) SEC_GATTS_DEMO: auth mode = ESP_LE_AUTH_REQ_SC_BOND
I (4881) SEC_GATTS_DEMO:绑定设备编号:1
I (4881) SEC_GATTS_DEMO:绑定设备列表:1
I (4891) SEC_GATTS_DEMO:7a 31 08 03 9d 36
W (4961) BT_HCI:hcif disc complete:hdl 0x1,rsn 0x3d
I (4961) SEC_GATTS_DEMO: ESP_GATTS_DISCONNECT_EVT, disconnect reason 0x3d
I (4961) SEC_GATTS_DEMO: advertising start success
I (5251) SEC_GATTS_DEMO: ESP_GATTS_CONNECT_EVT
I (5501) SEC_GATTS_DEMO: remote BD_ADDR: 7a3108039d36
I (5501) SEC_GATTS_DEMO: address type = 1
I (5501 ) SEC_GATTS_DEMO: pair status = success
I (5501) SEC_GATTS_DEMO: auth mode = ESP_LE_AUTH_REQ_SC_BOND
I (5511) SEC_GATTS_DEMO: 绑定设备编号:1
I (5521) SEC_GATTS_DEMO: 绑定设备列表:1
I (5521) SEC_GATTS_DEMO: 7a 31 908 08 36
W (5591) BT_HCI:hcif 光盘完整:hdl 0x1,rsn 0x3d
I (5591) SEC_GATTS_DEMO:ESP_GATTS_DISCONNECT_EVT,断开原因 0x3d
I (5601) SEC_GATTS_DEMO: 广告启动成功
I (6031) SEC_GATTS_DEMO: ESP_GATTS_CONNECT_EVT
I (6281) SEC_GATTS_DEMO: 远程 BD_ADDR: 7a3108039d36
I (6281) SEC_GATTS_DEMO: 地址类型 = 1 I (
6281
) SEC_GATTS_DEMO: pair81 status = success
SEC_GATTS_DEMO: auth mode = ESP_LE_AUTH_REQ_SC_BOND
I (6291) SEC_GATTS_DEMO: 绑定设备编号:1
I (6301) SEC_GATTS_DEMO: 绑定设备列表:1
I (6301) SEC_GATTS_DEMO: 7a 31 08 03 9d 36
W (6371) BT_discHCI: hcif complete hdl 0x1,rsn 0x3d
I (6371) SEC_GATTS_DEMO:ESP_GATTS_DISCONNECT_EVT,断开原因 0x3d
I (6381) SEC_GATTS_DEMO:广告开始成功
I (6811) SEC_GATTS_DEMO:ESP_GATTS_CONNECT_EVT
I(7161)SEC_GATTS_DEMO:远程 BD_ADDR:7a3108039d36
I(7161)SEC_GATTS_DEMO:地址类型 = 1
I(7161)SEC_GATTS_DEMO:配对状态 = 成功
I(7161)SEC_GATTS_DEMO:授权模式 = ESP_LE_AUTH_REQ_SC_BOND
I(7171)SEC_GATTS number_DEMO:绑定设备1
I (7171) SEC_GATTS_DEMO:绑定设备列表:1
I (7181) SEC_GATTS_DEMO:7a 31 08 03 9d 36
你能告诉我这是什么原因吗?
0