hfp_ag.c (b7e273518cd9f4945c397269be4329336dd36f70) | hfp_ag.c (50b9afa46bbafa0ea0b51cd71aeaf6ef5869f857) |
---|---|
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 --- 67 unchanged lines hidden (view full) --- 76// public prototypes 77hfp_generic_status_indicator_t * get_hfp_generic_status_indicators(void); 78int get_hfp_generic_status_indicators_nr(void); 79void set_hfp_generic_status_indicators(hfp_generic_status_indicator_t * indicators, int indicator_nr); 80void set_hfp_ag_indicators(hfp_ag_indicator_t * indicators, int indicator_nr); 81int get_hfp_ag_indicators_nr(hfp_connection_t * context); 82hfp_ag_indicator_t * get_hfp_ag_indicators(hfp_connection_t * context); 83 | 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 --- 67 unchanged lines hidden (view full) --- 76// public prototypes 77hfp_generic_status_indicator_t * get_hfp_generic_status_indicators(void); 78int get_hfp_generic_status_indicators_nr(void); 79void set_hfp_generic_status_indicators(hfp_generic_status_indicator_t * indicators, int indicator_nr); 80void set_hfp_ag_indicators(hfp_ag_indicator_t * indicators, int indicator_nr); 81int get_hfp_ag_indicators_nr(hfp_connection_t * context); 82hfp_ag_indicator_t * get_hfp_ag_indicators(hfp_connection_t * context); 83 |
84static void hfp_ag_trigger_ring_and_clip(); 85 |
|
84#define HFP_SUBEVENT_INVALID 0xFFFF 85 86// const 87static const char hfp_ag_default_service_name[] = "Voice gateway"; 88 89// globals 90 91// higher layer callbacks --- 1035 unchanged lines hidden (view full) --- 1127 if (hfp_connection->local_role != HFP_ROLE_AG) continue; 1128 if (hfp_connection->call_state != HFP_CALL_ACTIVE) continue; 1129 1130 hfp_connection->call_state = HFP_CALL_W2_SEND_CALL_WAITING; 1131 hfp_ag_run_for_context(hfp_connection); 1132 } 1133} 1134 | 86#define HFP_SUBEVENT_INVALID 0xFFFF 87 88// const 89static const char hfp_ag_default_service_name[] = "Voice gateway"; 90 91// globals 92 93// higher layer callbacks --- 1035 unchanged lines hidden (view full) --- 1129 if (hfp_connection->local_role != HFP_ROLE_AG) continue; 1130 if (hfp_connection->call_state != HFP_CALL_ACTIVE) continue; 1131 1132 hfp_connection->call_state = HFP_CALL_W2_SEND_CALL_WAITING; 1133 hfp_ag_run_for_context(hfp_connection); 1134 } 1135} 1136 |
1135// trigger RING and CLIP messages on connections that are ringing 1136static void hfp_ag_ring_timeout_handler(btstack_timer_source_t * timer){ | 1137static void hfp_ag_trigger_ring_and_clip() { |
1137 btstack_linked_list_iterator_t it; 1138 btstack_linked_list_iterator_init(&it, hfp_get_connections()); 1139 while (btstack_linked_list_iterator_has_next(&it)){ 1140 hfp_connection_t * hfp_connection = (hfp_connection_t *)btstack_linked_list_iterator_next(&it); 1141 if (hfp_connection->local_role != HFP_ROLE_AG) continue; 1142 switch (hfp_connection->call_state){ 1143 case HFP_CALL_INCOMING_RINGING: 1144 case HFP_CALL_W4_AUDIO_CONNECTION_FOR_IN_BAND_RING: --- 8 unchanged lines hidden (view full) --- 1153 1154 // trigger next message 1155 rfcomm_request_can_send_now_event(hfp_connection->rfcomm_cid); 1156 break; 1157 default: 1158 break; 1159 } 1160 } | 1138 btstack_linked_list_iterator_t it; 1139 btstack_linked_list_iterator_init(&it, hfp_get_connections()); 1140 while (btstack_linked_list_iterator_has_next(&it)){ 1141 hfp_connection_t * hfp_connection = (hfp_connection_t *)btstack_linked_list_iterator_next(&it); 1142 if (hfp_connection->local_role != HFP_ROLE_AG) continue; 1143 switch (hfp_connection->call_state){ 1144 case HFP_CALL_INCOMING_RINGING: 1145 case HFP_CALL_W4_AUDIO_CONNECTION_FOR_IN_BAND_RING: --- 8 unchanged lines hidden (view full) --- 1154 1155 // trigger next message 1156 rfcomm_request_can_send_now_event(hfp_connection->rfcomm_cid); 1157 break; 1158 default: 1159 break; 1160 } 1161 } |
1161 1162 btstack_run_loop_set_timer(timer, 2000); // 2 seconds timeout 1163 btstack_run_loop_add_timer(timer); | |
1164} 1165 | 1162} 1163 |
1166static void hfp_ag_ring_timeout_start(void){ 1167 btstack_run_loop_remove_timer(&hfp_ag_ring_timeout); 1168 btstack_run_loop_set_timer_handler(&hfp_ag_ring_timeout, hfp_ag_ring_timeout_handler); 1169 hfp_ag_ring_timeout_handler(&hfp_ag_ring_timeout); | 1164// trigger RING and CLIP messages on connections that are ringing 1165static void hfp_ag_ring_timeout_handler(btstack_timer_source_t * timer){ 1166 hfp_ag_trigger_ring_and_clip(); 1167 1168 btstack_run_loop_set_timer(timer, RING_PERIOD_MS); // 2 seconds timeout 1169 btstack_run_loop_add_timer(timer); |
1170} 1171 1172static void hfp_ag_ring_timeout_stop(void){ 1173 btstack_run_loop_remove_timer(&hfp_ag_ring_timeout); 1174} 1175 1176static void hfp_ag_start_ringing(void){ | 1170} 1171 1172static void hfp_ag_ring_timeout_stop(void){ 1173 btstack_run_loop_remove_timer(&hfp_ag_ring_timeout); 1174} 1175 1176static void hfp_ag_start_ringing(void){ |
1177 hfp_ag_ring_timeout_start(); | 1177 // setup ring timer 1178 btstack_run_loop_remove_timer(&hfp_ag_ring_timeout); 1179 btstack_run_loop_set_timer_handler(&hfp_ag_ring_timeout, hfp_ag_ring_timeout_handler); 1180 btstack_run_loop_set_timer(&hfp_ag_ring_timeout, RING_PERIOD_MS); // 2 seconds timeout 1181 btstack_run_loop_add_timer(&hfp_ag_ring_timeout); 1182 1183 // emit start ringing |
1178 hfp_ag_emit_general_simple_event(HFP_SUBEVENT_START_RINGING); | 1184 hfp_ag_emit_general_simple_event(HFP_SUBEVENT_START_RINGING); |
1185 1186 // send initial RING + CLIP 1187 hfp_ag_trigger_ring_and_clip(); |
|
1179} 1180 1181static void hfp_ag_stop_ringing(void){ 1182 hfp_ag_ring_timeout_stop(); 1183 hfp_ag_emit_general_simple_event(HFP_SUBEVENT_STOP_RINGING); 1184 1185 btstack_linked_list_iterator_t it; 1186 btstack_linked_list_iterator_init(&it, hfp_get_connections()); --- 1857 unchanged lines hidden --- | 1188} 1189 1190static void hfp_ag_stop_ringing(void){ 1191 hfp_ag_ring_timeout_stop(); 1192 hfp_ag_emit_general_simple_event(HFP_SUBEVENT_STOP_RINGING); 1193 1194 btstack_linked_list_iterator_t it; 1195 btstack_linked_list_iterator_init(&it, hfp_get_connections()); --- 1857 unchanged lines hidden --- |