BLE GAP password pin and BLE API

Palonso
Posts: 63
Joined: Tue Sep 24, 2019 8:43 pm

BLE GAP password pin and BLE API

Postby Palonso » Fri Oct 02, 2020 7:48 pm

Hi,

I'm trying to run a BLE server on an ESP-WROVER-B module and I want it to have pin security to connect to it with BLE.

Here is the code I'm running in order to set the password to the BLE:

Code: Select all

void app_main(void)
{
    esp_err_t ret;

    // Initialize NVS: Needed to start BLE
    ret = nvs_flash_init();
    if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
        ESP_ERROR_CHECK(nvs_flash_erase());
        ret = nvs_flash_init();
    }
    //ESP_ERROR_CHECK( ret );

    start_ble();

    // Just show how to clear all the bonded devices
    // Delay 30s, clear all the bonded devices

    //vTaskDelay(30000 / portTICK_PERIOD_MS);
    //remove_all_bonded_devices();

}

void start_ble(void)
{
    esp_err_t ret;

    //ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
    esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT);

    esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
    ret = esp_bt_controller_init(&bt_cfg);
    if (ret) 
    {
        ESP_LOGE(__func__, "%s initialize controller failed: %s\n", __func__, esp_err_to_name(ret));
        return;
    }
    ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
    if (ret) 
    {
        ESP_LOGE(__func__, "%s enable controller failed: %s\n", __func__, esp_err_to_name(ret));
        return;
    }
    ret = esp_bluedroid_init();
    if (ret) 
    {
        ESP_LOGE(__func__, "%s init bluetooth failed: %s\n", __func__, esp_err_to_name(ret));
        return;
    }
    ret = esp_bluedroid_enable();
    if (ret) 
    {
        ESP_LOGE(__func__, "%s enable bluetooth failed: %s\n", __func__, esp_err_to_name(ret));
        return;
    }
    //GATT: responsible for storing and exchanging real data through a set of 
    //services that consist of characteristics which hold the concerning data
    ret = esp_ble_gatts_register_callback(gatts_event_handler);
    if (ret)
    {
        ESP_LOGE(__func__, "gatts register error, error code = %x", ret);
        return;
    }
    //GAP: responsible mainly for advertising and broadcasting
    ret = esp_ble_gap_register_callback(gap_event_handler);
    if (ret)
    {
        ESP_LOGE(__func__, "gap register error, error code = %x", ret);
        return;
    }
    ret = esp_ble_gatts_app_register(APP_ID_0);
    if (ret)
    {
        ESP_LOGE(__func__, "gatts app 0 register error, error code = %x", ret);
        return;
    }
    ret = esp_ble_gatts_app_register(APP_ID_1);
    if (ret)
    {
        ESP_LOGE(__func__, "gatts app 1 register error, error code = %x", ret);
        return;
    }
    //What MTU defines is the size of Attribute PDU (packet not the bare ATT in the ATT table).
    //The ATT packets with a size larger than MTU (Maximum Transmition Unit) cannot be transferred.
    esp_err_t local_mtu_ret = esp_ble_gatt_set_local_mtu(500);
    if (local_mtu_ret)
    {
        ESP_LOGE(__func__, "set local  MTU failed, error code = %x", local_mtu_ret);
    }

    //set passkey
    uint32_t passkey = 654321;

    // set the security iocap & auth_req & key size & init key response key parameters to the stack
    esp_ble_auth_req_t auth_req 	= ESP_LE_AUTH_REQ_SC_MITM;              //bonding with peer device after authentication
    esp_ble_io_cap_t iocap      	= ESP_IO_CAP_OUT;                              	//set the IO capability
    uint8_t key_size            		= 16;                                           			//the key size should be 7~16 bytes
    uint8_t init_key            		= ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK;
    uint8_t rsp_key             		= ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK;
    uint8_t auth_option         		= ESP_BLE_ONLY_ACCEPT_SPECIFIED_AUTH_ENABLE;
    uint8_t oob_support         		= ESP_BLE_OOB_DISABLE;

    esp_ble_gap_set_security_param(ESP_BLE_SM_SET_STATIC_PASSKEY, &passkey, sizeof(uint32_t));
    esp_ble_gap_set_security_param(ESP_BLE_SM_AUTHEN_REQ_MODE, &auth_req, sizeof(uint8_t));
    esp_ble_gap_set_security_param(ESP_BLE_SM_IOCAP_MODE, &iocap, sizeof(uint8_t));
    esp_ble_gap_set_security_param(ESP_BLE_SM_MAX_KEY_SIZE, &key_size, sizeof(uint8_t));
    esp_ble_gap_set_security_param(ESP_BLE_SM_ONLY_ACCEPT_SPECIFIED_SEC_AUTH, &auth_option, sizeof(uint8_t));
    esp_ble_gap_set_security_param(ESP_BLE_SM_OOB_SUPPORT, &oob_support, sizeof(uint8_t));

    /** 
     *  If your BLE device acts as a Slave: 
     *  @param init_key means you hope which types of key of the master should distribute to you.
     *  @param rsp_key  means which key you can distribute to the master.
     * 
     *  If your BLE device acts as a Master:
     *  @param init_key means which key you can distribute to the slave.
     *  @param rsp_key  means you hope which types of key of the slave should distribute to you.
     */
    esp_ble_gap_set_security_param(ESP_BLE_SM_SET_INIT_KEY, &init_key, sizeof(uint8_t));
    esp_ble_gap_set_security_param(ESP_BLE_SM_SET_RSP_KEY, &rsp_key, sizeof(uint8_t));

    gaps_init();

    return;
}
The rest of the code it's similar to the BLE GATTS server example.

