完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
有那位可以帮帮忙? 谢谢。
1) 构建后的输出 build and flash giving output : E (356) EDDYSTONE_DEMO: app_main set prefered default phy failed: ESP_ERR_INVALID_STATE 问题在哪里? 2) 把 esp_ble_gap_set_prefered_default_phy( ESP_BLE_GAP_PHY_CODED_PREF_MASK, ESP_BLE_GAP_PHY_1M_PREF_MASK) 这样用法对吗? 有案例我可以参考吗? #include #include #include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_system.h" #include "esp_log.h" #include "nvs_flash.h" #include "esp_bt.h" #include "esp_gap_ble_api.h" #include "esp_gatts_api.h" #include "esp_bt_defs.h" #include "esp_bt_main.h" #include "esp_gatt_common_api.h" #include "sdkconfig.h" #define LOG_TAG "EDDYSTONE_DEMO" #define NAME "test4" #define ESP_BLE_GAP_PHY_CODED_PREF_MASK (1 << 2) #define ESP_BLE_GAP_PHY_1M_PREF_MASK (1 << 0) uint8_t addr_coded_eddystone[6] = {0xc0, 0xde, 0x52, 0x00, 0x00, 0x01}; static esp_ble_adv_params_t adv_params_coded_eddystone = { .adv_int_min = 0x30, .adv_int_max = 0x40, .adv_type = ADV_TYPE_NONCONN_IND, .own_addr_type = BLE_ADDR_TYPE_RANDOM, .channel_map = ADV_CHNL_ALL, .adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY, }; static uint8_t eddystone_data[] = { /* flags */ 0x02, 0x01, 0x06, /* service type*/ 0x03, 0x03, 0xAA, 0xFE, /* service data */ 0x13, 0x16, 0xAA, 0xFE, 0x10, 0xF8, 0x03,'g','o','o','.','g','l','/','a','0','m','n','s','S' }; static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) { switch (event) { case ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT: ESP_LOGI(LOG_TAG, "ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT, status %d", param->set_rand_addr_cmpl.status); break; case ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT: ESP_LOGI(LOG_TAG, "ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT, status %d", param->adv_data_raw_cmpl.status); esp_ble_gap_start_advertising(&adv_params_coded_eddystone); break; case ESP_GAP_BLE_ADV_START_COMPLETE_EVT: ESP_LOGI(LOG_TAG, "ESP_GAP_BLE_ADV_START_COMPLETE_EVT, status %d", param->adv_start_cmpl.status); break; case ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT: ESP_LOGI(LOG_TAG, "ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT, status %d", param->adv_stop_cmpl.status); break; default: break; } } void app_main(void) { esp_err_t ret; ret = esp_ble_gap_set_prefered_default_phy( ESP_BLE_GAP_PHY_CODED_PREF_MASK, ESP_BLE_GAP_PHY_1M_PREF_MASK); if (ret) { ESP_LOGE(LOG_TAG, "%s set prefered default phy failed: %sn", __func__, esp_err_to_name(ret)); return; } // Initialize NVS. 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 ); /* */ ESP_ERROR_CHECK(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(LOG_TAG, "%s initialize controller failed: %sn", __func__, esp_err_to_name(ret)); return; } ret = esp_bt_controller_enable(ESP_BT_MODE_BLE); if (ret) { ESP_LOGE(LOG_TAG, "%s enable controller failed: %sn", __func__, esp_err_to_name(ret)); return; } ret = esp_bluedroid_init(); if (ret) { ESP_LOGE(LOG_TAG, "%s init bluetooth failed: %sn", __func__, esp_err_to_name(ret)); return; } ret = esp_bluedroid_enable(); if (ret) { ESP_LOGE(LOG_TAG, "%s enable bluetooth failed: %sn", __func__, esp_err_to_name(ret)); return; } ret = esp_ble_gap_set_device_name(NAME); if (ret) { ESP_LOGE(LOG_TAG, "%s name device failed: %sn", __func__, esp_err_to_name(ret)); return; } ret = esp_ble_gap_register_callback(gap_event_handler); if (ret){ ESP_LOGE(LOG_TAG, "gap register error, error code = %x", ret); return; } vTaskDelay(200 / portTICK_PERIOD_MS); ret = esp_ble_gap_set_rand_addr(addr_coded_eddystone); if (ret) { ESP_LOGE(LOG_TAG, "%s set random address failed: %sn", __func__, esp_err_to_name(ret)); return; } ret = esp_ble_gap_config_adv_data_raw(eddystone_data, sizeof(eddystone_data)); if (ret) { ESP_LOGE(LOG_TAG, "%s config raw adv data failed: %sn", __func__, esp_err_to_name(ret)); return; } return; } ============================================================================================================== 构建后的输出 after build & flash, (see below) : E (356) EDDYSTONE_DEMO: app_main set prefered default phy failed: ESP_ERR_INVALID_STATE |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
544浏览 6评论
457浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
435浏览 5评论
441浏览 4评论
410浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-20 13:39 , Processed in 0.584543 second(s), Total 45, Slave 39 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号