From 8fed003ce52bb00734aaf1e46fd4d0ef8eca2e0c Mon Sep 17 00:00:00 2001 From: Tian Hao Date: Wed, 16 Nov 2016 11:28:41 +0800 Subject: [PATCH] component/bt : main api 1. use blufi check main api ok --- components/bt/bluedroid/api/esp_bt_main.c | 26 +++++++++++++++++++ .../bt/bluedroid/api/include/esp_bt_main.h | 16 ++++++++++++ components/bt/bluedroid/btc/core/btc_main.c | 2 +- examples/07_blufi/components/blufi/blufi.c | 1 + examples/07_blufi/main/demo_main.c | 3 ++- 5 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 components/bt/bluedroid/api/esp_bt_main.c create mode 100644 components/bt/bluedroid/api/include/esp_bt_main.h diff --git a/components/bt/bluedroid/api/esp_bt_main.c b/components/bt/bluedroid/api/esp_bt_main.c new file mode 100644 index 0000000000..9e2fbe545b --- /dev/null +++ b/components/bt/bluedroid/api/esp_bt_main.c @@ -0,0 +1,26 @@ +#include "esp_bt_main.h" + + + +esp_err_t esp_enable_bluetooth(esp_bt_sec_cb_t *p_cback) +{ + return btc_enable_bluetooth(p_cback) == BT_STATUS_SUCCESS ? ESP_OK: ESP_FAIL; +} + +esp_err_t esp_disable_bluetooth(void) +{ + return btc_disable_bluetooth() == BT_STATUS_SUCCESS ? ESP_OK: ESP_FAIL; +} + +esp_err_t esp_init_bluetooth(bluetooth_init_cb_t cb) +{ + return btc_init_bluetooth(cb) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL; +} + + +void esp_deinit_bluetooth(void) +{ + btc_deinit_bluetooth(); +} + + diff --git a/components/bt/bluedroid/api/include/esp_bt_main.h b/components/bt/bluedroid/api/include/esp_bt_main.h new file mode 100644 index 0000000000..247fbaa301 --- /dev/null +++ b/components/bt/bluedroid/api/include/esp_bt_main.h @@ -0,0 +1,16 @@ +#ifndef __ESP_BT_MAIN_H__ +#define __ESP_BT_MAIN_H__ + +#include "btc_main.h" +#include "esp_err.h" + +esp_err_t esp_enable_bluetooth(esp_bt_sec_cb_t *p_cback); + +esp_err_t esp_disable_bluetooth(void); + +esp_err_t esp_init_bluetooth(bluetooth_init_cb_t cb); + +void esp_deinit_bluetooth(void); + + +#endif /* __ESP_BT_MAIN_H__ */ diff --git a/components/bt/bluedroid/btc/core/btc_main.c b/components/bt/bluedroid/btc/core/btc_main.c index 08a2ff0119..e2c6d57653 100644 --- a/components/bt/bluedroid/btc/core/btc_main.c +++ b/components/bt/bluedroid/btc/core/btc_main.c @@ -16,7 +16,7 @@ bt_status_t btc_disable_bluetooth(void) bt_status_t btc_init_bluetooth(bluetooth_init_cb_t cb) { - return bte_main_boot_entry(cb) == 0 ? ESP_OK : ESP_FAIL; + return bte_main_boot_entry(cb) == 0 ? BT_STATUS_SUCCESS : BT_STATUS_FAIL; } diff --git a/examples/07_blufi/components/blufi/blufi.c b/examples/07_blufi/components/blufi/blufi.c index 39c5a0aae4..2ebe8bccda 100644 --- a/examples/07_blufi/components/blufi/blufi.c +++ b/examples/07_blufi/components/blufi/blufi.c @@ -41,6 +41,7 @@ #include "blufi_adv.h" #include "esp_bt_defs.h" +#include "esp_bt_main.h" static void BlufiDataCallBack(UINT8 app_id, UINT8 event, UINT8 len, UINT8 *p_data); diff --git a/examples/07_blufi/main/demo_main.c b/examples/07_blufi/main/demo_main.c index 3aeea617a9..6f49ac5ca7 100644 --- a/examples/07_blufi/main/demo_main.c +++ b/examples/07_blufi/main/demo_main.c @@ -26,7 +26,8 @@ #include "bt.h" #include "bta_api.h" -#include "esp_bt_common.h" +#include "esp_bt_defs.h" +#include "esp_bt_main.h" #include "blufi.h" #define WIFI_LIST_NUM 10 -- 2.40.0