mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 22:20:37 +00:00
hfp: emit HFP_SUBEVENT_AUDIO_CONNECTION_RELEASED on RFCOMM Disconnect
This commit is contained in:
parent
b398819556
commit
48e6eeee0f
@ -28,6 +28,7 @@ AVRCP: `AVRCP_SUBEVENT_OPERATION` emitted for button release
|
||||
### Fixed
|
||||
HCI: handle start inquiry failure
|
||||
AVRCP Target: fix notification changed event
|
||||
HFP: Emit Audio Connection Released on SLC Release, e.g. remote power off
|
||||
|
||||
### Changed
|
||||
HCI: config I2S for BCM Controllers if `ENABLE_SCO_OVER_PCM`, reduce bit clock to 256/512 kHz
|
||||
|
@ -487,7 +487,7 @@ static hfp_connection_t * create_hfp_connection_context(void){
|
||||
return hfp_connection;
|
||||
}
|
||||
|
||||
static void remove_hfp_connection_context(hfp_connection_t * hfp_connection){
|
||||
void hfp_finalize_connection_context(hfp_connection_t * hfp_connection){
|
||||
btstack_linked_list_remove(&hfp_connections, (btstack_linked_item_t*) hfp_connection);
|
||||
btstack_memory_hfp_connection_free(hfp_connection);
|
||||
}
|
||||
@ -813,6 +813,17 @@ void hfp_handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet
|
||||
#endif
|
||||
hfp_connection->sco_handle = HCI_CON_HANDLE_INVALID;
|
||||
hfp_connection->release_audio_connection = 0;
|
||||
|
||||
if (hfp_connection->state == HFP_W4_SCO_DISCONNECTED_TO_SHUTDOWN){
|
||||
// RFCOMM already closed -> remote power off
|
||||
#if defined(ENABLE_CC256X_ASSISTED_HFP) || defined (ENABLE_BCM_PCM_WBS)
|
||||
hfp_connection->state = HFP_W4_WBS_SHUTDOWN;
|
||||
#else
|
||||
hfp_finalize_connection_context(hfp_connection);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
hfp_connection->state = HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED;
|
||||
hfp_emit_event(hfp_connection, HFP_SUBEVENT_AUDIO_CONNECTION_RELEASED, 0);
|
||||
|
||||
@ -874,7 +885,7 @@ void hfp_handle_rfcomm_event(uint8_t packet_type, uint16_t channel, uint8_t *pac
|
||||
|
||||
if (status) {
|
||||
hfp_emit_slc_connection_event(hfp_connection, status, rfcomm_event_channel_opened_get_con_handle(packet), event_addr);
|
||||
remove_hfp_connection_context(hfp_connection);
|
||||
hfp_finalize_connection_context(hfp_connection);
|
||||
} else {
|
||||
hfp_connection->acl_handle = rfcomm_event_channel_opened_get_con_handle(packet);
|
||||
hfp_connection->rfcomm_cid = rfcomm_event_channel_opened_get_rfcomm_cid(packet);
|
||||
@ -903,9 +914,18 @@ void hfp_handle_rfcomm_event(uint8_t packet_type, uint16_t channel, uint8_t *pac
|
||||
hfp_establish_service_level_connection(hfp_connection->remote_addr, hfp_connection->service_uuid, local_role);
|
||||
break;
|
||||
}
|
||||
|
||||
hfp_emit_event(hfp_connection, HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_RELEASED, 0);
|
||||
remove_hfp_connection_context(hfp_connection);
|
||||
if ( hfp_connection->state == HFP_AUDIO_CONNECTION_ESTABLISHED){
|
||||
// service connection was released, this implicitly releases audio connection as well
|
||||
hfp_connection->release_audio_connection = 0;
|
||||
gap_disconnect(hfp_connection->sco_handle);
|
||||
hfp_connection->state = HFP_W4_SCO_DISCONNECTED_TO_SHUTDOWN;
|
||||
hfp_emit_event(hfp_connection, HFP_SUBEVENT_AUDIO_CONNECTION_RELEASED, 0);
|
||||
hfp_emit_event(hfp_connection, HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_RELEASED, 0);
|
||||
} else {
|
||||
// regular case
|
||||
hfp_emit_event(hfp_connection, HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_RELEASED, 0);
|
||||
hfp_finalize_connection_context(hfp_connection);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -357,7 +357,9 @@ typedef enum {
|
||||
HFP_AUDIO_CONNECTION_ESTABLISHED,
|
||||
|
||||
HFP_W2_DISCONNECT_SCO,
|
||||
HFP_W4_SCO_DISCONNECTED,
|
||||
HFP_W4_SCO_DISCONNECTED,
|
||||
HFP_W4_SCO_DISCONNECTED_TO_SHUTDOWN,
|
||||
HFP_W4_WBS_SHUTDOWN,
|
||||
|
||||
HFP_W2_DISCONNECT_RFCOMM,
|
||||
HFP_W4_RFCOMM_DISCONNECTED,
|
||||
@ -663,6 +665,7 @@ int get_bit(uint16_t bitmap, int position);
|
||||
int store_bit(uint32_t bitmap, int position, uint8_t value);
|
||||
// UTILS_END
|
||||
|
||||
void hfp_finalize_connection_context(hfp_connection_t * hfp_connection);
|
||||
void hfp_emit_sco_event(hfp_connection_t * hfp_connection, uint8_t status, hci_con_handle_t con_handle, bd_addr_t addr, uint8_t negotiated_codec);
|
||||
|
||||
void hfp_set_ag_callback(btstack_packet_handler_t callback);
|
||||
|
@ -1762,6 +1762,12 @@ static void hfp_ag_run_for_context(hfp_connection_t *hfp_connection){
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if defined (ENABLE_CC256X_ASSISTED_HFP) || defined (ENABLE_BCM_PCM_WBS)
|
||||
if (hfp_connection->state == HFP_W4_WBS_SHUTDOWN){
|
||||
hfp_finalize_connection_context(hfp_connection);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!rfcomm_can_send_packet_now(hfp_connection->rfcomm_cid)) {
|
||||
log_info("hfp_ag_run_for_context: request can send for 0x%02x", hfp_connection->rfcomm_cid);
|
||||
|
@ -590,6 +590,12 @@ static void hfp_hf_run_for_context(hfp_connection_t * hfp_connection){
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if defined (ENABLE_CC256X_ASSISTED_HFP) || defined (ENABLE_BCM_PCM_WBS)
|
||||
if (hfp_connection->state == HFP_W4_WBS_SHUTDOWN){
|
||||
hfp_finalize_connection_context(hfp_connection);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (hfp_connection->hf_accept_sco){
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user