Microchip® Advanced Software Framework

hsp_hs.h File Reference
#include "hci.h"
#include "classic/sdp_client_rfcomm.h"

Functions

void hsp_hs_connect (bd_addr_t bd_addr)
 Connect to HSP Audio Gateway. More...
 
void hsp_hs_create_sdp_record (uint8_t *service, uint32_t service_record_handle, int rfcomm_channel_nr, const char *name, uint8_t have_remote_audio_control)
 Create HSP Headset (HS) SDP service record. More...
 
void hsp_hs_disconnect (void)
 Disconnect from HSP Audio Gateway. More...
 
void hsp_hs_enable_custom_indications (int enable)
 Enable custom indications. More...
 
void hsp_hs_establish_audio_connection (void)
 Triger establishing audio connection. More...
 
void hsp_hs_init (uint8_t rfcomm_channel_nr)
 Set up HSP HS. More...
 
void hsp_hs_register_packet_handler (btstack_packet_handler_t callback)
 Register packet handler to receive HSP HS events. More...
 
void hsp_hs_release_audio_connection (void)
 Trigger releasing audio connection. More...
 
void hsp_hs_send_button_press (void)
 Send button press action. More...
 
int hsp_hs_send_result (const char *result)
 Send answer to custom indication. More...
 
void hsp_hs_set_microphone_gain (uint8_t gain)
 Set microphone gain. More...
 
void hsp_hs_set_speaker_gain (uint8_t gain)
 Set speaker gain. More...
 

void hsp_hs_connect ( bd_addr_t  bd_addr)

Connect to HSP Audio Gateway.

Perform SDP query for an RFCOMM service on a remote device, and establish an RFCOMM connection if such service is found. Reception of the HSP_SUBEVENT_RFCOMM_CONNECTION_COMPLETE with status 0 indicates if the connection is successfully established.

Parameters
bd_addr
void hsp_hs_create_sdp_record ( uint8_t *  service,
uint32_t  service_record_handle,
int  rfcomm_channel_nr,
const char *  name,
uint8_t  have_remote_audio_control 
)

Create HSP Headset (HS) SDP service record.

Parameters
serviceEmpty buffer in which a new service record will be stored.
rfcomm_channel_nr
name
have_remote_audio_control
void hsp_hs_disconnect ( void  )

Disconnect from HSP Audio Gateway.

Releases the RFCOMM channel. Reception of the HSP_SUBEVENT_RFCOMM_DISCONNECTION_COMPLETE with status 0 indicates if the connection is successfully released.

Parameters
bd_addr
void hsp_hs_enable_custom_indications ( int  enable)

Enable custom indications.

Custom indications are disabled by default. When enabled, custom indications are received via the HSP_SUBEVENT_AG_INDICATION.

Parameters
enable
void hsp_hs_establish_audio_connection ( void  )

Triger establishing audio connection.

Reception of the HSP_SUBEVENT_AUDIO_CONNECTION_COMPLETE with status 0 indicates if the audio connection is successfully established.

Parameters
bd_addr
void hsp_hs_init ( uint8_t  rfcomm_channel_nr)

Set up HSP HS.

Parameters
rfcomm_channel_nr
void hsp_hs_register_packet_handler ( btstack_packet_handler_t  callback)

Register packet handler to receive HSP HS events.

The HSP HS event has type HCI_EVENT_HSP_META with following subtypes:

  • HSP_SUBEVENT_RFCOMM_CONNECTION_COMPLETE
  • HSP_SUBEVENT_RFCOMM_DISCONNECTION_COMPLETE
  • 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
Parameters
callback
void hsp_hs_release_audio_connection ( void  )

Trigger releasing audio connection.

Reception of the HSP_SUBEVENT_AUDIO_DISCONNECTION_COMPLETE with status 0 indicates if the connection is successfully released.

Parameters
bd_addr
void hsp_hs_send_button_press ( void  )

Send button press action.

Toggle establish/release of audio connection.

int hsp_hs_send_result ( const char *  result)

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

Parameters
result
void hsp_hs_set_microphone_gain ( uint8_t  gain)

Set microphone gain.

The new gain value will be confirmed by the HSP Audio Gateway. A HSP_SUBEVENT_MICROPHONE_GAIN_CHANGED event will be received.

Parameters
gainValid range: [0,15]
void hsp_hs_set_speaker_gain ( uint8_t  gain)

Set speaker gain.

The new gain value will be confirmed by the HSP Audio Gateway. A HSP_SUBEVENT_SPEAKER_GAIN_CHANGED event will be received.

Parameters
gain- valid range: [0,15]