mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-18 14:42:33 +00:00
Merge branch 'master' of https://github.com/bluekitchen/btstack
This commit is contained in:
commit
b272847fe5
@ -72,69 +72,147 @@ static char clip_number[HFP_GSM_MAX_CALL_NUMBER_SIZE];
|
|||||||
static char last_dialed_number[HFP_GSM_MAX_CALL_NUMBER_SIZE];
|
static char last_dialed_number[HFP_GSM_MAX_CALL_NUMBER_SIZE];
|
||||||
|
|
||||||
static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t type, const char * number);
|
static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t type, const char * number);
|
||||||
|
static inline int get_number_active_calls(void);
|
||||||
|
|
||||||
|
static void set_callsetup_status(hfp_callsetup_status_t status){
|
||||||
|
callsetup_status = status;
|
||||||
|
if (callsetup_status != HFP_CALLSETUP_STATUS_OUTGOING_CALL_SETUP_IN_ALERTING_STATE) return;
|
||||||
|
|
||||||
|
int i ;
|
||||||
|
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
||||||
|
if (gsm_calls[i].direction == HFP_ENHANCED_CALL_DIR_OUTGOING){
|
||||||
|
gsm_calls[i].enhanced_status = HFP_ENHANCED_CALL_STATUS_OUTGOING_ALERTING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void set_enhanced_call_status_active(int index_in_table){
|
||||||
|
gsm_calls[index_in_table].enhanced_status = HFP_ENHANCED_CALL_STATUS_ACTIVE;
|
||||||
|
gsm_calls[index_in_table].used_slot = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void set_enhanced_call_status_held(int index_in_table){
|
||||||
|
gsm_calls[index_in_table].enhanced_status = HFP_ENHANCED_CALL_STATUS_HELD;
|
||||||
|
gsm_calls[index_in_table].used_slot = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void set_enhanced_call_status_response_hold(int index_in_table){
|
||||||
|
gsm_calls[index_in_table].enhanced_status = HFP_ENHANCED_CALL_STATUS_CALL_HELD_BY_RESPONSE_AND_HOLD;
|
||||||
|
gsm_calls[index_in_table].used_slot = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void set_enhanced_call_status_initiated(int index_in_table){
|
||||||
|
if (gsm_calls[index_in_table].direction == HFP_ENHANCED_CALL_DIR_OUTGOING){
|
||||||
|
gsm_calls[index_in_table].enhanced_status = HFP_ENHANCED_CALL_STATUS_OUTGOING_DIALING;
|
||||||
|
} else {
|
||||||
|
if (get_number_active_calls() > 0){
|
||||||
|
gsm_calls[index_in_table].enhanced_status = HFP_ENHANCED_CALL_STATUS_INCOMING_WAITING;
|
||||||
|
} else {
|
||||||
|
gsm_calls[index_in_table].enhanced_status = HFP_ENHANCED_CALL_STATUS_INCOMING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gsm_calls[index_in_table].used_slot = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int get_enhanced_call_status(int index_in_table){
|
||||||
|
if (!gsm_calls[index_in_table].used_slot) return -1;
|
||||||
|
return gsm_calls[index_in_table].enhanced_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int is_enhanced_call_status_active(int index_in_table){
|
||||||
|
return get_enhanced_call_status(index_in_table) == HFP_ENHANCED_CALL_STATUS_ACTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int is_enhanced_call_status_initiated(int index_in_table){
|
||||||
|
switch (get_enhanced_call_status(index_in_table)){
|
||||||
|
case HFP_ENHANCED_CALL_STATUS_OUTGOING_DIALING:
|
||||||
|
case HFP_ENHANCED_CALL_STATUS_OUTGOING_ALERTING:
|
||||||
|
case HFP_ENHANCED_CALL_STATUS_INCOMING:
|
||||||
|
case HFP_ENHANCED_CALL_STATUS_INCOMING_WAITING:
|
||||||
|
return 1;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void free_call_slot(int index_in_table){
|
||||||
|
gsm_calls[index_in_table].used_slot = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void hfp_gsm_init(void){
|
void hfp_gsm_init(void){
|
||||||
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
set_callsetup_status(HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS);
|
||||||
clip_type = 0;
|
clip_type = 0;
|
||||||
memset(clip_number, 0, sizeof(clip_number));
|
memset(clip_number, 0, sizeof(clip_number));
|
||||||
memset(last_dialed_number, 0, sizeof(last_dialed_number));
|
memset(last_dialed_number, 0, sizeof(last_dialed_number));
|
||||||
memset(gsm_calls, 0, sizeof(gsm_calls));
|
memset(gsm_calls, 0, sizeof(gsm_calls));
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
||||||
gsm_calls[i].status = CALL_NONE;
|
free_call_slot(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_number_calls_with_status(hfp_gsm_call_status_t status){
|
static int get_number_calls_with_enhanced_status(hfp_enhanced_call_status_t enhanced_status){
|
||||||
int i, count = 0;
|
int i, count = 0;
|
||||||
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
||||||
if (gsm_calls[i].status == status) count++;
|
if (get_enhanced_call_status(i) == enhanced_status) count++;
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_call_index_with_status(hfp_gsm_call_status_t status){
|
static int get_call_index_with_enhanced_status(hfp_enhanced_call_status_t enhanced_status){
|
||||||
int i ;
|
int i ;
|
||||||
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
||||||
if (gsm_calls[i].status == status) return i;
|
if (get_enhanced_call_status(i) == enhanced_status) return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int get_initiated_call_index(void){
|
||||||
|
int i ;
|
||||||
|
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
||||||
|
if (is_enhanced_call_status_initiated(i)) return i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_next_free_slot(void){
|
static inline int get_next_free_slot(void){
|
||||||
return get_call_index_with_status(CALL_NONE);
|
int i ;
|
||||||
|
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
||||||
|
if (!gsm_calls[i].used_slot) return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_active_call_index(void){
|
static inline int get_active_call_index(void){
|
||||||
return get_call_index_with_status(CALL_ACTIVE);
|
return get_call_index_with_enhanced_status(HFP_ENHANCED_CALL_STATUS_ACTIVE);
|
||||||
}
|
|
||||||
|
|
||||||
static inline int get_initiated_call_index(void){
|
|
||||||
return get_call_index_with_status(CALL_INITIATED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_held_call_index(void){
|
static inline int get_held_call_index(void){
|
||||||
return get_call_index_with_status(CALL_HELD);
|
return get_call_index_with_enhanced_status(HFP_ENHANCED_CALL_STATUS_HELD);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_response_held_call_index(void){
|
static inline int get_response_held_call_index(void){
|
||||||
return get_call_index_with_status(CALL_RESPONSE_HOLD);
|
return get_call_index_with_enhanced_status(HFP_ENHANCED_CALL_STATUS_CALL_HELD_BY_RESPONSE_AND_HOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_number_none_calls(void){
|
static inline int get_number_none_calls(void){
|
||||||
return get_number_calls_with_status(CALL_NONE);
|
int i, count = 0;
|
||||||
|
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
||||||
|
if (!gsm_calls[i].used_slot) count++;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_number_active_calls(void){
|
static inline int get_number_active_calls(void){
|
||||||
return get_number_calls_with_status(CALL_ACTIVE);
|
return get_number_calls_with_enhanced_status(HFP_ENHANCED_CALL_STATUS_ACTIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_number_held_calls(void){
|
static inline int get_number_held_calls(void){
|
||||||
return get_number_calls_with_status(CALL_HELD);
|
return get_number_calls_with_enhanced_status(HFP_ENHANCED_CALL_STATUS_HELD);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_number_response_held_calls(void){
|
static inline int get_number_response_held_calls(void){
|
||||||
return get_number_calls_with_status(CALL_RESPONSE_HOLD);
|
return get_number_calls_with_enhanced_status(HFP_ENHANCED_CALL_STATUS_CALL_HELD_BY_RESPONSE_AND_HOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int next_call_index(void){
|
static int next_call_index(void){
|
||||||
@ -163,8 +241,8 @@ static void delete_call(int delete_index_in_table){
|
|||||||
gsm_calls[i].index--;
|
gsm_calls[i].index--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free_call_slot(delete_index_in_table);
|
||||||
|
|
||||||
gsm_calls[delete_index_in_table].status = CALL_NONE;
|
|
||||||
gsm_calls[delete_index_in_table].clip_type = 0;
|
gsm_calls[delete_index_in_table].clip_type = 0;
|
||||||
gsm_calls[delete_index_in_table].index = 0;
|
gsm_calls[delete_index_in_table].index = 0;
|
||||||
gsm_calls[delete_index_in_table].clip_number[0] = '\0';
|
gsm_calls[delete_index_in_table].clip_number[0] = '\0';
|
||||||
@ -176,7 +254,7 @@ static void create_call(hfp_enhanced_call_dir_t direction){
|
|||||||
int next_free_slot = get_next_free_slot();
|
int next_free_slot = get_next_free_slot();
|
||||||
gsm_calls[next_free_slot].direction = direction;
|
gsm_calls[next_free_slot].direction = direction;
|
||||||
gsm_calls[next_free_slot].index = next_call_index();
|
gsm_calls[next_free_slot].index = next_call_index();
|
||||||
gsm_calls[next_free_slot].status = CALL_INITIATED;
|
set_enhanced_call_status_initiated(next_free_slot);
|
||||||
gsm_calls[next_free_slot].clip_type = 0;
|
gsm_calls[next_free_slot].clip_type = 0;
|
||||||
gsm_calls[next_free_slot].clip_number[0] = '\0';
|
gsm_calls[next_free_slot].clip_number[0] = '\0';
|
||||||
gsm_calls[next_free_slot].mpty = HFP_ENHANCED_CALL_MPTY_NOT_A_CONFERENCE_CALL;
|
gsm_calls[next_free_slot].mpty = HFP_ENHANCED_CALL_MPTY_NOT_A_CONFERENCE_CALL;
|
||||||
@ -202,27 +280,7 @@ hfp_gsm_call_t * hfp_gsm_call(int call_index){
|
|||||||
|
|
||||||
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
||||||
hfp_gsm_call_t * call = &gsm_calls[i];
|
hfp_gsm_call_t * call = &gsm_calls[i];
|
||||||
|
|
||||||
if (call->index != call_index) continue;
|
if (call->index != call_index) continue;
|
||||||
|
|
||||||
call->enhanced_status = HFP_ENHANCED_CALL_STATUS_CALL_HELD_BY_RESPONSE_AND_HOLD;
|
|
||||||
|
|
||||||
if (call->status == CALL_ACTIVE) call->enhanced_status = HFP_ENHANCED_CALL_STATUS_ACTIVE;
|
|
||||||
if (call->status == CALL_HELD) call->enhanced_status = HFP_ENHANCED_CALL_STATUS_HELD;
|
|
||||||
|
|
||||||
if (call->status == CALL_INITIATED){
|
|
||||||
if (call->direction == HFP_ENHANCED_CALL_DIR_OUTGOING){
|
|
||||||
if (callsetup_status == HFP_CALLSETUP_STATUS_OUTGOING_CALL_SETUP_IN_ALERTING_STATE){
|
|
||||||
call->enhanced_status = HFP_ENHANCED_CALL_STATUS_OUTGOING_ALERTING;
|
|
||||||
}
|
|
||||||
call->enhanced_status = HFP_ENHANCED_CALL_STATUS_OUTGOING_DIALING;
|
|
||||||
} else {
|
|
||||||
if (get_number_active_calls() > 0){
|
|
||||||
call->enhanced_status = HFP_ENHANCED_CALL_STATUS_INCOMING_WAITING;
|
|
||||||
}
|
|
||||||
call->enhanced_status = HFP_ENHANCED_CALL_STATUS_INCOMING;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return call;
|
return call;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -334,14 +392,14 @@ static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t ty
|
|||||||
if (current_call_index != -1){
|
if (current_call_index != -1){
|
||||||
delete_call(current_call_index);
|
delete_call(current_call_index);
|
||||||
}
|
}
|
||||||
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
set_callsetup_status(HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HFP_AG_OUTGOING_CALL_ACCEPTED:
|
case HFP_AG_OUTGOING_CALL_ACCEPTED:
|
||||||
if (current_call_index != -1){
|
if (current_call_index != -1){
|
||||||
gsm_calls[current_call_index].status = CALL_HELD;
|
set_enhanced_call_status_held(current_call_index);
|
||||||
}
|
}
|
||||||
callsetup_status = HFP_CALLSETUP_STATUS_OUTGOING_CALL_SETUP_IN_DIALING_STATE;
|
set_callsetup_status(HFP_CALLSETUP_STATUS_OUTGOING_CALL_SETUP_IN_DIALING_STATE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HFP_AG_OUTGOING_CALL_RINGING:
|
case HFP_AG_OUTGOING_CALL_RINGING:
|
||||||
@ -349,27 +407,27 @@ static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t ty
|
|||||||
log_error("gsm: no active call");
|
log_error("gsm: no active call");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
callsetup_status = HFP_CALLSETUP_STATUS_OUTGOING_CALL_SETUP_IN_ALERTING_STATE;
|
set_callsetup_status(HFP_CALLSETUP_STATUS_OUTGOING_CALL_SETUP_IN_ALERTING_STATE);
|
||||||
break;
|
break;
|
||||||
case HFP_AG_OUTGOING_CALL_ESTABLISHED:
|
case HFP_AG_OUTGOING_CALL_ESTABLISHED:
|
||||||
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
set_callsetup_status(HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS);
|
||||||
gsm_calls[initiated_call_index].status = CALL_ACTIVE;
|
set_enhanced_call_status_active(initiated_call_index);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HFP_AG_INCOMING_CALL:
|
case HFP_AG_INCOMING_CALL:
|
||||||
if (hfp_gsm_callsetup_status() != HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS) break;
|
if (hfp_gsm_callsetup_status() != HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS) break;
|
||||||
callsetup_status = HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS;
|
set_callsetup_status(HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS);
|
||||||
create_call(HFP_ENHANCED_CALL_DIR_INCOMING);
|
create_call(HFP_ENHANCED_CALL_DIR_INCOMING);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HFP_AG_INCOMING_CALL_ACCEPTED_BY_AG:
|
case HFP_AG_INCOMING_CALL_ACCEPTED_BY_AG:
|
||||||
if (hfp_gsm_callsetup_status() != HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS) break;
|
if (hfp_gsm_callsetup_status() != HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS) break;
|
||||||
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
set_callsetup_status(HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS);
|
||||||
|
|
||||||
if (hfp_gsm_call_status() == HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT){
|
if (hfp_gsm_call_status() == HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT){
|
||||||
gsm_calls[current_call_index].status = CALL_HELD;
|
set_enhanced_call_status_held(current_call_index);
|
||||||
}
|
}
|
||||||
gsm_calls[initiated_call_index].status = CALL_ACTIVE;
|
set_enhanced_call_status_active(initiated_call_index);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HFP_AG_HELD_CALL_JOINED_BY_AG:
|
case HFP_AG_HELD_CALL_JOINED_BY_AG:
|
||||||
@ -377,14 +435,14 @@ static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t ty
|
|||||||
|
|
||||||
// TODO: is following condition correct? Can we join incoming call before it is answered?
|
// TODO: is following condition correct? Can we join incoming call before it is answered?
|
||||||
if (callsetup_status == HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS){
|
if (callsetup_status == HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS){
|
||||||
gsm_calls[initiated_call_index].status = CALL_ACTIVE;
|
set_enhanced_call_status_active(initiated_call_index);
|
||||||
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
set_callsetup_status(HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS);
|
||||||
} else if (hfp_gsm_callheld_status() == HFP_CALLHELD_STATUS_CALL_ON_HOLD_OR_SWAPPED) {
|
} else if (hfp_gsm_callheld_status() == HFP_CALLHELD_STATUS_CALL_ON_HOLD_OR_SWAPPED) {
|
||||||
gsm_calls[held_call_index].status = CALL_ACTIVE;
|
set_enhanced_call_status_active(held_call_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
||||||
if (gsm_calls[i].status == CALL_ACTIVE){
|
if (is_enhanced_call_status_active(i)){
|
||||||
gsm_calls[i].mpty = HFP_ENHANCED_CALL_MPTY_CONFERENCE_CALL;
|
gsm_calls[i].mpty = HFP_ENHANCED_CALL_MPTY_CONFERENCE_CALL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -393,22 +451,22 @@ static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t ty
|
|||||||
case HFP_AG_INCOMING_CALL_ACCEPTED_BY_HF:
|
case HFP_AG_INCOMING_CALL_ACCEPTED_BY_HF:
|
||||||
if (hfp_gsm_callsetup_status() != HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS) break;
|
if (hfp_gsm_callsetup_status() != HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS) break;
|
||||||
if (hfp_gsm_call_status() != HFP_CALL_STATUS_NO_HELD_OR_ACTIVE_CALLS) break;
|
if (hfp_gsm_call_status() != HFP_CALL_STATUS_NO_HELD_OR_ACTIVE_CALLS) break;
|
||||||
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
set_callsetup_status(HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS);
|
||||||
gsm_calls[initiated_call_index].status = CALL_ACTIVE;
|
set_enhanced_call_status_active(initiated_call_index);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HFP_AG_RESPONSE_AND_HOLD_ACCEPT_INCOMING_CALL_BY_AG:
|
case HFP_AG_RESPONSE_AND_HOLD_ACCEPT_INCOMING_CALL_BY_AG:
|
||||||
case HFP_AG_RESPONSE_AND_HOLD_ACCEPT_INCOMING_CALL_BY_HF:
|
case HFP_AG_RESPONSE_AND_HOLD_ACCEPT_INCOMING_CALL_BY_HF:
|
||||||
if (hfp_gsm_callsetup_status() != HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS) break;
|
if (hfp_gsm_callsetup_status() != HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS) break;
|
||||||
if (hfp_gsm_call_status() != HFP_CALL_STATUS_NO_HELD_OR_ACTIVE_CALLS) break;
|
if (hfp_gsm_call_status() != HFP_CALL_STATUS_NO_HELD_OR_ACTIVE_CALLS) break;
|
||||||
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
set_callsetup_status(HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS);
|
||||||
gsm_calls[initiated_call_index].status = CALL_RESPONSE_HOLD;
|
set_enhanced_call_status_response_hold(initiated_call_index);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HFP_AG_RESPONSE_AND_HOLD_ACCEPT_HELD_CALL_BY_AG:
|
case HFP_AG_RESPONSE_AND_HOLD_ACCEPT_HELD_CALL_BY_AG:
|
||||||
case HFP_AG_RESPONSE_AND_HOLD_ACCEPT_HELD_CALL_BY_HF:
|
case HFP_AG_RESPONSE_AND_HOLD_ACCEPT_HELD_CALL_BY_HF:
|
||||||
if (!hfp_gsm_response_held_active()) break;
|
if (!hfp_gsm_response_held_active()) break;
|
||||||
gsm_calls[get_response_held_call_index()].status = CALL_ACTIVE;
|
set_enhanced_call_status_active(get_response_held_call_index());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HFP_AG_RESPONSE_AND_HOLD_REJECT_HELD_CALL_BY_AG:
|
case HFP_AG_RESPONSE_AND_HOLD_REJECT_HELD_CALL_BY_AG:
|
||||||
@ -421,7 +479,7 @@ static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t ty
|
|||||||
case HFP_AG_TERMINATE_CALL_BY_HF:
|
case HFP_AG_TERMINATE_CALL_BY_HF:
|
||||||
switch (hfp_gsm_call_status()){
|
switch (hfp_gsm_call_status()){
|
||||||
case HFP_CALL_STATUS_NO_HELD_OR_ACTIVE_CALLS:
|
case HFP_CALL_STATUS_NO_HELD_OR_ACTIVE_CALLS:
|
||||||
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
set_callsetup_status(HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS);
|
||||||
break;
|
break;
|
||||||
case HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT:
|
case HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT:
|
||||||
delete_call(current_call_index);
|
delete_call(current_call_index);
|
||||||
@ -433,10 +491,10 @@ static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t ty
|
|||||||
switch (hfp_gsm_call_status()){
|
switch (hfp_gsm_call_status()){
|
||||||
case HFP_CALL_STATUS_NO_HELD_OR_ACTIVE_CALLS:
|
case HFP_CALL_STATUS_NO_HELD_OR_ACTIVE_CALLS:
|
||||||
if (hfp_gsm_callsetup_status() != HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS) break;
|
if (hfp_gsm_callsetup_status() != HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS) break;
|
||||||
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
set_callsetup_status(HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS);
|
||||||
break;
|
break;
|
||||||
case HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT:
|
case HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT:
|
||||||
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
set_callsetup_status(HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS);
|
||||||
delete_call(current_call_index);
|
delete_call(current_call_index);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -445,7 +503,7 @@ static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t ty
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HFP_AG_CALL_DROPPED:
|
case HFP_AG_CALL_DROPPED:
|
||||||
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
set_callsetup_status(HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS);
|
||||||
if (hfp_gsm_call_status() != HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT) break;
|
if (hfp_gsm_call_status() != HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT) break;
|
||||||
|
|
||||||
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
||||||
@ -455,9 +513,9 @@ static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t ty
|
|||||||
|
|
||||||
case HFP_AG_CALL_HOLD_USER_BUSY:
|
case HFP_AG_CALL_HOLD_USER_BUSY:
|
||||||
// Held or waiting call gets active,
|
// Held or waiting call gets active,
|
||||||
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
set_callsetup_status(HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS);
|
||||||
gsm_calls[initiated_call_index].status = CALL_NONE;
|
free_call_slot(initiated_call_index);
|
||||||
gsm_calls[held_call_index].status = CALL_ACTIVE;
|
set_enhanced_call_status_active(held_call_index);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HFP_AG_CALL_HOLD_RELEASE_ACTIVE_ACCEPT_HELD_OR_WAITING_CALL:
|
case HFP_AG_CALL_HOLD_RELEASE_ACTIVE_ACCEPT_HELD_OR_WAITING_CALL:
|
||||||
@ -470,41 +528,41 @@ static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t ty
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
||||||
if (gsm_calls[i].status == CALL_ACTIVE){
|
if (is_enhanced_call_status_active(i)){
|
||||||
delete_call(i);
|
delete_call(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (callsetup_status != HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS){
|
if (callsetup_status != HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS){
|
||||||
gsm_calls[initiated_call_index].status = CALL_ACTIVE;
|
set_enhanced_call_status_active(initiated_call_index);
|
||||||
} else {
|
} else {
|
||||||
gsm_calls[held_call_index].status = CALL_ACTIVE;
|
set_enhanced_call_status_active(held_call_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
set_callsetup_status(HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HFP_AG_CALL_HOLD_PARK_ACTIVE_ACCEPT_HELD_OR_WAITING_CALL:
|
case HFP_AG_CALL_HOLD_PARK_ACTIVE_ACCEPT_HELD_OR_WAITING_CALL:
|
||||||
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
||||||
if (gsm_calls[i].status == CALL_ACTIVE && gsm_calls[i].index != index){
|
if (is_enhanced_call_status_active(i) && gsm_calls[i].index != index){
|
||||||
gsm_calls[i].status = CALL_HELD;
|
set_enhanced_call_status_held(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (callsetup_status != HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS){
|
if (callsetup_status != HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS){
|
||||||
gsm_calls[initiated_call_index].status = CALL_ACTIVE;
|
set_enhanced_call_status_active(initiated_call_index);
|
||||||
} else {
|
} else {
|
||||||
gsm_calls[held_call_index].status = CALL_ACTIVE;
|
set_enhanced_call_status_active(held_call_index);
|
||||||
}
|
}
|
||||||
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
set_callsetup_status(HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HFP_AG_CALL_HOLD_ADD_HELD_CALL:
|
case HFP_AG_CALL_HOLD_ADD_HELD_CALL:
|
||||||
if (hfp_gsm_callheld_status() != HFP_CALLHELD_STATUS_NO_CALLS_HELD){
|
if (hfp_gsm_callheld_status() != HFP_CALLHELD_STATUS_NO_CALLS_HELD){
|
||||||
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
||||||
if (gsm_calls[i].status != CALL_NONE){
|
if (gsm_calls[i].used_slot){
|
||||||
gsm_calls[i].status = CALL_ACTIVE;
|
set_enhanced_call_status_active(i);
|
||||||
gsm_calls[i].mpty = HFP_ENHANCED_CALL_MPTY_CONFERENCE_CALL;
|
gsm_calls[i].mpty = HFP_ENHANCED_CALL_MPTY_CONFERENCE_CALL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,20 +54,10 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* API_START */
|
/* API_START */
|
||||||
|
|
||||||
typedef enum{
|
|
||||||
CALL_NONE,
|
|
||||||
CALL_INITIATED,
|
|
||||||
CALL_RESPONSE_HOLD,
|
|
||||||
CALL_ACTIVE,
|
|
||||||
CALL_HELD
|
|
||||||
} hfp_gsm_call_status_t;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// TODO: use enhanced_status instead of status
|
uint8_t used_slot;
|
||||||
hfp_gsm_call_status_t status;
|
|
||||||
hfp_enhanced_call_dir_t direction;
|
|
||||||
hfp_enhanced_call_status_t enhanced_status;
|
hfp_enhanced_call_status_t enhanced_status;
|
||||||
|
hfp_enhanced_call_dir_t direction;
|
||||||
hfp_enhanced_call_mode_t mode;
|
hfp_enhanced_call_mode_t mode;
|
||||||
hfp_enhanced_call_mpty_t mpty;
|
hfp_enhanced_call_mpty_t mpty;
|
||||||
// TODO: sort on drop call, so that index corresponds to table index
|
// TODO: sort on drop call, so that index corresponds to table index
|
||||||
|
Loading…
x
Reference in New Issue
Block a user