Here is what I have at the LOG:

Code: Select all

W (1984) gaps_init: device name: ESP_BLE_WROVER
W (1984) BT_BTM: BTM_BleWriteAdvData, Partial data write into ADV
W (1994) BT_BTM: BTM_BleWriteScanRsp, Partial data write into ADV
I (2014) gap_event_handler: ESP_GAP_BLE_ADV_START_COMPLETE_EVT
I (380504) gatts_profile_a_event_handler: reg.app_id: 6530
I (380504) gatts_profile_a_event_handler: ESP_GATTS_CONNECT_EVT, conn_id 0, remote 4c:d8:82:19:9e:f0

I (380514) gatts_profile_b_event_handler: reg.app_id: 6530
I (380514) gatts_profile_b_event_handler: ESP_GATTS_CONNECT_EVT
I (380524) gatts_profile_b_event_handler: 
ESP_GATTS_CONNECT_EVT, conn_id 0, remote 4c:d8:82:19:9e:f0:

W (380544) BT_SMP: Non bonding: No keys will be exchanged
W (380544) BT_L2CAP: l2cble_start_conn_update, the last connection update command still pending.
E (380554) BT_APPL: earlier enc was not done for same device

I (380904) gap_event_handler: ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT
I (380904) gap_event_handler: update connetion params status = 0, min_int = 16, max_int = 32,conn_int = 24,latency = 0, timeout = 1000
I (381904) gap_event_handler: ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT
I (381904) gap_event_handler: update connetion params status = 16, min_int = 16, max_int = 32,conn_int = 24,latency = 0, timeout = 1000
I (383564) gap_event_handler: The passkey Notify number:654321
W (392494) BT_SMP: FOR LE SC LTK IS USED INSTEAD OF STK
I (392674) gap_event_handler: key type = ESP_LE_KEY_LENC
I (392674) gap_event_handler: key type = ESP_LE_KEY_PENC
I (392674) gap_event_handler: remote BD_ADDR: 4cd882199ef0
I (392684) gap_event_handler: address type = 1
I (392694) gap_event_handler: pair status = success
I (392694) gap_event_handler: auth mode = ESP_LE_AUTH_REQ_SC_MITM
I (392704) show_bonded_devices: Bonded devices number : 0
I (392704) show_bonded_devices: Bonded devices list : 0
What caught my attention was:

Code: Select all

W (1984) BT_BTM: BTM_BleWriteAdvData, Partial data write into ADV
W (1994) BT_BTM: BTM_BleWriteScanRsp, Partial data write into ADV
I have no clue of what that could mean. I would appreciate if anybody can explain me this.

