Microchip® Advanced Software Framework

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

Functions

void hsp_ag_connect (bd_addr_t bd_addr)
 Connect to HSP Headset. More...
 
void hsp_ag_create_sdp_record (uint8_t *service, uint32_t service_record_handle, int rfcomm_channel_nr, const char *name)
 Create HSP Audio Gateway (AG) SDP service record. More...
 
void hsp_ag_disconnect (void)
 Disconnect from HSP Headset. More...
 
void hsp_ag_enable_custom_commands (int enable)
 Enable custom AT commands. More...
 
void hsp_ag_establish_audio_connection (void)
 Establish audio connection. More...
 
void hsp_ag_init (uint8_t rfcomm_channel_nr)
 Set up HSP AG. More...
 
void hsp_ag_register_packet_handler (btstack_packet_handler_t callback)
 Register packet handler to receive HSP AG events. More...
 
void hsp_ag_release_audio_connection (void)
 Release audio connection. More...
 
int hsp_ag_send_result (char *result)
 Send a custom AT command to HSP Headset. More...
 
void hsp_ag_set_microphone_gain (uint8_t gain)
 Set microphone gain. More...
 
void hsp_ag_set_speaker_gain (uint8_t gain)
 Set speaker gain. More...
 
void hsp_ag_start_ringing (void)
 Start ringing because of incoming call. More...
 
void hsp_ag_stop_ringing (void)
 Stop ringing (e.g. More...
 

void hsp_ag_connect ( bd_addr_t  bd_addr)

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. Reception of the HSP_SUBEVENT_RFCOMM_CONNECTION_COMPLETE with status 0 indicates if the connection is successfully established.

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

Create HSP Audio Gateway (AG) SDP service record.

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

Disconnect from HSP Headset.

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

Parameters
bd_addr
void hsp_ag_enable_custom_commands ( int  enable)

Enable custom AT commands.

Custom commands are disabled by default. When enabled, custom AT commands are received via the HSP_SUBEVENT_HS_COMMAND.

Parameters
enable
void hsp_ag_establish_audio_connection ( void  )

Establish 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_ag_init ( uint8_t  rfcomm_channel_nr)

Set up HSP AG.

Parameters
rfcomm_channel_nr
void hsp_ag_register_packet_handler ( btstack_packet_handler_t  callback)

Register packet handler to receive HSP AG events.

The HSP AG 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_MICROPHONE_GAIN_CHANGED
  • HSP_SUBEVENT_SPEAKER_GAIN_CHANGED
  • HSP_SUBEVENT_HS_COMMAND
Parameters
callback
void hsp_ag_release_audio_connection ( void  )

Release audio connection.

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

Parameters
bd_addr
int hsp_ag_send_result ( char *  result)

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.

Parameters
result
void hsp_ag_set_microphone_gain ( uint8_t  gain)

Set microphone gain.

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

Set speaker gain.

Parameters
gainValid range: [0,15]
void hsp_ag_start_ringing ( void  )

Start ringing because of incoming call.

void hsp_ag_stop_ringing ( void  )

Stop ringing (e.g.

call was terminated).