update HFP/HSP demo docu

This commit is contained in:
Milanka Ringwald 2016-03-23 15:05:35 +01:00
parent 1bbaca756a
commit 632517f323
4 changed files with 67 additions and 23 deletions

View File

@ -42,6 +42,9 @@
// *****************************************************************************
/* EXAMPLE_START(hfp_ag_demo): HFP Audio Gateway (AG) Demo
*
* @text This HFP Audio Gateway example demonstrates how to receive
* an output from a remote HFP Hands-Free (HF) unit, and,
* if HAVE_STDIO is defined, how to control the HFP HF.
*/
// *****************************************************************************
@ -652,14 +655,25 @@ static hfp_phone_number_t subscriber_number = {
129, "225577"
};
/* @section Main Application Setup
*
* @text Listing MainConfiguration shows main application code.
* To run a HFP AG service you need to initialize the SDP, and to create and register HFP AG record with it.
* The packet_handler is used for sending commands to the HFP HF. It also receives the HFP HF's answers.
* The stdin_process callback allows for sending commands to the HFP HF.
* At the end the Bluetooth stack is started.
*/
/* LISTING_START(MainConfiguration): Setup HFP Audio Gateway */
int btstack_main(int argc, const char * argv[]);
int btstack_main(int argc, const char * argv[]){
// HFP HS address is hardcoded, please change it
// init L2CAP
l2cap_init();
rfcomm_init();
sdp_init();
hfp_ag_init(rfcomm_channel_nr);
hfp_ag_init_supported_features(0x3ef | (1<<HFP_AGSF_HF_INDICATORS) | (1<<HFP_AGSF_ESCO_S4));
hfp_ag_init_codecs(sizeof(codecs), codecs);
@ -670,12 +684,21 @@ int btstack_main(int argc, const char * argv[]){
hfp_ag_set_subcriber_number_information(&subscriber_number, 1);
hfp_ag_register_packet_handler(packet_handler);
sdp_init();
// init SDP, create record for SPP and register with SDP
memset((uint8_t *)hfp_service_buffer, 0, sizeof(hfp_service_buffer));
hfp_ag_create_sdp_record((uint8_t *)hfp_service_buffer, rfcomm_channel_nr, hfp_ag_service_name, 0, 0);
sdp_register_service_internal(NULL, (uint8_t *)hfp_service_buffer);
/* LISTING_PAUSE */
#ifdef EMBEDDED
/* LISTING_RESUME */
service_record_item_t * service_record_item = (service_record_item_t *) hfp_service_buffer;
hfp_ag_create_sdp_record((uint8_t*) &service_record_item->service_record, rfcomm_channel_nr, hfp_ag_service_name, 0, 0);
printf("SDP service buffer size: %u\n", (uint16_t) (sizeof(service_record_item_t) + de_get_len((uint8_t*) &service_record_item->service_record)));
sdp_register_service_internal(NULL, service_record_item);
/* LISTING_PAUSE */
#else
hfp_ag_create_sdp_record((uint8_t *) hfp_service_buffer, rfcomm_channel_nr, hfp_ag_service_name, 0, 0);
printf("SDP service record size: %u\n", de_get_len((uint8_t*) hfp_service_buffer));
sdp_register_service_internal(NULL, (uint8_t*)hfp_service_buffer);
#endif
/* LISTING_RESUME */
#ifdef HAVE_STDIO
btstack_stdin_setup(stdin_process);
@ -684,3 +707,4 @@ int btstack_main(int argc, const char * argv[]){
hci_power_control(HCI_POWER_ON);
return 0;
}
/* LISTING_END */

View File

@ -43,6 +43,9 @@
// *****************************************************************************
/* EXAMPLE_START(hfp_hs_demo): HFP Hands-Free (HF) Demo
*
* @text This HFP Hands-Free example demonstrates how to receive
* an output from a remote HFP audio gateway (AG), and,
* if HAVE_STDIO is defined, how to control the HFP AG.
*/
// *****************************************************************************
@ -515,15 +518,24 @@ static void packet_handler(uint8_t * event, uint16_t event_size){
}
}
/* @section Main Application Setup
*
* @text Listing MainConfiguration shows main application code.
* To run a HFP HF service you need to initialize the SDP, and to create and register HFP HF record with it.
* The packet_handler is used for sending commands to the HFP AG. It also receives the HFP AG's answers.
* The stdin_process callback allows for sending commands to the HFP AG.
* At the end the Bluetooth stack is started.
*/
/* LISTING_START(MainConfiguration): Setup HFP Hands-Free unit */
int btstack_main(int argc, const char * argv[]);
int btstack_main(int argc, const char * argv[]){
// HFP AG address is hardcoded, please change it
// init L2CAP
l2cap_init();
rfcomm_init();
// hfp_hf_init(rfcomm_channel_nr, HFP_DEFAULT_HF_SUPPORTED_FEATURES, codecs, sizeof(codecs), indicators, sizeof(indicators)/sizeof(uint16_t), 1);
sdp_init();
hfp_hf_init(rfcomm_channel_nr);
hfp_hf_init_supported_features(438 | (1<<HFP_HFSF_ESCO_S4) | (1<<HFP_HFSF_EC_NR_FUNCTION));
hfp_hf_init_hf_indicators(sizeof(indicators)/sizeof(uint16_t), indicators);
@ -531,11 +543,21 @@ int btstack_main(int argc, const char * argv[]){
hfp_hf_register_packet_handler(packet_handler);
sdp_init();
// init SDP, create record for SPP and register with SDP
memset((uint8_t *)hfp_service_buffer, 0, sizeof(hfp_service_buffer));
hfp_hf_create_sdp_record((uint8_t *)hfp_service_buffer, rfcomm_channel_nr, hfp_hf_service_name, 0);
sdp_register_service_internal(NULL, (uint8_t *)hfp_service_buffer);
/* LISTING_PAUSE */
#ifdef EMBEDDED
/* LISTING_RESUME */
service_record_item_t * service_record_item = (service_record_item_t *) hfp_service_buffer;
hfp_hf_create_sdp_record((uint8_t*) &service_record_item->service_record, rfcomm_channel_nr, hfp_hf_service_name, 0);
printf("SDP service buffer size: %u\n", (uint16_t) (sizeof(service_record_item_t) + de_get_len((uint8_t*) &service_record_item->service_record)));
sdp_register_service_internal(NULL, service_record_item);
/* LISTING_PAUSE */
#else
hfp_hf_create_sdp_record((uint8_t *) hfp_service_buffer, rfcomm_channel_nr, hfp_hf_service_name, 0);
printf("SDP service record size: %u\n", de_get_len((uint8_t*) hfp_service_buffer));
sdp_register_service_internal(NULL, (uint8_t*)hfp_service_buffer);
#endif
/* LISTING_RESUME */
#ifdef HAVE_STDIO
btstack_stdin_setup(stdin_process);
@ -544,3 +566,4 @@ int btstack_main(int argc, const char * argv[]){
hci_power_control(HCI_POWER_ON);
return 0;
}
/* LISTING_END */

View File

@ -322,7 +322,7 @@ static void packet_handler(uint8_t * event, uint16_t event_size){
* At the end the Bluetooth stack is started.
*/
/* LISTING_START(MainConfiguration): Setup packet handlers and audio data channel for HSP Audio Gateway */
/* LISTING_START(MainConfiguration): Setup HSP Audio Gateway */
int btstack_main(int argc, const char * argv[]);
int btstack_main(int argc, const char * argv[]){
l2cap_init();
@ -330,7 +330,6 @@ int btstack_main(int argc, const char * argv[]){
sdp_init();
memset((uint8_t *)hsp_service_buffer, 0, sizeof(hsp_service_buffer));
/* LISTING_PAUSE */
#ifdef EMBEDDED
/* LISTING_RESUME */
@ -348,7 +347,6 @@ int btstack_main(int argc, const char * argv[]){
hci_register_sco_packet_handler(&sco_packet_handler);
hsp_ag_init(rfcomm_channel_nr);
hsp_ag_register_packet_handler(packet_handler);
#ifdef HAVE_STDIO
@ -358,10 +356,10 @@ int btstack_main(int argc, const char * argv[]){
gap_set_local_name("BTstack HSP AG");
hci_discoverable_control(1);
hci_ssp_set_io_capability(SSP_IO_CAPABILITY_DISPLAY_YES_NO);
// turn on!
hci_set_class_of_device(0x400204);
// turn on!
hci_power_control(HCI_POWER_ON);
return 0;
}
/* LISTING_END */

View File

@ -319,7 +319,7 @@ static void packet_handler(uint8_t * event, uint16_t event_size){
* At the end the Bluetooth stack is started.
*/
/* LISTING_START(MainConfiguration): Setup packet handlers and audio data channel for HSP Headset */
/* LISTING_START(MainConfiguration): Setup HSP Headset */
int btstack_main(int argc, const char * argv[]);
int btstack_main(int argc, const char * argv[]){
l2cap_init();
@ -327,7 +327,6 @@ int btstack_main(int argc, const char * argv[]){
sdp_init();
memset((uint8_t *)hsp_service_buffer, 0, sizeof(hsp_service_buffer));
/* LISTING_PAUSE */
#ifdef EMBEDDED
/* LISTING_RESUME */
@ -355,10 +354,10 @@ int btstack_main(int argc, const char * argv[]){
gap_set_local_name("BTstack HSP HS");
hci_discoverable_control(1);
hci_ssp_set_io_capability(SSP_IO_CAPABILITY_DISPLAY_YES_NO);
// turn on!
hci_set_class_of_device(0x240404);
// turn on!
hci_power_control(HCI_POWER_ON);
return 0;
}
/* LISTING_END */