完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
esp-idf branch: release/v4.3 commit:06ce378142f91b90f6c0673fa9363e526664eada
example: bluetooth/bluedroid/ble/gatt_client 我的修改: 在esp_gap_cb中ESP_GAP_BLE_SCAN_START_COMPLETE_EVT事件 添加了resp adv中解析蓝牙设备名称的代码,其他无改动 Code: Select all case ESP_GAP_BLE_SCAN_RESULT_EVT: { esp_ble_gap_cb_param_t *scan_result = (esp_ble_gap_cb_param_t *)param; switch (scan_result->scan_rst.search_evt) { case ESP_GAP_SEARCH_INQ_RES_EVT: ESP_LOGI(GATTC_TAG, "----------Device Found-----mac addr-----"); esp_log_buffer_hex(GATTC_TAG, scan_result->scan_rst.bda, 6); ESP_LOGI(GATTC_TAG, "searched Adv Data Len %d, Scan Response Len %d", scan_result->scan_rst.adv_data_len, scan_result->scan_rst.scan_rsp_len); adv_name = esp_ble_resolve_adv_data(scan_result->scan_rst.ble_adv, ESP_BLE_AD_TYPE_NAME_CMPL, &adv_name_len); ESP_LOGI(GATTC_TAG, "searched Device Name Len %d", adv_name_len); ESP_LOGI(GATTC_TAG, "ble name:"); esp_log_buffer_char(GATTC_TAG, adv_name, adv_name_len); #if CONFIG_EXAMPLE_DUMP_ADV_DATA_AND_SCAN_RESP if (scan_result->scan_rst.adv_data_len > 0) { ESP_LOGI(GATTC_TAG, "adv data:"); esp_log_buffer_hex(GATTC_TAG, &scan_result->scan_rst.ble_adv[0], scan_result->scan_rst.adv_data_len); } if (scan_result->scan_rst.scan_rsp_len > 0) { ESP_LOGI(GATTC_TAG, "scan resp:"); esp_log_buffer_hex(GATTC_TAG, &scan_result->scan_rst.ble_adv[scan_result->scan_rst.adv_data_len], scan_result->scan_rst.scan_rsp_len); /* add by aaa*/ adv_name = esp_ble_resolve_adv_data(&scan_result->scan_rst.ble_adv[scan_result->scan_rst.adv_data_len], ESP_BLE_AD_TYPE_NAME_CMPL, &adv_name_len); ESP_LOGI(GATTC_TAG, "11searched Device Name Len %d", adv_name_len); ESP_LOGI(GATTC_TAG, "11ble name:"); esp_log_buffer_char(GATTC_TAG, adv_name, adv_name_len); /* end add by aaa*/ } #endif ESP_LOGI(GATTC_TAG, "n"); if (adv_name != NULL) { if (strlen(remote_device_name) == adv_name_len && strncmp((char *)adv_name, remote_device_name, adv_name_len) == 0) { ESP_LOGI(GATTC_TAG, "searched device %sn", remote_device_name); if (connect == false) { connect = true; ESP_LOGI(GATTC_TAG, "connect to the remote device.1n"); uint8_t ret = esp_ble_gap_stop_scanning(); ESP_LOGI(GATTC_TAG, "esp_ble_gap_stop_scanning ret = %dn",ret); //esp_ble_gattc_open(gl_profile_tab[PROFILE_A_APP_ID].gattc_if, scan_result->scan_rst.bda, scan_result->scan_rst.ble_addr_type, true); } } } ESP_LOGI(GATTC_TAG, "vz end ESP_GAP_BLE_SCAN_RESULT_EVTn"); break; |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
545浏览 6评论
457浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
437浏览 5评论
441浏览 4评论
411浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 06:08 , Processed in 0.872202 second(s), Total 73, Slave 57 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号