hfp.c (f14c5daf9a65a6d247dbd12e217750915dcbfa04) | hfp.c (d9290e95f9161d0d54f386663529767f67c89689) |
---|---|
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 --- 904 unchanged lines hidden (view full) --- 913 } 914 915 uint16_t sco_handle = hci_event_synchronous_connection_complete_get_handle(packet); 916 uint8_t link_type = hci_event_synchronous_connection_complete_get_link_type(packet); 917 uint8_t transmission_interval = hci_event_synchronous_connection_complete_get_transmission_interval(packet); // measured in slots 918 uint8_t retransmission_interval = hci_event_synchronous_connection_complete_get_retransmission_interval(packet);// measured in slots 919 uint16_t rx_packet_length = hci_event_synchronous_connection_complete_get_rx_packet_length(packet); // measured in bytes 920 uint16_t tx_packet_length = hci_event_synchronous_connection_complete_get_tx_packet_length(packet); // measured in bytes | 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 --- 904 unchanged lines hidden (view full) --- 913 } 914 915 uint16_t sco_handle = hci_event_synchronous_connection_complete_get_handle(packet); 916 uint8_t link_type = hci_event_synchronous_connection_complete_get_link_type(packet); 917 uint8_t transmission_interval = hci_event_synchronous_connection_complete_get_transmission_interval(packet); // measured in slots 918 uint8_t retransmission_interval = hci_event_synchronous_connection_complete_get_retransmission_interval(packet);// measured in slots 919 uint16_t rx_packet_length = hci_event_synchronous_connection_complete_get_rx_packet_length(packet); // measured in bytes 920 uint16_t tx_packet_length = hci_event_synchronous_connection_complete_get_tx_packet_length(packet); // measured in bytes |
921 uint16_t packet_types = hfp_link_settings[hfp_sco_establishment_active->link_setting].packet_types; | |
922 923 switch (link_type){ 924 case 0x00: 925 log_info("SCO Connection established."); 926 if (transmission_interval != 0) log_error("SCO Connection: transmission_interval not zero: %d.", transmission_interval); 927 if (retransmission_interval != 0) log_error("SCO Connection: retransmission_interval not zero: %d.", retransmission_interval); 928 if (rx_packet_length != 0) log_error("SCO Connection: rx_packet_length not zero: %d.", rx_packet_length); 929 if (tx_packet_length != 0) log_error("SCO Connection: tx_packet_length not zero: %d.", tx_packet_length); --- 26 unchanged lines hidden (view full) --- 956 hfp_connection->ag_audio_connection_opened_before_vra = false; 957 break; 958 default: 959 hfp_connection->ag_audio_connection_opened_before_vra = true; 960 break; 961 } 962 hfp_emit_sco_connection_established(hfp_connection, status, 963 hfp_connection->negotiated_codec, | 921 922 switch (link_type){ 923 case 0x00: 924 log_info("SCO Connection established."); 925 if (transmission_interval != 0) log_error("SCO Connection: transmission_interval not zero: %d.", transmission_interval); 926 if (retransmission_interval != 0) log_error("SCO Connection: retransmission_interval not zero: %d.", retransmission_interval); 927 if (rx_packet_length != 0) log_error("SCO Connection: rx_packet_length not zero: %d.", rx_packet_length); 928 if (tx_packet_length != 0) log_error("SCO Connection: tx_packet_length not zero: %d.", tx_packet_length); --- 26 unchanged lines hidden (view full) --- 955 hfp_connection->ag_audio_connection_opened_before_vra = false; 956 break; 957 default: 958 hfp_connection->ag_audio_connection_opened_before_vra = true; 959 break; 960 } 961 hfp_emit_sco_connection_established(hfp_connection, status, 962 hfp_connection->negotiated_codec, |
964 packet_types, rx_packet_length, tx_packet_length); | 963 hfp_connection->packet_types, rx_packet_length, tx_packet_length); |
965 break; 966 } 967 968 case HCI_EVENT_DISCONNECTION_COMPLETE: 969 handle = little_endian_read_16(packet,3); 970 hfp_connection = get_hfp_connection_context_for_sco_handle(handle, local_role); 971 972 if (!hfp_connection) break; --- 918 unchanged lines hidden (view full) --- 1891 uint16_t sco_voice_setting = hci_get_sco_voice_setting(); 1892 if (hfp_connection->negotiated_codec == HFP_CODEC_MSBC){ 1893#ifdef ENABLE_BCM_PCM_WBS 1894 sco_voice_setting = 0x0063; // Transparent data, 16-bit for BCM controllers 1895#else 1896 sco_voice_setting = 0x0043; // Transparent data, 8-bit otherwise 1897#endif 1898 } | 964 break; 965 } 966 967 case HCI_EVENT_DISCONNECTION_COMPLETE: 968 handle = little_endian_read_16(packet,3); 969 hfp_connection = get_hfp_connection_context_for_sco_handle(handle, local_role); 970 971 if (!hfp_connection) break; --- 918 unchanged lines hidden (view full) --- 1890 uint16_t sco_voice_setting = hci_get_sco_voice_setting(); 1891 if (hfp_connection->negotiated_codec == HFP_CODEC_MSBC){ 1892#ifdef ENABLE_BCM_PCM_WBS 1893 sco_voice_setting = 0x0063; // Transparent data, 16-bit for BCM controllers 1894#else 1895 sco_voice_setting = 0x0043; // Transparent data, 8-bit otherwise 1896#endif 1897 } |
1898 uint16_t packet_types = hfp_link_settings[setting].packet_types; 1899 hfp_connection->packet_types = packet_types; 1900 |
|
1899 // get packet types - bits 6-9 are 'don't allow' | 1901 // get packet types - bits 6-9 are 'don't allow' |
1900 uint16_t packet_types = hfp_link_settings[setting].packet_types ^ 0x03c0; | 1902 uint16_t packet_types_flipped = packet_types ^ 0x03c0; |
1901 hci_send_cmd(&hci_setup_synchronous_connection, hfp_connection->acl_handle, 8000, 8000, hfp_link_settings[setting].max_latency, | 1903 hci_send_cmd(&hci_setup_synchronous_connection, hfp_connection->acl_handle, 8000, 8000, hfp_link_settings[setting].max_latency, |
1902 sco_voice_setting, hfp_link_settings[setting].retransmission_effort, packet_types); | 1904 sco_voice_setting, hfp_link_settings[setting].retransmission_effort, packet_types_flipped); |
1903} 1904 1905void hfp_accept_synchronous_connection(hfp_connection_t * hfp_connection, bool incoming_eSCO){ 1906 1907 // remote supported feature eSCO is set if link type is eSCO 1908 // eSCO: S4 - max latency == transmission interval = 0x000c == 12 ms, 1909 uint16_t max_latency; 1910 uint8_t retransmission_effort; --- 19 unchanged lines hidden (view full) --- 1930#else 1931 sco_voice_setting = 0x0043; // Transparent data, 8-bit otherwise 1932#endif 1933 } 1934 1935 // filter packet types 1936 packet_types &= hfp_get_sco_packet_types(); 1937 | 1905} 1906 1907void hfp_accept_synchronous_connection(hfp_connection_t * hfp_connection, bool incoming_eSCO){ 1908 1909 // remote supported feature eSCO is set if link type is eSCO 1910 // eSCO: S4 - max latency == transmission interval = 0x000c == 12 ms, 1911 uint16_t max_latency; 1912 uint8_t retransmission_effort; --- 19 unchanged lines hidden (view full) --- 1932#else 1933 sco_voice_setting = 0x0043; // Transparent data, 8-bit otherwise 1934#endif 1935 } 1936 1937 // filter packet types 1938 packet_types &= hfp_get_sco_packet_types(); 1939 |
1940 hfp_connection->packet_types = packet_types; 1941 |
|
1938 // bits 6-9 are 'don't allow' | 1942 // bits 6-9 are 'don't allow' |
1939 packet_types ^= 0x3c0; | 1943 uint16_t packet_types_flipped = packet_types ^ 0x3c0; |
1940 1941 log_info("HFP: sending hci_accept_connection_request, packet types 0x%04x, sco_voice_setting 0x%02x", packet_types, sco_voice_setting); 1942 hci_send_cmd(&hci_accept_synchronous_connection, hfp_connection->remote_addr, 8000, 8000, max_latency, | 1944 1945 log_info("HFP: sending hci_accept_connection_request, packet types 0x%04x, sco_voice_setting 0x%02x", packet_types, sco_voice_setting); 1946 hci_send_cmd(&hci_accept_synchronous_connection, hfp_connection->remote_addr, 8000, 8000, max_latency, |
1943 sco_voice_setting, retransmission_effort, packet_types); | 1947 sco_voice_setting, retransmission_effort, packet_types_flipped); |
1944} 1945 1946#ifdef ENABLE_CC256X_ASSISTED_HFP 1947void hfp_cc256x_prepare_for_sco(hfp_connection_t * hfp_connection){ 1948 hfp_connection->cc256x_send_write_codec_config = true; 1949 if (hfp_connection->negotiated_codec == HFP_CODEC_MSBC){ 1950 hfp_connection->cc256x_send_wbs_associate = true; 1951 } --- 150 unchanged lines hidden --- | 1948} 1949 1950#ifdef ENABLE_CC256X_ASSISTED_HFP 1951void hfp_cc256x_prepare_for_sco(hfp_connection_t * hfp_connection){ 1952 hfp_connection->cc256x_send_write_codec_config = true; 1953 if (hfp_connection->negotiated_codec == HFP_CODEC_MSBC){ 1954 hfp_connection->cc256x_send_wbs_associate = true; 1955 } --- 150 unchanged lines hidden --- |