hsp_hs: code review

This commit is contained in:
Matthias Ringwald 2016-02-12 14:57:38 +01:00
parent b272847fe5
commit 294b9a8299
2 changed files with 17 additions and 22 deletions

View File

@ -37,7 +37,7 @@
// *****************************************************************************
//
// Minimal setup for HSP Headset (!! UNDER DEVELOPMENT !!)
// HSP Headset
//
// *****************************************************************************
@ -155,13 +155,10 @@ static int hsp_hs_send_str_over_rfcomm(uint16_t cid, const char * command){
return err;
}
void hsp_hs_support_custom_indications(int enable){
void hsp_hs_enable_custom_indications(int enable){
hs_support_custom_indications = enable;
}
// When support custom commands is enabled, AG will send HSP_SUBEVENT_HS_COMMAND.
// On occurance of this event, client's packet handler must send the result back
// by calling hsp_hs_send_result function.
int hsp_hs_send_result(char * result){
if (!hs_support_custom_indications) return 1;
return hsp_hs_send_str_over_rfcomm(rfcomm_cid, result);
@ -547,10 +544,6 @@ static void packet_handler (void * connection, uint8_t packet_type, uint16_t cha
break;
case HCI_EVENT_DISCONNECTION_COMPLETE:
printf("HCI_EVENT_DISCONNECTION_COMPLETE \n");
// if (hsp_state != HSP_W4_SCO_DISCONNECTED){
// printf("received gap disconnect in wrong hsp state\n");
// }
handle = READ_BT_16(packet,3);
if (handle == sco_handle){
sco_handle = 0;
@ -560,10 +553,6 @@ static void packet_handler (void * connection, uint8_t packet_type, uint16_t cha
}
break;
case RFCOMM_EVENT_CHANNEL_CLOSED:
printf("RFCOMM_EVENT_CHANNEL_CLOSED\n");
// if (hsp_state != HSP_W4_RFCOMM_DISCONNECTED){
// printf("received RFCOMM disconnect in wrong hsp state\n");
// }
printf("RFCOMM channel closed\n");
hsp_hs_reset_state();
emit_event(HSP_SUBEVENT_AUDIO_DISCONNECTION_COMPLETE,0);
@ -600,7 +589,7 @@ static void handle_query_rfcomm_event(sdp_query_event_t * event, void * context)
}
}
void hsp_hs_press_button(void){
void hsp_hs_send_button_press(void){
hs_send_button_press = 1;
hsp_run();
}

View File

@ -37,7 +37,7 @@
// *****************************************************************************
//
// HSP Headset (!! UNDER DEVELOPMENT !!)
// HSP Headset
//
// *****************************************************************************
@ -53,26 +53,32 @@ extern "C" {
#endif
typedef void (*hsp_hs_callback_t)(uint8_t * event, uint16_t event_size);
// Register callback (packet handler) for hsp headset
void hsp_hs_register_packet_handler(hsp_hs_callback_t callback);
void hsp_hs_create_service(uint8_t * service, int rfcomm_channel_nr, const char * name, uint8_t have_remote_audio_control);
void hsp_hs_init(uint8_t rfcomm_channel_nr);
void hsp_hs_create_service(uint8_t * service, int rfcomm_channel_nr, const char * name, uint8_t have_remote_audio_control);
// Register callback (packet handler) for hsp headset
void hsp_hs_register_packet_handler(hsp_hs_callback_t callback);
void hsp_hs_connect(bd_addr_t bd_addr);
void hsp_hs_disconnect(bd_addr_t bd_addr);
// AT+VGM=[0..15]
void hsp_hs_set_microphone_gain(uint8_t gain);
// AT+VGS=[0..15]
void hsp_hs_set_speaker_gain(uint8_t gain);
void hsp_hs_support_custom_indications(int enable);
void hsp_hs_send_button_press(void);
void hsp_hs_press_button(void);
// When support custom commands is enabled, AG will send HSP_SUBEVENT_AG_INDICATION.
// When support custom indications is enabled, HS will send HSP_SUBEVENT_HS_INDICATION.
// On occurance of this event, client's packet handler must send the result back
// by calling hsp_hs_send_result function.
void hsp_hs_enable_custom_indications(int enable);
int hsp_hs_send_result(char * indication);
#if defined __cplusplus