mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
component/bt : fix blufi second init fail bug
This commit is contained in:
parent
aefde1517d
commit
7cf5eea36f
@ -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.server_if = p_rcb->gatt_if;
|
||||||
cb_data.srvc_oper.service_id = p_srvc_cb->service_id;
|
cb_data.srvc_oper.service_id = p_srvc_cb->service_id;
|
||||||
cb_data.srvc_oper.status = BTA_GATT_OK;
|
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) {
|
if (p_rcb->p_cback) {
|
||||||
(*p_rcb->p_cback)(BTA_GATTS_STOP_EVT, &cb_data);
|
(*p_rcb->p_cback)(BTA_GATTS_STOP_EVT, &cb_data);
|
||||||
|
@ -109,6 +109,28 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
|||||||
blufi_create_service();
|
blufi_create_service();
|
||||||
}
|
}
|
||||||
break;
|
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, ¶m, sizeof(esp_blufi_cb_param_t), NULL);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
case BTA_GATTS_READ_EVT:
|
case BTA_GATTS_READ_EVT:
|
||||||
memset(&rsp, 0, sizeof(tBTA_GATTS_API_RSP));
|
memset(&rsp, 0, sizeof(tBTA_GATTS_API_RSP));
|
||||||
rsp.attr_value.handle = p_data->req_data.p_data->read_req.handle;
|
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)
|
static tGATT_STATUS btc_blufi_profile_deinit(void)
|
||||||
{
|
{
|
||||||
esp_blufi_cb_param_t param;
|
|
||||||
btc_msg_t msg;
|
|
||||||
|
|
||||||
if (!blufi_env.enabled) {
|
if (!blufi_env.enabled) {
|
||||||
LOG_ERROR("BLUFI already initialized");
|
LOG_ERROR("BLUFI already de-initialized");
|
||||||
return GATT_ERROR;
|
return GATT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,13 +345,6 @@ static tGATT_STATUS btc_blufi_profile_deinit(void)
|
|||||||
/* register the BLUFI profile to the BTA_GATTS module*/
|
/* register the BLUFI profile to the BTA_GATTS module*/
|
||||||
BTA_GATTS_AppDeregister(blufi_env.gatt_if);
|
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, ¶m, sizeof(esp_blufi_cb_param_t), NULL);
|
|
||||||
|
|
||||||
return GATT_SUCCESS;
|
return GATT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
esp_ble_gap_config_adv_data(&example_adv_data);
|
||||||
break;
|
break;
|
||||||
case ESP_BLUFI_EVENT_DEINIT_FINISH:
|
case ESP_BLUFI_EVENT_DEINIT_FINISH:
|
||||||
BLUFI_INFO("BLUFI init finish\n");
|
BLUFI_INFO("BLUFI deinit finish\n");
|
||||||
break;
|
break;
|
||||||
case ESP_BLUFI_EVENT_BLE_CONNECT:
|
case ESP_BLUFI_EVENT_BLE_CONNECT:
|
||||||
BLUFI_INFO("BLUFI ble connect\n");
|
BLUFI_INFO("BLUFI ble connect\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user