mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-01 19:54:32 +02:00
fix SPP initiator can not free resource when connection is failed
This commit is contained in:
@@ -352,6 +352,20 @@ static void *btc_spp_rfcomm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *u
|
|||||||
}
|
}
|
||||||
new_user_data = (void *)(uintptr_t)slot->id;
|
new_user_data = (void *)(uintptr_t)slot->id;
|
||||||
break;
|
break;
|
||||||
|
case BTA_JV_RFCOMM_CL_INIT_EVT:
|
||||||
|
slot = spp_find_slot_by_id(id);
|
||||||
|
if (!slot) {
|
||||||
|
BTC_TRACE_ERROR("%s unable to find RFCOMM slot, event:%d!", __func__, event);
|
||||||
|
p_data->rfc_cl_init.status = ESP_SPP_FAILURE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p_data->rfc_cl_init.status == BTA_JV_SUCCESS) {
|
||||||
|
slot->rfc_handle = p_data->rfc_cl_init.handle;
|
||||||
|
} else {
|
||||||
|
spp_free_slot(slot);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case BTA_JV_RFCOMM_OPEN_EVT:
|
case BTA_JV_RFCOMM_OPEN_EVT:
|
||||||
slot = spp_find_slot_by_id(id);
|
slot = spp_find_slot_by_id(id);
|
||||||
if (!slot) {
|
if (!slot) {
|
||||||
@@ -359,7 +373,7 @@ static void *btc_spp_rfcomm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *u
|
|||||||
p_data->rfc_open.status = ESP_SPP_NO_CONNECTION;
|
p_data->rfc_open.status = ESP_SPP_NO_CONNECTION;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
slot->connected = TRUE;
|
slot->connected = true;
|
||||||
slot->rfc_handle = p_data->rfc_open.handle;
|
slot->rfc_handle = p_data->rfc_open.handle;
|
||||||
slot->rfc_port_handle = BTA_JvRfcommGetPortHdl(p_data->rfc_open.handle);
|
slot->rfc_port_handle = BTA_JvRfcommGetPortHdl(p_data->rfc_open.handle);
|
||||||
BTA_JvSetPmProfile(p_data->rfc_open.handle, BTA_JV_PM_ID_1, BTA_JV_CONN_OPEN);
|
BTA_JvSetPmProfile(p_data->rfc_open.handle, BTA_JV_PM_ID_1, BTA_JV_CONN_OPEN);
|
||||||
@@ -371,7 +385,7 @@ static void *btc_spp_rfcomm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *u
|
|||||||
p_data->rfc_close.status = ESP_SPP_NO_CONNECTION;
|
p_data->rfc_close.status = ESP_SPP_NO_CONNECTION;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (slot->connected && p_data->rfc_close.port_status != PORT_LOCAL_CLOSED) {
|
if (slot->rfc_handle && p_data->rfc_close.port_status != PORT_LOCAL_CLOSED) {
|
||||||
BTA_JvRfcommClose(slot->rfc_handle, NULL, (void *)slot->id);
|
BTA_JvRfcommClose(slot->rfc_handle, NULL, (void *)slot->id);
|
||||||
}
|
}
|
||||||
p_data->rfc_close.status = BTA_JV_SUCCESS;
|
p_data->rfc_close.status = BTA_JV_SUCCESS;
|
||||||
|
Reference in New Issue
Block a user