And also this:

Code: Select all

W (380544) BT_SMP: Non bonding: No keys will be exchanged
W (380544) BT_L2CAP: l2cble_start_conn_update, the last connection update command still pending.
E (380554) BT_APPL: earlier enc was not done for same device
I tried connecting with my phone, then leaving the room (so I force disconnect) and when back I wasn't able to connect back, even when writing the password again I couldn't connect to the ESP until I force restart the device.

This is what I could get from the LOG:

Code: Select all

I (37134) gap_event_handler: remote BD_ADDR: 455c8273bc02
I (37134) gap_event_handler: address type = 1
I (37134) gap_event_handler: pair status = fail
I (37134) gap_event_handler: fail reason = 0x63
I (37144) show_bonded_devices: Bonded devices number : 0
I (37144) show_bonded_devices: Bonded devices list : 0

W (40134) BT_BTM: btm_sec_clr_temp_auth_service() - no dev CB

I (40134) gatts_profile_a_event_handler: reg.app_id: 29570
I (40134) gatts_profile_b_event_handler: reg.app_id: 29570
I (40154) gap_event_handler: ESP_GAP_BLE_ADV_START_COMPLETE_EVT
I (40164) gap_event_handler: ESP_GAP_BLE_ADV_START_COMPLETE_EVT
E (40174) BT_BTM: Device not found

So I have my doubts on the security params. If somebody sees any mistake on the password configuration.

Here I leave the gap_event_handler since is in charge of the setting with the peer device (phone):

Code: Select all

