Merge branch 'bugfix/btdm_blufi' into 'master'

component/bt : fix blufi second init fail bug

See merge request !866
This commit is contained in:
Jiang Jiang Jian 2017-06-15 13:37:31 +08:00
commit 5f24dcdf4e
3 changed files with 25 additions and 13 deletions

View File

@ -606,7 +606,7 @@ void bta_gatts_stop_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_ms
cb_data.srvc_oper.server_if = p_rcb->gatt_if;
cb_data.srvc_oper.service_id = p_srvc_cb->service_id;
cb_data.srvc_oper.status = BTA_GATT_OK;
APPL_TRACE_ERROR("bta_gatts_stop_service service_id= %d", p_srvc_cb->service_id);
APPL_TRACE_DEBUG("bta_gatts_stop_service service_id= %d", p_srvc_cb->service_id);
if (p_rcb->p_cback) {
(*p_rcb->p_cback)(BTA_GATTS_STOP_EVT, &cb_data);

View File

@ -109,6 +109,28 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
blufi_create_service();
}
break;
case BTA_GATTS_DEREG_EVT: {
esp_blufi_cb_param_t param;
btc_msg_t msg;
LOG_DEBUG("DEREG: status %d, gatt_if %d\n", p_data->reg_oper.status, p_data->reg_oper.server_if);
if (p_data->reg_oper.status != BTA_GATT_OK) {
LOG_ERROR("BLUFI profile unregister failed\n");
return;
}
blufi_env.enabled = false;
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_BLUFI;
msg.act = ESP_BLUFI_EVENT_DEINIT_FINISH;
param.deinit_finish.state = ESP_BLUFI_DEINIT_OK;
btc_transfer_context(&msg, &param, sizeof(esp_blufi_cb_param_t), NULL);
break;
}
case BTA_GATTS_READ_EVT:
memset(&rsp, 0, sizeof(tBTA_GATTS_API_RSP));
rsp.attr_value.handle = p_data->req_data.p_data->read_req.handle;
@ -313,11 +335,8 @@ static tGATT_STATUS btc_blufi_profile_init(void)
static tGATT_STATUS btc_blufi_profile_deinit(void)
{
esp_blufi_cb_param_t param;
btc_msg_t msg;
if (!blufi_env.enabled) {
LOG_ERROR("BLUFI already initialized");
LOG_ERROR("BLUFI already de-initialized");
return GATT_ERROR;
}
@ -326,13 +345,6 @@ static tGATT_STATUS btc_blufi_profile_deinit(void)
/* register the BLUFI profile to the BTA_GATTS module*/
BTA_GATTS_AppDeregister(blufi_env.gatt_if);
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_BLUFI;
msg.act = ESP_BLUFI_EVENT_DEINIT_FINISH;
param.deinit_finish.state = ESP_BLUFI_DEINIT_OK;
btc_transfer_context(&msg, &param, sizeof(esp_blufi_cb_param_t), NULL);
return GATT_SUCCESS;
}

View File

@ -177,7 +177,7 @@ static void example_event_callback(esp_blufi_cb_event_t event, esp_blufi_cb_para
esp_ble_gap_config_adv_data(&example_adv_data);
break;
case ESP_BLUFI_EVENT_DEINIT_FINISH:
BLUFI_INFO("BLUFI init finish\n");
BLUFI_INFO("BLUFI deinit finish\n");
break;
case ESP_BLUFI_EVENT_BLE_CONNECT:
BLUFI_INFO("BLUFI ble connect\n");