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 Audio Gateway (AG) unit (!! UNDER DEVELOPMENT !!) 41 // 42 // ***************************************************************************** 43 44 45 #ifndef btstack_hfp_ag_h 46 #define btstack_hfp_ag_h 47 48 #include "hci.h" 49 #include "classic/sdp_query_rfcomm.h" 50 #include "classic/hfp.h" 51 #include "classic/hfp_gsm_model.h" 52 53 #if defined __cplusplus 54 extern "C" { 55 #endif 56 57 /* API_START */ 58 typedef struct { 59 uint8_t type; 60 const char * number; 61 } hfp_phone_number_t; 62 63 /** 64 * @brief Create HFP Audio Gateway (AG) SDP service record. 65 */ 66 void hfp_ag_create_sdp_record(uint8_t * service, uint32_t service_record_handle, int rfcomm_channel_nr, const char * name, uint8_t ability_to_reject_call, uint16_t supported_features);; 67 68 /** 69 * @brief Intialize HFP Audio Gateway (AG) device. 70 * TODO: move optional params into setters 71 */ 72 void hfp_ag_init(uint16_t rfcomm_channel_nr, uint32_t supported_features, 73 uint8_t * codecs, int codecs_nr, 74 hfp_ag_indicator_t * ag_indicators, int ag_indicators_nr, 75 hfp_generic_status_indicator_t * hf_indicators, int hf_indicators_nr, 76 const char *call_hold_services[], int call_hold_services_nr); 77 78 /** 79 * @brief Register callback for the HFP Audio Gateway (AG) client. 80 */ 81 void hfp_ag_register_packet_handler(hfp_callback_t callback); 82 83 /** 84 * @brief Establish RFCOMM connection, and perform service level connection agreement: 85 * - exchange of supported features 86 * - report Audio Gateway (AG) indicators and their status 87 * - enable indicator status update in the AG 88 * - accept the information about available codecs in the Hands-Free (HF), if sent 89 * - report own information describing the call hold and multiparty services, if possible 90 * - report which HF indicators are enabled on the AG, if possible 91 */ 92 void hfp_ag_establish_service_level_connection(bd_addr_t bd_addr); 93 94 /** 95 * @brief Release the RFCOMM channel and the audio connection between the HF and the AG. 96 * TODO: trigger release of the audio connection 97 */ 98 void hfp_ag_release_service_level_connection(bd_addr_t bd_addr); 99 100 /** 101 * @brief Report Extended Audio Gateway Error result codes in the AG. 102 * Whenever there is an error relating to the functionality of the AG as a 103 * result of AT command, the AG shall send +CME ERROR: 104 * - +CME ERROR: 0 - AG failure 105 * - +CME ERROR: 1 - no connection to phone 106 * - +CME ERROR: 3 - operation not allowed 107 * - +CME ERROR: 4 - operation not supported 108 * - +CME ERROR: 5 - PH-SIM PIN required 109 * - +CME ERROR: 10 - SIM not inserted 110 * - +CME ERROR: 11 - SIM PIN required 111 * - +CME ERROR: 12 - SIM PUK required 112 * - +CME ERROR: 13 - SIM failure 113 * - +CME ERROR: 14 - SIM busy 114 * - +CME ERROR: 16 - incorrect password 115 * - +CME ERROR: 17 - SIM PIN2 required 116 * - +CME ERROR: 18 - SIM PUK2 required 117 * - +CME ERROR: 20 - memory full 118 * - +CME ERROR: 21 - invalid index 119 * - +CME ERROR: 23 - memory failure 120 * - +CME ERROR: 24 - text string too long 121 * - +CME ERROR: 25 - invalid characters in text string 122 * - +CME ERROR: 26 - dial string too long 123 * - +CME ERROR: 27 - invalid characters in dial string 124 * - +CME ERROR: 30 - no network service 125 * - +CME ERROR: 31 - network Timeout. 126 * - +CME ERROR: 32 - network not allowed – Emergency calls only 127 */ 128 void hfp_ag_report_extended_audio_gateway_error_result_code(bd_addr_t bd_addr, hfp_cme_error_t error); 129 130 /** 131 * @brief Report the change in AG's call status. 132 * Call status: 133 * - 0 = No calls (held or active) 134 * - 1 = Call is present (active or held) 135 */ 136 void hfp_ag_transfer_call_status(bd_addr_t bd_addr, hfp_call_status_t status); 137 138 /** 139 * @brief Report the change in AG's call setup status. 140 * Call setup status: 141 * - 0 = No call setup in progress 142 * - 1 = Incoming call setup in progress 143 * - 2 = Outgoing call setup in dialing state 144 * - 3 = Outgoing call setup in alerting state 145 */ 146 void hfp_ag_transfer_callsetup_status(bd_addr_t bd_addr, hfp_callsetup_status_t status); 147 148 /** 149 * @brief Report the change in AG's held call status. 150 * Held call status: 151 * - 0 = No calls held 152 * - 1 = Call is placed on hold or active/held calls are swapped 153 * - 2 = Call on hold, no active calls 154 */ 155 void hfp_ag_transfer_callheld_status(bd_addr_t bd_addr, hfp_callheld_status_t status); 156 157 /** 158 * @brief 159 */ 160 void hfp_ag_negotiate_codecs(bd_addr_t bd_addr); 161 162 /** 163 * @brief 164 */ 165 void hfp_ag_establish_audio_connection(bd_addr_t bd_addr); 166 167 /** 168 * @brief 169 */ 170 void hfp_ag_release_audio_connection(bd_addr_t bd_addr); 171 172 173 /** 174 * @brief Enable in-band ring tone 175 */ 176 void hfp_ag_set_use_in_band_ring_tone(int use_in_band_ring_tone); 177 178 /** 179 * @brief 180 */ 181 void hfp_ag_incoming_call(void); 182 183 /** 184 * @brief number is stored. 185 */ 186 void hfp_ag_set_clip(uint8_t type, const char * number); 187 188 /** 189 * @brief 190 */ 191 void hfp_ag_outgoing_call_rejected(void); 192 193 /** 194 * @brief 195 */ 196 void hfp_ag_outgoing_call_accepted(void); 197 198 /** 199 * @brief 200 */ 201 void hfp_ag_outgoing_call_ringing(void); 202 203 /** 204 * @brief 205 */ 206 void hfp_ag_outgoing_call_established(void); 207 208 /** 209 * @brief 210 */ 211 void hfp_ag_call_dropped(void); 212 213 /** 214 * @brief 215 */ 216 void hfp_ag_answer_incoming_call(void); 217 218 /** 219 * @brief 220 */ 221 void hfp_ag_join_held_call(void); 222 223 /** 224 * @brief 225 */ 226 void hfp_ag_terminate_call(void); 227 228 /* 229 * @brief 230 */ 231 void hfp_ag_set_registration_status(int status); 232 233 /* 234 * @brief 235 */ 236 void hfp_ag_set_signal_strength(int strength); 237 238 /* 239 * @brief 240 */ 241 void hfp_ag_set_roaming_status(int status); 242 243 /* 244 * @brief 245 */ 246 void hfp_ag_set_battery_level(int level); 247 248 249 /* 250 * @brief 251 */ 252 void hfp_ag_activate_voice_recognition(bd_addr_t bd_addr, int activate); 253 254 /* 255 * @brief 256 */ 257 void hfp_ag_set_microphone_gain(bd_addr_t bd_addr, int gain); 258 259 /* 260 * @brief 261 */ 262 void hfp_ag_set_speaker_gain(bd_addr_t bd_addr, int gain); 263 264 /* 265 * @brief 266 */ 267 void hfp_ag_send_phone_number_for_voice_tag(bd_addr_t bd_addr, const char * number); 268 269 /* 270 * @brief 271 */ 272 void hfp_ag_reject_phone_number_for_voice_tag(bd_addr_t bd_addr); 273 274 /* 275 * @brief 276 */ 277 void hfp_ag_send_dtmf_code_done(bd_addr_t bd_addr); 278 279 /* 280 * @brief 281 */ 282 void hfp_ag_set_subcriber_number_information(hfp_phone_number_t * numbers, int numbers_count); 283 284 /* 285 * @brief 286 */ 287 288 void hfp_ag_send_current_call_status(bd_addr_t bd_addr, int idx); 289 290 /* 291 * @brief 292 */ 293 void hfp_ag_hold_incoming_call(void); 294 295 /* 296 * @brief 297 */ 298 void hfp_ag_accept_held_incoming_call(void); 299 300 /* 301 * @brief 302 */ 303 void hfp_ag_reject_held_incoming_call(void); 304 305 /* 306 * @brief 307 */ 308 void hfp_ag_clear_last_dialed_number(void); 309 310 /* API_END */ 311 312 #if defined __cplusplus 313 } 314 #endif 315 316 #endif