void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) 
{
    /* GAP events meaning
     * 0:   When advertising data set complete, the event comes
     * 1:   When scan response data set complete, the event comes
     * 2:   When scan parameters set complete, the event comes
     * 3:   When one scan result ready, the event comes each time
     * 4:   When raw advertising data set complete, the event comes
     * 5:   When raw advertising data set complete, the event comes
     * 6:   When starting advertising complete, the event comes
     * 7:   When starting scan complete, the event comes
     * 8:   Authentication complete indication.
     * 9:   BLE  key event for peer device keys
     * 10:  BLE  security request
     * 11:  passkey notification event
     * 12:  passkey request event
     * 13:  OOB request event
     * 14:  BLE local IR event
     * 15:  BLE local ER event
     * 16:  Numeric Comparison request event
     * 17:  When stopping adv complete, the event comes
     * 18:  When stopping scan complete, the event comes
     * 19:  When setting the rand address complete, the event comes
     * 20:  When updating connection parameters complete, the event comes
     * 21:  When setting pkt length complete, the event comes
     * 22:  When enabling/disabling privacy on the local device complete, the event comes
     * 23:  When removing the bond device complete, the event comes
     * 24:  When clearing the bond device clear complete, the event comes
     * 25:  When getting the bond device list complete, the event comes
     * 26:  When reading the rssi complete, the event comes
     * 27:  When adding or removing whitelist complete, the event comes
     * 28:  When updating duplicate exceptional list complete, the event comes
     * 29:  When setting BLE channels complete, the event comes
     * 30:  GAP event max (?)
     */
	switch (event) 
    {
        case ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT: // When advertising data set complete, the event comes
        {    
            adv_config_done &= (~ADV_CONFIG_FLAG);
            if (adv_config_done == 0)
            {
                esp_ble_gap_start_advertising(&ble_adv_params);
            }
            break;
        }
        case ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT:    // When scan response data set complete, the event comes
        {    
            adv_config_done &= (~SCAN_RSP_CONFIG_FLAG);
            if (adv_config_done == 0)
            {
                esp_ble_gap_start_advertising(&ble_adv_params);
            }
            break;
        }
        case ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT:    // When scan parameters set complete, the event comes
        {
            ESP_LOGI(__func__, "ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT");
            break;
        }
        case ESP_GAP_BLE_SCAN_RESULT_EVT:    // When one scan result ready, the event comes each time
        {
            ESP_LOGI(__func__, "ESP_GAP_BLE_SCAN_RESULT_EVT");
            break;
        }
        case ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT:    // When raw advertising data set complete, the event comes
        {
            ESP_LOGI(__func__, "ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT");
            break;
        }
        case ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT:    // When raw advertising data set complete, the event comes
        {
            ESP_LOGI(__func__, "ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT");
            break;
        }
        case ESP_GAP_BLE_ADV_START_COMPLETE_EVT:    //  When starting advertising complete, the event comes
        {
            ESP_LOGI(__func__, "ESP_GAP_BLE_ADV_START_COMPLETE_EVT");
            //advertising start complete event to indicate advertising start successfully or failed
            if (param->adv_start_cmpl.status != ESP_BT_STATUS_SUCCESS) 
            {
                ESP_LOGE(__func__, "Advertising start failed\n");
            }
            break;
        }
        case ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT: // 
        {
            ESP_LOGI(__func__, "ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT");
            if (param->adv_stop_cmpl.status != ESP_BT_STATUS_SUCCESS) 
            {
                ESP_LOGE(__func__, "Advertising stop failed\n");
            } 
            else 
            {
                ESP_LOGI(__func__, "Stop adv successfully\n");
            }
            break;
        }
        case ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT:
        {
            ESP_LOGI(__func__, "ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT");
            ESP_LOGI(__func__, "update connetion params status = %d, min_int = %d, max_int = %d,conn_int = %d,latency = %d, timeout = %d",
                    param->update_conn_params.status,
                    param->update_conn_params.min_int,
                    param->update_conn_params.max_int,
                    param->update_conn_params.conn_int,
                    param->update_conn_params.latency,
                    param->update_conn_params.timeout);
            break;
        }
        //-----------------------------------------------------------------------------------------
        case ESP_GAP_BLE_PASSKEY_REQ_EVT:                           // passkey request event
        {
            ESP_LOGI(__func__, "ESP_GAP_BLE_PASSKEY_REQ_EVT");
            // Call the following function to input the passkey which is displayed on the remote device
            //esp_ble_passkey_reply(heart_rate_profile_tab[HEART_PROFILE_APP_IDX].remote_bda, true, 0x00);
            esp_ble_passkey_reply(param->ble_security.auth_cmpl.bd_addr, true, 0x00);
            break;
        }
        case ESP_GAP_BLE_OOB_REQ_EVT: 
        {
            ESP_LOGI(__func__, "ESP_GAP_BLE_OOB_REQ_EVT");
            uint8_t tk[16] = {1}; //If you paired with OOB, both devices need to use the same tk
            esp_ble_oob_req_reply(param->ble_security.ble_req.bd_addr, tk, sizeof(tk));
            break;
        }
        case ESP_GAP_BLE_LOCAL_IR_EVT:                               // BLE local IR event
        {    
            ESP_LOGI(__func__, "ESP_GAP_BLE_LOCAL_IR_EVT");
            break;
        }
        case ESP_GAP_BLE_LOCAL_ER_EVT:                               // BLE local ER event
        {    
            ESP_LOGI(__func__, "ESP_GAP_BLE_LOCAL_ER_EVT");
            break;
        }
        case ESP_GAP_BLE_NC_REQ_EVT:
        {    
            // The app will receive this evt when the IO has DisplayYesNO capability and the peer device IO also has DisplayYesNo capability.
            // show the passkey number to the user to confirm it with the number displayed by peer device.
            esp_ble_confirm_reply(param->ble_security.ble_req.bd_addr, true);
            ESP_LOGI(__func__, "ESP_GAP_BLE_NC_REQ_EVT, the passkey Notify number:%d", param->ble_security.key_notif.passkey);
            break;
        }
        case ESP_GAP_BLE_SEC_REQ_EVT:
        {    
            // send the positive(true) security response to the peer device to accept the security request.
            // If not accept the security request, should send the security response with negative(false) accept value
            esp_ble_gap_security_rsp(param->ble_security.ble_req.bd_addr, true);
            break;
        }
        case ESP_GAP_BLE_PASSKEY_NOTIF_EVT:  ///the app will receive this evt when the IO has Output capability and the peer device IO has Input capability.
        {    
            // Show the passkey number to the user to input it in the peer device.
            ESP_LOGI(__func__, "The passkey Notify number:%06d", param->ble_security.key_notif.passkey);
            break;
        }
        case ESP_GAP_BLE_KEY_EVT:
        {    
            // Shows the ble key info share with peer device to the user.
            ESP_LOGI(__func__, "key type = %s", esp_key_type_to_str(param->ble_security.ble_key.key_type));
            break;
        }
        case ESP_GAP_BLE_AUTH_CMPL_EVT: 
        {
            esp_bd_addr_t bd_addr;
            memcpy(bd_addr, param->ble_security.auth_cmpl.bd_addr, sizeof(esp_bd_addr_t));
            ESP_LOGI(__func__, "remote BD_ADDR: %08x%04x",\
                    (bd_addr[0] << 24) + (bd_addr[1] << 16) + (bd_addr[2] << 8) + bd_addr[3],
                    (bd_addr[4] << 8) + bd_addr[5]);
            ESP_LOGI(__func__, "address type = %d", param->ble_security.auth_cmpl.addr_type);
            ESP_LOGI(__func__, "pair status = %s",param->ble_security.auth_cmpl.success ? "success" : "fail");
            if(!param->ble_security.auth_cmpl.success) {
                ESP_LOGI(__func__, "fail reason = 0x%x",param->ble_security.auth_cmpl.fail_reason);
            } else {
                ESP_LOGI(__func__, "auth mode = %s",esp_auth_req_to_str(param->ble_security.auth_cmpl.auth_mode));
            }
            show_bonded_devices();
            break;
        }
        case ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT: 
        {
            ESP_LOGD(__func__, "ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT status = %d", param->remove_bond_dev_cmpl.status);
            ESP_LOGI(__func__, "ESP_GAP_BLE_REMOVE_BOND_DEV");
            ESP_LOGI(__func__, "-----ESP_GAP_BLE_REMOVE_BOND_DEV----");
            esp_log_buffer_hex(__func__, (void *)param->remove_bond_dev_cmpl.bd_addr, sizeof(esp_bd_addr_t));
            ESP_LOGI(__func__, "------------------------------------");
            break;
        }
        case ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT:
        default:
            break;
	}
}
Any help would be appreciated.

