mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
feat(bt/bluedroid): Add supprot for specific indicator sending from AG to Client
This commit is contained in:
parent
e1ead7ae40
commit
e989d9eb32
@ -255,6 +255,27 @@ esp_err_t esp_hf_ag_devices_status_indchange(esp_bd_addr_t remote_addr,
|
||||
return (state == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_ag_ciev_report(esp_bd_addr_t remote_addr, esp_hf_ciev_report_type_t ind_type, int value)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
btc_msg_t msg;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF;
|
||||
msg.act = BTC_HF_CIEV_REPORT_EVT;
|
||||
|
||||
btc_hf_args_t arg;
|
||||
memset(&arg, 0, sizeof(btc_hf_args_t));
|
||||
memcpy(&(arg.ciev_rep.remote_addr), remote_addr, sizeof(esp_bd_addr_t));
|
||||
arg.ciev_rep.ind.type = ind_type;
|
||||
arg.ciev_rep.ind.value = value;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t state = btc_transfer_context(&msg, &arg, sizeof(btc_hf_args_t), NULL, NULL);
|
||||
return (state == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_ag_cind_response(esp_bd_addr_t remote_addr,
|
||||
esp_hf_call_status_t call_state,
|
||||
esp_hf_call_setup_status_t call_setup_state,
|
||||
|
@ -402,7 +402,7 @@ esp_err_t esp_hf_ag_vra_control(esp_bd_addr_t remote_bda, esp_hf_vr_state_t valu
|
||||
*/
|
||||
esp_err_t esp_hf_ag_volume_control(esp_bd_addr_t remote_bda, esp_hf_volume_control_target_t type, int volume);
|
||||
|
||||
/**
|
||||
/**
|
||||
*
|
||||
* @brief Handle Unknown AT command from HFP Client.
|
||||
* As a precondition to use this API, Service Level Connection shall exist with HFP client.
|
||||
@ -419,7 +419,7 @@ esp_err_t esp_hf_ag_volume_control(esp_bd_addr_t remote_bda, esp_hf_volume_contr
|
||||
*/
|
||||
esp_err_t esp_hf_ag_unknown_at_send(esp_bd_addr_t remote_addr, char *unat);
|
||||
|
||||
/**
|
||||
/**
|
||||
*
|
||||
* @brief Unsolicited send extend AT error code to HFP Client.
|
||||
* As a precondition to use this API, Service Level Connection shall exist with HFP client.
|
||||
@ -435,7 +435,7 @@ esp_err_t esp_hf_ag_unknown_at_send(esp_bd_addr_t remote_addr, char *unat);
|
||||
*/
|
||||
esp_err_t esp_hf_ag_cmee_send(esp_bd_addr_t remote_bda, esp_hf_at_response_code_t response_code, esp_hf_cme_err_t error_code);
|
||||
|
||||
/**
|
||||
/**
|
||||
*
|
||||
* @brief Unsolicited send device status notification to HFP Client.
|
||||
* As a precondition to use this API, Service Level Connection shall exist with HFP client.
|
||||
@ -452,10 +452,29 @@ esp_err_t esp_hf_ag_cmee_send(esp_bd_addr_t remote_bda, esp_hf_at_response_code_
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_ag_devices_status_indchange(esp_bd_addr_t remote_addr, esp_hf_call_status_t call_state,
|
||||
esp_hf_call_setup_status_t call_setup_state,
|
||||
esp_hf_network_state_t ntk_state, int signal);
|
||||
esp_hf_call_setup_status_t call_setup_state,
|
||||
esp_hf_network_state_t ntk_state, int signal) __attribute__((
|
||||
deprecated("Please use esp_hf_ag_ciev_report")
|
||||
));
|
||||
|
||||
/**
|
||||
/**
|
||||
*
|
||||
* @brief Send indicator report "+CIEV: <ind> <value>" to HFP Client. "CIEV" means “indicator events reporting",
|
||||
* and all indicator types can be sent one type at a time.
|
||||
* As a precondition to use this API, Service Level Connection shall exist with HFP client.
|
||||
*
|
||||
* @param[in] remote_addr: remote bluetooth device address
|
||||
* @param[in] ind_type: indicator type
|
||||
* @param[in] value: indicator value
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_ag_ciev_report(esp_bd_addr_t remote_addr, esp_hf_ciev_report_type_t ind_type, int value);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Response to device individual indicators to HFP Client.
|
||||
* As a precondition to use this API, Service Level Connection shall exist with HFP client.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -51,6 +51,17 @@ typedef enum
|
||||
ESP_HF_NETWORK_STATE_AVAILABLE
|
||||
} esp_hf_network_state_t;
|
||||
|
||||
/// +CIEV report type
|
||||
typedef enum {
|
||||
ESP_HF_IND_TYPE_CALL = 1, /*!< position of call indicator */
|
||||
ESP_HF_IND_TYPE_CALLSETUP, /*!< position of callsetup indicator */
|
||||
ESP_HF_IND_TYPE_SERVICE, /*!< position of service indicator */
|
||||
ESP_HF_IND_TYPE_SIGNAL, /*!< position of signal strength indicator, range: 0-5 */
|
||||
ESP_HF_IND_TYPE_ROAM, /*!< position of roaming indicator */
|
||||
ESP_HF_IND_TYPE_BATTCHG, /*!< position of battery charge indicator, range: 0-5 */
|
||||
ESP_HF_IND_TYPE_CALLHELD /*!< position of callheld indicator */
|
||||
} esp_hf_ciev_report_type_t;
|
||||
|
||||
/** +CIEV Service type */
|
||||
typedef enum
|
||||
{
|
||||
@ -60,7 +71,7 @@ typedef enum
|
||||
|
||||
/// +CIND call status indicator values
|
||||
typedef enum {
|
||||
ESP_HF_CALL_STATUS_NO_CALLS = 0, /*!< no call in progress */
|
||||
ESP_HF_CALL_STATUS_NO_CALLS = 0, /*!< no call in progress */
|
||||
ESP_HF_CALL_STATUS_CALL_IN_PROGRESS = 1, /*!< call is present(active or held) */
|
||||
} esp_hf_call_status_t;
|
||||
|
||||
|
@ -528,6 +528,19 @@ static bt_status_t btc_hf_indchange_notification(bt_bdaddr_t *bd_addr,
|
||||
return BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// +CIEV<...> for device status update, send other indicators, e.g. roaming, battery, call held and bearer
|
||||
bt_status_t btc_hf_ciev_report(bt_bdaddr_t *bd_addr, tBTA_AG_IND_TYPE indicator, uint16_t value)
|
||||
{
|
||||
int idx = btc_hf_idx_by_bdaddr(bd_addr);
|
||||
CHECK_HF_INIT(idx);
|
||||
|
||||
if (is_connected(idx, bd_addr)) {
|
||||
send_indicator_update(indicator, value);
|
||||
return BT_STATUS_SUCCESS;
|
||||
}
|
||||
return BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
//AT+CIND response
|
||||
static bt_status_t btc_hf_cind_response(bt_bdaddr_t *bd_addr,
|
||||
esp_hf_call_setup_status_t call_status,
|
||||
@ -1117,6 +1130,12 @@ void btc_hf_call_handler(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
|
||||
case BTC_HF_CIEV_REPORT_EVT:
|
||||
{
|
||||
btc_hf_ciev_report(&arg->ciev_rep.remote_addr, arg->ciev_rep.ind.type, arg->ciev_rep.ind.value);
|
||||
break;
|
||||
}
|
||||
|
||||
case BTC_HF_CIND_RESPONSE_EVT:
|
||||
{
|
||||
btc_hf_cind_response(&arg->cind_rep.remote_addr,
|
||||
|
@ -44,6 +44,7 @@ typedef enum
|
||||
BTC_HF_UNAT_RESPONSE_EVT,
|
||||
BTC_HF_CME_ERR_EVT,
|
||||
BTC_HF_IND_NOTIFICATION_EVT,
|
||||
BTC_HF_CIEV_REPORT_EVT,
|
||||
BTC_HF_CIND_RESPONSE_EVT,
|
||||
BTC_HF_COPS_RESPONSE_EVT,
|
||||
BTC_HF_CLCC_RESPONSE_EVT,
|
||||
@ -109,6 +110,12 @@ typedef union
|
||||
int signal;
|
||||
} ind_change;
|
||||
|
||||
//BTC_HF_CIEV_REPORT_EVT
|
||||
struct ciev_args {
|
||||
bt_bdaddr_t remote_addr;
|
||||
tBTA_AG_IND ind;
|
||||
} ciev_rep;
|
||||
|
||||
//BTC_HF_CIND_RESPONSE_EVT
|
||||
struct cind_args {
|
||||
bt_bdaddr_t remote_addr;
|
||||
|
@ -1033,7 +1033,7 @@ void btm_sco_connected (UINT8 hci_status, BD_ADDR bda, UINT16 hci_handle,
|
||||
#endif
|
||||
|
||||
btm_cb.sco_cb.sco_disc_reason = hci_status;
|
||||
BTM_TRACE_ERROR("%s, handle %x", __FUNCTION__, hci_handle);
|
||||
BTM_TRACE_API("%s, handle %x", __FUNCTION__, hci_handle);
|
||||
#if (BTM_MAX_SCO_LINKS>0)
|
||||
for (xx = 0; xx < BTM_MAX_SCO_LINKS; xx++, p++) {
|
||||
if (((p->state == SCO_ST_CONNECTING) ||
|
||||
|
@ -157,7 +157,10 @@ HF_CMD_HANDLER(ind_change)
|
||||
return 1;
|
||||
}
|
||||
printf("Device Indicator Changed!\n");
|
||||
esp_hf_ag_devices_status_indchange(hf_peer_addr, call_state, call_setup_state, ntk_state, signal);
|
||||
esp_hf_ag_ciev_report(hf_peer_addr, ESP_HF_IND_TYPE_CALL, call_state);
|
||||
esp_hf_ag_ciev_report(hf_peer_addr, ESP_HF_IND_TYPE_CALLSETUP, call_setup_state);
|
||||
esp_hf_ag_ciev_report(hf_peer_addr, ESP_HF_IND_TYPE_SERVICE, ntk_state);
|
||||
esp_hf_ag_ciev_report(hf_peer_addr, ESP_HF_IND_TYPE_SIGNAL, signal);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user