mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-26 12:35:25 +00:00
hsp docu
This commit is contained in:
parent
d4d01b595d
commit
6c63e7d47b
@ -33,6 +33,10 @@ apis = [
|
||||
["src/sdp_query_rfcomm.h", "SDP RFCOMM Query", "sdpQueries"],
|
||||
["src/sdp_query_util.h","SDP Query Utils","sdpQueryUtil"],
|
||||
["include/btstack/sdp_util.h","SDP Utils", "sdpUtil"]
|
||||
["src/hsp_hf.h","HSP Headset","hspHF"],
|
||||
["src/hsp_ag.h","HSP Audio Gateway","hspAG"],
|
||||
["src/hsp_hf.h","HFP Headset","hfpHF"],
|
||||
["src/hsp_ag.h","HFP Audio Gateway","hfpAG"]
|
||||
]
|
||||
|
||||
functions = {}
|
||||
|
20
src/hsp_ag.c
20
src/hsp_ag.c
@ -310,18 +310,20 @@ void hsp_ag_set_speaker_gain(uint8_t gain){
|
||||
hsp_run();
|
||||
}
|
||||
|
||||
static void hsp_timeout_handler(timer_source_t * timer){
|
||||
static void hsp_ringing_timeout_handler(timer_source_t * timer){
|
||||
ag_ring = 1;
|
||||
}
|
||||
|
||||
static void hsp_timeout_start(void){
|
||||
run_loop_remove_timer(&hs_timeout);
|
||||
run_loop_set_timer_handler(&hs_timeout, hsp_timeout_handler);
|
||||
run_loop_set_timer(&hs_timeout, 2000); // 2 seconds timeout
|
||||
run_loop_add_timer(&hs_timeout);
|
||||
}
|
||||
|
||||
static void hsp_timeout_stop(void){
|
||||
static void hsp_ringing_timer_start(void){
|
||||
run_loop_remove_timer(&hs_timeout);
|
||||
run_loop_set_timer_handler(&hs_timeout, hsp_ringing_timeout_handler);
|
||||
run_loop_set_timer(&hs_timeout, 2000); // 2 seconds timeout
|
||||
run_loop_add_timer(&hs_timeout);
|
||||
}
|
||||
|
||||
static void hsp_ringing_timer_stop(void){
|
||||
run_loop_remove_timer(&hs_timeout);
|
||||
}
|
||||
|
||||
@ -329,14 +331,14 @@ void hsp_ag_start_ringing(void){
|
||||
if (hsp_state != HSP_W2_CONNECT_SCO) return;
|
||||
ag_ring = 1;
|
||||
hsp_state = HSP_W4_RING_ANSWER;
|
||||
hsp_timeout_start();
|
||||
hsp_ringing_timer_start();
|
||||
}
|
||||
|
||||
void hsp_ag_stop_ringing(void){
|
||||
ag_ring = 0;
|
||||
ag_num_button_press_received = 0;
|
||||
hsp_state = HSP_W2_CONNECT_SCO;
|
||||
hsp_timeout_stop();
|
||||
hsp_ringing_timer_stop();
|
||||
}
|
||||
|
||||
static void hsp_run(void){
|
||||
|
90
src/hsp_ag.h
90
src/hsp_ag.h
@ -52,39 +52,107 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* API_START */
|
||||
|
||||
/**
|
||||
* @brief Packet handler for HSP Audio Gateway (AG) events.
|
||||
*
|
||||
* The HSP AG event has type HCI_EVENT_HSP_META with following subtypes:
|
||||
* - HSP_SUBEVENT_ERROR
|
||||
* - HSP_SUBEVENT_AUDIO_CONNECTION_COMPLETE
|
||||
* - HSP_SUBEVENT_AUDIO_DISCONNECTION_COMPLETE
|
||||
* - HSP_SUBEVENT_MICROPHONE_GAIN_CHANGED
|
||||
* - HSP_SUBEVENT_SPEAKER_GAIN_CHANGED
|
||||
* - HSP_SUBEVENT_HS_COMMAND
|
||||
*
|
||||
* @param event See include/btstack/hci_cmds.h
|
||||
* @param event_size
|
||||
*/
|
||||
typedef void (*hsp_ag_callback_t)(uint8_t * event, uint16_t event_size);
|
||||
|
||||
|
||||
void hsp_ag_create_sdp_record(uint8_t * service, int rfcomm_channel_nr, const char * name);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set up HSP AG.
|
||||
* @param rfcomm_channel_nr
|
||||
*/
|
||||
void hsp_ag_init(uint8_t rfcomm_channel_nr);
|
||||
|
||||
// Register callback (packet handler) for hsp audio gateway
|
||||
/**
|
||||
* @brief Create HSP Audio Gateway (AG) SDP service record.
|
||||
* @param service Empty buffer in which a new service record will be stored.
|
||||
* @param rfcomm_channel_nr
|
||||
* @param name
|
||||
*/
|
||||
void hsp_ag_create_sdp_record(uint8_t * service, int rfcomm_channel_nr, const char * name);
|
||||
|
||||
/**
|
||||
* @brief Register packet handler to receive HSP AG events.
|
||||
* @param callback
|
||||
*/
|
||||
void hsp_ag_register_packet_handler(hsp_ag_callback_t callback);
|
||||
|
||||
/**
|
||||
* @brief Connect to HSP Headset
|
||||
*
|
||||
* Perform SDP query for an RFCOMM service on a remote device,
|
||||
* and establish an RFCOMM connection if such service is found. The reception of the
|
||||
* HSP_SUBEVENT_AUDIO_CONNECTION_COMPLETE or
|
||||
* HSP_SUBEVENT_AUDIO_DISCONNECTION_COMPLETE event
|
||||
* indicate if the connection is successfully established or not.
|
||||
*
|
||||
* @param bd_addr
|
||||
*/
|
||||
void hsp_ag_connect(bd_addr_t bd_addr);
|
||||
|
||||
/**
|
||||
* @brief Disconnect from HSP Headset.
|
||||
*
|
||||
* Releases the RFCOMM channel.
|
||||
* @param bd_addr
|
||||
*/
|
||||
void hsp_ag_disconnect(void);
|
||||
|
||||
// +VGM=[0..15]
|
||||
/**
|
||||
* @brief Set microphone gain.
|
||||
* @param gain Valid range: [0,15]
|
||||
*/
|
||||
void hsp_ag_set_microphone_gain(uint8_t gain);
|
||||
|
||||
// +VGS=[0..15]
|
||||
/**
|
||||
* @brief Set speaker gain.
|
||||
* @param gain Valid range: [0,15]
|
||||
*/
|
||||
void hsp_ag_set_speaker_gain(uint8_t gain);
|
||||
|
||||
/**
|
||||
* @brief Start ringing because of incoming call.
|
||||
*/
|
||||
void hsp_ag_start_ringing(void);
|
||||
|
||||
/**
|
||||
* @brief Stop ringing (e.g. call was terminated).
|
||||
*/
|
||||
void hsp_ag_stop_ringing(void);
|
||||
|
||||
// When support custom commands is enabled, AG will emit HSP_SUBEVENT_HS_COMMAND.
|
||||
// On occurance of this event, client's packet handler must send the result back
|
||||
// by calling hsp_ag_send_result function.
|
||||
|
||||
/**
|
||||
* @brief Enable custom AT commands.
|
||||
*
|
||||
* Custom commands are disabled by default.
|
||||
* When enabled, custom AT commands are received via the HSP_SUBEVENT_HS_COMMAND.
|
||||
* @param enable
|
||||
*/
|
||||
void hsp_ag_enable_custom_commands(int enable);
|
||||
|
||||
/**
|
||||
* @brief Send a custom AT command to HSP Headset.
|
||||
*
|
||||
* On HSP_SUBEVENT_AG_INDICATION, the client needs to respond
|
||||
* with this function with the result to the custom command.
|
||||
* @param result
|
||||
*/
|
||||
int hsp_ag_send_result(char * result);
|
||||
|
||||
/* API_END */
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
32
src/hsp_hs.h
32
src/hsp_hs.h
@ -55,30 +55,40 @@ extern "C" {
|
||||
/* API_START */
|
||||
|
||||
/**
|
||||
* @brief Packet handler for HSP Headset (HS) events. The HSP HS event has type HCI_EVENT_HSP_META with following subtypes:
|
||||
* @brief Packet handler for HSP Headset (HS) events.
|
||||
*
|
||||
* The HSP HS event has type HCI_EVENT_HSP_META with following subtypes:
|
||||
* - HSP_SUBEVENT_ERROR
|
||||
* - HSP_SUBEVENT_AUDIO_CONNECTION_COMPLETE
|
||||
* - HSP_SUBEVENT_AUDIO_DISCONNECTION_COMPLETE
|
||||
* - HSP_SUBEVENT_RING
|
||||
* - HSP_SUBEVENT_MICROPHONE_GAIN_CHANGED
|
||||
* - HSP_SUBEVENT_SPEAKER_GAIN_CHANGED
|
||||
* - HSP_SUBEVENT_AG_INDICATION
|
||||
* - HSP_SUBEVENT_AG_INDICATION
|
||||
*
|
||||
* @param event See include/btstack/hci_cmds.h
|
||||
* @param event_size
|
||||
*/
|
||||
typedef void (*hsp_hs_callback_t)(uint8_t * event, uint16_t event_size);
|
||||
|
||||
/**
|
||||
* @brief Set up HSP HS
|
||||
* @brief Set up HSP HS.
|
||||
* @param rfcomm_channel_nr
|
||||
*/
|
||||
void hsp_hs_init(uint8_t rfcomm_channel_nr);
|
||||
|
||||
/**
|
||||
* @brief Create HSP Headset (HS) SDP service record. have_remote_audio_control?
|
||||
* @brief Create HSP Headset (HS) SDP service record.
|
||||
* @param service Empty buffer in which a new service record will be stored.
|
||||
* @param rfcomm_channel_nr
|
||||
* @param name
|
||||
* @param have_remote_audio_control
|
||||
*/
|
||||
void hsp_hs_create_sdp_record(uint8_t * service, int rfcomm_channel_nr, const char * name, uint8_t have_remote_audio_control);
|
||||
|
||||
/**
|
||||
* @brief Register packet handler to receive HSP HS events.
|
||||
* @param callback
|
||||
*/
|
||||
void hsp_hs_register_packet_handler(hsp_hs_callback_t callback);
|
||||
|
||||
@ -90,6 +100,8 @@ void hsp_hs_register_packet_handler(hsp_hs_callback_t callback);
|
||||
* HSP_SUBEVENT_AUDIO_CONNECTION_COMPLETE or
|
||||
* HSP_SUBEVENT_AUDIO_DISCONNECTION_COMPLETE event
|
||||
* indicate if the connection is successfully established or not.
|
||||
*
|
||||
* @param bd_addr
|
||||
*/
|
||||
void hsp_hs_connect(bd_addr_t bd_addr);
|
||||
|
||||
@ -97,6 +109,7 @@ void hsp_hs_connect(bd_addr_t bd_addr);
|
||||
* @brief Disconnect from HSP Audio Gateway
|
||||
*
|
||||
* Releases the RFCOMM channel.
|
||||
* @param bd_addr
|
||||
*/
|
||||
void hsp_hs_disconnect(bd_addr_t bd_addr);
|
||||
|
||||
@ -105,7 +118,7 @@ void hsp_hs_disconnect(bd_addr_t bd_addr);
|
||||
*
|
||||
* The new gain value will be confirmed by the HSP Audio Gateway.
|
||||
* A HSP_SUBEVENT_MICROPHONE_GAIN_CHANGED event will be received.
|
||||
* @param gain - valid range: [0,15]
|
||||
* @param gain Valid range: [0,15]
|
||||
*/
|
||||
void hsp_hs_set_microphone_gain(uint8_t gain);
|
||||
|
||||
@ -120,24 +133,27 @@ void hsp_hs_set_speaker_gain(uint8_t gain);
|
||||
|
||||
/**
|
||||
* @brief Send button press action.
|
||||
* @param gain Valid range: [0,15]
|
||||
*/
|
||||
void hsp_hs_send_button_press(void);
|
||||
|
||||
/**
|
||||
* @brief Enable custom indications
|
||||
*
|
||||
* Custom indications are disable by default.
|
||||
* Custom indications are disabled by default.
|
||||
* When enabled, custom indications are received via the HSP_SUBEVENT_AG_INDICATION.
|
||||
* @param enable
|
||||
*/
|
||||
void hsp_hs_enable_custom_indications(int enable);
|
||||
|
||||
/**
|
||||
* @brief Send answer to custom command
|
||||
* @brief Send answer to custom indication
|
||||
*
|
||||
* On HSP_SUBEVENT_AG_INDICATION, the client needs to respond
|
||||
* with this function with the result to the custom indication
|
||||
* @param result
|
||||
*/
|
||||
int hsp_hs_send_result(const char * indication);
|
||||
int hsp_hs_send_result(const char * result);
|
||||
|
||||
/* API_END */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user