Best regards,
P

PS: I also have problems with the password, since the code input starts with the "password" it will connect. i.e.: "65432111" would work for a "654321" password.

[UPDATE]:
I activated the verbose of BTM, L2CAP, APPL, SMP and GAP and here is more info about the warnings I'm concerned:

Regarding the BTM:

Code: Select all

D (2834) BT_APPL: BTA got event 0x116

D (2834) BT_APPL: bta_dm_sm_execute event:0x16
D (2844) BT_SMP: static passkey 654321
W (2844) gaps_init: device name: ESP-B6D85C
D (2854) BT_APPL: BTA got event 0x102

D (2854) BT_APPL: bta_dm_sm_execute event:0x2
D (2864) BT_APPL: BTA got event 0x128

D (2864) BT_APPL: bta_dm_sm_execute event:0x28
D (2864) BT_BTM: BTM_BleWriteAdvData 
D (2874) BT_BTM:  btm_ble_build_adv_data
D (2874) BT_BTM: cp_len = 2
,p_data->p_manu->len=2

D (2884) BT_BTM: p_data->p_manu->p_val[0] = ff

D (2884) BT_BTM: p_data->p_manu->p_val[1] = ff

D (2894) BT_BTM: p_addr = 0x3ffc3b75
,p_data->p_manu->p_val = 0x3ffbdaf4

W (2894) BT_BTM: BTM_BleWriteAdvData, Partial data write into ADV
D (2904) BT_APPL: BTA got event 0x12a

D (2904) BT_APPL: bta_dm_sm_execute event:0x2a
D (2914) BT_BTM:  BTM_BleWriteScanRsp
D (2914) BT_BTM:  btm_ble_build_adv_data
D (2924) BT_BTM: cp_len = 2
,p_data->p_manu->len=2

D (2924) BT_BTM: p_data->p_manu->p_val[0] = ff

D (2924) BT_BTM: p_data->p_manu->p_val[1] = ff

