mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-05 09:40:00 +00:00
hfp gsm cleanup
This commit is contained in:
parent
79d3c2ada7
commit
915fbfcbc0
@ -381,9 +381,7 @@ typedef enum{
|
|||||||
HFP_ENHANCED_CALL_STATUS_OUTGOING_ALERTING,
|
HFP_ENHANCED_CALL_STATUS_OUTGOING_ALERTING,
|
||||||
HFP_ENHANCED_CALL_STATUS_INCOMING,
|
HFP_ENHANCED_CALL_STATUS_INCOMING,
|
||||||
HFP_ENHANCED_CALL_STATUS_INCOMING_WAITING,
|
HFP_ENHANCED_CALL_STATUS_INCOMING_WAITING,
|
||||||
HFP_ENHANCED_CALL_STATUS_CALL_HELD_BY_RESPONSE_AND_HOLD,
|
HFP_ENHANCED_CALL_STATUS_CALL_HELD_BY_RESPONSE_AND_HOLD
|
||||||
// used only internally
|
|
||||||
HFP_ENHANCED_CALL_STATUS_NONE
|
|
||||||
} hfp_enhanced_call_status_t;
|
} hfp_enhanced_call_status_t;
|
||||||
|
|
||||||
typedef enum{
|
typedef enum{
|
||||||
|
@ -75,12 +75,17 @@ static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t ty
|
|||||||
|
|
||||||
static void set_call_status(int index_in_table, hfp_gsm_call_status_t status){
|
static void set_call_status(int index_in_table, hfp_gsm_call_status_t status){
|
||||||
gsm_calls[index_in_table].status = status;
|
gsm_calls[index_in_table].status = status;
|
||||||
|
gsm_calls[index_in_table].used_slot = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_call_status(int index_in_table){
|
static int get_call_status(int index_in_table){
|
||||||
return gsm_calls[index_in_table].status;
|
return gsm_calls[index_in_table].status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void free_call_slot(int index_in_table){
|
||||||
|
gsm_calls[index_in_table].used_slot = 0;
|
||||||
|
gsm_calls[index_in_table].status = CALL_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
void hfp_gsm_init(void){
|
void hfp_gsm_init(void){
|
||||||
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
||||||
@ -90,26 +95,10 @@ void hfp_gsm_init(void){
|
|||||||
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++){
|
||||||
set_call_status(i, CALL_NONE);
|
free_call_slot(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_number_calls_with_enhanced_status(hfp_enhanced_call_status_t status){
|
|
||||||
int i, count = 0;
|
|
||||||
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
|
||||||
if (gsm_calls[i].enhanced_status == status) count++;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_call_index_with_enhanced_status(hfp_enhanced_call_status_t status){
|
|
||||||
int i ;
|
|
||||||
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
|
||||||
if (gsm_calls[i].enhanced_status == status) return i;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_number_calls_with_status(hfp_gsm_call_status_t status){
|
static int get_number_calls_with_status(hfp_gsm_call_status_t 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++){
|
||||||
@ -127,7 +116,11 @@ static int get_call_index_with_status(hfp_gsm_call_status_t status){
|
|||||||
}
|
}
|
||||||
|
|
||||||
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){
|
||||||
@ -147,7 +140,11 @@ static inline int get_response_held_call_index(void){
|
|||||||
}
|
}
|
||||||
|
|
||||||
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){
|
||||||
@ -188,7 +185,7 @@ static void delete_call(int delete_index_in_table){
|
|||||||
gsm_calls[i].index--;
|
gsm_calls[i].index--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set_call_status(delete_index_in_table, CALL_NONE);
|
free_call_slot(delete_index_in_table);
|
||||||
|
|
||||||
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;
|
||||||
@ -230,11 +227,14 @@ hfp_gsm_call_t * hfp_gsm_call(int call_index){
|
|||||||
|
|
||||||
if (call->index != call_index) continue;
|
if (call->index != call_index) continue;
|
||||||
|
|
||||||
if (call->status == CALL_ACTIVE){
|
switch (call->status){
|
||||||
|
case CALL_ACTIVE:
|
||||||
call->enhanced_status = HFP_ENHANCED_CALL_STATUS_ACTIVE;
|
call->enhanced_status = HFP_ENHANCED_CALL_STATUS_ACTIVE;
|
||||||
} else if (call->status == CALL_HELD) {
|
break;
|
||||||
|
case CALL_HELD:
|
||||||
call->enhanced_status = HFP_ENHANCED_CALL_STATUS_HELD;
|
call->enhanced_status = HFP_ENHANCED_CALL_STATUS_HELD;
|
||||||
} else if (call->status == CALL_INITIATED){
|
break;
|
||||||
|
case CALL_INITIATED:
|
||||||
if (call->direction == HFP_ENHANCED_CALL_DIR_OUTGOING){
|
if (call->direction == HFP_ENHANCED_CALL_DIR_OUTGOING){
|
||||||
if (callsetup_status == HFP_CALLSETUP_STATUS_OUTGOING_CALL_SETUP_IN_ALERTING_STATE){
|
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_ALERTING;
|
||||||
@ -246,8 +246,14 @@ hfp_gsm_call_t * hfp_gsm_call(int call_index){
|
|||||||
}
|
}
|
||||||
call->enhanced_status = HFP_ENHANCED_CALL_STATUS_INCOMING;
|
call->enhanced_status = HFP_ENHANCED_CALL_STATUS_INCOMING;
|
||||||
}
|
}
|
||||||
} else {
|
break;
|
||||||
|
case CALL_RESPONSE_HOLD:
|
||||||
call->enhanced_status = HFP_ENHANCED_CALL_STATUS_CALL_HELD_BY_RESPONSE_AND_HOLD;
|
call->enhanced_status = HFP_ENHANCED_CALL_STATUS_CALL_HELD_BY_RESPONSE_AND_HOLD;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
log_error("no call status");
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
return call;
|
return call;
|
||||||
}
|
}
|
||||||
@ -482,8 +488,8 @@ 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;
|
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
||||||
set_call_status(initiated_call_index, CALL_NONE);
|
// set_call_status(initiated_call_index, CALL_NONE);
|
||||||
|
free_call_slot(initiated_call_index);
|
||||||
set_call_status(held_call_index, CALL_ACTIVE);
|
set_call_status(held_call_index, CALL_ACTIVE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -65,7 +65,8 @@ typedef enum{
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// TODO: use enhanced_status instead of status
|
// TODO: use enhanced_status instead of status
|
||||||
//uint8_t used_slot;
|
uint8_t initiated;
|
||||||
|
uint8_t used_slot;
|
||||||
hfp_gsm_call_status_t status;
|
hfp_gsm_call_status_t status;
|
||||||
hfp_enhanced_call_dir_t direction;
|
hfp_enhanced_call_dir_t direction;
|
||||||
hfp_enhanced_call_status_t enhanced_status;
|
hfp_enhanced_call_status_t enhanced_status;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user