--- /dev/null
+#include "esp_bt_defs.h"
+#include "esp_bt_common.h"
+#include "esp_err.h"
+
+extern int bte_main_boot_entry(void *cb);
+extern int bte_main_shutdown(void);
+
+// tBTA_STATUS BTA_EnableBluetooth(tBTA_DM_SEC_CBACK *p_cback)
+esp_err_t esp_enable_bluetooth(esp_bt_sec_cb_t *p_cback)
+{
+ return BTA_EnableBluetooth(p_cback) == BTA_SUCCESS ? ESP_OK : ESP_FAIL;
+}
+
+esp_err_t esp_disable_bluetooth(void)
+{
+ return BTA_DisableBluetooth() == BTA_SUCCESS ? ESP_OK : ESP_FAIL;
+}
+
+esp_err_t esp_init_bluetooth(bluetooth_init_cb_t cb)
+{
+ return bte_main_boot_entry(cb) == 0 ? ESP_OK : ESP_FAIL;
+}
+
+
+void esp_deinit_bluetooth(void)
+{
+ bte_main_shutdown();
+}
+
+
#include <stdint.h>
#include "bt_types.h"
-
+#include "bta_api.h"
+#include "esp_err.h"
typedef tBT_UUID esp_bt_uuid_t; /* tBT_UUID in "bt_types.h" */
typedef BD_ADDR esp_bd_addr_t; /* BD_ADDR in bt_types.h */
+typedef tBTA_DM_SEC_CBACK esp_bt_sec_cb_t;
+
+typedef void (*bluetooth_init_cb_t)(void);
+
+/*******************************************************************************
+**
+** @function esp_enable_bluetooth
+**
+** @brief This function is called to enable bluetooth host. This
+** function must be called before any other functions in the
+** API (except esp_bluetooth_init) are called.
+**
+** @param[in] p_cback:
+** security call back function
+** @param[out] None
+**
+** @return ESP_OK - Success; Other - Failed
+**
+*******************************************************************************/
+esp_err_t esp_enable_bluetooth(esp_bt_sec_cb_t p_cback);
+
+
+/*******************************************************************************
+**
+** @function esp_disable_bluetooth
+**
+** @brief This function is called to disable bluetooth host
+**
+** @param[in] None
+**
+** @param[out] None
+**
+** @return ESP_OK - Success; Other - Failed
+**
+*******************************************************************************/
+esp_err_t esp_disable_bluetooth(void);
+
+/*******************************************************************************
+**
+** @function esp_init_bluetooth
+**
+** @brief This function is called to init bluetooth host and alloc the
+** resource. This function must be called before all othor API
+** are called.
+**
+** @param[in] cb: When this function called success, the callback will be called
+**
+** @param[out] None
+**
+** @return ESP_OK - Success; Other - Failed
+**
+*******************************************************************************/
+esp_err_t esp_init_bluetooth(bluetooth_init_cb_t cb);
+
+/*******************************************************************************
+**
+** @function esp_deinit_bluetooth
+**
+** @brief This function is called to deinit bluetooth host and free the
+** resource.
+**
+** @param[in] None
+**
+** @param[out] None
+**
+** @return ESP_OK - Success; Other - Failed
+**
+*******************************************************************************/
+void esp_deinit_bluetooth(void);
+
#endif /* __ESP_BT_COMMON_H__ */
** Static variables
*******************************************************************************/
static const hci_t *hci;
-static void bte_main_enable(void);
+
/*******************************************************************************
** Static functions
*******************************************************************************/
+static void bte_main_disable(void);
+static void bte_main_enable(void);
/*******************************************************************************
** Externs
** Returns None
**
******************************************************************************/
-void bte_main_boot_entry(bluedroid_init_done_cb_t cb)
+int bte_main_boot_entry(bluedroid_init_done_cb_t cb)
{
- if (gki_init())
+ if (gki_init()) {
LOG_ERROR("%s: Init GKI Module Failure.\n", __func__);
+ return -1;
+ }
hci = hci_layer_get_interface();
- if (!hci)
+ if (!hci) {
LOG_ERROR("%s could not get hci layer interface.\n", __func__);
+ return -2;
+ }
btu_hci_msg_queue = fixed_queue_new(SIZE_MAX);
if (btu_hci_msg_queue == NULL) {
LOG_ERROR("%s unable to allocate hci message queue.\n", __func__);
- return;
+ return -3;
}
bluedroid_init_done_cb = cb;
//Enbale HCI
bte_main_enable();
+
+ return 0;
}
/******************************************************************************
** Returns None
**
******************************************************************************/
-void bte_main_shutdown()
+void bte_main_shutdown(void)
{
//data_dispatcher_register_default(hci_layer_get_interface()->event_dispatcher, NULL);
hci->set_data_queue(NULL);
*/
gki_clean_up();
+
+ bte_main_disable();
}
/******************************************************************************
** Returns None
**
******************************************************************************/
-void bte_main_disable(void)
+static void bte_main_disable(void)
{
/*
APPL_TRACE_DEBUG("%s", __FUNCTION__);
// limitations under the License.
#include "blufi_adv.h"
-
+#include "esp_adv_api.h"
/*******************************************************************************
**
** Returns None
**
*******************************************************************************/
- void BlufiBleConfigadvData(tBLUFI_BLE_ADV_DATA *adv_data,
- tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
+ void BlufiBleConfigadvData(esp_ble_adv_data_cfg_t *adv_data,
+ esp_ble_set_adv_data_cmpl_cb_t *p_adv_data_cback)
{
- tBTA_BLE_AD_MASK data_mask = 0;
- if(adv_data->adv_name != NULL)
- {
- data_mask |= BTM_BLE_AD_BIT_DEV_NAME;
- BTA_DmSetDeviceName(adv_data->adv_name);
- }
- if(adv_data->ble_adv_data.int_range.low != 0 ||
- adv_data->ble_adv_data.int_range.hi != 0)
- data_mask |= BTM_BLE_AD_BIT_INT_RANGE;
-
- if(adv_data->ble_adv_data.p_manu != NULL)
- {
- data_mask |= BTM_BLE_AD_BIT_MANU;
- }
-
- if(adv_data->ble_adv_data.p_services != NULL)
- {
- data_mask |= BTM_BLE_AD_BIT_SERVICE;
- }
-
- if(adv_data->ble_adv_data.p_service_32b != NULL)
- {
- data_mask |= BTM_BLE_AD_BIT_SERVICE_32;
- }
-
- if(adv_data->ble_adv_data.p_services_128b != NULL)
- {
- data_mask |= BTM_BLE_AD_BIT_SERVICE_128;
- }
-
- if(adv_data->ble_adv_data.p_sol_services != NULL)
- {
- data_mask |= BTM_BLE_AD_BIT_SERVICE_SOL;
- }
-
- if(adv_data->ble_adv_data.p_sol_service_32b != NULL)
- {
- data_mask |= BTM_BLE_AD_BIT_SERVICE_32SOL;
- }
-
- if(adv_data->ble_adv_data.p_sol_service_128b != NULL)
- {
- data_mask |= BTM_BLE_AD_BIT_SERVICE_128SOL;
- }
-
- if(adv_data->ble_adv_data.p_service_data != NULL)
- {
- data_mask |= BTM_BLE_AD_BIT_SERVICE_DATA;
- }
-
- if(adv_data->ble_adv_data.appearance != 0)
- {
- data_mask |= BTM_BLE_AD_BIT_APPEARANCE;
- }
-
- if(adv_data->ble_adv_data.p_proprietary != NULL)
- {
- data_mask |= BTM_BLE_AD_BIT_PROPRIETARY;
- }
-
- if(adv_data->ble_adv_data.tx_power != 0)
- {
- data_mask |= BTM_BLE_AD_BIT_TX_PWR;
- }
-
- BTA_DmBleSetAdvConfig(data_mask, &(adv_data->ble_adv_data), p_adv_data_cback);
+ esp_ble_config_adv_data(adv_data, p_adv_data_cback);
}
** Returns None
**
*******************************************************************************/
-void BlufiBleSetScanRsp(tBLUFI_BLE_ADV_DATA *scan_rsp_data,
- tBTA_SET_ADV_DATA_CMPL_CBACK *p_scan_rsp_data_cback)
+void BlufiBleSetScanRsp(esp_ble_adv_data_cfg_t *scan_rsp_data,
+ esp_ble_set_adv_data_cmpl_cb_t *p_scan_rsp_data_cback)
{
- tBTA_BLE_AD_MASK data_mask = 0;
- if(scan_rsp_data->adv_name != NULL)
- {
- data_mask |= BTM_BLE_AD_BIT_DEV_NAME;
- BTA_DmSetDeviceName(scan_rsp_data->adv_name);
- }
- if(scan_rsp_data->ble_adv_data.int_range.low != 0 ||
- scan_rsp_data->ble_adv_data.int_range.hi != 0)
- data_mask |= BTM_BLE_AD_BIT_INT_RANGE;
-
- if(scan_rsp_data->ble_adv_data.p_manu != NULL)
- {
- data_mask |= BTM_BLE_AD_BIT_MANU;
- }
-
- if(scan_rsp_data->ble_adv_data.p_services != NULL)
- {
- data_mask |= BTM_BLE_AD_BIT_SERVICE;
- }
-
- if(scan_rsp_data->ble_adv_data.p_service_32b != NULL)
- {
- data_mask |= BTM_BLE_AD_BIT_SERVICE_32;
- }
-
- if(scan_rsp_data->ble_adv_data.p_services_128b != NULL)
- {
- data_mask |= BTM_BLE_AD_BIT_SERVICE_128;
- }
-
- if(scan_rsp_data->ble_adv_data.p_sol_services != NULL)
- {
- data_mask |= BTM_BLE_AD_BIT_SERVICE_SOL;
- }
-
- if(scan_rsp_data->ble_adv_data.p_sol_service_32b != NULL)
- {
- data_mask |= BTM_BLE_AD_BIT_SERVICE_32SOL;
- }
-
- if(scan_rsp_data->ble_adv_data.p_sol_service_128b != NULL)
- {
- data_mask |= BTM_BLE_AD_BIT_SERVICE_128SOL;
- }
-
- if(scan_rsp_data->ble_adv_data.p_service_data != NULL)
- {
- data_mask |= BTM_BLE_AD_BIT_SERVICE_DATA;
- }
-
- if(scan_rsp_data->ble_adv_data.appearance != 0)
- {
- data_mask |= BTM_BLE_AD_BIT_APPEARANCE;
- }
-
- if(scan_rsp_data->ble_adv_data.p_proprietary != NULL)
- {
- data_mask |= BTM_BLE_AD_BIT_PROPRIETARY;
- }
-
- if(scan_rsp_data->ble_adv_data.tx_power != 0)
- {
- data_mask |= BTM_BLE_AD_BIT_TX_PWR;
- }
-
- BTA_DmBleSetScanRsp(data_mask, &(scan_rsp_data->ble_adv_data), p_scan_rsp_data_cback);
+ esp_ble_set_scan_rsp(scan_rsp_data, p_scan_rsp_data_cback);
}
#include "blufi_prf.h"
#include "blufi_adv.h"
+#include "esp_adv_api.h"
+#include "esp_bt_defs.h"
+#include "esp_gatt_api.h"
+
#define BT_BD_ADDR_STR "%02x:%02x:%02x:%02x:%02x:%02x"
#define BT_BD_ADDR_HEX(addr) addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
tBTA_BLE_MANU p_esp32_manu = {sizeof(esp32_manu),esp32_manu}; /* manufacturer data */
tBTA_BLE_SERVICE esp32_service = {
- 0x01, //only one service in the ijiazu button profile
+ 0x01, //only one service in the blufi profile
false,
&esp32_uuid
}; /* 16 bits services */
-tBLUFI_BLE_ADV_DATA esp32_adv_data[ADV_SCAN_IDX_MAX] =
+esp_ble_adv_data_cfg_t esp32_adv_data[ADV_SCAN_IDX_MAX] =
{
[BLE_ADV_DATA_IDX] = {
.adv_name = "Espressif_008",
}
};
+tBLE_BD_ADDR peer_bda = {
+ .type = API_PUBLIC_ADDR,
+ .bda = {0}
+};
+esp_ble_adv_params_all_t adv_params =
+{
+ .adv_int_min = BTM_BLE_ADV_INT_MIN + 0x100,
+ .adv_int_max = BTM_BLE_ADV_INT_MIN + 0x100,
+ .adv_type = API_NON_DISCOVERABLE,
+ .addr_type_own = API_PUBLIC_ADDR,
+ .channel_map = ESP_BLE_ADV_CHNL_MAP,
+ .adv_filter_policy = ADV_ALLOW_SCAN_ANY_CON_ANY,
+ .p_dir_bda = &peer_bda
+};
static tBLUFI_CB_ENV blufi_cb_env;
/*****************************************************************************
** Constants
*****************************************************************************/
-static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data);
+static void blufi_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data);
/*******************************************************************************
** Returns NULL
**
*******************************************************************************/
-static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
+static void blufi_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data)
{
- tBTA_GATTS_RSP rsp;
- tBT_UUID uuid = {LEN_UUID_16, {SVC_BLUFI_UUID}};
+ esp_gatts_rsp_t rsp;
+ esp_bt_uuid_t uuid = {LEN_UUID_16, {SVC_BLUFI_UUID}};
tBLUFI_INST *p_inst = &blufi_cb_env.blufi_inst;
UINT8 net_event = 0xff;
UINT8 len = 0;
UINT8 *p_rec_data = NULL;
- tBTA_GATT_STATUS status;
+ esp_gatt_status_t status;
LOG_DEBUG("blufi profile cb event = %x\n",event);
switch(event) {
- case BTA_GATTS_REG_EVT:
+ case ESP_GATTS_REG_EVT:
status = p_data->reg_oper.status;
LOG_DEBUG("p_data->reg_oper.status = %x\n",p_data->reg_oper.status);
LOG_DEBUG("(p_data->reg_oper.uuid.uu.uuid16=%x\n",p_data->reg_oper.uuid.uu.uuid16);
- if(p_data->reg_oper.status != BTA_GATT_OK) {
+ if(p_data->reg_oper.status != ESP_GATT_OK) {
LOG_ERROR("blufi profile register failed\n");
return;
}
BlufiBleConfigadvData(&esp32_adv_data[BLE_ADV_DATA_IDX], NULL);
//set the adversting data to the btm layer
BlufiBleSetScanRsp(&esp32_adv_data[BLE_SCAN_RSP_DATA_IDX],NULL);
- BTA_GATTS_Listen(blufi_cb_env.gatt_if, true, NULL);
-
+ esp_ble_start_advertising(&adv_params);
//create the blufi service to the service data base.
if(p_data->reg_oper.uuid.uu.uuid16 == SVC_BLUFI_UUID) {
blufi_create_service();
}
break;
- case BTA_GATTS_READ_EVT:
+ case ESP_GATTS_READ_EVT:
memset(&rsp, 0, sizeof(tBTA_GATTS_API_RSP));
rsp.attr_value.handle = p_data->req_data.p_data->read_req.handle;
rsp.attr_value.len = 2;
//rsp.attr_value.value[1] = 0xed;
//rsp.attr_value.value[2] = 0xbe;
//rsp.attr_value.value[3] = 0xef;
- BTA_GATTS_SendRsp(p_data->req_data.conn_id,p_data->req_data.trans_id,
+ esp_ble_gatts_send_rsp(p_data->req_data.conn_id,p_data->req_data.trans_id,
p_data->req_data.status,&rsp);
break;
- case BTA_GATTS_WRITE_EVT:
- BTA_GATTS_SendRsp(p_data->req_data.conn_id,p_data->req_data.trans_id,
+ case ESP_GATTS_WRITE_EVT:
+ esp_ble_gatts_send_rsp(p_data->req_data.conn_id,p_data->req_data.trans_id,
p_data->req_data.status,NULL);
LOG_DEBUG("Received blufi data:");
p_inst->blufi_cback(blufi_cb_env.blufi_inst.app_id, net_event, len, p_rec_data);
}
break;
- case BTA_GATTS_CONF_EVT:
+ case ESP_GATTS_CFM_EVT:
/* Nothing */
break;
- case BTA_GATTS_CREATE_EVT:
+ case ESP_GATTS_CREATE_EVT:
uuid.uu.uuid16 = CHAR_BLUFI_UUID;
blufi_cb_env.clcb.cur_srvc_id = p_data->create.service_id;
blufi_cb_env.is_primery = p_data->create.is_primary;
//start the blufi service after created
- BTA_GATTS_StartService(p_data->create.service_id, BTA_GATT_TRANSPORT_LE);
+ esp_ble_gatts_start_srvc(p_data->create.service_id);
//add the frist blufi characteristic --> write characteristic
- BTA_GATTS_AddCharacteristic(blufi_cb_env.clcb.cur_srvc_id, &uuid,
+ esp_ble_gatts_add_char(blufi_cb_env.clcb.cur_srvc_id, &uuid,
(GATT_PERM_WRITE | GATT_PERM_READ),
(GATT_CHAR_PROP_BIT_READ | GATT_CHAR_PROP_BIT_WRITE | GATT_CHAR_PROP_BIT_NOTIFY));
break;
- case BTA_GATTS_ADD_CHAR_EVT:
+ case ESP_GATTS_ADD_CHAR_EVT:
if(p_data->add_result.char_uuid.uu.uuid16 == CHAR_BLUFI_UUID)
{
//save the att handle to the env
blufi_cb_env.blufi_inst.blufi_hdl = p_data->add_result.attr_id;
uuid.uu.uuid16 = GATT_UUID_CHAR_CLIENT_CONFIG;
- BTA_GATTS_AddCharDescriptor (blufi_cb_env.clcb.cur_srvc_id,
+ esp_ble_gatts_add_char_descr(blufi_cb_env.clcb.cur_srvc_id,
(GATT_PERM_WRITE|GATT_PERM_WRITE),
&uuid);
}
break;
- case BTA_GATTS_ADD_CHAR_DESCR_EVT:
+ case ESP_GATTS_ADD_CHAR_DESCR_EVT:
/* Nothing */
break;
- case BTA_GATTS_CONNECT_EVT:
+ case ESP_GATTS_CONNECT_EVT:
//set the connection flag to true
blufi_env_clcb_alloc(p_data->conn.conn_id, p_data->conn.remote_bda);
LOG_DEBUG("\ndevice is connected "BT_BD_ADDR_STR", server_if=%d,reason=0x%x,connect_id=%d\n",
/*return whether the remote device is currently connected*/
int is_connected = BTA_DmGetConnectionState(p_data->conn.remote_bda);
LOG_DEBUG("is_connected=%d\n",is_connected);
- BTA_DmBleBroadcast(0); //stop adv
+ esp_ble_stop_advertising(); //stop adv
break;
- case BTA_GATTS_DISCONNECT_EVT:
+ case ESP_GATTS_DISCONNECT_EVT:
//set the connection flag to true
blufi_cb_env.clcb.connected = false;
+ esp_ble_start_advertising(&adv_params);
break;
- case BTA_GATTS_OPEN_EVT:
+ case ESP_GATTS_OPEN_EVT:
break;
- case BTA_GATTS_CLOSE_EVT:
+ case ESP_GATTS_CLOSE_EVT:
if(blufi_cb_env.clcb.connected && (blufi_cb_env.clcb.conn_id == p_data->conn.conn_id))
{
//set the connection channal congested flag to true
blufi_cb_env.clcb.congest = p_data->congest.congested;
}
break;
- case BTA_GATTS_LISTEN_EVT:
- break;
- case BTA_GATTS_CONGEST_EVT:
+ case ESP_GATTS_CONGEST_EVT:
break;
default:
break;
*******************************************************************************/
void blufi_create_service(void)
{
- tBTA_GATTS_IF server_if ;
- tBT_UUID uuid = {LEN_UUID_16, {SVC_BLUFI_UUID}};
+ esp_gatts_if_t server_if ;
+ esp_bt_uuid_t uuid = {LEN_UUID_16, {SVC_BLUFI_UUID}};
UINT16 num_handle = BLUFI_HDL_NUM;
UINT8 inst = 0x00;
server_if = blufi_cb_env.gatt_if;
LOG_ERROR("blufi service added error.");
return;
}
- BTA_GATTS_CreateService(server_if, &uuid, inst, num_handle, true);
+ esp_ble_gatts_create_srvc(server_if, &uuid, inst, num_handle, true);
}
** Description Initializa the GATT Service for blufi profiles.
**
*******************************************************************************/
-tGATT_STATUS blufi_profile_init (tBLUFI_CBACK *call_back)
+esp_gatt_status_t blufi_profile_init (tBLUFI_CBACK *call_back)
{
- tBT_UUID app_uuid = {LEN_UUID_16, {SVC_BLUFI_UUID}};
+ esp_bt_uuid_t app_uuid = {LEN_UUID_16, {SVC_BLUFI_UUID}};
if(blufi_cb_env.enabled)
}
- /* register the blufi profile to the BTA_GATTS module*/
- BTA_GATTS_AppRegister(&app_uuid, blufi_profile_cb);
+ /* register the blufi profile to the ESP_GATTS module*/
+ esp_ble_gatts_app_register(&app_uuid, blufi_profile_cb);
return GATT_SUCCESS;
}
return;
}
- BTA_GATTS_HandleValueIndication (conn_id, attr_id, len,
+ esp_ble_gatts_hdl_val_indica(conn_id, attr_id, len,
blufi_msg, rsp);
}
#include "btm_ble_api.h"
#include "esp_bt_defs.h"
-typedef struct
-{
- char *adv_name; //set the device name to be sent on the advertising
- tBTA_BLE_ADV_DATA ble_adv_data;
-}tBLUFI_BLE_ADV_DATA;
+extern void BlufiBleConfigadvData(esp_ble_adv_data_cfg_t *adv_data,
+ esp_ble_set_adv_data_cmpl_cb_t *p_adv_data_cback);
-extern void BlufiBleConfigadvData(tBLUFI_BLE_ADV_DATA *adv_data,
- tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback);
-
-extern void BlufiBleSetScanRsp(tBLUFI_BLE_ADV_DATA *scan_rsp_data,
- tBTA_SET_ADV_DATA_CMPL_CBACK *p_scan_rsp_data_cback);
+extern void BlufiBleSetScanRsp(esp_ble_adv_data_cfg_t *scan_rsp_data,
+ esp_ble_set_adv_data_cmpl_cb_t *p_scan_rsp_data_cback);
#endif /* __BLUFI_ADV_H__ */
#include "blufi.h"
#include "blufi_adv.h"
+#include "esp_bt_common.h"
+
static void BlufiDataCallBack(UINT8 app_id, UINT8 event, UINT8 len, UINT8 *p_data);
struct dm_evt {
}
-static bt_status_t blufi_dm_upstreams_evt(void *arg)
+static esp_err_t blufi_dm_upstreams_evt(void *arg)
{
struct dm_evt *evt = (struct dm_evt *)arg;
GKI_freebuf(evt);
- return BT_STATUS_SUCCESS;
+ return ESP_OK;
}
blufi_transfer_context(blufi_dm_upstreams_evt, evt);
}
-bt_status_t blufi_enable(void *arg)
+esp_err_t blufi_enable(void *arg)
{
+ esp_err_t err;
+
BTM_SetTraceLevel(BT_TRACE_LEVEL_ERROR);
- BTA_EnableBluetooth(blufi_bte_dm_evt);
+ err = esp_enable_bluetooth(blufi_bte_dm_evt);
vTaskDelay(1000 / portTICK_PERIOD_MS);
+
+ return err;
+}
+
+esp_err_t blufi_disable(void *arg)
+{
+ esp_err_t err;
+
+ err = esp_disable_bluetooth();
+
+ if (arg) {
+ ((void (*)(void))arg)();
+ }
+
+ return err;
}
}
}
-static int blufi_task_post(uint32_t sig, void *par, void *cb, void *arg)
+static esp_err_t blufi_task_post(uint32_t sig, void *par, void *cb, void *arg)
{
BtTaskEvt_t evt;
if (xQueueSend(xBlufiTaskQueue, &evt, 10/portTICK_RATE_MS) != pdTRUE) {
LOG_ERROR("Blufi Post failed\n");
- return -1;
+ return ESP_FAIL;
}
- return 0;
+ return ESP_OK;
}
-bt_status_t blufi_transfer_context(BtTaskCb_t cb, void *arg)
+esp_err_t blufi_transfer_context(blufi_task_cb_t cb, void *arg)
{
LOG_DEBUG("%s cb %08x, arg %u\n", __func__, cb, arg);
blufi_transfer_context(blufi_enable, NULL);
}
+void blufi_deinit(void) {
+ blufi_transfer_context(blufi_disable, blufi_task_deinit);
+}
+
#include <stdint.h>
#include "osi.h"
#include "bt_common_types.h"
+#include "esp_err.h"
enum BLUFI_SIG {
BLUFI_SIG_SWITCH_CONTEXT = 0,
BLUFI_SIG_DISABLE,
};
+typedef esp_err_t (*blufi_task_cb_t)(void *arg);
+
void blufi_init(void);
-bt_status_t blufi_enable(void *arg);
-bt_status_t blufi_transfer_context(BtTaskCb_t cb, void *arg);
+void blufi_deinit(void);
+
+esp_err_t blufi_enable(void *arg);
+esp_err_t blufi_disable(void *arg);
+
+esp_err_t blufi_transfer_context(blufi_task_cb_t cb, void *arg);
#endif /* __BT_APP_COMMON_H__ */
#include "bt.h"
#include "bta_api.h"
-extern tBTA_STATUS BTA_DisableBluetooth(void);
-extern void phy_set_wifi_mode_only(bool wifi_only);
-extern void bte_main_boot_entry(void *);
-extern void blufi_init(void);
+#include "esp_bt_common.h"
+#include "blufi.h"
#define WIFI_LIST_NUM 10
case SYSTEM_EVENT_STA_GOT_IP:
xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
blufi_config_success();
- BTA_DisableBluetooth();
+ esp_disable_bluetooth(); //close bluetooth function
+ //esp_deinit_bluetooth(); //free bluetooth resource
break;
case SYSTEM_EVENT_STA_DISCONNECTED:
/* This is a workaround as ESP32 WiFi libs don't currently
vTaskDelay(1000 / portTICK_PERIOD_MS);
if (confirm) {
confirm = false;
- //BTA_DisableBluetooth();
strcpy(sta_config.sta.ssid, tmp_ssid);
strcpy(sta_config.sta.password, tmp_passwd);
bt_controller_init();
xTaskCreatePinnedToCore(&wifiTestTask, "wifiTestTask", 2048, NULL, 20, NULL, 0);
- // bt_app_task_start_up();
- bte_main_boot_entry(blufi_init);
+
+ esp_init_bluetooth(blufi_init);
}