hfp: emit packet types in HFP_SUBEVENT_AUDIO_CONNECTION_ESTABLISHED

This commit is contained in:
Matthias Ringwald 2023-01-17 15:47:55 +01:00
parent 4e01e80283
commit 090c81feb6
4 changed files with 22 additions and 8 deletions

View File

@ -10,7 +10,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## Added
- HCI_ACL_CHUNK_SIZE_ALIGNMENT allows to keep HCI transport writes aligned
- HFP: provide SCO packet types in HFP_SUBEVENT_AUDIO_CONNECTION_ESTABLISHED
## Fixed
- btstack_stdin_embedded: use timer to poll RTT input, fix for tickless RTOS
- gatt_client: return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER for invalid connection handle
@ -20,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- GAP: add gap_set_peer_privacy_mode with default LE_PRIVACY_MODE_DEVICE
- bluetooth: indicated identity address in resolved address types
## Release v1.5.5
### Added

View File

@ -468,9 +468,10 @@ static void hfp_emit_audio_connection_released(hfp_connection_t * hfp_connection
hfp_emit_event_for_context(hfp_connection, event, sizeof(event));
}
void hfp_emit_sco_event(hfp_connection_t * hfp_connection, uint8_t status, hci_con_handle_t sco_handle, bd_addr_t addr, uint8_t negotiated_codec){
void hfp_emit_sco_connection_established(hfp_connection_t *hfp_connection, uint8_t status, hci_con_handle_t sco_handle, bd_addr_t addr,
uint8_t negotiated_codec, uint16_t packet_types) {
btstack_assert(hfp_connection != NULL);
uint8_t event[15];
uint8_t event[17];
int pos = 0;
event[pos++] = HCI_EVENT_HFP_META;
event[pos++] = sizeof(event) - 2;
@ -483,6 +484,7 @@ void hfp_emit_sco_event(hfp_connection_t * hfp_connection, uint8_t status, hci_c
reverse_bd_addr(addr,&event[pos]);
pos += 6;
event[pos++] = negotiated_codec;
little_endian_store_16(event, pos, packet_types);
hfp_emit_event_for_context(hfp_connection, event, sizeof(event));
}
@ -883,7 +885,8 @@ void hfp_handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet
if (hfp_handle_failed_sco_connection(status)) break;
hfp_connection->establish_audio_connection = 0;
hfp_connection->state = HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED;
hfp_emit_sco_event(hfp_connection, status, 0, hfp_connection->remote_addr, hfp_connection->negotiated_codec);
hfp_emit_sco_connection_established(hfp_connection, status, 0, hfp_connection->remote_addr,
hfp_connection->negotiated_codec, 0);
}
break;
@ -903,7 +906,9 @@ void hfp_handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet
hfp_connection->establish_audio_connection = 0;
hfp_connection->state = HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED;
hfp_emit_sco_event(hfp_connection, status, 0, event_addr, hfp_connection->negotiated_codec);
hfp_emit_sco_connection_established(hfp_connection, status, 0, event_addr,
hfp_connection->negotiated_codec,
0);
break;
}
@ -913,6 +918,7 @@ void hfp_handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet
uint8_t retransmission_interval = hci_event_synchronous_connection_complete_get_retransmission_interval(packet);// measured in slots
uint16_t rx_packet_length = hci_event_synchronous_connection_complete_get_rx_packet_length(packet); // measured in bytes
uint16_t tx_packet_length = hci_event_synchronous_connection_complete_get_tx_packet_length(packet); // measured in bytes
uint16_t packet_types = hfp_link_settings[hfp_sco_establishment_active->link_setting].packet_types;
switch (link_type){
case 0x00:
@ -953,7 +959,9 @@ void hfp_handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet
hfp_connection->ag_audio_connection_opened_before_vra = true;
break;
}
hfp_emit_sco_event(hfp_connection, status, sco_handle, event_addr, hfp_connection->negotiated_codec);
hfp_emit_sco_connection_established(hfp_connection, status, sco_handle, event_addr,
hfp_connection->negotiated_codec,
packet_types);
break;
}

View File

@ -759,7 +759,8 @@ 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_emit_sco_connection_established(hfp_connection_t *hfp_connection, uint8_t status, hci_con_handle_t sco_handle, bd_addr_t addr,
uint8_t negotiated_codec, uint16_t packet_types);
void hfp_set_ag_callback(btstack_packet_handler_t callback);
void hfp_set_ag_rfcomm_packet_handler(btstack_packet_handler_t handler);

View File

@ -1352,7 +1352,10 @@ static void hfp_hf_handle_rfcomm_command(hfp_connection_t * hfp_connection){
switch (hfp_connection->codecs_state){
case HFP_CODECS_RECEIVED_TRIGGER_CODEC_EXCHANGE:
hfp_reset_context_flags(hfp_connection);
hfp_emit_sco_event(hfp_connection, HFP_REMOTE_REJECTS_AUDIO_CONNECTION, 0, hfp_connection->remote_addr, hfp_connection->negotiated_codec);
hfp_emit_sco_connection_established(hfp_connection, HFP_REMOTE_REJECTS_AUDIO_CONNECTION, 0,
hfp_connection->remote_addr,
hfp_connection->negotiated_codec,
0);
return;
default:
break;