hfp_ag: API review

This commit is contained in:
Matthias Ringwald 2016-02-12 15:36:11 +01:00
parent 294b9a8299
commit bd23fc3eaf
10 changed files with 137 additions and 163 deletions

View File

@ -239,7 +239,7 @@ int btstack_main(int argc, const char * argv[]){
sdp_init();
memset((uint8_t *)hsp_service_buffer, 0, sizeof(hsp_service_buffer));
hsp_hs_create_service((uint8_t *)hsp_service_buffer, rfcomm_channel_nr, hsp_hs_service_name, 0);
hsp_hs_create_sdp_record((uint8_t *)hsp_service_buffer, rfcomm_channel_nr, hsp_hs_service_name, 0);
sdp_register_service_internal(NULL, (uint8_t *)hsp_service_buffer);

View File

@ -37,7 +37,7 @@
// *****************************************************************************
//
// Minimal setup for HFP Audio Gateway (AG) unit (!! UNDER DEVELOPMENT !!)
// HFP Audio Gateway (AG) unit
//
// *****************************************************************************
@ -51,16 +51,16 @@
#include <btstack/hci_cmds.h>
#include <btstack/run_loop.h>
#include "hci.h"
#include "btstack_memory.h"
#include "hci_dump.h"
#include "l2cap.h"
#include "sdp_query_rfcomm.h"
#include "sdp.h"
#include "debug.h"
#include "hci.h"
#include "hci_dump.h"
#include "hfp.h"
#include "hfp_gsm_model.h"
#include "hfp_ag.h"
#include "hfp_gsm_model.h"
#include "l2cap.h"
#include "sdp.h"
#include "sdp_query_rfcomm.h"
static const char default_hfp_ag_service_name[] = "Voice gateway";

View File

@ -37,7 +37,7 @@
// *****************************************************************************
//
// Minimal setup for HFP Audio Gateway (AG) unit (!! UNDER DEVELOPMENT !!)
// HFP Audio Gateway (AG) unit
//
// *****************************************************************************
@ -46,9 +46,7 @@
#define btstack_hfp_ag_h
#include "hci.h"
#include "sdp_query_rfcomm.h"
#include "hfp.h"
#include "hfp_gsm_model.h"
#if defined __cplusplus
extern "C" {
@ -80,6 +78,14 @@ void hfp_ag_init(uint16_t rfcomm_channel_nr, uint32_t supported_features,
*/
void hfp_ag_register_packet_handler(hfp_callback_t callback);
/**
* @brief Enable in-band ring tone
*/
void hfp_ag_set_use_in_band_ring_tone(int use_in_band_ring_tone);
// actions used by local device / user
/**
* @brief Establish RFCOMM connection, and perform service level connection agreement:
* - exchange of supported features
@ -93,72 +99,10 @@ void hfp_ag_establish_service_level_connection(bd_addr_t bd_addr);
/**
* @brief Release the RFCOMM channel and the audio connection between the HF and the AG.
* TODO: trigger release of the audio connection
* TODO: trigger release of the audio connection ??
*/
void hfp_ag_release_service_level_connection(bd_addr_t bd_addr);
/**
* @brief Report Extended Audio Gateway Error result codes in the AG.
* Whenever there is an error relating to the functionality of the AG as a
* result of AT command, the AG shall send +CME ERROR:
* - +CME ERROR: 0 - AG failure
* - +CME ERROR: 1 - no connection to phone
* - +CME ERROR: 3 - operation not allowed
* - +CME ERROR: 4 - operation not supported
* - +CME ERROR: 5 - PH-SIM PIN required
* - +CME ERROR: 10 - SIM not inserted
* - +CME ERROR: 11 - SIM PIN required
* - +CME ERROR: 12 - SIM PUK required
* - +CME ERROR: 13 - SIM failure
* - +CME ERROR: 14 - SIM busy
* - +CME ERROR: 16 - incorrect password
* - +CME ERROR: 17 - SIM PIN2 required
* - +CME ERROR: 18 - SIM PUK2 required
* - +CME ERROR: 20 - memory full
* - +CME ERROR: 21 - invalid index
* - +CME ERROR: 23 - memory failure
* - +CME ERROR: 24 - text string too long
* - +CME ERROR: 25 - invalid characters in text string
* - +CME ERROR: 26 - dial string too long
* - +CME ERROR: 27 - invalid characters in dial string
* - +CME ERROR: 30 - no network service
* - +CME ERROR: 31 - network Timeout.
* - +CME ERROR: 32 - network not allowed Emergency calls only
*/
void hfp_ag_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr, hfp_cme_error_t error);
/**
* @brief Report the change in AG's call status.
* Call status:
* - 0 = No calls (held or active)
* - 1 = Call is present (active or held)
*/
void hfp_ag_transfer_call_status(bd_addr_t bd_addr, hfp_call_status_t status);
/**
* @brief Report the change in AG's call setup status.
* Call setup status:
* - 0 = No call setup in progress
* - 1 = Incoming call setup in progress
* - 2 = Outgoing call setup in dialing state
* - 3 = Outgoing call setup in alerting state
*/
void hfp_ag_transfer_callsetup_status(bd_addr_t bd_addr, hfp_callsetup_status_t status);
/**
* @brief Report the change in AG's held call status.
* Held call status:
* - 0 = No calls held
* - 1 = Call is placed on hold or active/held calls are swapped
* - 2 = Call on hold, no active calls
*/
void hfp_ag_transfer_callheld_status(bd_addr_t bd_addr, hfp_callheld_status_t status);
/**
* @brief
*/
void hfp_ag_negotiate_codecs(bd_addr_t bd_addr);
/**
* @brief
*/
@ -169,11 +113,76 @@ void hfp_ag_establish_audio_connection(bd_addr_t bd_addr);
*/
void hfp_ag_release_audio_connection(bd_addr_t bd_addr);
/**
* @brief
*/
void hfp_ag_answer_incoming_call(void);
/**
* @brief Enable in-band ring tone
* @brief
*/
void hfp_ag_set_use_in_band_ring_tone(int use_in_band_ring_tone);
void hfp_ag_join_held_call(void);
/**
* @brief
*/
void hfp_ag_terminate_call(void);
/*
* @brief
*/
void hfp_ag_hold_incoming_call(void);
/*
* @brief
*/
void hfp_ag_accept_held_incoming_call(void);
/*
* @brief
*/
void hfp_ag_reject_held_incoming_call(void);
/*
* @brief
*/
void hfp_ag_set_microphone_gain(bd_addr_t bd_addr, int gain);
/*
* @brief
*/
void hfp_ag_set_speaker_gain(bd_addr_t bd_addr, int gain);
/*
* @brief
*/
void hfp_ag_set_battery_level(int level);
/*
* @brief
*/
void hfp_ag_clear_last_dialed_number(void);
// Voice Recognition
/*
* @brief
*/
void hfp_ag_activate_voice_recognition(bd_addr_t bd_addr, int activate);
/*
* @brief
*/
void hfp_ag_send_phone_number_for_voice_tag(bd_addr_t bd_addr, const char * number);
/*
* @brief
*/
void hfp_ag_reject_phone_number_for_voice_tag(bd_addr_t bd_addr);
// Cellular Actions
/**
* @brief
@ -209,22 +218,6 @@ void hfp_ag_outgoing_call_established(void);
* @brief
*/
void hfp_ag_call_dropped(void);
/**
* @brief
*/
void hfp_ag_answer_incoming_call(void);
/**
* @brief
*/
void hfp_ag_join_held_call(void);
/**
* @brief
*/
void hfp_ag_terminate_call(void);
/*
* @brief
*/
@ -240,75 +233,49 @@ void hfp_ag_set_signal_strength(int strength);
*/
void hfp_ag_set_roaming_status(int status);
/*
* @brief
*/
void hfp_ag_set_battery_level(int level);
/*
* @brief
*/
void hfp_ag_activate_voice_recognition(bd_addr_t bd_addr, int activate);
/*
* @brief
*/
void hfp_ag_set_microphone_gain(bd_addr_t bd_addr, int gain);
/*
* @brief
*/
void hfp_ag_set_speaker_gain(bd_addr_t bd_addr, int gain);
/*
* @brief
*/
void hfp_ag_send_phone_number_for_voice_tag(bd_addr_t bd_addr, const char * number);
/*
* @brief
*/
void hfp_ag_reject_phone_number_for_voice_tag(bd_addr_t bd_addr);
/*
* @brief
*/
void hfp_ag_send_dtmf_code_done(bd_addr_t bd_addr);
/*
* @brief
*/
void hfp_ag_set_subcriber_number_information(hfp_phone_number_t * numbers, int numbers_count);
/*
* @brief
* @brief Called by cellular unit after a DTMF code was transmitted, so that the next one can be emitted
*/
void hfp_ag_send_dtmf_code_done(bd_addr_t bd_addr);
void hfp_ag_send_current_call_status(bd_addr_t bd_addr, int idx);
/*
* @brief
/**
* @brief Report Extended Audio Gateway Error result codes in the AG.
* Whenever there is an error relating to the functionality of the AG as a
* result of AT command, the AG shall send +CME ERROR:
* - +CME ERROR: 0 - AG failure
* - +CME ERROR: 1 - no connection to phone
* - +CME ERROR: 3 - operation not allowed
* - +CME ERROR: 4 - operation not supported
* - +CME ERROR: 5 - PH-SIM PIN required
* - +CME ERROR: 10 - SIM not inserted
* - +CME ERROR: 11 - SIM PIN required
* - +CME ERROR: 12 - SIM PUK required
* - +CME ERROR: 13 - SIM failure
* - +CME ERROR: 14 - SIM busy
* - +CME ERROR: 16 - incorrect password
* - +CME ERROR: 17 - SIM PIN2 required
* - +CME ERROR: 18 - SIM PUK2 required
* - +CME ERROR: 20 - memory full
* - +CME ERROR: 21 - invalid index
* - +CME ERROR: 23 - memory failure
* - +CME ERROR: 24 - text string too long
* - +CME ERROR: 25 - invalid characters in text string
* - +CME ERROR: 26 - dial string too long
* - +CME ERROR: 27 - invalid characters in dial string
* - +CME ERROR: 30 - no network service
* - +CME ERROR: 31 - network Timeout.
* - +CME ERROR: 32 - network not allowed Emergency calls only
*/
void hfp_ag_hold_incoming_call(void);
/*
* @brief
*/
void hfp_ag_accept_held_incoming_call(void);
/*
* @brief
*/
void hfp_ag_reject_held_incoming_call(void);
/*
* @brief
*/
void hfp_ag_clear_last_dialed_number(void);
void hfp_ag_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr, hfp_cme_error_t error);
/* API_END */
#if defined __cplusplus
}
#endif