D (2934) BT_BTM: p_addr = 0x3ffc9539
,p_data->p_manu->p_val = 0x3ffcc56c

W (2944) BT_BTM: BTM_BleWriteScanRsp, Partial data write into ADV
I (2954) BT_APPL: BTA_DmSetBleAdvParamsAll: 32, 64

I (2954) BT_APPL: adv_type = 0, addr_type_own = 0, chnl_map = 7, adv_fil_pol = 0

D (2964) BT_APPL: BTA got event 0x127

D (2964) BT_APPL: bta_dm_sm_execute event:0x27
D (2974) BT_BTM: BTM_BleSetAdvParamsAll

D (2974) BT_BTM: update params for an active adv

D (2984) BT_APPL: bta_dm_ble_set_adv_params_all(), success to set ble adv params.
D (2994) BT_BTM: btm_ble_start_adv

D (2994) BT_BTM: BTM_SUCCESS

I (2994) gap_event_handler: ESP_GAP_BLE_ADV_START_COMPLETE_EVT

Regarding L2CAP, APPL and SMP:

Code: Select all

ESP_GATTS_CONNECT_EVT, conn_id 0, remote 4c:33:71:a8:cf:02:

D (16814) BT_APPL: BTA got event 0x120

D (16824) BT_APPL: bta_dm_sm_execute event:0x20
D (16824) BT_L2CAP: l2c_link_check_send_pkts
D (16834) BT_L2CAP: partial_segment_being_sent=0,link_state=4,power_mode=0
D (16834) BT_L2CAP: l2c_link_send_to_lower
D (16844) BT_L2CAP: TotalWin=9,Hndl=0x0,Quota=10,Unack=1,RRQuota=0,RRUnack=0
D (16854) BT_GAP: GAP_BleAttrDBUpdate attr_uuid=0x2a04

D (16854) BT_L2CAP: l2c_link_check_send_pkts
D (16854) BT_L2CAP: partial_segment_being_sent=0,link_state=4,power_mode=0
D (16864) BT_L2CAP: TotalWin=10,LinkUnack(0x0)=0,RRCheck=0,RRUnack=0

D (16874) BT_L2CAP: l2cble_process_data_length_change_event TX data len = 251
I (16884) BT_APPL: BTA_DmSetEncryption
D (16884) BT_APPL: BTA got event 0x10e

D (16884) BT_APPL: bta_dm_sm_execute event:0xe
D (16894) BT_APPL: bta_dm_set_encryption

D (16894) BT_SMP: smp_encrypt_data

D (16904) BT_SMP: smp_encrypt_data

D (16904) BT_SMP: SMP_Pair state=0 br_state=0 flag=0x0 

I (16914) BT_L2CAP: L2CA_ConnectFixedChnl() CID: 0x0006  BDA: 4c3371a8cf02
D (16914) BT_L2CAP: l2cu_allocate_ccb: cid 0x0000
D (16924) BT_L2CAP: l2c_link_adjust_chnl_allocation
D (16924) BT_L2CAP: CID:0x0004 FCR Mode:0 Priority:2 TxDataRate:1 RxDataRate:1 Quota:20
D (16934) BT_SMP: SMDBG l2c smp_connect_callback

D (16944) BT_SMP: smp_connect_callback()  for pairing BDA: 4c3371a8cf02  Event: connected

D (16944) BT_SMP: main smp_sm_event

D (16954) BT_SMP: SMP Role: Slave State: [SMP_STATE_IDLE (0)], Event: [L2CAP_CONN_EVT (18)]
D (16964) BT_SMP: State change: SMP_STATE_IDLE(0) ==> SMP_STATE_WAIT_APP_RSP(1)
D (16964) BT_SMP: smp_send_app_cback p_cb->cb_evt=1

D (16974) BT_SMP: io_cap = 4
D (16974) BT_SMP: smp_encrypt_data

D (16984) BT_APPL: io mitm: 13 oob_data:0

D (16984) BT_SMP: callback_rc=0  p_cb->cb_evt=1

D (16984) BT_SMP: rcvd auth_req: 0x0d, io_cap: 0                         loc_oob_flag: 0 loc_enc_size: 16,local_i_key: 0x03, local_r_key: 0x03

