xref: /btstack/src/classic/hfp_hf.h (revision 3edc84c5b6b1e23a3d103fe8ce1f6b5ad1df3498)
1 /*
2  * Copyright (C) 2014 BlueKitchen GmbH
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the copyright holders nor the names of
14  *    contributors may be used to endorse or promote products derived
15  *    from this software without specific prior written permission.
16  * 4. Any redistribution, use, or modification is done solely for
17  *    personal benefit and not for any commercial purpose or for
18  *    monetary gain.
19  *
20  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
24  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  * Please inquire about commercial licensing options at
34  * [email protected]
35  *
36  */
37 
38 // *****************************************************************************
39 //
40 //  Minimal setup for HFP Hands-Free (HF) unit (!! UNDER DEVELOPMENT !!)
41 //
42 // *****************************************************************************
43 
44 
45 #ifndef btstack_hfp_hf_h
46 #define btstack_hfp_hf_h
47 
48 #include "hci.h"
49 #include "classic/sdp_query_rfcomm.h"
50 #include "classic/hfp.h"
51 
52 #if defined __cplusplus
53 extern "C" {
54 #endif
55 
56 /* API_START */
57 
58 
59 /**
60  * @brief Create HFP Hands-Free (HF) SDP service record.
61  */
62 void hfp_hf_create_sdp_record(uint8_t * service, int rfcomm_channel_nr, const char * name, uint16_t supported_features);
63 
64 /**
65  * @brief Intialize HFP Hands-Free (HF) device.
66  * TODO:  move optional params into setters
67  */
68 void hfp_hf_init(uint16_t rfcomm_channel_nr, uint32_t supported_features, uint16_t * indicators, int indicators_nr, uint32_t indicators_status);
69 void hfp_hf_set_codecs(uint8_t * codecs, int codecs_nr);
70 
71 /**
72  * @brief Register callback for the HFP Hands-Free (HF) client.
73  */
74 void hfp_hf_register_packet_handler(hfp_callback_t callback);
75 
76 /**
77  * @brief Establish RFCOMM connection, and perform service level connection agreement:
78  * - exchange of supported features
79  * - retrieve Audio Gateway (AG) indicators and their status
80  * - enable indicator status update in the AG
81  * - notify the AG about its own available codecs, if possible
82  * - retrieve the AG information describing the call hold and multiparty services, if possible
83  * - retrieve which HF indicators are enabled on the AG, if possible
84  */
85 void hfp_hf_establish_service_level_connection(bd_addr_t bd_addr);
86 
87 
88 /**
89  * @brief Release the RFCOMM channel and the audio connection between the HF and the AG.
90  * TODO: trigger release of the audio connection
91  */
92 void hfp_hf_release_service_level_connection(bd_addr_t bd_addr);
93 
94 /**
95  * @brief Deactivate/reactivate status update for all indicators in the AG.
96  */
97 void hfp_hf_enable_status_update_for_all_ag_indicators(bd_addr_t bd_addr, uint8_t enable);
98 
99 /**
100  * @brief Deactivate/reactivate status update for the individual indicators in the AG using bitmap.
101  */
102 void hfp_hf_enable_status_update_for_individual_ag_indicators(bd_addr_t bd_addr, uint32_t indicators_status_bitmap);
103 
104 
105 /**
106  * @brief Find out the name of the currently selected Network operator by AG.
107  * The name is restricted to max 16 characters.
108  */
109 void hfp_hf_query_operator_selection(bd_addr_t bd_addr);
110 
111 /**
112  * @brief Enable/disable Extended Audio Gateway Error result codes in the AG.
113  * Whenever there is an error relating to the functionality of the AG as a
114  * result of AT command, the AG shall send +CME ERROR:
115  * - +CME ERROR: 0  - AG failure
116  * - +CME ERROR: 1  - no connection to phone
117  * - +CME ERROR: 3  - operation not allowed
118  * - +CME ERROR: 4  - operation not supported
119  * - +CME ERROR: 5  - PH-SIM PIN required
120  * - +CME ERROR: 10 - SIM not inserted
121  * - +CME ERROR: 11 - SIM PIN required
122  * - +CME ERROR: 12 - SIM PUK required
123  * - +CME ERROR: 13 - SIM failure
124  * - +CME ERROR: 14 - SIM busy
125  * - +CME ERROR: 16 - incorrect password
126  * - +CME ERROR: 17 - SIM PIN2 required
127  * - +CME ERROR: 18 - SIM PUK2 required
128  * - +CME ERROR: 20 - memory full
129  * - +CME ERROR: 21 - invalid index
130  * - +CME ERROR: 23 - memory failure
131  * - +CME ERROR: 24 - text string too long
132  * - +CME ERROR: 25 - invalid characters in text string
133  * - +CME ERROR: 26 - dial string too long
134  * - +CME ERROR: 27 - invalid characters in dial string
135  * - +CME ERROR: 30 - no network service
136  * - +CME ERROR: 31 - network Timeout.
137  * - +CME ERROR: 32 - network not allowed – Emergency calls only
138  */
139 void hfp_hf_enable_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr, uint8_t enable);
140 
141 /**
142  * @brief
143  */
144 void hfp_hf_negotiate_codecs(bd_addr_t bd_addr);
145 
146 void hfp_hf_establish_audio_connection(bd_addr_t bd_addr);
147 
148 /**
149  * @brief
150  */
151 void hfp_hf_release_audio_connection(bd_addr_t bd_addr);
152 
153 
154 /* API_END */
155 
156 #if defined __cplusplus
157 }
158 #endif
159 
160 #endif