View File

@ -37,13 +37,13 @@
// *****************************************************************************
//
// Minimal setup for HFP Hands-Free (HF) unit (!! UNDER DEVELOPMENT !!)
// HFP Hands-Free (HF) unit
//
// *****************************************************************************
#ifndef btstack_hfp_hf_h
#define btstack_hfp_hf_h
#ifndef __BTSTACK_HFP_HF_H
#define __BTSTACK_HFP_HF_H
#include "hci.h"
#include "sdp_query_rfcomm.h"
@ -55,7 +55,6 @@ extern "C" {
/* API_START */
/**
* @brief Create HFP Hands-Free (HF) SDP service record.
*/
@ -66,8 +65,11 @@ void hfp_hf_create_sdp_record(uint8_t * service, int rfcomm_channel_nr, const ch
* TODO: move optional params into setters
*/
void hfp_hf_init(uint16_t rfcomm_channel_nr, uint32_t supported_features, uint16_t * indicators, int indicators_nr, uint32_t indicators_status);
void hfp_hf_set_codecs(uint8_t * codecs, int codecs_nr);
void hfp_hf_set_supported_features(uint32_t supported_features);
/**
* @brief Register callback for the HFP Hands-Free (HF) client.
*/
@ -83,7 +85,6 @@ void hfp_hf_register_packet_handler(hfp_callback_t callback);
* - retrieve which HF indicators are enabled on the AG, if possible
*/
void hfp_hf_establish_service_level_connection(bd_addr_t bd_addr);
void hfp_hf_set_supported_features(uint32_t supported_features);
/**
* @brief Release the RFCOMM channel and the audio connection between the HF and the AG.
@ -95,6 +96,7 @@ void hfp_hf_release_service_level_connection(bd_addr_t bd_addr);
* @brief Deactivate/reactivate status update for all indicators in the AG.
*/
void hfp_hf_enable_status_update_for_all_ag_indicators(bd_addr_t bd_addr);
void hfp_hf_disable_status_update_for_all_ag_indicators(bd_addr_t bd_addr);
/**
@ -106,6 +108,8 @@ void hfp_hf_set_status_update_for_individual_ag_indicators(bd_addr_t bd_addr, ui
/**
* @brief Find out the name of the currently selected Network operator by AG.
* The name is restricted to max 16 characters.
*
* TODO: what is the result of this?
*/
void hfp_hf_query_operator_selection(bd_addr_t bd_addr);
@ -196,7 +200,8 @@ void hfp_hf_terminate_call(bd_addr_t bd_addr);
void hfp_hf_dial_number(bd_addr_t bd_addr, char * number);
/**
* @brief
* @brief
* TODO: use int for number instead of string?
*/
void hfp_hf_dial_memory(bd_addr_t bd_addr, char * number);
@ -317,4 +322,4 @@ void hfp_hf_set_hf_indicator(bd_addr_t addr, int assigned_number, int value);
}
#endif
#endif
#endif // __BTSTACK_HFP_HF_H

View File

@ -146,7 +146,7 @@ static void emit_event_audio_connected(uint8_t status, uint16_t handle){
(*hsp_hs_callback)(event, sizeof(event));
}
void hsp_ag_create_service(uint8_t * service, int rfcomm_channel_nr, const char * name){
void hsp_ag_create_sdp_record(uint8_t * service, int rfcomm_channel_nr, const char * name){
uint8_t* attribute;
de_create_sequence(service);

View File

@ -54,9 +54,11 @@ extern "C" {
typedef void (*hsp_ag_callback_t)(uint8_t * event, uint16_t event_size);
void hsp_ag_init(uint8_t rfcomm_channel_nr);
void hsp_ag_create_service(uint8_t * service, int rfcomm_channel_nr, const char * name);
void hsp_ag_create_sdp_record(uint8_t * service, int rfcomm_channel_nr, const char * name);
void hsp_ag_init(uint8_t rfcomm_channel_nr);
// Register callback (packet handler) for hsp audio gateway
void hsp_ag_register_packet_handler(hsp_ag_callback_t callback);

View File

@ -165,7 +165,7 @@ int hsp_hs_send_result(char * result){
}
void hsp_hs_create_service(uint8_t * service, int rfcomm_channel_nr, const char * name, uint8_t 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){
uint8_t* attribute;
de_create_sequence(service);

View File

@ -56,7 +56,7 @@ typedef void (*hsp_hs_callback_t)(uint8_t * event, uint16_t event_size);
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);
void hsp_hs_create_sdp_record(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);

View File

@ -186,7 +186,7 @@ int btstack_main(int argc, const char * argv[]);
int btstack_main(int argc, const char * argv[]){
// init SDP, create record for SPP and register with SDP
memset((uint8_t *)hsp_service_buffer, 0, sizeof(hsp_service_buffer));
hsp_ag_create_service((uint8_t *)hsp_service_buffer, rfcomm_channel_nr, hsp_ag_service_name);
hsp_ag_create_sdp_record((uint8_t *)hsp_service_buffer, rfcomm_channel_nr, hsp_ag_service_name);
hsp_ag_init(rfcomm_channel_nr);
hsp_ag_register_packet_handler(packet_handler);

View File

@ -317,7 +317,7 @@ int btstack_main(int argc, const char * argv[]){
hci_register_sco_packet_handler(&sco_packet_handler);
memset((uint8_t *)hsp_service_buffer, 0, sizeof(hsp_service_buffer));
hsp_hs_create_service((uint8_t *)hsp_service_buffer, rfcomm_channel_nr, hsp_hs_service_name, 0);
hsp_hs_create_sdp_record((uint8_t *)hsp_service_buffer, rfcomm_channel_nr, hsp_hs_service_name, 0);
hsp_hs_init(rfcomm_channel_nr);
hsp_hs_register_packet_handler(packet_handler);