D (17004) BT_SMP: lmp_version_below LMP version 9 < 8
D (17004) BT_SMP: set auth_req: 0x0d, local_i_key: 0x03, local_r_key: 0x03

D (17014) BT_SMP: main smp_sm_event

D (17014) BT_SMP: SMP Role: Slave State: [SMP_STATE_WAIT_APP_RSP (1)], Event: [API_IO_RSP_EVT (20)]
D (17024) BT_SMP: State change: SMP_STATE_WAIT_APP_RSP(1) ==> SMP_STATE_PAIR_REQ_RSP(3)
D (17034) BT_SMP: smp_process_io_response

D (17034) BT_SMP: State change: SMP_STATE_PAIR_REQ_RSP(3) ==> SMP_STATE_SEC_REQ_PENDING(2)
D (17044) BT_SMP: smp_send_cmd on l2cap cmd_code=0xb

D (17054) BT_SMP: smp_build_security_request

D (17054) BT_SMP: opcode=11 auth_req=0xd
D (17064) BT_SMP: smp_send_msg_to_L2CAP
I (17064) BT_L2CAP: L2CA_SendFixedChnlData()  CID: 0x0006  BDA: 4c3371a8cf02
D (17074) BT_L2CAP: l2c_link_check_send_pkts
D (17074) BT_L2CAP: partial_segment_being_sent=0,link_state=4,power_mode=0
D (17084) BT_L2CAP: l2c_link_send_to_lower
D (17084) BT_L2CAP: TotalWin=9,Hndl=0x0,Quota=10,Unack=1,RRQuota=0,RRUnack=0
D (17094) BT_SMP: result state = SMP_STATE_SEC_REQ_PENDING

D (17104) BT_SMP: smp_send_app_cback return

D (17104) BT_SMP: result state = SMP_STATE_SEC_REQ_PENDING

D (17114) BT_L2CAP: L2CAP - rcv_cid CID: 0x0005

D (17114) BT_APPL: BTA got event 0x120

D (17124) BT_APPL: bta_dm_sm_execute event:0x20
W (17124) BT_L2CAP: l2cble_start_conn_update, the last connection update command still pending.
D (17134) BT_GAP: GAP_BleAttrDBUpdate attr_uuid=0x2a04

I (17134) BT_APPL: BTA_DmSetEncryption
D (17144) BT_APPL: BTA got event 0x10e

D (17144) BT_APPL: bta_dm_sm_execute event:0xe
D (17154) BT_APPL: bta_dm_set_encryption

E (17154) BT_APPL: earlier enc was not done for same device

D (17204) BT_L2CAP: l2c_link_check_send_pkts
D (17204) BT_L2CAP: partial_segment_being_sent=0,link_state=4,power_mode=0
D (17204) BT_L2CAP: TotalWin=10,LinkUnack(0x0)=0,RRCheck=0,RRUnack=0

D (17524) BT_L2CAP: l2c_link_check_send_pkts
D (17524) BT_L2CAP: partial_segment_being_sent=0,link_state=4,power_mode=0
D (17524) BT_L2CAP: l2c_link_send_to_lower
D (17524) BT_L2CAP: TotalWin=9,Hndl=0x0,Quota=10,Unack=1,RRQuota=0,RRUnack=0
D (17534) BT_L2CAP: l2cble_process_conn_update_evt: conn_update_mask=12
I (17534) gap_event_handler: ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT
I (17544) gap_event_handler: update connetion params status = 0, min_int = 16, max_int = 32,conn_int = 24,latency = 0, timeout = 1000
D (17594) BT_L2CAP: l2c_link_check_send_pkts
D (17594) BT_L2CAP: partial_segment_being_sent=0,link_state=4,power_mode=0
D (17594) BT_L2CAP: TotalWin=10,LinkUnack(0x0)=0,RRCheck=0,RRUnack=0

D (17604) BT_L2CAP: L2CAP - rcv_cid CID: 0x0005

I (18534) gap_event_handler: ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT


Who is online

Users browsing this forum: No registered users and 31 guests