hfp_ag.c (1ec112deb972d04575b0fada678da234fad428a7) | hfp_ag.c (3721a235468b7b00a1583fbaab9ebe94f874a0f4) |
---|---|
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 --- 541 unchanged lines hidden (view full) --- 550 hfp_ag_send_error(hfp_connection->rfcomm_cid); 551 return 1; 552 } 553 hfp_connection->negotiated_codec = hfp_connection->codec_confirmed; 554 hfp_connection->codecs_state = HFP_CODECS_EXCHANGED; 555 log_info("hfp: codec confirmed: %s", (hfp_connection->negotiated_codec == HFP_CODEC_MSBC) ? "mSBC" : "CVSD"); 556 hfp_ag_send_ok(hfp_connection->rfcomm_cid); 557 // now, pick link settings | 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 --- 541 unchanged lines hidden (view full) --- 550 hfp_ag_send_error(hfp_connection->rfcomm_cid); 551 return 1; 552 } 553 hfp_connection->negotiated_codec = hfp_connection->codec_confirmed; 554 hfp_connection->codecs_state = HFP_CODECS_EXCHANGED; 555 log_info("hfp: codec confirmed: %s", (hfp_connection->negotiated_codec == HFP_CODEC_MSBC) ? "mSBC" : "CVSD"); 556 hfp_ag_send_ok(hfp_connection->rfcomm_cid); 557 // now, pick link settings |
558 | |
559 hfp_init_link_settings(hfp_connection, hfp_ag_esco_s4_supported(hfp_connection)); | 558 hfp_init_link_settings(hfp_connection, hfp_ag_esco_s4_supported(hfp_connection)); |
560 return 1; | 559#ifdef ENABLE_CC256X_ASSISTED_HFP 560 hfp_cc256x_prepare_for_sco(hfp_connection); 561#endif 562 return 1; |
561 default: 562 break; 563 } 564 return 0; 565} 566 567static void hfp_ag_slc_established(hfp_connection_t * hfp_connection){ 568 hfp_connection->state = HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED; --- 1138 unchanged lines hidden (view full) --- 1707static void hfp_ag_run_for_context(hfp_connection_t *hfp_connection){ 1708 1709 btstack_assert(hfp_connection != NULL); 1710 btstack_assert(hfp_connection->local_role == HFP_ROLE_AG); 1711 1712 // during SDP query, RFCOMM CID is not set 1713 if (hfp_connection->rfcomm_cid == 0) return; 1714 | 563 default: 564 break; 565 } 566 return 0; 567} 568 569static void hfp_ag_slc_established(hfp_connection_t * hfp_connection){ 570 hfp_connection->state = HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED; --- 1138 unchanged lines hidden (view full) --- 1709static void hfp_ag_run_for_context(hfp_connection_t *hfp_connection){ 1710 1711 btstack_assert(hfp_connection != NULL); 1712 btstack_assert(hfp_connection->local_role == HFP_ROLE_AG); 1713 1714 // during SDP query, RFCOMM CID is not set 1715 if (hfp_connection->rfcomm_cid == 0) return; 1716 |
1717 // assert command could be sent 1718 if (hci_can_send_command_packet_now() == 0) return; 1719 1720#ifdef ENABLE_CC256X_ASSISTED_HFP 1721 // WBS Disassociate 1722 if (hfp_connection->cc256x_send_wbs_disassociate){ 1723 hfp_connection->cc256x_send_wbs_disassociate = false; 1724 hci_send_cmd(&hci_ti_wbs_disassociate); 1725 return; 1726 } 1727 // Write Codec Config 1728 if (hfp_connection->cc256x_send_write_codec_config){ 1729 hfp_connection->cc256x_send_write_codec_config = false; 1730 hfp_cc256x_write_codec_config(hfp_connection); 1731 return; 1732 } 1733 // WBS Associate 1734 if (hfp_connection->cc256x_send_wbs_associate){ 1735 hfp_connection->cc256x_send_wbs_associate = false; 1736 hci_send_cmd(&hci_ti_wbs_associate, hfp_connection->acl_handle); 1737 return; 1738 } 1739#endif 1740 |
|
1715 if (!rfcomm_can_send_packet_now(hfp_connection->rfcomm_cid)) { 1716 log_info("hfp_ag_run_for_context: request can send for 0x%02x", hfp_connection->rfcomm_cid); 1717 rfcomm_request_can_send_now_event(hfp_connection->rfcomm_cid); 1718 return; 1719 } 1720 1721 int cmd_sent = hfp_ag_send_commands(hfp_connection); 1722 --- 285 unchanged lines hidden (view full) --- 2008 break; 2009 } 2010 2011 hfp_ag_run(); 2012} 2013 2014static void hfp_ag_hci_event_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){ 2015 hfp_handle_hci_event(packet_type, channel, packet, size, HFP_ROLE_AG); | 1741 if (!rfcomm_can_send_packet_now(hfp_connection->rfcomm_cid)) { 1742 log_info("hfp_ag_run_for_context: request can send for 0x%02x", hfp_connection->rfcomm_cid); 1743 rfcomm_request_can_send_now_event(hfp_connection->rfcomm_cid); 1744 return; 1745 } 1746 1747 int cmd_sent = hfp_ag_send_commands(hfp_connection); 1748 --- 285 unchanged lines hidden (view full) --- 2034 break; 2035 } 2036 2037 hfp_ag_run(); 2038} 2039 2040static void hfp_ag_hci_event_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){ 2041 hfp_handle_hci_event(packet_type, channel, packet, size, HFP_ROLE_AG); |
2016 2017 // allow for sco established -> ring transition 2018 if (packet_type != HCI_EVENT_PACKET) return; 2019 if (hci_event_packet_get_type(packet) != HCI_EVENT_SYNCHRONOUS_CONNECTION_COMPLETE) return; | |
2020 hfp_ag_run(); 2021} 2022 2023void hfp_ag_init_codecs(int codecs_nr, uint8_t * codecs){ 2024 if (codecs_nr > HFP_MAX_NUM_CODECS){ 2025 log_error("hfp_init: codecs_nr (%d) > HFP_MAX_NUM_CODECS (%d)", codecs_nr, HFP_MAX_NUM_CODECS); 2026 return; 2027 } --- 82 unchanged lines hidden (view full) --- 2110 2111 hfp_connection->establish_audio_connection = 1; 2112 if (!has_codec_negotiation_feature(hfp_connection)){ 2113 log_info("hfp_ag_establish_audio_connection - no codec negotiation feature, using CVSD"); 2114 hfp_connection->negotiated_codec = HFP_CODEC_CVSD; 2115 hfp_connection->codecs_state = HFP_CODECS_EXCHANGED; 2116 // now, pick link settings 2117 hfp_init_link_settings(hfp_connection, hfp_ag_esco_s4_supported(hfp_connection)); | 2042 hfp_ag_run(); 2043} 2044 2045void hfp_ag_init_codecs(int codecs_nr, uint8_t * codecs){ 2046 if (codecs_nr > HFP_MAX_NUM_CODECS){ 2047 log_error("hfp_init: codecs_nr (%d) > HFP_MAX_NUM_CODECS (%d)", codecs_nr, HFP_MAX_NUM_CODECS); 2048 return; 2049 } --- 82 unchanged lines hidden (view full) --- 2132 2133 hfp_connection->establish_audio_connection = 1; 2134 if (!has_codec_negotiation_feature(hfp_connection)){ 2135 log_info("hfp_ag_establish_audio_connection - no codec negotiation feature, using CVSD"); 2136 hfp_connection->negotiated_codec = HFP_CODEC_CVSD; 2137 hfp_connection->codecs_state = HFP_CODECS_EXCHANGED; 2138 // now, pick link settings 2139 hfp_init_link_settings(hfp_connection, hfp_ag_esco_s4_supported(hfp_connection)); |
2140#ifdef ENABLE_CC256X_ASSISTED_HFP 2141 hfp_cc256x_prepare_for_sco(hfp_connection); 2142#endif |
|
2118 return; 2119 } 2120 2121 hfp_connection->trigger_codec_exchange = 1; 2122} 2123 2124void hfp_ag_establish_audio_connection(hci_con_handle_t acl_handle){ 2125 hfp_connection_t * hfp_connection = get_hfp_ag_connection_context_for_acl_handle(acl_handle); --- 269 unchanged lines hidden --- | 2143 return; 2144 } 2145 2146 hfp_connection->trigger_codec_exchange = 1; 2147} 2148 2149void hfp_ag_establish_audio_connection(hci_con_handle_t acl_handle){ 2150 hfp_connection_t * hfp_connection = get_hfp_ag_connection_context_for_acl_handle(acl_handle); --- 269 unchanged lines hidden --- |