hfp_ag.c (7ca89cabe01ec06969a60ca277f5f47c7557fd57) hfp_ag.c (d0a0eceedac645e29f717691adb705ab7dcbf04a)
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

--- 1763 unchanged lines hidden (view full) ---

1772 if (!rfcomm_can_send_packet_now(hfp_connection->rfcomm_cid)) {
1773 log_info("hfp_ag_run_for_context: request can send for 0x%02x", hfp_connection->rfcomm_cid);
1774 rfcomm_request_can_send_now_event(hfp_connection->rfcomm_cid);
1775 return;
1776 }
1777
1778 int cmd_sent = hfp_ag_send_commands(hfp_connection);
1779
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

--- 1763 unchanged lines hidden (view full) ---

1772 if (!rfcomm_can_send_packet_now(hfp_connection->rfcomm_cid)) {
1773 log_info("hfp_ag_run_for_context: request can send for 0x%02x", hfp_connection->rfcomm_cid);
1774 rfcomm_request_can_send_now_event(hfp_connection->rfcomm_cid);
1775 return;
1776 }
1777
1778 int cmd_sent = hfp_ag_send_commands(hfp_connection);
1779
1780 // trigger codec exchange if requested by app
1781 if (hfp_connection->trigger_codec_exchange){
1782 log_info("trigger codec, command %u, codec state %u", hfp_connection->command, hfp_connection->codecs_state);
1783 }
1784
1785 if (hfp_connection->trigger_codec_exchange && (hfp_connection->command == HFP_CMD_NONE)){
1786 switch (hfp_connection->codecs_state){
1787 case HFP_CODECS_IDLE:
1788 case HFP_CODECS_RECEIVED_LIST:
1789 case HFP_CODECS_AG_RESEND_COMMON_CODEC:
1790 case HFP_CODECS_ERROR:
1791 hfp_connection->trigger_codec_exchange = 0;
1792 hfp_connection->command = HFP_CMD_AG_SEND_COMMON_CODEC;
1793 break;
1794 default:
1795 break;
1796 }
1797 }
1798
1799 if (!cmd_sent){
1800 cmd_sent = hfp_ag_run_for_context_service_level_connection(hfp_connection);
1801 }
1802
1803 if (!cmd_sent){
1804 cmd_sent = hfp_ag_run_for_context_service_level_connection_queries(hfp_connection);
1805 }
1806
1807 if (!cmd_sent){
1808 cmd_sent = call_setup_state_machine(hfp_connection);
1809 }
1810
1811 if (!cmd_sent){
1812 cmd_sent = hfp_ag_run_for_audio_connection(hfp_connection);
1813 }
1814
1780 if (!cmd_sent){
1781 cmd_sent = hfp_ag_run_for_context_service_level_connection(hfp_connection);
1782 }
1783
1784 if (!cmd_sent){
1785 cmd_sent = hfp_ag_run_for_context_service_level_connection_queries(hfp_connection);
1786 }
1787
1788 if (!cmd_sent){
1789 cmd_sent = call_setup_state_machine(hfp_connection);
1790 }
1791
1792 if (!cmd_sent){
1793 cmd_sent = hfp_ag_run_for_audio_connection(hfp_connection);
1794 }
1795
1815 if ((hfp_connection->command == HFP_CMD_NONE) && !cmd_sent){
1816 // log_info("hfp_connection->command == HFP_CMD_NONE");
1817 switch(hfp_connection->state){
1818 case HFP_W2_DISCONNECT_RFCOMM:
1819 hfp_connection->state = HFP_W4_RFCOMM_DISCONNECTED;
1820 rfcomm_disconnect(hfp_connection->rfcomm_cid);
1796 // trigger codec exchange
1797 if (!cmd_sent && (hfp_connection->command == HFP_CMD_NONE) && hfp_connection->trigger_codec_exchange){
1798 log_info("trigger codec, command %u, codec state %u", hfp_connection->command, hfp_connection->codecs_state);
1799 switch (hfp_connection->codecs_state){
1800 case HFP_CODECS_IDLE:
1801 case HFP_CODECS_RECEIVED_LIST:
1802 case HFP_CODECS_AG_RESEND_COMMON_CODEC:
1803 case HFP_CODECS_ERROR:
1804 hfp_connection->trigger_codec_exchange = 0;
1805 hfp_connection->command = HFP_CMD_AG_SEND_COMMON_CODEC;
1821 break;
1822 default:
1823 break;
1824 }
1825 }
1806 break;
1807 default:
1808 break;
1809 }
1810 }
1811
1812 // disconnect
1813 if (!cmd_sent && (hfp_connection->command == HFP_CMD_NONE) && (hfp_connection->state == HFP_W2_DISCONNECT_RFCOMM)){
1814 hfp_connection->state = HFP_W4_RFCOMM_DISCONNECTED;
1815 rfcomm_disconnect(hfp_connection->rfcomm_cid);
1816 }
1826
1827 if (cmd_sent){
1828 hfp_connection->command = HFP_CMD_NONE;
1829 rfcomm_request_can_send_now_event(hfp_connection->rfcomm_cid);
1830 }
1831}
1832
1833static hfp_generic_status_indicator_t *get_hf_indicator_by_number(int number){

--- 634 unchanged lines hidden ---
1817
1818 if (cmd_sent){
1819 hfp_connection->command = HFP_CMD_NONE;
1820 rfcomm_request_can_send_now_event(hfp_connection->rfcomm_cid);
1821 }
1822}
1823
1824static hfp_generic_status_indicator_t *get_hf_indicator_by_number(int number){

--- 634 unchanged lines hidden ---