From 37269dbbca2419cb701b7b092f9f378de7e127e2 Mon Sep 17 00:00:00 2001 From: wangmengyang Date: Tue, 11 Sep 2018 11:18:13 +0800 Subject: [PATCH 1/2] component/bt: bugfix for mismatch of controller mode in sdkconfig.defaults and source code in some examples --- examples/bluetooth/a2dp_source/main/main.c | 2 +- .../bluetooth/ble_hid_device_demo/main/ble_hidd_demo_main.c | 2 +- examples/bluetooth/bt_discovery/main/bt_discovery.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/bluetooth/a2dp_source/main/main.c b/examples/bluetooth/a2dp_source/main/main.c index d87188835..0e87478b8 100644 --- a/examples/bluetooth/a2dp_source/main/main.c +++ b/examples/bluetooth/a2dp_source/main/main.c @@ -113,7 +113,7 @@ void app_main() return; } - if (esp_bt_controller_enable(ESP_BT_MODE_BTDM) != ESP_OK) { + if (esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT) != ESP_OK) { ESP_LOGE(BT_AV_TAG, "%s enable controller failed\n", __func__); return; } diff --git a/examples/bluetooth/ble_hid_device_demo/main/ble_hidd_demo_main.c b/examples/bluetooth/ble_hid_device_demo/main/ble_hidd_demo_main.c index 3094f6bc7..12c9483e3 100644 --- a/examples/bluetooth/ble_hid_device_demo/main/ble_hidd_demo_main.c +++ b/examples/bluetooth/ble_hid_device_demo/main/ble_hidd_demo_main.c @@ -278,7 +278,7 @@ void app_main() return; } - ret = esp_bt_controller_enable(ESP_BT_MODE_BTDM); + ret = esp_bt_controller_enable(ESP_BT_MODE_BLE); if (ret) { ESP_LOGE(HID_DEMO_TAG, "%s enable controller failed\n", __func__); return; diff --git a/examples/bluetooth/bt_discovery/main/bt_discovery.c b/examples/bluetooth/bt_discovery/main/bt_discovery.c index ef2b11ef5..20c072611 100644 --- a/examples/bluetooth/bt_discovery/main/bt_discovery.c +++ b/examples/bluetooth/bt_discovery/main/bt_discovery.c @@ -285,7 +285,7 @@ void app_main() return; } - if ((ret = esp_bt_controller_enable(ESP_BT_MODE_BTDM)) != ESP_OK) { + if ((ret = esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT)) != ESP_OK) { ESP_LOGE(GAP_TAG, "%s enable controller failed: %s\n", __func__, esp_err_to_name(ret)); return; } From ee7a73e5a7f36f2f98e3fcf2b89a0032ee1aab0e Mon Sep 17 00:00:00 2001 From: wangmengyang Date: Tue, 11 Sep 2018 11:20:30 +0800 Subject: [PATCH 2/2] component/bt: release some controller memory according to the configuration of bluetooth examples --- examples/bluetooth/a2dp_source/main/main.c | 2 ++ .../bluetooth/ble_hid_device_demo/main/ble_hidd_demo_main.c | 2 ++ examples/bluetooth/bt_discovery/main/bt_discovery.c | 2 ++ .../bluetooth/bt_spp_acceptor/main/example_spp_acceptor_demo.c | 1 + .../bt_spp_initiator/main/example_spp_initiator_demo.c | 1 + .../bt_spp_vfs_acceptor/main/example_spp_vfs_acceptor_demo.c | 2 ++ .../bt_spp_vfs_initiator/main/example_spp_vfs_initiator_demo.c | 1 + 7 files changed, 11 insertions(+) diff --git a/examples/bluetooth/a2dp_source/main/main.c b/examples/bluetooth/a2dp_source/main/main.c index 0e87478b8..174448c10 100644 --- a/examples/bluetooth/a2dp_source/main/main.c +++ b/examples/bluetooth/a2dp_source/main/main.c @@ -106,6 +106,8 @@ void app_main() } ESP_ERROR_CHECK( ret ); + ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_BLE)); + esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); if (esp_bt_controller_init(&bt_cfg) != ESP_OK) { diff --git a/examples/bluetooth/ble_hid_device_demo/main/ble_hidd_demo_main.c b/examples/bluetooth/ble_hid_device_demo/main/ble_hidd_demo_main.c index 12c9483e3..2aaa74726 100644 --- a/examples/bluetooth/ble_hid_device_demo/main/ble_hidd_demo_main.c +++ b/examples/bluetooth/ble_hid_device_demo/main/ble_hidd_demo_main.c @@ -271,6 +271,8 @@ void app_main() } 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) { diff --git a/examples/bluetooth/bt_discovery/main/bt_discovery.c b/examples/bluetooth/bt_discovery/main/bt_discovery.c index 20c072611..9fa3a7561 100644 --- a/examples/bluetooth/bt_discovery/main/bt_discovery.c +++ b/examples/bluetooth/bt_discovery/main/bt_discovery.c @@ -279,6 +279,8 @@ void app_main() } ESP_ERROR_CHECK( ret ); + ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_BLE)); + esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); if ((ret = esp_bt_controller_init(&bt_cfg)) != ESP_OK) { ESP_LOGE(GAP_TAG, "%s initialize controller failed: %s\n", __func__, esp_err_to_name(ret)); diff --git a/examples/bluetooth/bt_spp_acceptor/main/example_spp_acceptor_demo.c b/examples/bluetooth/bt_spp_acceptor/main/example_spp_acceptor_demo.c index e6c1cf6be..713e94c85 100644 --- a/examples/bluetooth/bt_spp_acceptor/main/example_spp_acceptor_demo.c +++ b/examples/bluetooth/bt_spp_acceptor/main/example_spp_acceptor_demo.c @@ -159,6 +159,7 @@ void app_main() } ESP_ERROR_CHECK( ret ); + ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_BLE)); esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); if ((ret = esp_bt_controller_init(&bt_cfg)) != ESP_OK) { diff --git a/examples/bluetooth/bt_spp_initiator/main/example_spp_initiator_demo.c b/examples/bluetooth/bt_spp_initiator/main/example_spp_initiator_demo.c index 8ab19b55d..37233ee37 100644 --- a/examples/bluetooth/bt_spp_initiator/main/example_spp_initiator_demo.c +++ b/examples/bluetooth/bt_spp_initiator/main/example_spp_initiator_demo.c @@ -244,6 +244,7 @@ void app_main() } ESP_ERROR_CHECK( ret ); + ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_BLE)); esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); if ((ret = esp_bt_controller_init(&bt_cfg)) != ESP_OK) { diff --git a/examples/bluetooth/bt_spp_vfs_acceptor/main/example_spp_vfs_acceptor_demo.c b/examples/bluetooth/bt_spp_vfs_acceptor/main/example_spp_vfs_acceptor_demo.c index caa978c7b..7ab10dcf6 100644 --- a/examples/bluetooth/bt_spp_vfs_acceptor/main/example_spp_vfs_acceptor_demo.c +++ b/examples/bluetooth/bt_spp_vfs_acceptor/main/example_spp_vfs_acceptor_demo.c @@ -164,6 +164,8 @@ void app_main() } ESP_ERROR_CHECK( ret ); + ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_BLE)); + esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); if (esp_bt_controller_init(&bt_cfg) != ESP_OK) { ESP_LOGE(SPP_TAG, "%s initialize controller failed", __func__); diff --git a/examples/bluetooth/bt_spp_vfs_initiator/main/example_spp_vfs_initiator_demo.c b/examples/bluetooth/bt_spp_vfs_initiator/main/example_spp_vfs_initiator_demo.c index 00462a309..1e309285a 100644 --- a/examples/bluetooth/bt_spp_vfs_initiator/main/example_spp_vfs_initiator_demo.c +++ b/examples/bluetooth/bt_spp_vfs_initiator/main/example_spp_vfs_initiator_demo.c @@ -232,6 +232,7 @@ void app_main() } ESP_ERROR_CHECK( ret ); + ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_BLE)); esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); if (esp_bt_controller_init(&bt_cfg) != ESP_OK) {