Add AG component API_REFERENCE

Expose esp_hf_indchange_notification to this example.
This commit is contained in:
weitianhua 2019-11-07 14:45:18 +08:00 committed by bot
parent 0c6e1f7ef8
commit 7c18299571
13 changed files with 204 additions and 120 deletions

View file

@ -49,10 +49,11 @@ typedef enum
{
ESP_HF_CONNECTION_STATE_EVT = 0, /*!< Connection state changed event */
ESP_HF_AUDIO_STATE_EVT, /*!< Audio connection state change event */
ESP_HF_BVRA_RESPONSE_EVT, /*!< Voice recognition state change event */
ESP_HF_BVRA_RESPONSE_EVT, /*!< Voice recognition state change event */
ESP_HF_VOLUME_CONTROL_EVT, /*!< Audio volume control command from HF Client, provided by +VGM or +VGS message */
ESP_HF_UNAT_RESPONSE_EVT, /*!< Unknown AT cmd Response*/
ESP_HF_IND_UPDATE_EVT, /*!< Indicator Update Event*/
ESP_HF_CIND_RESPONSE_EVT, /*!< Call And Device Indicator Response*/
ESP_HF_COPS_RESPONSE_EVT, /*!< Current operator information */
ESP_HF_CLCC_RESPONSE_EVT, /*!< List of current calls notification */
@ -67,7 +68,7 @@ typedef enum
ESP_HF_BCS_RESPONSE_EVT, /*!< Codec Negotiation */
} esp_hf_cb_event_t;
// HF callback parameters of corresponding esp event in esp_hf_cb_event_t
/// HFP AG callback parameters
typedef union
{
/**
@ -75,98 +76,85 @@ typedef union
*/
struct hf_conn_stat_param {
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
esp_hf_connection_state_t state; /*!< HF connection state */
uint32_t peer_feat; /*!< AG supported features */
esp_hf_connection_state_t state; /*!< Connection state */
uint32_t peer_feat; /*!< HF supported features */
uint32_t chld_feat; /*!< AG supported features on call hold and multiparty services */
} conn_stat; /*!< AG callback param of ESP_AG_CONNECTION_STATE_EVT */
} conn_stat; /*!< AG callback param of ESP_HF_CONNECTION_STATE_EVT */
/**
* @brief ESP_HF_AUDIO_STATE_EVT
*/
struct hf_audio_stat_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
esp_hf_audio_state_t state; /*!< audio connection state */
} audio_stat; /*!< AG callback param of ESP_AG_AUDIO_STATE_EVT */
} audio_stat; /*!< AG callback param of ESP_HF_AUDIO_STATE_EVT */
/**
* @brief ESP_HF_BVRA_RESPONSE_EVT
*/
struct hf_bvra_param {
esp_bd_addr_t remote_addr;
struct hf_vra_rep_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
esp_hf_vr_state_t value; /*!< voice recognition state */
} vra_rep; /*!< AG callback param of ESP_AG_BVRA_EVT */
} vra_rep; /*!< AG callback param of ESP_HF_BVRA_RESPONSE_EVT */
/**
* @brief ESP_HF_VOLUME_CONTROL_EVT
*/
struct hf_volume_control_param {
esp_hf_volume_type_t type; /*!< volume control target, speaker or microphone */
int volume; /*!< gain, ranges from 0 to 15 */
} volume_control; /*!< AG callback param of ESP_AG_VOLUME_CONTROL_EVT */
esp_hf_volume_type_t type; /*!< volume control target, speaker or microphone */
int volume; /*!< gain, ranges from 0 to 15 */
} volume_control; /*!< AG callback param of ESP_HF_VOLUME_CONTROL_EVT */
/**
* @brief ESP_HF_UNAT_RESPOSNE_EVT
*/
struct hf_unat_param {
char *unat;
}unat_rep;
struct hf_unat_rep_param {
char *unat; /*!< unknown AT command string */
}unat_rep; /*!< AG callback param of ESP_HF_UNAT_RESPONSE_EVT */
/**
* @brief ESP_HF_AT_RESPONSE_EVT
*/
struct hf_at_code_param {
esp_hf_at_response_code_t code; /*!< AT response code */
esp_hf_cme_err_t cme; /*!< Extended Audio Gateway Error Result Code */
} at; /*!< AG callback param of ESP_HF_EXT_AT_EVT */
/**
* @brief ESP_HF_CIND_CALL_EVT
* @brief ESP_HF_CIND_RESPONSE_EVT
*/
struct hf_cind_param {
esp_hf_call_status_t call_status; /*!< call status indicator */
esp_hf_call_setup_status_t call_setup_status; /*!< call setup status indicator */
esp_hf_network_state_t svc; /*!< bluetooth proprietary call hold status indicator */
esp_hf_network_state_t svc; /*!< bluetooth proprietary call hold status indicator */
int signal_strength; /*!< bluetooth proprietary call hold status indicator */
esp_hf_roaming_status_t roam; /*!< bluetooth proprietary call hold status indicator */
int battery_level; /*!< battery charge value, ranges from 0 to 5 */
esp_hf_call_held_status_t call_held_status; /*!< bluetooth proprietary call hold status indicator */
} cind;
} cind; /*!< AG callback param of ESP_HF_CIND_RESPONSE_EVT */
/**
* @brief ESP_HF_DIAL_EVT
*/
struct hf_out_call_param {
esp_bd_addr_t remote_addr; /*!< remote bluetooth device address */
char *num_or_loc; /*!< location in phone memory */
} out_call; /*!< AG callback param of ESP_HF_DIAL_EVT */
/**
* @brief ESP_HF_VTS_RESPOSNE_EVT
*/
struct hf_vts_param {
char *code;
}vts_rep;
struct hf_vts_rep_param {
char *code; /*!< MTF code from HF Client */
}vts_rep; /*!< AG callback param of ESP_HF_VTS_RESPONSE_EVT */
/**
* @brief ESP_HF_NREC_RESPOSNE_EVT
*/
struct hf_nrec_param {
esp_hf_nrec_t state;
} nrec;
struct hf_outcall_param {
esp_bd_addr_t remote_addr;
char *num_or_loc;
} out_call;
/**
* @brief ESP_HF_BSIR_EVT
*/
struct hf_bsir_param {
esp_bd_addr_t remote_addr;
esp_hf_in_band_ring_state_t state; /*!< setting state of in-band ring tone */
} bsir;
esp_hf_nrec_t state; /*!< NREC enabled or disabled */
} nrec; /*!< AG callback param of ESP_HF_NREC_RESPONSE_EVT */
/**
* @brief ESP_HF_BCS_RESPONSE_EVT
*/
struct hf_codec_param {
esp_hf_wbs_config_t mode;
} codec;
esp_hf_wbs_config_t mode; /*!< codec mode CVSD or mSBC */
} codec; /*!< AG callback param of ESP_HF_BAC_RESPONSE_EVT */
} esp_hf_cb_param_t;
} esp_hf_cb_param_t; /*!< HFP AG callback param compound*/
/**
* @brief AG incoming data callback function, the callback is useful in case of
@ -206,8 +194,8 @@ typedef void (* esp_hf_cb_t) (esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
** ESP HF API
************************************************************************************/
/**
* @brief Register application callback function to HFP client module. This function should be called
* only after esp_bluedroid_enable() completes successfully, used by HFP client
* @brief Register application callback function to HFP AG module. This function should be called
* only after esp_bluedroid_enable() completes successfully, used by HFP AG
*
* @param[in] callback: HFP AG event callback function
*
@ -224,6 +212,7 @@ esp_err_t esp_bt_hf_register_callback(esp_hf_cb_t callback);
* @brief Initialize the bluetooth HF AG module. This function should be called
* after esp_bluedroid_enable() completes successfully
*
* @param[in] remote_addr: remote bluetooth device address
* @return
* - ESP_OK: if the initialization request is sent successfully
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
@ -237,6 +226,7 @@ esp_err_t esp_bt_hf_init(esp_bd_addr_t remote_addr);
* @brief De-initialize for HF AG module. This function
* should be called only after esp_bluedroid_enable() completes successfully
*
* @param[in] remote_addr: remote bluetooth device address
* @return
* - ESP_OK: success
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
@ -304,8 +294,8 @@ esp_err_t esp_bt_hf_disconnect_audio(esp_bd_addr_t remote_bda);
* @brief Response of Volume Recognition Command(AT+VRA) from HFP client. As a precondition to use this API,
* Service Level Connection shall exist with HFP client.
*
* @param[in] remote: volume control target, speaker or microphone
* @param[in] volume: gain of the speaker of microphone, ranges 0 to 15
* @param[in] remote_bda: volume control target, speaker or microphone
* @param[in] value: gain of the speaker of microphone, ranges 0 to 15
*
* @return
* - ESP_OK: disconnect request is sent to lower layer
@ -318,8 +308,9 @@ esp_err_t esp_bt_hf_vra(esp_bd_addr_t remote_bda, esp_hf_vr_state_t value);
/**
*
* @brief Volume synchronization with HFP client. As a precondition to use this API,
* Service Level Connection shall exist with HFP client
* Service Level Connection shall exist with HFP client.
*
* @param[in] remote_bda: remote bluetooth device address
* @param[in] type: volume control target, speaker or microphone
* @param[in] volume: gain of the speaker of microphone, ranges 0 to 15
*
@ -334,8 +325,10 @@ esp_err_t esp_bt_hf_volume_control(esp_bd_addr_t remote_bda, esp_hf_volume_contr
/**
*
* @brief Handle Unknown AT command from HFP Client.
* As a precondition to use this API, Service Level Connection shall exist between AG and HF Client
* As a precondition to use this API, Service Level Connection shall exist between AG and HF Client.
*
* @param[in] remote_addr: remote bluetooth device address
* @param[in] unat: AT command string from HF Client
* @return
* - ESP_OK: disconnect request is sent to lower layer
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
@ -347,8 +340,11 @@ esp_err_t esp_hf_unat_response(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 between AG and HF Client
* As a precondition to use this API, Service Level Connection shall exist between AG and HF Client.
*
* @param[in] remote_bda: remote bluetooth device address
* @param[in] response_code: AT command response code
* @param[in] error_code: CME error code
* @return
* - ESP_OK: disconnect request is sent to lower layer
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
@ -362,6 +358,11 @@ esp_err_t esp_bt_hf_cmee_response(esp_bd_addr_t remote_bda, esp_hf_at_response_c
* @brief Usolicited send device status notificationto HFP Client.
* As a precondition to use this API, Service Level Connection shall exist between AG and HF Client
*
* @param[in] remote_addr: remote bluetooth device address
* @param[in] call_state: call state
* @param[in] call_setup_state: call setup state
* @param[in] ntk_state: network service state
* @param[in] signal: signal strength from 0 to 5
* @return
* - ESP_OK: disconnect request is sent to lower layer
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
@ -377,6 +378,14 @@ esp_err_t esp_bt_hf_indchange_notification(esp_bd_addr_t remote_addr, esp_hf_cal
* @brief Response to device individual indicatiors to HFP Client.
* As a precondition to use this API, Service Level Connection shall exist between AG and HF Client.
*
* @param[in] remote_addr: remote bluetooth device address
* @param[in] call_state: call state
* @param[in] call_setup_state: call setup state
* @param[in] ntk_state: network service state
* @param[in] signal: signal strength from 0 to 5
* @param[in] roam: roam state
* @param[in] batt_lev: batery level from 0 to 5
* @param[in] call_held_status: call held status
* @return
* - ESP_OK: disconnect request is sent to lower layer
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
@ -391,9 +400,11 @@ esp_err_t esp_bt_hf_cind_response(esp_bd_addr_t remote_addr,
/**
*
* @brief Query the name of currently selected network operator in AG,
* As a precondition to use this API, Service Level Connection shall exist with HFP Client
* @brief Reponse for AT+COPS command from HF Client.
* 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] name: current operator name
* @return
* - ESP_OK: disconnect request is sent to lower layer
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
@ -404,9 +415,17 @@ esp_err_t esp_bt_hf_cops_response(esp_bd_addr_t remote_addr, char *name);
/**
*
* @brief Response to Query list of current calls from HFP Client (use AT+CLCC command),
* As a precondition to use this API, Service Level Connection shall exist between AG and HF Client
* @brief Response to AT+CLCC command from HFP Client.
* As a precondition to use this API, Service Level Connection shall exist between AG and HF Client.
*
* @param[in] remote_addr: remote bluetooth device address
* @param[in] index: the index of current call
* @param[in] dir: call direction (incoming/outgoing)
* @param[in] current_call_state: current call state
* @param[in] mode: current call mode (voice/data/fax)
* @param[in] mpty: single or multi type
* @param[in] number: current call number
* @param[in] type: international type or unknow
* @return
* - ESP_OK: disconnect request is sent to lower layer
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
@ -419,9 +438,12 @@ esp_err_t esp_bt_hf_clcc_response(esp_bd_addr_t remote_addr, int index, esp_hf_c
/**
*
* @brief Get subscriber information number from HFP client(send AT+CNUM command),
* As a precondition to use this API, Service Level Connection shall exist with AG
* @brief Response for AT+CNUM command from HF Client.
* As a precondition to use this API, Service Level Connection shall exist with AG.
*
* @param[in] remote_addr: remote bluetooth device address
* @param[in] number: registration number
* @param[in] type: service type (unknown/voice/fax)
* @return
* - ESP_OK: disconnect request is sent to lower layer
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
@ -432,9 +454,11 @@ esp_err_t esp_bt_hf_cnum_response(esp_bd_addr_t remote_addr, char *number, esp_h
/**
*
* @brief Inform HF Client of Provided or not Inband Ring Tone.
* As a precondition to use this API, Service Level Connection shall exist with AG
* @brief Inform HF Client that AG Provided in-band ring tone or not.
* As a precondition to use this API, Service Level Connection shall exist with AG.
*
* @param[in] remote_addr: remote bluetooth device address
* @param[in] state: in-band ring tone state
* @return
* - ESP_OK: disconnect request is sent to lower layer
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
@ -445,9 +469,16 @@ esp_err_t esp_bt_hf_bsir(esp_bd_addr_t remote_addr, esp_hf_in_band_ring_state_t
/**
*
* @brief Answer Incoming Call by AG or response to the AT+A command from Hands-Free Unit.
* @brief Answer Incoming Call from AG.
* As a precondition to use this API, Service Level Connection shall exist with AG.
*
* @param[in] remote_addr: remote bluetooth device address
* @param[in] num_active: the number of active call
* @param[in] num_held: the number of held call
* @param[in] call_state: call state
* @param[in] call_setup_state: call setup state
* @param[in] number: number of the incoming call
* @param[in] call_addr_type: call address type
* @return
* - ESP_OK: disconnect request is sent to lower layer
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
@ -460,9 +491,16 @@ esp_err_t esp_bt_hf_answer_call(esp_bd_addr_t remote_addr, int num_active, int n
/**
*
* @brief Reject Incoming Call by AG or response to the AT+CHUP command from Hands-Free Unit.
* @brief Reject Incoming Call from AG.
* As a precondition to use this API, Service Level Connection shall exist with AG.
*
* @param[in] remote_addr: remote bluetooth device address
* @param[in] num_active: the number of active call
* @param[in] num_held: the number of held call
* @param[in] call_state: call state
* @param[in] call_setup_state: call setup state
* @param[in] number: number of the incoming call
* @param[in] call_addr_type: call address type
* @return
* - ESP_OK: disconnect request is sent to lower layer
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
@ -475,9 +513,16 @@ esp_err_t esp_bt_hf_reject_call(esp_bd_addr_t remote_addr, int num_active, int n
/**
*
* @brief Reject Incoming Call by AG or response to the AT+CHUP command from Hands-Free Unit.
* @brief Reject incoming call from AG.
* As a precondition to use this API, Service Level Connection shall exist with AG.
*
* @param[in] remote_addr: remote bluetooth device address
* @param[in] num_active: the number of active call
* @param[in] num_held: the number of held call
* @param[in] call_state: call state
* @param[in] call_setup_state: call setup state
* @param[in] number: number of the outgoing call
* @param[in] call_addr_type: call address type
* @return
* - ESP_OK: disconnect request is sent to lower layer
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
@ -490,9 +535,16 @@ esp_err_t esp_bt_hf_out_call(esp_bd_addr_t remote_addr, int num_active, int num_
/**
*
* @brief Reject Incoming Call by AG or response to the AT+CHUP command from Hands-Free Unit.
* @brief End an ongoing call.
* As a precondition to use this API, Service Level Connection shall exist with AG.
*
* @param[in] remote_addr: remote bluetooth device address
* @param[in] num_active: the number of active call
* @param[in] num_held: the number of held call
* @param[in] call_state: call state
* @param[in] call_setup_state: call setup state
* @param[in] number: number of the call
* @param[in] call_addr_type: call address type
* @return
* - ESP_OK: disconnect request is sent to lower layer
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled

View file

@ -321,7 +321,6 @@ static void bta_ag_sco_read_cback(UINT16 sco_inx, BT_HDR *p_data, tBTM_SCO_DATA_
/* Callout function must free the data. */
bta_ag_sco_co_in_data(p_data, status);
osi_free(p_data);
}
#endif
/*******************************************************************************

View file

@ -1332,6 +1332,11 @@ void btc_hf_cb_handler(btc_msg_t *msg)
}
case BTA_AG_AT_CBC_EVT:
{
btc_hf_cb_to_app(ESP_HF_IND_UPDATE_EVT, NULL);
break;
}
case BTA_AG_AT_CIND_EVT:
{
btc_hf_cind_evt(&p_data->ind);

View file

@ -152,6 +152,7 @@ static void btu_hci_msg_process(void *param)
case BT_EVT_TO_BTU_HCI_SCO:
#if BTM_SCO_INCLUDED == TRUE
btm_route_sco_data (p_msg);
osi_free(p_msg);
break;
#endif

View file

@ -57,6 +57,7 @@ INPUT = \
../../components/bt/host/bluedroid/api/include/api/esp_spp_api.h \
../../components/bt/host/bluedroid/api/include/api/esp_hf_defs.h \
../../components/bt/host/bluedroid/api/include/api/esp_hf_client_api.h \
../../components/bt/host/bluedroid/api/include/api/esp_hf_ag_api.h \
## NimBLE related Bluetooth APIs
../../components/bt/host/nimble/esp-hci/include/esp_nimble_hci.h \
## ESP BLE Mesh APIs

View file

@ -143,3 +143,4 @@ Various modules of the Bluetooth stack deliver events to applications via dedica
* A2DP: :cpp:func:`esp_a2d_register_callback`, :cpp:type:`esp_a2d_cb_event_t`, :cpp:type:`esp_a2d_cb_param_t`.
* AVRC: :cpp:func:`esp_avrc_ct_register_callback`, :cpp:type:`esp_avrc_ct_cb_event_t`, :cpp:type:`esp_avrc_ct_cb_param_t`.
* HFP Client: :cpp:func:`esp_hf_client_register_callback`, :cpp:type:`esp_hf_client_cb_event_t`, :cpp:type:`esp_hf_client_cb_param_t`.
* HFP AG: :cpp:func:`esp_hf_ag_register_callback`, :cpp:type:`esp_hf_ag_cb_event_t`, :cpp:type:`esp_hf_ag_cb_param_t`.

View file

@ -10,3 +10,4 @@ CLASSIC BT
BT SPP <esp_spp>
BT HFP Define <esp_hf_defs>
BT HFP Client <esp_hf_client>
BT HFP AG <esp_hf_ag>

View file

@ -0,0 +1,14 @@
HFP AG API
==============
Overview
--------
`Instructions`_
.. _Instructions: ../template.html
API Reference
-------------
.. include:: /_build/inc/esp_hf_ag_api.inc

View file

@ -0,0 +1 @@
.. include:: ../../../en/api-reference/bluetooth/esp_hf_ag.rst

View file

@ -1,19 +1,12 @@
# Hands-Free Audio Gateway
This example is to show how to use the APIs of Hands-Free (HF) Audio Gateway (AG) Component and the effects of them by providing a set of commands. You can use this example to communicate with a Hands-Free Unit (e.g. a headphone set). This example uses UART for user commands and uses GPIO for PCM audio data stream.
This example is to show how to use the APIs of Hands-Free (HF) Audio Gateway (AG) Component and the effects of them by providing a set of commands. You can use this example to communicate with a Hands-Free Unit (e.g. a headphone set). This example uses UART for user commands.
## How to use example
### Hardware Required
If possible, example should be able to run on any commonly available ESP32 development board and is supposed to connect to _Hands Free Unit example (hfp_hf)_ in ESP-IDF.
### Audio Data Path
ESP32 supports two types of audio data path: PCM and HCI.
- PCM : When using PCM, audio data stream is mapped to GPIO pins and you should link these GPIO pins to a speaker via I2S port.
- HCI : When using HCI, audio data stream will be transport to HF unit app via HCI.
This example is designed to run on commonly available ESP32 development board, e.g. ESP32-DevKitC. To operate it should be connected to an Hands-Free Unit running on a Headphone/Headset or on another ESP32 development board loaded with Hands Free Unit (hfp_hf) example from ESP-IDF.
### Configure the project
@ -21,9 +14,16 @@ ESP32 supports two types of audio data path: PCM and HCI.
idf.py menuconfig
```
ESP32 supports two types of audio data paths: PCM and HCI but the default sdkconfig of this example does not config the data path in a specific way. You should config the data path you want:
- PCM : When using PCM, audio data stream is directed to GPIO pins and you should link these GPIO pins to a speaker via I2S port. You should choose PCM in `menuconfig` path: `Component config --> Bluetooth controller --> BR/EDR Sync(SCO/eSCO) default data path --> PCM`and also `Component config --> Bluetooth --> Bluedroid Options -->Hands Free/Handset Profile --> audio(SCO) data path --> PCM`.
- HCI : When using HCI, audio data stream will be transport to HF unit app via HCI. You should choose HCI in `menuconfig` path: `Component config -->Bluetooth controller -->BR/EDR Sync(SCO/eSCO) default data path --> HCI` and also `Component config --> Bluetooth --> Bluedroid Options -->Hands Free/Handset Profile --> audio(SCO) data path --> HCI`.
**Note: Wide Band Speech is disabled by default, if you want to use it please select it in the menuconfig path: `Component config --> Bluetooth --> Bluedroid Options --> Wide Band Speech`.**
### Build and Flash
Build the project and flash it to the board, then run monitor tool to view serial output:
Build the project and flash it to the board. Then, run monitor tool to view serial output:
```
idf.py -p PORT flash monitor
@ -33,11 +33,11 @@ idf.py -p PORT flash monitor
(To exit the serial monitor, type ``Ctrl-]``.)
See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html) for full steps to configure and use ESP-IDF to build projects.
## Example Output
When you run this example the commands help table prints like:
When you flash and monitor this example the commands help table prints the following at the very begining:
```
########################################################################
@ -54,7 +54,7 @@ hf vroff; -- stop voice recognition
hf vu <tgt> <vol>; -- volume update
tgt: 0-speaker, 1-microphone
vol: volume gain ranges from 0 to 15
hf ind <call> <ntk> <callsetup> <sig>; -- unsolicited notify device notification to HF Client
hf ind <call> <ntk> <callsetup> <sig>; -- unsolicited indication device status to HF Client
call: call status [0,1]
callsetup: call setup status [0,3]
ntk: network status [0,1]
@ -72,11 +72,15 @@ hf h; -- to see the command for HFP AG
########################################################################
```
The commands help table will print out in monitor whenever you type `hf h;` or input a command that is not required by the command parse rule.
**Note:**
- This command help table will print out in monitor whenever you type `hf h;` or if you input a command that is not required by the command parse rule.
- The command you type will not echo in monitor and your command should always start with `hf` and end with `;` or the example will not responds.
- The command you typed will not echo in monitor.
### Service Level Connection and Disconnection
You can type `hf con;` to establish a service level connection with HF Unit device and log prints like:
You can type `hf con;` to establish a service level connection with HF Unit device and log prints such as:
```
W (2211) BT_APPL: new conn_srvc id:5, app_id:0
@ -88,9 +92,9 @@ I (2331) BT_APP_HF: APP HFP event: CONNECTION_STATE_EVT
I (2331) BT_APP_HF: --connection state SLC_CONNECTED, peer feats 0xff, chld_feats 0x4010
```
**Note: Only after HFP service is initialized and a service level connection exists between an HF Unit and an AG device, could other commands be available.**
**Note: Only after Hands-free Profile(HFP) service is initialized and a service level connection exists between an HF Unit and an AG device, could other commands be available.**
You can type `hf dis;` to disconnect with the connected HF Unit device, and log prints like:
You can type `hf dis;` to disconnect with the connected HF Unit device, and log prints such as:
```
E (100147) CNSL: Command [hf dis;]
@ -106,37 +110,32 @@ W (77381) BT_RFCOMM: RFCOMM_DisconnectInd LCID:0x41
You can type `hf cona;` to establish the audio connection between HF Unit and AG device. Also, you can type `hf disa;` to close the audio data stream.
#### Use Scenarios for Audio Connection
#### Scenarios for Audio Connection
- Answer an incoming call
- Enable voice recognition
- Dial an outgoing call
#### Use Scenarios for Audio Disconnection
#### Scenarios for Audio Disconnection
- Reject an incoming call
- Disable the voice recognition
#### Audio Data path
#### Choise of Codec
- When using PCM as the data path and this example configures PCM audio data to GPIO pins. You can link the GPIO pins to a speaker via I2S port. PCM data path does not support mSBC codec but CVSD codec.
- When using HCI data path, ESP32 support both CVSD and mSBC codec.
ESP32 supports both CVSD and mSBC codec. HF Unit and AG device determine which codec to use by exchanging features during service level connection. The choice of codec also depends on the your configuration in `menuconfig`.
#### Codec
ESP32 supports both CVSD and mSBC codec. HF Unit and AG device determine which codec to use by exchanging features in the process of a service level connection. The choice of codec also depends on the user's configuration in `menuconfig`.
Since CVSD is the default codec in HFP, we just show the scenarios using mSBC :
Since CVSD is the default codec in HFP, we just show the scenarios using mSBC:
- If you enable `BT_HFP_WBS_ENABLE` in `menuconfig`, mSBC will be available.
- If both HF Unit and AG support mSBC and also `BT_HFP_WBS_ENABLE` is enabled, ESP32 chooses mSBC.
- If both HF Unit and AG support mSBC and `BT_HFP_WBS_ENABLE` is enabled, ESP32 chooses mSBC.
- If you use PCM data path, mSBC is not available.
### Answer or Reject an Incoming Call
#### Answer an Incoming Call
You can type `hf ac;` to answer an incoming call and log prints like:
You can type `hf ac;` to answer an incoming call and log prints such as:
```
E (1066280) CNSL: Command [hf ac;]
@ -151,7 +150,7 @@ I (1067240) BT_APP_HF: --Audio State connected
#### Reject an Incoming Call
You can type `hf rc;` to reject an incoming call and log prints like:
You can type `hf rc;` to reject an incoming call and log prints such as:
```
E (10040) CNSL: Command [hf rc;]
@ -162,7 +161,7 @@ I (1067240) BT_APP_HF: --Audio State disconnected
#### End a Call
You can type `hf end;` to end the current ongoing call and log prints like:
You can type `hf end;` to end the current ongoing call and log prints such as:
```
E (157741) CNSL: Command [hf end;]
@ -175,7 +174,7 @@ I (159311) BT_APP_HF: --ESP AG Audio Connection Disconnected.
### Dial Number
You can type `hf d <num>;` to dial `<num>` from AG and log prints like:
You can type `hf d <num>;` to dial `<num>` from AG and log prints such as:
```
E (207351) CNSL: Command [hf d 18629485549;]
@ -191,19 +190,19 @@ I (208811) BT_APP_HF: --Audio State connected
### Volume Control
You can type `hf vu <tgt> <vol>;` to update volume gain of headset or microphone. The parameter set:
You can type `hf vu <tgt> <vol>;` to update the volume of a headset or microphone. The parameter should be set as follows:
- `<tgt>` : 0 - headset, 1 - microphone.
- `<vol>` : Integer among 0 - 15.
For example, `hf vu 0 9;` update the volume of headset and log on AG side prints `Volume Update`, on HF Unit side log prints like:
For example, `hf vu 0 9;` updates the volume of headset and the log on the AG side prints `Volume Update`, while on the HF Unit side the log prints:
```
E (17087) BT_HF: APP HFP event: VOLUME_CONTROL_EVT
E (17087) BT_HF: --volume_target: SPEAKER, volume 9
```
And also, `hf vu 1 9;` update the volume gain of microphone and log on HF Unit side prints like:
And also, `hf vu 1 9;` updates the volume of a microphone and the log on the HF Unit side prints:
```
E (32087) BT_HF: APP HFP event: VOLUME_CONTROL_EVT
@ -212,7 +211,7 @@ E (32087) BT_HF: --volume_target: MICROPHONE, volume 9
#### Voice Recognition
You can type `hf vron;` to start the voice recognition of AG and type `hf vroff;` to terminate the voice recognition. Both command will notify the HF Unit the status of voice recognition. For example, type `hf vron;` and log prints like:
You can type `hf vron;` to start the voice recognition and type `hf vroff;` to terminate this function in the AG device. Both commands will notify the HF Unit the status of voice recognition. For example, type `hf vron;` and the log will prints:
```
E (244131) CNSL: Command [hf vron;]
@ -224,9 +223,9 @@ I (245311) BT_APP_HF: APP HFP event: AUDIO_STATE_EVT
I (245311) BT_APP_HF: --Audio State connected
```
#### Notify Device Notification
#### Device Status Indication
You can type `hf ind <call> <ntk> <callsetup> <sig>` to send device status of AG to HF Unit. Log on AG prints like: `Device Indicator Changed!` and on HF Unit side prints like:
You can type `hf ind <call> <ntk> <callsetup> <sig>` to send device status of AG to HF Unit. Log on AG prints such as: `Device Indicator Changed!` and on HF Unit side prints such as:
```
E (293641) BT_HF: APP HFP event: CALL_IND_EVT
@ -237,26 +236,25 @@ E (293651) BT_HF: APP HFP event: SIGNAL_STRENGTH_IND_EVT
E (293661) BT_HF: -- signal strength: 5
```
**Note: AG only sends changed status to HF Unit.**
**Note: The AG device sends only the changed status to the HF Unit.**
#### Send Extended AT Error Code
You can type `hf ate <rep> <err>` to send extended AT error code to HF Unit. Parameter set:
You can type `hf ate <rep> <err>` to send extended AT error code to HF Unit. The parameter should be set as follows:
- `<rep>` : integer among 0 - 7.
- `<err>` : integer among 0 - 32.
When you type `hf ate 7 7;` log on AG side prints like `Send CME Error.` and on HF Unit side prints like:
When you type `hf ate 7 7;` the log on the AG side prints `Send CME Error.` while on the HF Unit side prints:
```
E (448146) BT_HF: APP HFP event: AT_RESPONSE
E (448146) BT_HF: --AT response event, code 7, cme 7
```
#### In-Band Ring Tone Setting
You can type `hf iron;` to enable in-band ring tone and type `hf iroff;` to disable in-band ring tone. Log on AG side prints like `Device Indicator Changed!` and on HF Unit side prints like:
You can type `hf iron;` to enable the in-band ring tone and type `hf iroff;` to disable it. The log on the AG side prints such as `Device Indicator Changed!` and on HF Unit side it prints such as:
```
E (19546) BT_HF: APP HFP event: IN-BAND_RING_TONE_EVT
@ -268,17 +266,17 @@ E (19556) BT_HF: --in-band ring state Provided
If you encounter any problems, please check if the following rules are followed:
- You should type the command in the terminal according to the format described in the commands help table.
- Not all commands in the table are supported by HF Unit.
- If you want to `hf con;` to establish a service level connection with specific HF Unit, you should add the MAC address of HF Unit in `app_hf_msg_set.c`, for example: `esp_bd_addr_t peer_addr = {0xb4, 0xe6, 0x2d, 0xeb, 0x09, 0x93};`
- Not all commands in the table are supported by the HF Unit.
- If you want to `hf con;` to establish a service level connection with a specific HF Unit, you should add the MAC address of the HF Unit in `app_hf_msg_set.c` for example: `esp_bd_addr_t peer_addr = {0xb4, 0xe6, 0x2d, 0xeb, 0x09, 0x93};`
- Use `esp_hf_client_register_callback()` and `esp_hf_client_init();` before establishing a service level connection.
## Example Breakdown
Due to the complexity of Hands Free Profile, this example has more source files than other bluetooth examples. To show functions of Hands Free Profile in a simple way, we use the Commands and Effects scheme to illustrate APIs of HFP in ESP-IDF.
Due to the complexity of the HFP, this example has more source files than other bluetooth examples. To show the functions of HFP in a simple way, we use the Commands and Effects scheme to illustrate APIs of the HFP in ESP-IDF.
- The example will respond to user command through UART console. Please go to `console_uart.c` for the configuration details.
- For voice interface, ESP32 has provided PCM input/output signals which can be mapped to GPIO pins, please go to `gpio_pcm_config.c` for the configuration details.
- The example will respond to user command through the UART console. Please go to `console_uart.c` for the configuration details.
- For the voice interface, ESP32 has provided PCM input/output signals which can be directed to GPIO pins. So, please go to `gpio_pcm_config.c` for the configuration details.
- If you want to update the command table, please refer to `app_hf_msg_set.c`.
- If you want to update the command parse rules, please refer to `app_hf_msg_prs.c`.
- If you want to update the responses of AG or want to update the log, please refer to `bt_app_hf.c`.
- Task configuration part is in `bt_app_core.c`.
- If you want to update the responses of the AG or want to update the log, please refer to `bt_app_hf.c`.
- The task configuration part is in `bt_app_core.c`.

View file

@ -30,7 +30,7 @@ void hf_msg_show_usage(void)
printf("hf vu <tgt> <vol>; -- volume update\n");
printf(" tgt: 0-speaker, 1-microphone\n");
printf(" vol: volume gain ranges from 0 to 15\n");
printf("hf ind <call> <ntk> <callsetup> <sig>; -- unsolicited notify device notification to HF Client\n");
printf("hf ind <call> <ntk> <callsetup> <sig>; -- unsolicited indication device status to HF Client\n");
printf(" call: call status [0,1]\n");
printf(" callsetup: call setup status [0,3]\n");
printf(" ntk: network status [0,1]\n");

View file

@ -190,6 +190,17 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
break;
}
case ESP_HF_IND_UPDATE_EVT:
{
ESP_LOGI(BT_HF_TAG, "--UPDATE INDCATOR!");
esp_hf_call_status_t call_state = 1;
esp_hf_call_setup_status_t call_setup_state = 2;
esp_hf_network_state_t ntk_state = 1;
int signal = 2;
esp_bt_hf_indchange_notification(hf_peer_addr,call_state,call_setup_state,ntk_state,signal);
break;
}
case ESP_HF_CIND_RESPONSE_EVT:
{
ESP_LOGI(BT_HF_TAG, "--CIND Start.");

View file

@ -96,7 +96,7 @@ esp_err_t console_uart_init(void)
ret = uart_param_config(CONSOLE_UART_NUM, &uart_cfg);
if (ret != ESP_OK) {
ESP_LOGE(TAG_CNSL, "Uart %d initialize err %04x\n", CONSOLE_UART_NUM, ret);
ESP_LOGE(TAG_CNSL, "Uart %d initialize err %04x", CONSOLE_UART_NUM, ret);
return ret;
}