mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-11 18:40:22 +00:00
hfp_hf: send custom AT command with hfp_hf_send_at_command
This commit is contained in:
parent
b3e7b9f5ef
commit
51a2ebde00
@ -9,9 +9,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
## Unreleased
|
||||
|
||||
### Added
|
||||
- HFP HF: send custom AT command with hfp_hf_send_at_command
|
||||
- port: CMake build files in all windows-* ports allow to use Visual Studio 2022
|
||||
- embedded audio: mono audio is played on both channels if HAVE_HAL_AUDIO_SINK_STEREO_ONLY is defined
|
||||
|
||||
|
||||
### Fixed
|
||||
|
||||
### Changed
|
||||
|
@ -222,7 +222,8 @@ typedef enum {
|
||||
HFP_CMD_RESPONSE_AND_HOLD_QUERY,
|
||||
HFP_CMD_RESPONSE_AND_HOLD_COMMAND,
|
||||
HFP_CMD_RESPONSE_AND_HOLD_STATUS,
|
||||
HFP_CMD_HF_INDICATOR_STATUS
|
||||
HFP_CMD_HF_INDICATOR_STATUS,
|
||||
HFP_CMD_CUSTOM_MESSAGE
|
||||
} hfp_command_t;
|
||||
|
||||
|
||||
@ -631,7 +632,10 @@ typedef struct hfp_connection {
|
||||
uint8_t send_ag_status_indicators;
|
||||
uint8_t send_ag_indicators_segment;
|
||||
uint8_t send_response_and_hold_status; // 0 - don't send. BRTH:0 == 1, ..
|
||||
|
||||
|
||||
// HF: AT Command, AG: Unsolicited Result Code
|
||||
const char * send_custom_message;
|
||||
|
||||
bool emit_vra_enabled_after_audio_established;
|
||||
// AG only
|
||||
uint8_t change_in_band_ring_tone_setting;
|
||||
|
@ -1049,6 +1049,15 @@ static void hfp_hf_run_for_context(hfp_connection_t * hfp_connection){
|
||||
}
|
||||
}
|
||||
|
||||
if (hfp_connection->send_custom_message != NULL){
|
||||
const char * message = hfp_connection->send_custom_message;
|
||||
hfp_connection->send_custom_message = NULL;
|
||||
hfp_connection->ok_pending = 1;
|
||||
hfp_connection->response_pending_for_command = HFP_CMD_CUSTOM_MESSAGE;
|
||||
send_str_over_rfcomm(hfp_connection->rfcomm_cid, message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (done) return;
|
||||
// deal with disconnect
|
||||
switch (hfp_connection->state){
|
||||
@ -1124,6 +1133,9 @@ static bool hfp_hf_switch_on_ok_pending(hfp_connection_t *hfp_connection, uint8_
|
||||
case HFP_CMD_TURN_OFF_EC_AND_NR:
|
||||
hfp_emit_event(hfp_connection, HFP_SUBEVENT_ECHO_CANCELING_AND_NOISE_REDUCTION_DEACTIVATE, status);
|
||||
break;
|
||||
case HFP_CMD_CUSTOM_MESSAGE:
|
||||
hfp_emit_event(hfp_connection, HFP_SUBEVENT_COMPLETE, status);
|
||||
break;
|
||||
default:
|
||||
event_emited = false;
|
||||
|
||||
@ -2171,6 +2183,19 @@ uint8_t hfp_hf_set_hf_indicator(hci_con_handle_t acl_handle, int assigned_number
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
uint8_t hfp_hf_send_at_command(hci_con_handle_t acl_handle, const char * at_command){
|
||||
hfp_connection_t * hfp_connection = get_hfp_hf_connection_context_for_acl_handle(acl_handle);
|
||||
if (!hfp_connection) {
|
||||
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
|
||||
}
|
||||
if (hfp_connection->send_custom_message != NULL){
|
||||
return ERROR_CODE_COMMAND_DISALLOWED;
|
||||
}
|
||||
hfp_connection->send_custom_message = at_command;
|
||||
hfp_hf_run_for_context(hfp_connection);
|
||||
return ERROR_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int hfp_hf_in_band_ringtone_active(hci_con_handle_t acl_handle){
|
||||
hfp_connection_t * hfp_connection = get_hfp_hf_connection_context_for_acl_handle(acl_handle);
|
||||
if (!hfp_connection) {
|
||||
|
@ -520,6 +520,18 @@ uint8_t hfp_hf_set_hf_indicator(hci_con_handle_t acl_handle, int assigned_number
|
||||
*/
|
||||
int hfp_hf_in_band_ringtone_active(hci_con_handle_t acl_handle);
|
||||
|
||||
/*
|
||||
* @brief Send AT command (most likely a vendor-specific command not part of standard HFP).
|
||||
* @note Result (OK/ERROR) is reported via HFP_SUBEVENT_COMPLETE
|
||||
* To receive potential unsolicited result code, add ENABLE_HFP_AT_MESSAGES to get all message via HFP_SUBEVENT_AT_MESSAGE_RECEIVED
|
||||
*
|
||||
* @param at_command to send
|
||||
* @return status ERROR_CODE_SUCCESS if successful, otherwise:
|
||||
* - ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection does not exist, or
|
||||
* - ERROR_CODE_COMMAND_DISALLOWED if extended audio gateway error report is disabled
|
||||
*/
|
||||
uint8_t hfp_hf_send_at_command(hci_con_handle_t hfp_ag_acl_handle, const char * at_command);
|
||||
|
||||
/**
|
||||
* @brief De-Init HFP HF
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user