hfp_hf.c (5fd6f36099526806c27882ae7a0e3cfa50950641) | hfp_hf.c (aa10b9cbee75a92ba10686b7ba42c869ecdf5325) |
---|---|
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 --- 1552 unchanged lines hidden (view full) --- 1561 hfp_deinit(); 1562 hfp_hf_set_defaults(); 1563 1564 hfp_hf_callback = NULL; 1565 (void) memset(&hfp_hf_hci_event_callback_registration, 0, sizeof(btstack_packet_callback_registration_t)); 1566 (void) memset(hfp_hf_phone_number, 0, sizeof(hfp_hf_phone_number)); 1567} 1568 | 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 --- 1552 unchanged lines hidden (view full) --- 1561 hfp_deinit(); 1562 hfp_hf_set_defaults(); 1563 1564 hfp_hf_callback = NULL; 1565 (void) memset(&hfp_hf_hci_event_callback_registration, 0, sizeof(btstack_packet_callback_registration_t)); 1566 (void) memset(hfp_hf_phone_number, 0, sizeof(hfp_hf_phone_number)); 1567} 1568 |
1569void hfp_hf_init_codecs(int codecs_nr, const uint8_t * codecs){ | 1569void hfp_hf_init_codecs(uint8_t codecs_nr, const uint8_t * codecs){ |
1570 btstack_assert(codecs_nr <= HFP_MAX_NUM_CODECS); 1571 1572 hfp_hf_codecs_nr = codecs_nr; | 1570 btstack_assert(codecs_nr <= HFP_MAX_NUM_CODECS); 1571 1572 hfp_hf_codecs_nr = codecs_nr; |
1573 int i; | 1573 uint8_t i; |
1574 for (i=0; i<codecs_nr; i++){ 1575 hfp_hf_codecs[i] = codecs[i]; 1576 } 1577} 1578 1579void hfp_hf_init_supported_features(uint32_t supported_features){ 1580 hfp_hf_supported_features = supported_features; 1581} --- 682 unchanged lines hidden (view full) --- 2264int hfp_hf_in_band_ringtone_active(hci_con_handle_t acl_handle){ 2265 hfp_connection_t * hfp_connection = get_hfp_hf_connection_context_for_acl_handle(acl_handle); 2266 if (!hfp_connection) { 2267 return 0; 2268 } 2269 return get_bit(hfp_connection->remote_supported_features, HFP_AGSF_IN_BAND_RING_TONE); 2270} 2271 | 1574 for (i=0; i<codecs_nr; i++){ 1575 hfp_hf_codecs[i] = codecs[i]; 1576 } 1577} 1578 1579void hfp_hf_init_supported_features(uint32_t supported_features){ 1580 hfp_hf_supported_features = supported_features; 1581} --- 682 unchanged lines hidden (view full) --- 2264int hfp_hf_in_band_ringtone_active(hci_con_handle_t acl_handle){ 2265 hfp_connection_t * hfp_connection = get_hfp_hf_connection_context_for_acl_handle(acl_handle); 2266 if (!hfp_connection) { 2267 return 0; 2268 } 2269 return get_bit(hfp_connection->remote_supported_features, HFP_AGSF_IN_BAND_RING_TONE); 2270} 2271 |
2272void hfp_hf_create_sdp_record(uint8_t * service, uint32_t service_record_handle, int rfcomm_channel_nr, const char * name, uint16_t supported_features, int wide_band_speech){ 2273 if (!name){ 2274 name = hfp_hf_default_service_name; 2275 } 2276 hfp_create_sdp_record(service, service_record_handle, BLUETOOTH_SERVICE_CLASS_HANDSFREE, rfcomm_channel_nr, name); | 2272void hfp_hf_create_sdp_record_with_codecs(uint8_t * service, uint32_t service_record_handle, int rfcomm_channel_nr, 2273 const char * name, uint16_t supported_features, uint8_t codecs_nr, const uint8_t * codecs){ 2274 if (!name){ 2275 name = hfp_hf_default_service_name; 2276 } 2277 hfp_create_sdp_record(service, service_record_handle, BLUETOOTH_SERVICE_CLASS_HANDSFREE, rfcomm_channel_nr, name); |
2277 | 2278 |
2278 // Construct SupportedFeatures for SDP bitmap: 2279 // 2280 // "The values of the “SupportedFeatures” bitmap given in Table 5.4 shall be the same as the values 2281 // of the Bits 0 to 4 of the unsolicited result code +BRSF" 2282 // 2283 // Wide band speech (bit 5) requires Codec negotiation 2284 // 2285 uint16_t sdp_features = supported_features & 0x1f; 2286 if ( (wide_band_speech != 0) && (supported_features & (1 << HFP_HFSF_CODEC_NEGOTIATION))){ 2287 sdp_features |= 1 << 5; 2288 } 2289 | 2279 // Construct SupportedFeatures for SDP bitmap: 2280 // 2281 // "The values of the “SupportedFeatures” bitmap given in Table 5.4 shall be the same as the values 2282 // of the Bits 0 to 4 of the unsolicited result code +BRSF" 2283 // 2284 // Wide band speech (bit 5) and LC3-SWB (bit 8) require Codec negotiation 2285 // 2286 uint16_t sdp_features = supported_features & 0x1f; 2287 |
2290 if (supported_features & (1 << HFP_HFSF_ENHANCED_VOICE_RECOGNITION_STATUS)){ 2291 sdp_features |= 1 << 6; 2292 } | 2288 if (supported_features & (1 << HFP_HFSF_ENHANCED_VOICE_RECOGNITION_STATUS)){ 2289 sdp_features |= 1 << 6; 2290 } |
2293 | 2291 |
2294 if (supported_features & (1 << HFP_HFSF_VOICE_RECOGNITION_TEXT)){ 2295 sdp_features |= 1 << 7; 2296 } | 2292 if (supported_features & (1 << HFP_HFSF_VOICE_RECOGNITION_TEXT)){ 2293 sdp_features |= 1 << 7; 2294 } |
2297 2298 de_add_number(service, DE_UINT, DE_SIZE_16, 0x0311); // Hands-Free Profile - SupportedFeatures 2299 de_add_number(service, DE_UINT, DE_SIZE_16, sdp_features); | 2295 2296 // codecs 2297 if ((supported_features & (1 << HFP_HFSF_CODEC_NEGOTIATION)) != 0){ 2298 uint8_t i; 2299 for (i=0;i<codecs_nr;i++){ 2300 switch (codecs[i]){ 2301 case HFP_CODEC_MSBC: 2302 sdp_features |= 1 << 5; 2303 break; 2304 case HFP_CODEC_LC3_SWB: 2305 sdp_features |= 1 << 8; 2306 break; 2307 } 2308 } 2309 } 2310 2311 de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SUPPORTED_FEATURES); 2312 de_add_number(service, DE_UINT, DE_SIZE_16, sdp_features); |
2300} 2301 | 2313} 2314 |
2315// @deprecated, call new API 2316void hfp_hf_create_sdp_record(uint8_t * service, uint32_t service_record_handle, int rfcomm_channel_nr, const char * name, uint16_t supported_features, int wide_band_speech){ 2317 uint8_t codecs_nr; 2318 const uint8_t * codecs; 2319 const uint8_t wide_band_codecs[] = { HFP_CODEC_MSBC }; 2320 if (wide_band_speech == 0){ 2321 codecs_nr = 0; 2322 codecs = NULL; 2323 } else { 2324 codecs_nr = 1; 2325 codecs = wide_band_codecs; 2326 } 2327 hfp_hf_create_sdp_record_with_codecs(service, service_record_handle, rfcomm_channel_nr, name, supported_features, codecs_nr, codecs); 2328} 2329 |
|
2302void hfp_hf_register_custom_at_command(hfp_custom_at_command_t * custom_at_command){ 2303 hfp_register_custom_hf_command(custom_at_command); 2304} 2305 2306void hfp_hf_register_packet_handler(btstack_packet_handler_t callback){ 2307 btstack_assert(callback != NULL); 2308 2309 hfp_hf_callback = callback; 2310 hfp_set_hf_callback(callback); 2311} | 2330void hfp_hf_register_custom_at_command(hfp_custom_at_command_t * custom_at_command){ 2331 hfp_register_custom_hf_command(custom_at_command); 2332} 2333 2334void hfp_hf_register_packet_handler(btstack_packet_handler_t callback){ 2335 btstack_assert(callback != NULL); 2336 2337 hfp_hf_callback = callback; 2338 hfp_set_hf_callback(callback); 2339} |