mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-13 15:41:17 +00:00
hfp hf doku
This commit is contained in:
parent
b60a2e308f
commit
91617f4954
@ -671,14 +671,68 @@ extern "C" {
|
||||
|
||||
#define HCI_EVENT_HFP_META 0xE9
|
||||
|
||||
/**
|
||||
* @format 11
|
||||
* @param subevent_code
|
||||
* @param status 0 == OK
|
||||
*/
|
||||
#define HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_ESTABLISHED 0x01
|
||||
|
||||
/**
|
||||
* @format 11
|
||||
* @param subevent_code
|
||||
* @param status 0 == OK
|
||||
*/
|
||||
#define HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_RELEASED 0x02
|
||||
|
||||
/**
|
||||
* @format 11
|
||||
* @param subevent_code
|
||||
* @param status 0 == OK
|
||||
*/
|
||||
#define HFP_SUBEVENT_AUDIO_CONNECTION_ESTABLISHED 0x03
|
||||
|
||||
/**
|
||||
* @format 11
|
||||
* @param subevent_code
|
||||
* @param status 0 == OK
|
||||
*/
|
||||
#define HFP_SUBEVENT_AUDIO_CONNECTION_RELEASED 0x04
|
||||
|
||||
/**
|
||||
* @format 11
|
||||
* @param subevent_code
|
||||
* @param status 0 == OK
|
||||
*/
|
||||
#define HFP_SUBEVENT_COMPLETE 0x05
|
||||
|
||||
/**
|
||||
* @format 1111T
|
||||
* @param subevent_code
|
||||
* @param status
|
||||
* @param indicator_index
|
||||
* @param indicator_status
|
||||
* @param indicator_name
|
||||
*/
|
||||
#define HFP_SUBEVENT_AG_INDICATOR_STATUS_CHANGED 0x06
|
||||
|
||||
/**
|
||||
* @format 1111T
|
||||
* @param subevent_code
|
||||
* @param status
|
||||
* @param network_operator_mode
|
||||
* @param network_operator_format
|
||||
* @param network_operator_name
|
||||
*/
|
||||
#define HFP_SUBEVENT_NETWORK_OPERATOR_CHANGED 0x07
|
||||
|
||||
/**
|
||||
* @format 11
|
||||
* @param subevent_code
|
||||
* @param error
|
||||
*/
|
||||
#define HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR 0x08
|
||||
|
||||
#define HFP_SUBEVENT_CODECS_CONNECTION_COMPLETE 0x09
|
||||
#define HFP_SUBEVENT_START_RINGINIG 0x0A
|
||||
#define HFP_SUBEVENT_STOP_RINGINIG 0x0B
|
||||
|
@ -1259,7 +1259,8 @@ static void parse_sequence(hfp_connection_t * context){
|
||||
case HFP_CMD_ERROR:
|
||||
break;
|
||||
case HFP_CMD_EXTENDED_AUDIO_GATEWAY_ERROR:
|
||||
context->extended_audio_gateway_error = (uint8_t)atoi((char*)context->line_buffer);
|
||||
context->extended_audio_gateway_error = 1;
|
||||
context->extended_audio_gateway_error_value = (uint8_t)atoi((char*)context->line_buffer);
|
||||
break;
|
||||
case HFP_CMD_ENABLE_EXTENDED_AUDIO_GATEWAY_ERROR:
|
||||
context->enable_extended_audio_gateway_error_report = (uint8_t)atoi((char*)context->line_buffer);
|
||||
@ -1311,7 +1312,7 @@ void hfp_establish_service_level_connection(bd_addr_t bd_addr, uint16_t service_
|
||||
void hfp_release_service_level_connection(hfp_connection_t * context){
|
||||
if (!context) return;
|
||||
hfp_release_audio_connection(context);
|
||||
|
||||
|
||||
if (context->state < HFP_W4_RFCOMM_CONNECTED){
|
||||
context->state = HFP_IDLE;
|
||||
return;
|
||||
|
@ -526,6 +526,7 @@ typedef struct hfp_connection {
|
||||
uint8_t operator_name_changed;
|
||||
|
||||
uint8_t enable_extended_audio_gateway_error_report;
|
||||
uint8_t extended_audio_gateway_error_value;
|
||||
uint8_t extended_audio_gateway_error;
|
||||
|
||||
// establish codecs connection
|
||||
|
@ -759,7 +759,7 @@ static int hfp_ag_run_for_context_service_level_connection_queries(hfp_connectio
|
||||
case HFP_CMD_ENABLE_EXTENDED_AUDIO_GATEWAY_ERROR:
|
||||
if (context->extended_audio_gateway_error){
|
||||
context->extended_audio_gateway_error = 0;
|
||||
hfp_ag_report_extended_audio_gateway_error(context->rfcomm_cid, context->extended_audio_gateway_error);
|
||||
hfp_ag_report_extended_audio_gateway_error(context->rfcomm_cid, context->extended_audio_gateway_error_value);
|
||||
return 1;
|
||||
}
|
||||
case HFP_CMD_ENABLE_INDICATOR_STATUS_UPDATE:
|
||||
|
@ -340,13 +340,12 @@ static void hfp_emit_ag_indicator_event(hfp_callback_t callback, int status, hfp
|
||||
(*callback)(event, sizeof(event));
|
||||
}
|
||||
|
||||
static void hfp_emit_network_operator_event(hfp_callback_t callback, int status, hfp_network_opearator_t network_operator){
|
||||
static void hfp_emit_network_operator_event(hfp_callback_t callback, hfp_network_opearator_t network_operator){
|
||||
if (!callback) return;
|
||||
uint8_t event[24];
|
||||
event[0] = HCI_EVENT_HFP_META;
|
||||
event[1] = sizeof(event) - 2;
|
||||
event[2] = HFP_SUBEVENT_NETWORK_OPERATOR_CHANGED;
|
||||
event[3] = status;
|
||||
event[4] = network_operator.mode;
|
||||
event[5] = network_operator.format;
|
||||
strcpy((char*)&event[6], network_operator.name);
|
||||
@ -881,7 +880,7 @@ static void hfp_hf_switch_on_ok(hfp_connection_t *context){
|
||||
break;
|
||||
case HPF_HF_QUERY_OPERATOR_W4_RESULT:
|
||||
context->hf_query_operator_state = HFP_HF_QUERY_OPERATOR_FORMAT_SET;
|
||||
hfp_emit_network_operator_event(hfp_callback, 0, context->network_operator);
|
||||
hfp_emit_network_operator_event(hfp_callback, context->network_operator);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -962,9 +961,9 @@ static void hfp_handle_rfcomm_event(uint8_t packet_type, uint16_t channel, uint8
|
||||
break;
|
||||
case HFP_CMD_EXTENDED_AUDIO_GATEWAY_ERROR:
|
||||
context->ok_pending = 0;
|
||||
context->extended_audio_gateway_error = 0;
|
||||
context->command = HFP_CMD_NONE;
|
||||
hfp_emit_event(hfp_callback, HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR, context->extended_audio_gateway_error);
|
||||
context->extended_audio_gateway_error = 0;
|
||||
hfp_emit_event(hfp_callback, HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR, context->extended_audio_gateway_error_value);
|
||||
break;
|
||||
case HFP_CMD_ERROR:
|
||||
context->ok_pending = 0;
|
||||
|
38
src/hfp_hf.h
38
src/hfp_hf.h
@ -107,53 +107,63 @@ void hfp_hf_set_indicators_status(uint32_t indicators_status);
|
||||
void hfp_hf_register_packet_handler(hfp_callback_t callback);
|
||||
|
||||
/**
|
||||
* @brief Establish RFCOMM connection with the AG with given Bluetooth address, and perform service level connection agreement:
|
||||
* @brief Establish RFCOMM connection with the AG with given Bluetooth address,
|
||||
* and perform service level connection (SLC) agreement:
|
||||
* - exchange supported features
|
||||
* - retrieve Audio Gateway (AG) indicators and their status
|
||||
* - enable indicator status update in the AG
|
||||
* - notify the AG about its own available codecs, if possible
|
||||
* - retrieve the AG information describing the call hold and multiparty services, if possible
|
||||
* - retrieve which HF indicators are enabled on the AG, if possible
|
||||
*
|
||||
* The status of SLC connection establishment is reported via
|
||||
* HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_ESTABLISHED.
|
||||
* @param bd_addr Bluetooth address of the AG
|
||||
*/
|
||||
void hfp_hf_establish_service_level_connection(bd_addr_t bd_addr);
|
||||
|
||||
/**
|
||||
* @brief Release the RFCOMM channel and the audio connection between the HF and the AG.
|
||||
* The status of releasing the SLC connection is reported via
|
||||
* HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_RELEASED.
|
||||
*
|
||||
* @param bd_addr Bluetooth address of the AG
|
||||
*/
|
||||
void hfp_hf_release_service_level_connection(bd_addr_t bd_addr);
|
||||
|
||||
/**
|
||||
* @brief Enable status update for all indicators in the AG.
|
||||
* The status field of the HFP_SUBEVENT_COMPLETE reports if the command was accepted.
|
||||
* The status of an AG indicator is reported via HFP_SUBEVENT_AG_INDICATOR_STATUS_CHANGED.
|
||||
*
|
||||
* @param bd_addr Bluetooth address of the AG
|
||||
*/
|
||||
void hfp_hf_enable_status_update_for_all_ag_indicators(bd_addr_t bd_addr);
|
||||
|
||||
/**
|
||||
* @brief Disable status update for all indicators in the AG.
|
||||
* The status field of the HFP_SUBEVENT_COMPLETE reports if the command was accepted.
|
||||
* @param bd_addr Bluetooth address of the AG
|
||||
*/
|
||||
void hfp_hf_disable_status_update_for_all_ag_indicators(bd_addr_t bd_addr);
|
||||
|
||||
/**
|
||||
* @brief Enable or disable status update for the individual indicators in the AG using bitmap.
|
||||
*
|
||||
* The status field of the HFP_SUBEVENT_COMPLETE reports if the command was accepted.
|
||||
* The status of an AG indicator is reported via HFP_SUBEVENT_AG_INDICATOR_STATUS_CHANGED.
|
||||
*
|
||||
* @param bd_addr Bluetooth address of the AG
|
||||
* @param indicators_status_bitmap 32-bit bitmap, 0 - indicator is disabled, 1 - indicator is enabled
|
||||
*/
|
||||
void hfp_hf_set_status_update_for_individual_ag_indicators(bd_addr_t bd_addr, uint32_t indicators_status_bitmap);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Find out the name of the currently selected Network operator by AG.
|
||||
*
|
||||
* The name is restricted to max 16 characters. If the operator is selected, a
|
||||
* HCI_EVENT_HFP_META event with HFP_SUBEVENT_NETWORK_OPERATOR_CHANGED subtype
|
||||
* containing network operator mode, format and name, is sent.
|
||||
* The name is restricted to max 16 characters. The result is reported via
|
||||
* HFP_SUBEVENT_NETWORK_OPERATOR_CHANGED subtype
|
||||
* containing network operator mode, format and name.
|
||||
* If no operator is selected, format and operator are omitted.
|
||||
*
|
||||
*
|
||||
* @param bd_addr Bluetooth address of the AG
|
||||
*/
|
||||
void hfp_hf_query_operator_selection(bd_addr_t bd_addr);
|
||||
@ -161,7 +171,8 @@ void hfp_hf_query_operator_selection(bd_addr_t bd_addr);
|
||||
/**
|
||||
* @brief Enable Extended Audio Gateway Error result codes in the AG.
|
||||
* Whenever there is an error relating to the functionality of the AG as a
|
||||
* result of AT command, the AG shall send +CME ERROR, see hfp_cme_error_t in hfp.h
|
||||
* result of AT command, the AG shall send +CME ERROR. This error is reported via
|
||||
* HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR, see hfp_cme_error_t in hfp.h
|
||||
*
|
||||
* @param bd_addr Bluetooth address of the AG
|
||||
*/
|
||||
@ -175,13 +186,18 @@ void hfp_hf_enable_report_extended_audio_gateway_error_result_code(bd_addr_t bd_
|
||||
void hfp_hf_disable_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @brief Establish audio connection.
|
||||
* The status of audio connection establishment is reported via
|
||||
* HFP_SUBEVENT_AUDIO_CONNECTION_ESTABLISHED.
|
||||
* @param bd_addr Bluetooth address of the AG
|
||||
*/
|
||||
void hfp_hf_establish_audio_connection(bd_addr_t bd_addr);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @brief Release audio connection.
|
||||
* The status of releasing of the audio connection is reported via
|
||||
* HFP_SUBEVENT_AUDIO_CONNECTION_RELEASED.
|
||||
*
|
||||
* @param bd_addr Bluetooth address of the AG
|
||||
*/
|
||||
void hfp_hf_release_audio_connection(bd_addr_t bd_addr);
|
||||
|
@ -239,7 +239,7 @@ TEST(HFPParser, HFP_HF_EXTENDED_AUDIO_GATEWAY_ERROR){
|
||||
}
|
||||
|
||||
CHECK_EQUAL(context.command, HFP_CMD_EXTENDED_AUDIO_GATEWAY_ERROR);
|
||||
CHECK_EQUAL(context.extended_audio_gateway_error, HFP_CME_ERROR_NO_NETWORK_SERVICE);
|
||||
CHECK_EQUAL(context.extended_audio_gateway_error_value, HFP_CME_ERROR_NO_NETWORK_SERVICE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -537,7 +537,7 @@ int btstack_main(int argc, const char * argv[]){
|
||||
hfp_hf_init(rfcomm_channel_nr);
|
||||
hfp_hf_set_supported_features(438 | (1<<HFP_HFSF_ESCO_S4) | (1<<HFP_HFSF_EC_NR_FUNCTION));
|
||||
hfp_hf_set_indicators(sizeof(indicators)/sizeof(uint16_t), indicators);
|
||||
hfp_hf_set_codecs(sizeof(codecs), codecs);
|
||||
hfp_hf_set_codecs(sizeof(codecs), );
|
||||
hfp_hf_set_indicators_status(1);
|
||||
|
||||
hfp_hf_register_packet_handler(packet_handler);
|
||||
|
Loading…
x
Reference in New Issue
Block a user