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 // HFP Hands-Free (HF) unit 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 * @brief Create HFP Hands-Free (HF) SDP service record. 60 */ 61 void hfp_hf_create_sdp_record(uint8_t * service, uint32_t service_record_handle, int rfcomm_channel_nr, const char * name, uint16_t supported_features); 62 63 /** 64 * @brief Intialize HFP Hands-Free (HF) device. 65 * TODO: move optional params into setters 66 */ 67 void hfp_hf_init(uint16_t rfcomm_channel_nr, uint32_t supported_features, uint16_t * indicators, int indicators_nr, uint32_t indicators_status); 68 69 void hfp_hf_set_codecs(uint8_t * codecs, int codecs_nr); 70 71 void hfp_hf_set_supported_features(uint32_t supported_features); 72 73 /** 74 * @brief Register callback for the HFP Hands-Free (HF) client. 75 */ 76 void hfp_hf_register_packet_handler(hfp_callback_t callback); 77 78 /** 79 * @brief Establish RFCOMM connection, and perform service level connection agreement: 80 * - exchange of supported features 81 * - retrieve Audio Gateway (AG) indicators and their status 82 * - enable indicator status update in the AG 83 * - notify the AG about its own available codecs, if possible 84 * - retrieve the AG information describing the call hold and multiparty services, if possible 85 * - retrieve which HF indicators are enabled on the AG, if possible 86 */ 87 void hfp_hf_establish_service_level_connection(bd_addr_t bd_addr); 88 89 /** 90 * @brief Release the RFCOMM channel and the audio connection between the HF and the AG. 91 * TODO: trigger release of the audio connection 92 */ 93 void hfp_hf_release_service_level_connection(bd_addr_t bd_addr); 94 95 /** 96 * @brief Deactivate/reactivate status update for all indicators in the AG. 97 */ 98 void hfp_hf_enable_status_update_for_all_ag_indicators(bd_addr_t bd_addr); 99 100 void hfp_hf_disable_status_update_for_all_ag_indicators(bd_addr_t bd_addr); 101 102 /** 103 * @brief Deactivate/reactivate status update for the individual indicators in the AG using bitmap. 104 */ 105 void hfp_hf_set_status_update_for_individual_ag_indicators(bd_addr_t bd_addr, uint32_t indicators_status_bitmap); 106 107 108 /** 109 * @brief Find out the name of the currently selected Network operator by AG. 110 * The name is restricted to max 16 characters. 111 * 112 * TODO: what is the result of this? 113 */ 114 void hfp_hf_query_operator_selection(bd_addr_t bd_addr); 115 116 /** 117 * @brief Enable/disable Extended Audio Gateway Error result codes in the AG. 118 * Whenever there is an error relating to the functionality of the AG as a 119 * result of AT command, the AG shall send +CME ERROR: 120 * - +CME ERROR: 0 - AG failure 121 * - +CME ERROR: 1 - no connection to phone 122 * - +CME ERROR: 3 - operation not allowed 123 * - +CME ERROR: 4 - operation not supported 124 * - +CME ERROR: 5 - PH-SIM PIN required 125 * - +CME ERROR: 10 - SIM not inserted 126 * - +CME ERROR: 11 - SIM PIN required 127 * - +CME ERROR: 12 - SIM PUK required 128 * - +CME ERROR: 13 - SIM failure 129 * - +CME ERROR: 14 - SIM busy 130 * - +CME ERROR: 16 - incorrect password 131 * - +CME ERROR: 17 - SIM PIN2 required 132 * - +CME ERROR: 18 - SIM PUK2 required 133 * - +CME ERROR: 20 - memory full 134 * - +CME ERROR: 21 - invalid index 135 * - +CME ERROR: 23 - memory failure 136 * - +CME ERROR: 24 - text string too long 137 * - +CME ERROR: 25 - invalid characters in text string 138 * - +CME ERROR: 26 - dial string too long 139 * - +CME ERROR: 27 - invalid characters in dial string 140 * - +CME ERROR: 30 - no network service 141 * - +CME ERROR: 31 - network Timeout. 142 * - +CME ERROR: 32 - network not allowed – Emergency calls only 143 */ 144 void hfp_hf_enable_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr); 145 void hfp_hf_disable_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr); 146 147 /** 148 * @brief 149 */ 150 void hfp_hf_establish_audio_connection(bd_addr_t bd_addr); 151 152 /** 153 * @brief 154 */ 155 void hfp_hf_release_audio_connection(bd_addr_t bd_addr); 156 157 /** 158 * @brief 159 */ 160 void hfp_hf_answer_incoming_call(bd_addr_t bd_addr); 161 162 /** 163 * @brief 164 */ 165 void hfp_hf_reject_call(bd_addr_t bd_addr); 166 167 /** 168 * @brief 169 */ 170 void hfp_hf_user_busy(bd_addr_t addr); 171 172 /** 173 * @brief 174 */ 175 void hfp_hf_end_active_and_accept_other(bd_addr_t addr); 176 177 /** 178 * @brief 179 */ 180 void hfp_hf_swap_calls(bd_addr_t addr); 181 182 /** 183 * @brief 184 */ 185 void hfp_hf_join_held_call(bd_addr_t addr); 186 187 /** 188 * @brief 189 */ 190 void hfp_hf_connect_calls(bd_addr_t addr); 191 192 /** 193 * @brief 194 */ 195 void hfp_hf_terminate_call(bd_addr_t bd_addr); 196 197 /** 198 * @brief 199 */ 200 void hfp_hf_dial_number(bd_addr_t bd_addr, char * number); 201 202 /** 203 * @brief 204 * TODO: use int for number instead of string? 205 */ 206 void hfp_hf_dial_memory(bd_addr_t bd_addr, char * number); 207 208 /** 209 * @brief 210 */ 211 void hfp_hf_redial_last_number(bd_addr_t bd_addr); 212 213 /* 214 * @brief 215 */ 216 void hfp_hf_activate_call_waiting_notification(bd_addr_t bd_addr); 217 218 /* 219 * @brief 220 */ 221 void hfp_hf_deactivate_call_waiting_notification(bd_addr_t bd_addr); 222 223 /* 224 * @brief 225 */ 226 void hfp_hf_activate_calling_line_notification(bd_addr_t bd_addr); 227 228 /* 229 * @brief 230 */ 231 void hfp_hf_deactivate_calling_line_notification(bd_addr_t bd_addr); 232 233 234 /* 235 * @brief 236 */ 237 void hfp_hf_activate_echo_canceling_and_noise_reduction(bd_addr_t bd_addr); 238 239 /* 240 * @brief 241 */ 242 void hfp_hf_deactivate_echo_canceling_and_noise_reduction(bd_addr_t bd_addr); 243 244 /* 245 * @brief 246 */ 247 void hfp_hf_activate_voice_recognition_notification(bd_addr_t bd_addr); 248 249 /* 250 * @brief 251 */ 252 void hfp_hf_deactivate_voice_recognition_notification(bd_addr_t bd_addr); 253 254 /* 255 * @brief 256 */ 257 void hfp_hf_set_microphone_gain(bd_addr_t bd_addr, int gain); 258 259 /* 260 * @brief 261 */ 262 void hfp_hf_set_speaker_gain(bd_addr_t bd_addr, int gain); 263 264 /* 265 * @brief 266 */ 267 void hfp_hf_send_dtmf_code(bd_addr_t bd_addr, char code); 268 269 /* 270 * @brief 271 */ 272 void hfp_hf_request_phone_number_for_voice_tag(bd_addr_t addr); 273 274 /* 275 * @brief 276 */ 277 void hfp_hf_query_current_call_status(bd_addr_t addr); 278 279 /* 280 * @brief 281 */ 282 void hfp_hf_release_call_with_index(bd_addr_t addr, int index); 283 284 /* 285 * @brief 286 */ 287 void hfp_hf_private_consultation_with_call(bd_addr_t addr, int index); 288 289 /* 290 * @brief 291 */ 292 void hfp_hf_rrh_query_status(bd_addr_t addr); 293 294 /* 295 * @brief 296 */ 297 void hfp_hf_rrh_hold_call(bd_addr_t addr); 298 299 /* 300 * @brief 301 */ 302 void hfp_hf_rrh_accept_held_call(bd_addr_t addr); 303 304 /* 305 * @brief 306 */ 307 void hfp_hf_rrh_reject_held_call(bd_addr_t addr); 308 309 /* 310 * @brief 311 */ 312 void hfp_hf_query_subscriber_number(bd_addr_t addr); 313 314 /* 315 * @brief 316 */ 317 void hfp_hf_set_hf_indicator(bd_addr_t addr, int assigned_number, int value); 318 319 /* API_END */ 320 321 #if defined __cplusplus 322 } 323 #endif 324 325 #endif // __BTSTACK_HFP_HF_H