mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-27 23:37:25 +00:00
Merge branch 'master' into ble-api-cleanup
This commit is contained in:
commit
9cae807ed4
@ -560,6 +560,7 @@ typedef struct hfp_connection {
|
|||||||
uint8_t next_subscriber_number_to_send;
|
uint8_t next_subscriber_number_to_send;
|
||||||
|
|
||||||
int send_status_of_current_calls;
|
int send_status_of_current_calls;
|
||||||
|
int next_call_index;
|
||||||
|
|
||||||
// HF only
|
// HF only
|
||||||
hfp_hf_query_operator_state_t hf_query_operator_state;
|
hfp_hf_query_operator_state_t hf_query_operator_state;
|
||||||
|
@ -1376,13 +1376,14 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * connect
|
|||||||
hfp_run_for_context(connection);
|
hfp_run_for_context(connection);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
hfp_gsm_handle_event(HFP_AG_OUTGOING_CALL_INITIATED);
|
hfp_gsm_handle_event_with_call_number(HFP_AG_OUTGOING_CALL_INITIATED, (const char *) &connection->line_buffer[3]);
|
||||||
|
|
||||||
connection->call_state = HFP_CALL_OUTGOING_INITIATED;
|
connection->call_state = HFP_CALL_OUTGOING_INITIATED;
|
||||||
|
|
||||||
hfp_emit_string_event(hfp_callback, HFP_SUBEVENT_PLACE_CALL_WITH_NUMBER, (const char *) &connection->line_buffer[3]);
|
hfp_emit_string_event(hfp_callback, HFP_SUBEVENT_PLACE_CALL_WITH_NUMBER, (const char *) &connection->line_buffer[3]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HFP_AG_OUTGOING_REDIAL_INITIATED:
|
case HFP_AG_OUTGOING_REDIAL_INITIATED:{
|
||||||
// directly reject call if number of free slots is exceeded
|
// directly reject call if number of free slots is exceeded
|
||||||
if (!hfp_gsm_call_possible()){
|
if (!hfp_gsm_call_possible()){
|
||||||
connection->send_error = 1;
|
connection->send_error = 1;
|
||||||
@ -1393,9 +1394,18 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * connect
|
|||||||
hfp_gsm_handle_event(HFP_AG_OUTGOING_REDIAL_INITIATED);
|
hfp_gsm_handle_event(HFP_AG_OUTGOING_REDIAL_INITIATED);
|
||||||
connection->call_state = HFP_CALL_OUTGOING_INITIATED;
|
connection->call_state = HFP_CALL_OUTGOING_INITIATED;
|
||||||
|
|
||||||
hfp_emit_event(hfp_callback, HFP_SUBEVENT_REDIAL_LAST_NUMBER, 0);
|
printf("\nRedial last number");
|
||||||
|
char * last_dialed_number = hfp_gsm_last_dialed_number();
|
||||||
|
|
||||||
|
if (strlen(last_dialed_number) > 0){
|
||||||
|
printf("\nLast number exists: accept call");
|
||||||
|
hfp_emit_string_event(hfp_callback, HFP_SUBEVENT_PLACE_CALL_WITH_NUMBER, last_dialed_number);
|
||||||
|
} else {
|
||||||
|
printf("\nLast number missing: reject call");
|
||||||
|
hfp_ag_outgoing_call_rejected();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case HFP_AG_OUTGOING_CALL_REJECTED:
|
case HFP_AG_OUTGOING_CALL_REJECTED:
|
||||||
connection = hfp_ag_connection_for_call_state(HFP_CALL_OUTGOING_INITIATED);
|
connection = hfp_ag_connection_for_call_state(HFP_CALL_OUTGOING_INITIATED);
|
||||||
if (!connection){
|
if (!connection){
|
||||||
@ -1440,7 +1450,6 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * connect
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case HFP_AG_OUTGOING_CALL_RINGING:
|
case HFP_AG_OUTGOING_CALL_RINGING:
|
||||||
// hfp_gsm_handle_event();
|
|
||||||
connection = hfp_ag_connection_for_call_state(HFP_CALL_OUTGOING_DIALING);
|
connection = hfp_ag_connection_for_call_state(HFP_CALL_OUTGOING_DIALING);
|
||||||
if (!connection){
|
if (!connection){
|
||||||
log_info("hfp_ag_call_sm: did not find outgoing connection in dialing state");
|
log_info("hfp_ag_call_sm: did not find outgoing connection in dialing state");
|
||||||
@ -1562,12 +1571,45 @@ static void hfp_ag_call_sm(hfp_ag_call_event_t event, hfp_connection_t * connect
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void hfp_ag_send_call_status(hfp_connection_t * connection, int call_index){
|
||||||
|
hfp_gsm_call_t * active_call = hfp_gsm_call(call_index);
|
||||||
|
if (!active_call) return;
|
||||||
|
|
||||||
|
int idx = active_call->index;
|
||||||
|
hfp_enhanced_call_dir_t dir = active_call->direction;
|
||||||
|
hfp_enhanced_call_status_t status = active_call->enhanced_status;
|
||||||
|
hfp_enhanced_call_mode_t mode = active_call->mode;
|
||||||
|
hfp_enhanced_call_mpty_t mpty = active_call->mpty;
|
||||||
|
uint8_t type = active_call->clip_type;
|
||||||
|
char * number = active_call->clip_number;
|
||||||
|
|
||||||
|
char buffer[100];
|
||||||
|
// TODO: check length of a buffer, to fit the MTU
|
||||||
|
int offset = snprintf(buffer, sizeof(buffer), "\r\n%s: %d,%d,%d,%d,%d", HFP_LIST_CURRENT_CALLS, idx, dir, status, mode, mpty);
|
||||||
|
if (number){
|
||||||
|
offset += snprintf(buffer+offset, sizeof(buffer)-offset, ", \"%s\",%u", number, type);
|
||||||
|
}
|
||||||
|
snprintf(buffer+offset, sizeof(buffer)-offset, "\r\n");
|
||||||
|
printf("hfp_ag_send_current_call_status 000 index %d, dir %d, status %d, mode %d, mpty %d, type %d, number %s\n", idx, dir, status,
|
||||||
|
mode, mpty, type, number);
|
||||||
|
send_str_over_rfcomm(connection->rfcomm_cid, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
static void hfp_run_for_context(hfp_connection_t *context){
|
static void hfp_run_for_context(hfp_connection_t *context){
|
||||||
if (!context) return;
|
if (!context) return;
|
||||||
if (!rfcomm_can_send_packet_now(context->rfcomm_cid)) return;
|
if (!rfcomm_can_send_packet_now(context->rfcomm_cid)) return;
|
||||||
|
|
||||||
if (context->send_status_of_current_calls){
|
if (context->send_status_of_current_calls){
|
||||||
hfp_emit_event(hfp_callback, HFP_SUBEVENT_TRANSMIT_STATUS_OF_CURRENT_CALL, 0);
|
context->ok_pending = 0;
|
||||||
|
if (context->next_call_index < hfp_gsm_get_number_of_calls()){
|
||||||
|
context->next_call_index++;
|
||||||
|
hfp_ag_send_call_status(context, context->next_call_index);
|
||||||
|
} else {
|
||||||
|
context->next_call_index = 0;
|
||||||
|
context->ok_pending = 1;
|
||||||
|
context->send_status_of_current_calls = 0;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1788,8 +1830,8 @@ static void hfp_handle_rfcomm_data(uint8_t packet_type, uint16_t channel, uint8_
|
|||||||
break;
|
break;
|
||||||
case HFP_CMD_LIST_CURRENT_CALLS:
|
case HFP_CMD_LIST_CURRENT_CALLS:
|
||||||
context->command = HFP_CMD_NONE;
|
context->command = HFP_CMD_NONE;
|
||||||
|
context->next_call_index = 0;
|
||||||
context->send_status_of_current_calls = 1;
|
context->send_status_of_current_calls = 1;
|
||||||
hfp_emit_event(hfp_callback, HFP_SUBEVENT_TRANSMIT_STATUS_OF_CURRENT_CALL, 0);
|
|
||||||
break;
|
break;
|
||||||
case HFP_CMD_GET_SUBSCRIBER_NUMBER_INFORMATION:
|
case HFP_CMD_GET_SUBSCRIBER_NUMBER_INFORMATION:
|
||||||
if (subscriber_numbers_count == 0){
|
if (subscriber_numbers_count == 0){
|
||||||
@ -2227,26 +2269,8 @@ void hfp_ag_set_subcriber_number_information(hfp_phone_number_t * numbers, int n
|
|||||||
subscriber_numbers_count = numbers_count;
|
subscriber_numbers_count = numbers_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hfp_ag_send_current_call_status(bd_addr_t bd_addr, int idx, hfp_enhanced_call_dir_t dir,
|
void hfp_ag_clear_last_dialed_number(void){
|
||||||
hfp_enhanced_call_status_t status, hfp_enhanced_call_mode_t mode,
|
hfp_gsm_clear_last_dialed_number();
|
||||||
hfp_enhanced_call_mpty_t mpty, uint8_t type, const char * number){
|
|
||||||
|
|
||||||
hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr);
|
|
||||||
|
|
||||||
char buffer[100];
|
|
||||||
// TODO: check length of a buffer, to fit the MTU
|
|
||||||
int offset = snprintf(buffer, sizeof(buffer), "\r\n%s: %d,%d,%d,%d,%d", HFP_LIST_CURRENT_CALLS, idx, dir, status, mode, mpty);
|
|
||||||
if (number){
|
|
||||||
offset += snprintf(buffer+offset, sizeof(buffer)-offset, ", \"%s\",%u", number, type);
|
|
||||||
}
|
|
||||||
snprintf(buffer+offset, sizeof(buffer)-offset, "\r\n");
|
|
||||||
send_str_over_rfcomm(connection->rfcomm_cid, buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void hfp_ag_send_current_call_status_done(bd_addr_t bd_addr){
|
|
||||||
hfp_connection_t * connection = get_hfp_connection_context_for_bd_addr(bd_addr);
|
|
||||||
connection->ok_pending = 1;
|
|
||||||
connection->send_status_of_current_calls = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -284,14 +284,8 @@ void hfp_ag_set_subcriber_number_information(hfp_phone_number_t * numbers, int n
|
|||||||
/*
|
/*
|
||||||
* @brief
|
* @brief
|
||||||
*/
|
*/
|
||||||
void hfp_ag_send_current_call_status(bd_addr_t bd_addr, int idx, hfp_enhanced_call_dir_t dir,
|
|
||||||
hfp_enhanced_call_status_t status, hfp_enhanced_call_mode_t mode,
|
|
||||||
hfp_enhanced_call_mpty_t mpty, uint8_t type, const char * number);
|
|
||||||
|
|
||||||
/*
|
void hfp_ag_send_current_call_status(bd_addr_t bd_addr, int idx);
|
||||||
* @brief
|
|
||||||
*/
|
|
||||||
void hfp_ag_send_current_call_status_done(bd_addr_t bd_addr);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief
|
* @brief
|
||||||
@ -308,6 +302,11 @@ void hfp_ag_accept_held_incoming_call(void);
|
|||||||
*/
|
*/
|
||||||
void hfp_ag_reject_held_incoming_call(void);
|
void hfp_ag_reject_held_incoming_call(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief
|
||||||
|
*/
|
||||||
|
void hfp_ag_clear_last_dialed_number(void);
|
||||||
|
|
||||||
/* API_END */
|
/* API_END */
|
||||||
|
|
||||||
#if defined __cplusplus
|
#if defined __cplusplus
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
// *****************************************************************************
|
// *****************************************************************************
|
||||||
//
|
//
|
||||||
// Minimal setup for HFP Audio Gateway (AG) unit (!! UNDER DEVELOPMENT !!)
|
// GSM Model
|
||||||
//
|
//
|
||||||
// *****************************************************************************
|
// *****************************************************************************
|
||||||
|
|
||||||
@ -61,28 +61,14 @@
|
|||||||
#include "btstack_run_loop.h"
|
#include "btstack_run_loop.h"
|
||||||
|
|
||||||
#define HFP_GSM_MAX_NR_CALLS 3
|
#define HFP_GSM_MAX_NR_CALLS 3
|
||||||
|
#define HFP_GSM_MAX_CALL_NUMBER_SIZE 25
|
||||||
typedef enum{
|
|
||||||
CALL_NONE,
|
|
||||||
CALL_INITIATED,
|
|
||||||
CALL_RESPONSE_HOLD,
|
|
||||||
CALL_ACTIVE,
|
|
||||||
CALL_HELD
|
|
||||||
} hfp_gsm_call_status_t;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
hfp_gsm_call_status_t status;
|
|
||||||
int index;
|
|
||||||
uint8_t clip_type;
|
|
||||||
char clip_number[25];
|
|
||||||
} hfp_gsm_call_t;
|
|
||||||
|
|
||||||
static hfp_gsm_call_t gsm_calls[HFP_GSM_MAX_NR_CALLS];
|
static hfp_gsm_call_t gsm_calls[HFP_GSM_MAX_NR_CALLS];
|
||||||
static hfp_callsetup_status_t callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
static hfp_callsetup_status_t callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
||||||
|
|
||||||
static uint8_t clip_type;
|
static uint8_t clip_type;
|
||||||
static char clip_number[25];
|
static char clip_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);
|
||||||
|
|
||||||
@ -90,7 +76,7 @@ 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;
|
||||||
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(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++){
|
||||||
@ -114,52 +100,59 @@ static int get_call_index_with_status(hfp_gsm_call_status_t status){
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_next_free_slot(){
|
static inline int get_next_free_slot(void){
|
||||||
return get_call_index_with_status(CALL_NONE);
|
return get_call_index_with_status(CALL_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_active_call_index(){
|
static inline int get_active_call_index(void){
|
||||||
return get_call_index_with_status(CALL_ACTIVE);
|
return get_call_index_with_status(CALL_ACTIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_initiated_call_index(){
|
static inline int get_initiated_call_index(void){
|
||||||
return get_call_index_with_status(CALL_INITIATED);
|
return get_call_index_with_status(CALL_INITIATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_held_call_index(){
|
static inline int get_held_call_index(void){
|
||||||
return get_call_index_with_status(CALL_HELD);
|
return get_call_index_with_status(CALL_HELD);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_response_held_call_index(){
|
static inline int get_response_held_call_index(void){
|
||||||
return get_call_index_with_status(CALL_RESPONSE_HOLD);
|
return get_call_index_with_status(CALL_RESPONSE_HOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_number_none_calls(){
|
static inline int get_number_none_calls(void){
|
||||||
return get_number_calls_with_status(CALL_NONE);
|
return get_number_calls_with_status(CALL_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_number_active_calls(){
|
static inline int get_number_active_calls(void){
|
||||||
return get_number_calls_with_status(CALL_ACTIVE);
|
return get_number_calls_with_status(CALL_ACTIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_number_held_calls(){
|
static inline int get_number_held_calls(void){
|
||||||
return get_number_calls_with_status(CALL_HELD);
|
return get_number_calls_with_status(CALL_HELD);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_number_response_held_calls(){
|
static inline int get_number_response_held_calls(void){
|
||||||
return get_number_calls_with_status(CALL_RESPONSE_HOLD);
|
return get_number_calls_with_status(CALL_RESPONSE_HOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int next_call_index(){
|
static int next_call_index(void){
|
||||||
return HFP_GSM_MAX_NR_CALLS + 1 - get_number_none_calls();
|
return HFP_GSM_MAX_NR_CALLS + 1 - get_number_none_calls();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hfp_gsm_set_clip(int index_in_table, uint8_t type, const char * number){
|
static void hfp_gsm_set_clip(int index_in_table, uint8_t type, const char * number){
|
||||||
|
if (strlen(number) == 0) return;
|
||||||
|
|
||||||
gsm_calls[index_in_table].clip_type = type;
|
gsm_calls[index_in_table].clip_type = type;
|
||||||
|
|
||||||
int clip_number_size = sizeof(gsm_calls[index_in_table].clip_number);
|
int clip_number_size = strlen(number) < HFP_GSM_MAX_CALL_NUMBER_SIZE ? strlen(number) : HFP_GSM_MAX_CALL_NUMBER_SIZE-1;
|
||||||
strncpy(gsm_calls[index_in_table].clip_number, number, clip_number_size);
|
strncpy(gsm_calls[index_in_table].clip_number, number, clip_number_size);
|
||||||
gsm_calls[index_in_table].clip_number[clip_number_size-1] = '\0';
|
gsm_calls[index_in_table].clip_number[clip_number_size] = '\0';
|
||||||
|
strncpy(last_dialed_number, number, clip_number_size);
|
||||||
|
last_dialed_number[clip_number_size] = '\0';
|
||||||
|
|
||||||
|
clip_type = 0;
|
||||||
|
memset(clip_number, 0, sizeof(clip_number));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void delete_call(int delete_index_in_table){
|
static void delete_call(int delete_index_in_table){
|
||||||
@ -174,23 +167,67 @@ static void delete_call(int 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;
|
||||||
gsm_calls[delete_index_in_table].clip_number[0] = '\0';
|
gsm_calls[delete_index_in_table].clip_number[0] = '\0';
|
||||||
|
gsm_calls[delete_index_in_table].mpty = HFP_ENHANCED_CALL_MPTY_NOT_A_CONFERENCE_CALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void create_call(){
|
|
||||||
|
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].index = next_call_index();
|
gsm_calls[next_free_slot].index = next_call_index();
|
||||||
gsm_calls[next_free_slot].status = CALL_INITIATED;
|
gsm_calls[next_free_slot].status = CALL_INITIATED;
|
||||||
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;
|
||||||
if (clip_type != 0){
|
|
||||||
hfp_gsm_set_clip(next_free_slot, clip_type, clip_number);
|
hfp_gsm_set_clip(next_free_slot, clip_type, clip_number);
|
||||||
clip_type = 0;
|
|
||||||
memset(clip_number, 0, sizeof(clip_number));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t hfp_gsm_clip_type(){
|
|
||||||
|
int hfp_gsm_get_number_of_calls(void){
|
||||||
|
return HFP_GSM_MAX_NR_CALLS - get_number_none_calls();
|
||||||
|
}
|
||||||
|
|
||||||
|
void hfp_gsm_clear_last_dialed_number(void){
|
||||||
|
memset(last_dialed_number, 0, sizeof(last_dialed_number));
|
||||||
|
}
|
||||||
|
|
||||||
|
char * hfp_gsm_last_dialed_number(void){
|
||||||
|
return &last_dialed_number[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
hfp_gsm_call_t * hfp_gsm_call(int call_index){
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
||||||
|
hfp_gsm_call_t * call = &gsm_calls[i];
|
||||||
|
|
||||||
|
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 NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t hfp_gsm_clip_type(void){
|
||||||
if (clip_type != 0) return clip_type;
|
if (clip_type != 0) return clip_type;
|
||||||
|
|
||||||
int initiated_call_index = get_initiated_call_index();
|
int initiated_call_index = get_initiated_call_index();
|
||||||
@ -209,8 +246,8 @@ uint8_t hfp_gsm_clip_type(){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * hfp_gsm_clip_number(){
|
char * hfp_gsm_clip_number(void){
|
||||||
if (clip_type != 0) return clip_number;
|
if (strlen(clip_number) != 0) return clip_number;
|
||||||
|
|
||||||
int initiated_call_index = get_initiated_call_index();
|
int initiated_call_index = get_initiated_call_index();
|
||||||
if (initiated_call_index != -1){
|
if (initiated_call_index != -1){
|
||||||
@ -229,14 +266,14 @@ char * hfp_gsm_clip_number(){
|
|||||||
return clip_number;
|
return clip_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
hfp_call_status_t hfp_gsm_call_status(){
|
hfp_call_status_t hfp_gsm_call_status(void){
|
||||||
if (get_number_active_calls() + get_number_held_calls() + get_number_response_held_calls()){
|
if (get_number_active_calls() + get_number_held_calls() + get_number_response_held_calls()){
|
||||||
return HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT;
|
return HFP_CALL_STATUS_ACTIVE_OR_HELD_CALL_IS_PRESENT;
|
||||||
}
|
}
|
||||||
return HFP_CALL_STATUS_NO_HELD_OR_ACTIVE_CALLS;
|
return HFP_CALL_STATUS_NO_HELD_OR_ACTIVE_CALLS;
|
||||||
}
|
}
|
||||||
|
|
||||||
hfp_callheld_status_t hfp_gsm_callheld_status(){
|
hfp_callheld_status_t hfp_gsm_callheld_status(void){
|
||||||
// @note: order is important
|
// @note: order is important
|
||||||
if (get_number_held_calls() == 0){
|
if (get_number_held_calls() == 0){
|
||||||
return HFP_CALLHELD_STATUS_NO_CALLS_HELD;
|
return HFP_CALLHELD_STATUS_NO_CALLS_HELD;
|
||||||
@ -247,11 +284,11 @@ hfp_callheld_status_t hfp_gsm_callheld_status(){
|
|||||||
return HFP_CALLHELD_STATUS_CALL_ON_HOLD_OR_SWAPPED;
|
return HFP_CALLHELD_STATUS_CALL_ON_HOLD_OR_SWAPPED;
|
||||||
}
|
}
|
||||||
|
|
||||||
hfp_callsetup_status_t hfp_gsm_callsetup_status(){
|
hfp_callsetup_status_t hfp_gsm_callsetup_status(void){
|
||||||
return callsetup_status;
|
return callsetup_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hfp_gsm_response_held_active(){
|
static int hfp_gsm_response_held_active(void){
|
||||||
return get_response_held_call_index() != -1 ;
|
return get_response_held_call_index() != -1 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,6 +308,10 @@ void hfp_gsm_handle_event_with_call_index(hfp_ag_call_event_t event, uint8_t ind
|
|||||||
hfp_gsm_handler(event, index, 0, NULL);
|
hfp_gsm_handler(event, index, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hfp_gsm_handle_event_with_call_number(hfp_ag_call_event_t event, const char * number){
|
||||||
|
hfp_gsm_handler(event, 0, 0, number);
|
||||||
|
}
|
||||||
|
|
||||||
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){
|
||||||
int next_free_slot = get_next_free_slot();
|
int next_free_slot = get_next_free_slot();
|
||||||
int current_call_index = get_active_call_index();
|
int current_call_index = get_active_call_index();
|
||||||
@ -285,12 +326,11 @@ static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t ty
|
|||||||
log_error("gsm: max call nr exceeded");
|
log_error("gsm: max call nr exceeded");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
create_call();
|
create_call(HFP_ENHANCED_CALL_DIR_OUTGOING);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HFP_AG_OUTGOING_CALL_REJECTED:
|
case HFP_AG_OUTGOING_CALL_REJECTED:
|
||||||
if (current_call_index != -1){
|
if (current_call_index != -1){
|
||||||
// gsm_calls[current_call_index].status = CALL_NONE;
|
|
||||||
delete_call(current_call_index);
|
delete_call(current_call_index);
|
||||||
}
|
}
|
||||||
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
||||||
@ -300,7 +340,6 @@ 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){
|
||||||
gsm_calls[current_call_index].status = CALL_HELD;
|
gsm_calls[current_call_index].status = CALL_HELD;
|
||||||
}
|
}
|
||||||
create_call();
|
|
||||||
callsetup_status = HFP_CALLSETUP_STATUS_OUTGOING_CALL_SETUP_IN_DIALING_STATE;
|
callsetup_status = HFP_CALLSETUP_STATUS_OUTGOING_CALL_SETUP_IN_DIALING_STATE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -319,7 +358,7 @@ static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t ty
|
|||||||
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;
|
callsetup_status = HFP_CALLSETUP_STATUS_INCOMING_CALL_SETUP_IN_PROGRESS;
|
||||||
create_call();
|
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:
|
||||||
@ -335,18 +374,19 @@ static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t ty
|
|||||||
case HFP_AG_HELD_CALL_JOINED_BY_AG:
|
case HFP_AG_HELD_CALL_JOINED_BY_AG:
|
||||||
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;
|
||||||
|
|
||||||
// TODO: mark joined calls with "multiparty flag" (if we cannot calculate it otherwise)
|
|
||||||
// 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;
|
gsm_calls[initiated_call_index].status = CALL_ACTIVE;
|
||||||
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
||||||
break;
|
} else if (hfp_gsm_callheld_status() == HFP_CALLHELD_STATUS_CALL_ON_HOLD_OR_SWAPPED) {
|
||||||
}
|
|
||||||
|
|
||||||
if (hfp_gsm_callheld_status() == HFP_CALLHELD_STATUS_CALL_ON_HOLD_OR_SWAPPED) {
|
|
||||||
gsm_calls[held_call_index].status = CALL_ACTIVE;
|
gsm_calls[held_call_index].status = CALL_ACTIVE;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < HFP_GSM_MAX_NR_CALLS; i++){
|
||||||
|
if (gsm_calls[i].status == CALL_ACTIVE){
|
||||||
|
gsm_calls[i].mpty = HFP_ENHANCED_CALL_MPTY_CONFERENCE_CALL;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HFP_AG_INCOMING_CALL_ACCEPTED_BY_HF:
|
case HFP_AG_INCOMING_CALL_ACCEPTED_BY_HF:
|
||||||
@ -373,7 +413,6 @@ static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t ty
|
|||||||
case HFP_AG_RESPONSE_AND_HOLD_REJECT_HELD_CALL_BY_AG:
|
case HFP_AG_RESPONSE_AND_HOLD_REJECT_HELD_CALL_BY_AG:
|
||||||
case HFP_AG_RESPONSE_AND_HOLD_REJECT_HELD_CALL_BY_HF:
|
case HFP_AG_RESPONSE_AND_HOLD_REJECT_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_NONE;
|
|
||||||
delete_call(get_response_held_call_index());
|
delete_call(get_response_held_call_index());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -384,7 +423,6 @@ static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t ty
|
|||||||
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
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:
|
||||||
// gsm_calls[current_call_index].status = CALL_NONE;
|
|
||||||
delete_call(current_call_index);
|
delete_call(current_call_index);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -398,7 +436,6 @@ static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t ty
|
|||||||
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;
|
callsetup_status = HFP_CALLSETUP_STATUS_NO_CALL_SETUP_IN_PROGRESS;
|
||||||
// gsm_calls[current_call_index].status = CALL_NONE;
|
|
||||||
delete_call(current_call_index);
|
delete_call(current_call_index);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -450,8 +487,6 @@ static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t ty
|
|||||||
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 (gsm_calls[i].status == CALL_ACTIVE && gsm_calls[i].index != index){
|
||||||
gsm_calls[i].clip_type = 0;
|
|
||||||
gsm_calls[i].clip_number[0] = '\0';
|
|
||||||
gsm_calls[i].status = CALL_HELD;
|
gsm_calls[i].status = CALL_HELD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -467,14 +502,12 @@ static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t ty
|
|||||||
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_HELD){
|
if (gsm_calls[i].status != CALL_NONE){
|
||||||
gsm_calls[i].clip_type = 0;
|
|
||||||
gsm_calls[i].clip_number[0] = '\0';
|
|
||||||
gsm_calls[i].status = CALL_ACTIVE;
|
gsm_calls[i].status = CALL_ACTIVE;
|
||||||
|
gsm_calls[i].mpty = HFP_ENHANCED_CALL_MPTY_CONFERENCE_CALL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gsm_calls[initiated_call_index].status = CALL_ACTIVE;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HFP_AG_CALL_HOLD_EXIT_AND_JOIN_CALLS:
|
case HFP_AG_CALL_HOLD_EXIT_AND_JOIN_CALLS:
|
||||||
@ -488,10 +521,7 @@ static void hfp_gsm_handler(hfp_ag_call_event_t event, uint8_t index, uint8_t ty
|
|||||||
hfp_gsm_set_clip(initiated_call_index, type, number);
|
hfp_gsm_set_clip(initiated_call_index, type, number);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (current_call_index != -1){
|
|
||||||
hfp_gsm_set_clip(current_call_index, type, number);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
clip_type = type;
|
clip_type = type;
|
||||||
strncpy(clip_number, number, sizeof(clip_number));
|
strncpy(clip_number, number, sizeof(clip_number));
|
||||||
clip_number[sizeof(clip_number)-1] = '\0';
|
clip_number[sizeof(clip_number)-1] = '\0';
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
// *****************************************************************************
|
// *****************************************************************************
|
||||||
//
|
//
|
||||||
// GSM model (!! UNDER DEVELOPMENT !!)
|
// GSM model
|
||||||
//
|
//
|
||||||
// *****************************************************************************
|
// *****************************************************************************
|
||||||
|
|
||||||
@ -55,180 +55,50 @@ extern "C" {
|
|||||||
|
|
||||||
/* API_START */
|
/* API_START */
|
||||||
|
|
||||||
/**
|
typedef enum{
|
||||||
* @brief
|
CALL_NONE,
|
||||||
*/
|
CALL_INITIATED,
|
||||||
|
CALL_RESPONSE_HOLD,
|
||||||
|
CALL_ACTIVE,
|
||||||
|
CALL_HELD
|
||||||
|
} hfp_gsm_call_status_t;
|
||||||
|
|
||||||
hfp_callheld_status_t hfp_gsm_callheld_status();
|
typedef struct {
|
||||||
hfp_call_status_t hfp_gsm_call_status();
|
// TODO: use enhanced_status instead of status
|
||||||
hfp_callsetup_status_t hfp_gsm_callsetup_status();
|
hfp_gsm_call_status_t status;
|
||||||
|
hfp_enhanced_call_dir_t direction;
|
||||||
|
hfp_enhanced_call_status_t enhanced_status;
|
||||||
|
hfp_enhanced_call_mode_t mode;
|
||||||
|
hfp_enhanced_call_mpty_t mpty;
|
||||||
|
// TODO: sort on drop call, so that index corresponds to table index
|
||||||
|
int index;
|
||||||
|
uint8_t clip_type;
|
||||||
|
char clip_number[25];
|
||||||
|
} hfp_gsm_call_t;
|
||||||
|
|
||||||
|
hfp_callheld_status_t hfp_gsm_callheld_status(void);
|
||||||
|
hfp_call_status_t hfp_gsm_call_status(void);
|
||||||
|
hfp_callsetup_status_t hfp_gsm_callsetup_status(void);
|
||||||
|
|
||||||
|
int hfp_gsm_get_number_of_calls(void);
|
||||||
|
char * hfp_gsm_last_dialed_number(void);
|
||||||
|
void hfp_gsm_clear_last_dialed_number(void);
|
||||||
|
|
||||||
|
|
||||||
|
hfp_gsm_call_t * hfp_gsm_call(int index);
|
||||||
|
|
||||||
int hfp_gsm_call_possible(void);
|
int hfp_gsm_call_possible(void);
|
||||||
|
|
||||||
uint8_t hfp_gsm_clip_type();
|
uint8_t hfp_gsm_clip_type(void);
|
||||||
char * hfp_gsm_clip_number();
|
char * hfp_gsm_clip_number(void);
|
||||||
|
|
||||||
void hfp_gsm_init(void);
|
void hfp_gsm_init(void);
|
||||||
|
|
||||||
void hfp_gsm_handle_event_with_clip(hfp_ag_call_event_t event, uint8_t type, const char * number);
|
void hfp_gsm_handle_event_with_clip(hfp_ag_call_event_t event, uint8_t type, const char * number);
|
||||||
void hfp_gsm_handle_event_with_call_index(hfp_ag_call_event_t event, uint8_t index);
|
void hfp_gsm_handle_event_with_call_index(hfp_ag_call_event_t event, uint8_t index);
|
||||||
|
void hfp_gsm_handle_event_with_call_number(hfp_ag_call_event_t event, const char * number);
|
||||||
void hfp_gsm_handle_event(hfp_ag_call_event_t event);
|
void hfp_gsm_handle_event(hfp_ag_call_event_t event);
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @brief
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_incoming_call(void);
|
|
||||||
|
|
||||||
|
|
||||||
// /
|
|
||||||
// /**
|
|
||||||
// * @brief Report the change in AG's call status.
|
|
||||||
// * Call status:
|
|
||||||
// * - 0 = No calls (held or active)
|
|
||||||
// * - 1 = Call is present (active or held)
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_transfer_call_status(bd_addr_t bd_addr, hfp_call_status_t status);
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @brief Report the change in AG's call setup status.
|
|
||||||
// * Call setup status:
|
|
||||||
// * - 0 = No call setup in progress
|
|
||||||
// * - 1 = Incoming call setup in progress
|
|
||||||
// * - 2 = Outgoing call setup in dialing state
|
|
||||||
// * - 3 = Outgoing call setup in alerting state
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_transfer_callsetup_status(bd_addr_t bd_addr, hfp_callsetup_status_t status);
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @brief Report the change in AG's held call status.
|
|
||||||
// * Held call status:
|
|
||||||
// * - 0 = No calls held
|
|
||||||
// * - 1 = Call is placed on hold or active/held calls are swapped
|
|
||||||
// * - 2 = Call on hold, no active calls
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_transfer_callheld_status(bd_addr_t bd_addr, hfp_callheld_status_t status);
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @brief Enable in-band ring tone
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_set_use_in_band_ring_tone(int use_in_band_ring_tone);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @brief number is stored.
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_set_clip(uint8_t type, const char * number);
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @brief
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_outgoing_call_rejected(void);
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @brief
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_outgoing_call_accepted(void);
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @brief
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_outgoing_call_ringing(void);
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @brief
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_outgoing_call_established(void);
|
|
||||||
|
|
||||||
// *
|
|
||||||
// * @brief
|
|
||||||
|
|
||||||
// void hfp_gsm_call_dropped(void);
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @brief
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_answer_incoming_call(void);
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @brief
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_join_held_call(void);
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @brief
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_terminate_call(void);
|
|
||||||
|
|
||||||
// /*
|
|
||||||
// * @brief
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_set_registration_status(int status);
|
|
||||||
|
|
||||||
// /*
|
|
||||||
// * @brief
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_set_signal_strength(int strength);
|
|
||||||
|
|
||||||
// /*
|
|
||||||
// * @brief
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_set_roaming_status(int status);
|
|
||||||
|
|
||||||
|
|
||||||
// /*
|
|
||||||
// * @brief
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_activate_voice_recognition(bd_addr_t bd_addr, int activate);
|
|
||||||
|
|
||||||
|
|
||||||
// /*
|
|
||||||
// * @brief
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_send_phone_number_for_voice_tag(bd_addr_t bd_addr, const char * number);
|
|
||||||
|
|
||||||
// /*
|
|
||||||
// * @brief
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_reject_phone_number_for_voice_tag(bd_addr_t bd_addr);
|
|
||||||
|
|
||||||
// /*
|
|
||||||
// * @brief
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_send_dtmf_code_done(bd_addr_t bd_addr);
|
|
||||||
|
|
||||||
// /*
|
|
||||||
// * @brief
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_set_subcriber_number_information(hfp_phone_number_t * numbers, int numbers_count);
|
|
||||||
|
|
||||||
// /*
|
|
||||||
// * @brief
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_send_current_call_status(bd_addr_t bd_addr, int idx, hfp_enhanced_call_dir_t dir,
|
|
||||||
// hfp_enhanced_call_status_t status, hfp_enhanced_call_mode_t mode,
|
|
||||||
// hfp_enhanced_call_mpty_t mpty, uint8_t type, const char * number);
|
|
||||||
|
|
||||||
// /*
|
|
||||||
// * @brief
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_send_current_call_status_done(bd_addr_t bd_addr);
|
|
||||||
|
|
||||||
// /*
|
|
||||||
// * @brief
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_hold_incoming_call(void);
|
|
||||||
|
|
||||||
// /*
|
|
||||||
// * @brief
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_accept_held_incoming_call(void);
|
|
||||||
|
|
||||||
// /*
|
|
||||||
// * @brief
|
|
||||||
// */
|
|
||||||
// void hfp_gsm_reject_held_incoming_call(void);
|
|
||||||
|
|
||||||
/* API_END */
|
/* API_END */
|
||||||
|
|
||||||
#if defined __cplusplus
|
#if defined __cplusplus
|
||||||
|
@ -67,13 +67,6 @@
|
|||||||
#include "test_sequences.h"
|
#include "test_sequences.h"
|
||||||
|
|
||||||
static bd_addr_t pts_addr = {0x00,0x15,0x83,0x5F,0x9D,0x46};
|
static bd_addr_t pts_addr = {0x00,0x15,0x83,0x5F,0x9D,0x46};
|
||||||
static int current_call_index = 0;
|
|
||||||
static hfp_enhanced_call_dir_t current_call_dir;
|
|
||||||
static int current_call_exists_a = 0;
|
|
||||||
static int current_call_exists_b = 0;
|
|
||||||
static hfp_enhanced_call_status_t current_call_status_a;
|
|
||||||
static hfp_enhanced_call_status_t current_call_status_b;
|
|
||||||
static hfp_enhanced_call_mpty_t current_call_mpty = HFP_ENHANCED_CALL_MPTY_NOT_A_CONFERENCE_CALL;
|
|
||||||
|
|
||||||
const uint8_t rfcomm_channel_nr = 1;
|
const uint8_t rfcomm_channel_nr = 1;
|
||||||
|
|
||||||
@ -115,17 +108,8 @@ static hfp_generic_status_indicator_t hf_indicators[] = {
|
|||||||
{2, 1},
|
{2, 1},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static uint8_t service_level_connection_established = 0;
|
|
||||||
static uint8_t codecs_connection_established = 0;
|
|
||||||
static uint8_t audio_connection_established = 0;
|
|
||||||
static uint8_t start_ringing = 0;
|
|
||||||
static uint8_t stop_ringing = 0;
|
|
||||||
static uint8_t call_termiated = 0;
|
|
||||||
|
|
||||||
static uint16_t handle = -1;
|
static uint16_t handle = -1;
|
||||||
static int memory_1_enabled = 1;
|
static int memory_1_enabled = 1;
|
||||||
static int last_number_exists = 1;
|
|
||||||
|
|
||||||
int has_more_hfp_ag_commands(){
|
int has_more_hfp_ag_commands(){
|
||||||
return has_more_hfp_commands(2,2);
|
return has_more_hfp_commands(2,2);
|
||||||
@ -160,17 +144,11 @@ static void user_command(char cmd){
|
|||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
printf("Simulate incoming call from 1234567\n");
|
printf("Simulate incoming call from 1234567\n");
|
||||||
current_call_exists_a = 1;
|
|
||||||
current_call_status_a = HFP_ENHANCED_CALL_STATUS_INCOMING;
|
|
||||||
current_call_dir = HFP_ENHANCED_CALL_DIR_INCOMING;
|
|
||||||
hfp_ag_set_clip(129, "1234567");
|
hfp_ag_set_clip(129, "1234567");
|
||||||
hfp_ag_incoming_call();
|
hfp_ag_incoming_call();
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
printf("Simulate incoming call from 7654321\n");
|
printf("Simulate incoming call from 7654321\n");
|
||||||
current_call_exists_b = 1;
|
|
||||||
current_call_status_b = HFP_ENHANCED_CALL_STATUS_INCOMING;
|
|
||||||
current_call_dir = HFP_ENHANCED_CALL_DIR_INCOMING;
|
|
||||||
hfp_ag_set_clip(129, "7654321");
|
hfp_ag_set_clip(129, "7654321");
|
||||||
hfp_ag_incoming_call();
|
hfp_ag_incoming_call();
|
||||||
break;
|
break;
|
||||||
@ -184,13 +162,6 @@ static void user_command(char cmd){
|
|||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
printf("Answer call on AG\n");
|
printf("Answer call on AG\n");
|
||||||
if (current_call_status_a == HFP_ENHANCED_CALL_STATUS_INCOMING){
|
|
||||||
current_call_status_a = HFP_ENHANCED_CALL_STATUS_ACTIVE;
|
|
||||||
}
|
|
||||||
if (current_call_status_b == HFP_ENHANCED_CALL_STATUS_INCOMING){
|
|
||||||
current_call_status_b = HFP_ENHANCED_CALL_STATUS_ACTIVE;
|
|
||||||
current_call_status_a = HFP_ENHANCED_CALL_STATUS_HELD;
|
|
||||||
}
|
|
||||||
hfp_ag_answer_incoming_call();
|
hfp_ag_answer_incoming_call();
|
||||||
break;
|
break;
|
||||||
case 'E':
|
case 'E':
|
||||||
@ -247,11 +218,11 @@ static void user_command(char cmd){
|
|||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
printf("Last dialed number cleared\n");
|
printf("Last dialed number cleared\n");
|
||||||
last_number_exists = 0;
|
hfp_ag_clear_last_dialed_number();
|
||||||
break;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
printf("Last dialed number set\n");
|
printf("Outgoing call connected, ringing\n");
|
||||||
last_number_exists = 1;
|
hfp_ag_outgoing_call_ringing();
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
printf("Disable Voice Recognition\n");
|
printf("Disable Voice Recognition\n");
|
||||||
@ -303,7 +274,6 @@ static void user_command(char cmd){
|
|||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
printf("Join held call\n");
|
printf("Join held call\n");
|
||||||
current_call_mpty = HFP_ENHANCED_CALL_MPTY_CONFERENCE_CALL;
|
|
||||||
hfp_ag_join_held_call();
|
hfp_ag_join_held_call();
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
@ -425,25 +395,11 @@ void packet_handler(uint8_t * event, uint16_t event_size){
|
|||||||
|| (memory_1_enabled && strcmp(">1", (char*) &event[3]) == 0)){
|
|| (memory_1_enabled && strcmp(">1", (char*) &event[3]) == 0)){
|
||||||
printf("Dialstring valid: accept call\n");
|
printf("Dialstring valid: accept call\n");
|
||||||
hfp_ag_outgoing_call_accepted();
|
hfp_ag_outgoing_call_accepted();
|
||||||
// TODO: calling ringing right away leads to callstatus=2 being skipped. don't call for now
|
|
||||||
// hfp_ag_outgoing_call_ringing();
|
|
||||||
} else {
|
} else {
|
||||||
printf("Dialstring invalid: reject call\n");
|
printf("Dialstring invalid: reject call\n");
|
||||||
hfp_ag_outgoing_call_rejected();
|
hfp_ag_outgoing_call_rejected();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HFP_SUBEVENT_REDIAL_LAST_NUMBER:
|
|
||||||
printf("\n** Redial last number\n");
|
|
||||||
if (last_number_exists){
|
|
||||||
hfp_ag_outgoing_call_accepted();
|
|
||||||
printf("Last number exists: accept call\n");
|
|
||||||
// TODO: calling ringing right away leads to callstatus=2 being skipped. don't call for now
|
|
||||||
// hfp_ag_outgoing_call_ringing();
|
|
||||||
} else {
|
|
||||||
printf("Last number missing: reject call\n");
|
|
||||||
hfp_ag_outgoing_call_rejected();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case HFP_SUBEVENT_ATTACH_NUMBER_TO_VOICE_TAG:
|
case HFP_SUBEVENT_ATTACH_NUMBER_TO_VOICE_TAG:
|
||||||
printf("\n** Attach number to voice tag. Sending '1234567\n");
|
printf("\n** Attach number to voice tag. Sending '1234567\n");
|
||||||
hfp_ag_send_phone_number_for_voice_tag(device_addr, "1234567");
|
hfp_ag_send_phone_number_for_voice_tag(device_addr, "1234567");
|
||||||
@ -452,38 +408,6 @@ void packet_handler(uint8_t * event, uint16_t event_size){
|
|||||||
printf("\n** Send DTMF Codes: '%s'\n", &event[3]);
|
printf("\n** Send DTMF Codes: '%s'\n", &event[3]);
|
||||||
hfp_ag_send_dtmf_code_done(device_addr);
|
hfp_ag_send_dtmf_code_done(device_addr);
|
||||||
break;
|
break;
|
||||||
case HFP_SUBEVENT_TRANSMIT_STATUS_OF_CURRENT_CALL:
|
|
||||||
if (current_call_index == 0 && current_call_exists_a){
|
|
||||||
printf("HFP_SUBEVENT_TRANSMIT_STATUS_OF_CURRENT_CALL 1\n");
|
|
||||||
hfp_ag_send_current_call_status(device_addr, 1, current_call_dir, current_call_status_a,
|
|
||||||
HFP_ENHANCED_CALL_MODE_VOICE, current_call_mpty, 129, "1234567");
|
|
||||||
current_call_index = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (current_call_index == 1 && current_call_exists_b){
|
|
||||||
printf("HFP_SUBEVENT_TRANSMIT_STATUS_OF_CURRENT_CALL 2 \n");
|
|
||||||
hfp_ag_send_current_call_status(device_addr, 2, current_call_dir, current_call_status_b,
|
|
||||||
HFP_ENHANCED_CALL_MODE_VOICE, current_call_mpty, 129, "7654321");
|
|
||||||
current_call_index = 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
printf("HFP_SUBEVENT_TRANSMIT_STATUS_OF_CURRENT_CALL 3\n");
|
|
||||||
hfp_ag_send_current_call_status_done(device_addr);
|
|
||||||
break;
|
|
||||||
case HFP_CMD_CALL_ANSWERED:
|
|
||||||
printf("Call answered by HF\n");
|
|
||||||
if (current_call_status_a == HFP_ENHANCED_CALL_STATUS_INCOMING){
|
|
||||||
current_call_status_a = HFP_ENHANCED_CALL_STATUS_ACTIVE;
|
|
||||||
}
|
|
||||||
if (current_call_status_b == HFP_ENHANCED_CALL_STATUS_INCOMING){
|
|
||||||
current_call_status_b = HFP_ENHANCED_CALL_STATUS_ACTIVE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case HFP_SUBEVENT_CONFERENCE_CALL:
|
|
||||||
current_call_mpty = HFP_ENHANCED_CALL_MPTY_CONFERENCE_CALL;
|
|
||||||
current_call_status_a = HFP_ENHANCED_CALL_STATUS_ACTIVE;
|
|
||||||
current_call_status_b = HFP_ENHANCED_CALL_STATUS_ACTIVE;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
printf("Event not handled %u\n", event[2]);
|
printf("Event not handled %u\n", event[2]);
|
||||||
break;
|
break;
|
||||||
@ -494,13 +418,6 @@ void packet_handler(uint8_t * event, uint16_t event_size){
|
|||||||
|
|
||||||
TEST_GROUP(HFPClient){
|
TEST_GROUP(HFPClient){
|
||||||
void setup(void){
|
void setup(void){
|
||||||
service_level_connection_established = 0;
|
|
||||||
codecs_connection_established = 0;
|
|
||||||
audio_connection_established = 0;
|
|
||||||
start_ringing = 0;
|
|
||||||
stop_ringing = 0;
|
|
||||||
call_termiated = 0;
|
|
||||||
|
|
||||||
hfp_ag_init(rfcomm_channel_nr, supported_features_with_codec_negotiation,
|
hfp_ag_init(rfcomm_channel_nr, supported_features_with_codec_negotiation,
|
||||||
codecs, sizeof(codecs),
|
codecs, sizeof(codecs),
|
||||||
ag_indicators, ag_indicators_nr,
|
ag_indicators, ag_indicators_nr,
|
||||||
@ -511,17 +428,6 @@ TEST_GROUP(HFPClient){
|
|||||||
void teardown(void){
|
void teardown(void){
|
||||||
hfp_ag_release_audio_connection(device_addr);
|
hfp_ag_release_audio_connection(device_addr);
|
||||||
hfp_ag_release_service_level_connection(device_addr);
|
hfp_ag_release_service_level_connection(device_addr);
|
||||||
|
|
||||||
current_call_exists_a = 0;
|
|
||||||
current_call_exists_b = 0;
|
|
||||||
current_call_status_b = HFP_ENHANCED_CALL_STATUS_ACTIVE;
|
|
||||||
current_call_status_a = HFP_ENHANCED_CALL_STATUS_ACTIVE;
|
|
||||||
current_call_mpty = HFP_ENHANCED_CALL_MPTY_NOT_A_CONFERENCE_CALL;
|
|
||||||
current_call_index = 0;
|
|
||||||
|
|
||||||
service_level_connection_established = 0;
|
|
||||||
codecs_connection_established = 0;
|
|
||||||
audio_connection_established = 0;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ hsp_hs_test: ${CORE_OBJ} ${COMMON_OBJ} ${SDP_CLIENT} hsp_hs.o hsp_hs_test.c
|
|||||||
hfp_hf_test: ${CORE_OBJ} ${COMMON_OBJ} ${SDP_CLIENT} hfp.o hfp_hf.o hfp_hf_test.c
|
hfp_hf_test: ${CORE_OBJ} ${COMMON_OBJ} ${SDP_CLIENT} hfp.o hfp_hf.o hfp_hf_test.c
|
||||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||||
|
|
||||||
hfp_ag_test: ${CORE_OBJ} ${COMMON_OBJ} ${SDP_CLIENT} hfp.o hfp_ag_model.o hfp_ag.o hfp_ag_test.c
|
hfp_ag_test: ${CORE_OBJ} ${COMMON_OBJ} ${SDP_CLIENT} hfp.o hfp_gsm_model.o hfp_ag.o hfp_ag_test.c
|
||||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||||
|
|
||||||
l2cap_test: ${CORE_OBJ} ${COMMON_OBJ} l2cap_test.c
|
l2cap_test: ${CORE_OBJ} ${COMMON_OBJ} l2cap_test.c
|
||||||
|
@ -78,16 +78,6 @@ static bd_addr_t speaker_addr = {0x00, 0x21, 0x3C, 0xAC, 0xF7, 0x38};
|
|||||||
static uint8_t codecs[1] = {HFP_CODEC_CVSD};
|
static uint8_t codecs[1] = {HFP_CODEC_CVSD};
|
||||||
static uint16_t handle = -1;
|
static uint16_t handle = -1;
|
||||||
static int memory_1_enabled = 1;
|
static int memory_1_enabled = 1;
|
||||||
static int last_number_exists = 1;
|
|
||||||
|
|
||||||
static int current_call_index = 0;
|
|
||||||
static hfp_enhanced_call_dir_t current_call_dir;
|
|
||||||
static int current_call_exists_a = 0;
|
|
||||||
static int current_call_exists_b = 0;
|
|
||||||
static hfp_enhanced_call_status_t current_call_status_a;
|
|
||||||
static hfp_enhanced_call_status_t current_call_status_b;
|
|
||||||
static hfp_enhanced_call_mpty_t current_call_mpty = HFP_ENHANCED_CALL_MPTY_NOT_A_CONFERENCE_CALL;
|
|
||||||
|
|
||||||
|
|
||||||
static int ag_indicators_nr = 7;
|
static int ag_indicators_nr = 7;
|
||||||
static hfp_ag_indicator_t ag_indicators[] = {
|
static hfp_ag_indicator_t ag_indicators[] = {
|
||||||
@ -387,18 +377,12 @@ static int stdin_process(struct btstack_data_source *ds){
|
|||||||
case 'c':
|
case 'c':
|
||||||
log_info("USER:\'%c\'", cmd);
|
log_info("USER:\'%c\'", cmd);
|
||||||
printf("Simulate incoming call from 1234567\n");
|
printf("Simulate incoming call from 1234567\n");
|
||||||
current_call_exists_a = 1;
|
|
||||||
current_call_status_a = HFP_ENHANCED_CALL_STATUS_INCOMING;
|
|
||||||
current_call_dir = HFP_ENHANCED_CALL_DIR_INCOMING;
|
|
||||||
hfp_ag_set_clip(129, "1234567");
|
hfp_ag_set_clip(129, "1234567");
|
||||||
hfp_ag_incoming_call();
|
hfp_ag_incoming_call();
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
log_info("USER:\'%c\'", cmd);
|
log_info("USER:\'%c\'", cmd);
|
||||||
printf("Simulate incoming call from 7654321\n");
|
printf("Simulate incoming call from 7654321\n");
|
||||||
current_call_exists_b = 1;
|
|
||||||
current_call_status_b = HFP_ENHANCED_CALL_STATUS_INCOMING;
|
|
||||||
current_call_dir = HFP_ENHANCED_CALL_DIR_INCOMING;
|
|
||||||
hfp_ag_set_clip(129, "7654321");
|
hfp_ag_set_clip(129, "7654321");
|
||||||
hfp_ag_incoming_call();
|
hfp_ag_incoming_call();
|
||||||
break;
|
break;
|
||||||
@ -415,13 +399,6 @@ static int stdin_process(struct btstack_data_source *ds){
|
|||||||
case 'e':
|
case 'e':
|
||||||
log_info("USER:\'%c\'", cmd);
|
log_info("USER:\'%c\'", cmd);
|
||||||
printf("Answer call on AG\n");
|
printf("Answer call on AG\n");
|
||||||
if (current_call_status_a == HFP_ENHANCED_CALL_STATUS_INCOMING){
|
|
||||||
current_call_status_a = HFP_ENHANCED_CALL_STATUS_ACTIVE;
|
|
||||||
}
|
|
||||||
if (current_call_status_b == HFP_ENHANCED_CALL_STATUS_INCOMING){
|
|
||||||
current_call_status_b = HFP_ENHANCED_CALL_STATUS_ACTIVE;
|
|
||||||
current_call_status_a = HFP_ENHANCED_CALL_STATUS_HELD;
|
|
||||||
}
|
|
||||||
hfp_ag_answer_incoming_call();
|
hfp_ag_answer_incoming_call();
|
||||||
break;
|
break;
|
||||||
case 'E':
|
case 'E':
|
||||||
@ -492,12 +469,12 @@ static int stdin_process(struct btstack_data_source *ds){
|
|||||||
case 'l':
|
case 'l':
|
||||||
log_info("USER:\'%c\'", cmd);
|
log_info("USER:\'%c\'", cmd);
|
||||||
printf("Last dialed number cleared\n");
|
printf("Last dialed number cleared\n");
|
||||||
last_number_exists = 0;
|
hfp_ag_clear_last_dialed_number();
|
||||||
break;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
log_info("USER:\'%c\'", cmd);
|
log_info("USER:\'%c\'", cmd);
|
||||||
printf("Last dialed number set\n");
|
printf("Outgoing call connected, ringing\n");
|
||||||
last_number_exists = 1;
|
hfp_ag_outgoing_call_ringing();
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
log_info("USER:\'%c\'", cmd);
|
log_info("USER:\'%c\'", cmd);
|
||||||
@ -562,7 +539,6 @@ static int stdin_process(struct btstack_data_source *ds){
|
|||||||
case 'u':
|
case 'u':
|
||||||
log_info("USER:\'%c\'", cmd);
|
log_info("USER:\'%c\'", cmd);
|
||||||
printf("Join held call\n");
|
printf("Join held call\n");
|
||||||
current_call_mpty = HFP_ENHANCED_CALL_MPTY_CONFERENCE_CALL;
|
|
||||||
hfp_ag_join_held_call();
|
hfp_ag_join_held_call();
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
@ -656,25 +632,12 @@ static void packet_handler(uint8_t * event, uint16_t event_size){
|
|||||||
|| (memory_1_enabled && strcmp(">1", (char*) &event[3]) == 0)){
|
|| (memory_1_enabled && strcmp(">1", (char*) &event[3]) == 0)){
|
||||||
printf("Dialstring valid: accept call\n");
|
printf("Dialstring valid: accept call\n");
|
||||||
hfp_ag_outgoing_call_accepted();
|
hfp_ag_outgoing_call_accepted();
|
||||||
// TODO: calling ringing right away leads to callstatus=2 being skipped. don't call for now
|
|
||||||
// hfp_ag_outgoing_call_ringing();
|
|
||||||
} else {
|
} else {
|
||||||
printf("Dialstring invalid: reject call\n");
|
printf("Dialstring invalid: reject call\n");
|
||||||
hfp_ag_outgoing_call_rejected();
|
hfp_ag_outgoing_call_rejected();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HFP_SUBEVENT_REDIAL_LAST_NUMBER:
|
|
||||||
printf("\n** Redial last number\n");
|
|
||||||
if (last_number_exists){
|
|
||||||
hfp_ag_outgoing_call_accepted();
|
|
||||||
printf("Last number exists: accept call\n");
|
|
||||||
// TODO: calling ringing right away leads to callstatus=2 being skipped. don't call for now
|
|
||||||
// hfp_ag_outgoing_call_ringing();
|
|
||||||
} else {
|
|
||||||
printf("Last number missing: reject call\n");
|
|
||||||
hfp_ag_outgoing_call_rejected();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case HFP_SUBEVENT_ATTACH_NUMBER_TO_VOICE_TAG:
|
case HFP_SUBEVENT_ATTACH_NUMBER_TO_VOICE_TAG:
|
||||||
printf("\n** Attach number to voice tag. Sending '1234567\n");
|
printf("\n** Attach number to voice tag. Sending '1234567\n");
|
||||||
hfp_ag_send_phone_number_for_voice_tag(device_addr, "1234567");
|
hfp_ag_send_phone_number_for_voice_tag(device_addr, "1234567");
|
||||||
@ -683,34 +646,8 @@ static void packet_handler(uint8_t * event, uint16_t event_size){
|
|||||||
printf("\n** Send DTMF Codes: '%s'\n", &event[3]);
|
printf("\n** Send DTMF Codes: '%s'\n", &event[3]);
|
||||||
hfp_ag_send_dtmf_code_done(device_addr);
|
hfp_ag_send_dtmf_code_done(device_addr);
|
||||||
break;
|
break;
|
||||||
case HFP_SUBEVENT_TRANSMIT_STATUS_OF_CURRENT_CALL:
|
|
||||||
if (current_call_index == 0 && current_call_exists_a){
|
|
||||||
hfp_ag_send_current_call_status(device_addr, 1, current_call_dir, current_call_status_a,
|
|
||||||
HFP_ENHANCED_CALL_MODE_VOICE, current_call_mpty, 129, "1234567");
|
|
||||||
current_call_index = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (current_call_index == 1 && current_call_exists_b){
|
|
||||||
hfp_ag_send_current_call_status(device_addr, 2, current_call_dir, current_call_status_b,
|
|
||||||
HFP_ENHANCED_CALL_MODE_VOICE, current_call_mpty, 129, "7654321");
|
|
||||||
current_call_index = 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
hfp_ag_send_current_call_status_done(device_addr);
|
|
||||||
break;
|
|
||||||
case HFP_CMD_CALL_ANSWERED:
|
case HFP_CMD_CALL_ANSWERED:
|
||||||
printf("Call answered by HF\n");
|
printf("Call answered by HF\n");
|
||||||
if (current_call_status_a == HFP_ENHANCED_CALL_STATUS_INCOMING){
|
|
||||||
current_call_status_a = HFP_ENHANCED_CALL_STATUS_ACTIVE;
|
|
||||||
}
|
|
||||||
if (current_call_status_b == HFP_ENHANCED_CALL_STATUS_INCOMING){
|
|
||||||
current_call_status_b = HFP_ENHANCED_CALL_STATUS_ACTIVE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case HFP_SUBEVENT_CONFERENCE_CALL:
|
|
||||||
current_call_mpty = HFP_ENHANCED_CALL_MPTY_CONFERENCE_CALL;
|
|
||||||
current_call_status_a = HFP_ENHANCED_CALL_STATUS_ACTIVE;
|
|
||||||
current_call_status_b = HFP_ENHANCED_CALL_STATUS_ACTIVE;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("Event not handled %u\n", event[2]);
|
printf("Event not handled %u\n", event[2]);
|
||||||
|
@ -441,6 +441,49 @@ def parseCharacteristicAggregateFormat(fout, parts):
|
|||||||
fout.write("\n")
|
fout.write("\n")
|
||||||
handle = handle + 1
|
handle = handle + 1
|
||||||
|
|
||||||
|
def parseReportReference(fout, parts):
|
||||||
|
global handle
|
||||||
|
global total_size
|
||||||
|
|
||||||
|
property_read = property_flags['READ'];
|
||||||
|
size = 2 + 2 + 2 + 2 + 1 + 1
|
||||||
|
|
||||||
|
report_id = parts[1]
|
||||||
|
report_type = parts[2]
|
||||||
|
|
||||||
|
write_indent(fout)
|
||||||
|
fout.write('// 0x%04x REPORT_REFERENCE-%s\n' % (handle, '-'.join(parts[1:])))
|
||||||
|
write_indent(fout)
|
||||||
|
write_16(fout, size)
|
||||||
|
write_16(fout, property_read)
|
||||||
|
write_16(fout, handle)
|
||||||
|
write_16(fout, 0x2908)
|
||||||
|
write_sequence(fout, report_id)
|
||||||
|
write_sequence(fout, report_type)
|
||||||
|
fout.write("\n")
|
||||||
|
handle = handle + 1
|
||||||
|
|
||||||
|
|
||||||
|
def parseNumberOfDigitals(fout, parts):
|
||||||
|
global handle
|
||||||
|
global total_size
|
||||||
|
|
||||||
|
property_read = property_flags['READ'];
|
||||||
|
size = 2 + 2 + 2 + 2 + 1
|
||||||
|
|
||||||
|
no_of_digitals = parts[1]
|
||||||
|
|
||||||
|
write_indent(fout)
|
||||||
|
fout.write('// 0x%04x NUMBER_OF_DIGITALS-%s\n' % (handle, '-'.join(parts[1:])))
|
||||||
|
write_indent(fout)
|
||||||
|
write_16(fout, size)
|
||||||
|
write_16(fout, property_read)
|
||||||
|
write_16(fout, handle)
|
||||||
|
write_16(fout, 0x2909)
|
||||||
|
write_sequence(fout, no_of_digitals)
|
||||||
|
fout.write("\n")
|
||||||
|
handle = handle + 1
|
||||||
|
|
||||||
|
|
||||||
def parse(fname_in, fin, fname_out, fout):
|
def parse(fname_in, fin, fname_out, fout):
|
||||||
global handle
|
global handle
|
||||||
@ -478,26 +521,81 @@ def parse(fname_in, fin, fname_out, fout):
|
|||||||
parseIncludeService(fout, parts)
|
parseIncludeService(fout, parts)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# 2803
|
||||||
if parts[0] == 'CHARACTERISTIC':
|
if parts[0] == 'CHARACTERISTIC':
|
||||||
parseCharacteristic(fout, parts)
|
parseCharacteristic(fout, parts)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# 2900 Characteristic Extended Properties
|
||||||
|
|
||||||
|
# 2901
|
||||||
if parts[0] == 'CHARACTERISTIC_USER_DESCRIPTION':
|
if parts[0] == 'CHARACTERISTIC_USER_DESCRIPTION':
|
||||||
parseCharacteristicUserDescription(fout, parts)
|
parseCharacteristicUserDescription(fout, parts)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# 2902 Client Characteristic Configuration - included in Characteristic if
|
||||||
|
# notification / indication is supported
|
||||||
|
|
||||||
|
# 2903
|
||||||
if parts[0] == 'SERVER_CHARACTERISTIC_CONFIGURATION':
|
if parts[0] == 'SERVER_CHARACTERISTIC_CONFIGURATION':
|
||||||
parseServerCharacteristicConfiguration(fout, parts)
|
parseServerCharacteristicConfiguration(fout, parts)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# 2904
|
||||||
if parts[0] == 'CHARACTERISTIC_FORMAT':
|
if parts[0] == 'CHARACTERISTIC_FORMAT':
|
||||||
parseCharacteristicFormat(fout, parts)
|
parseCharacteristicFormat(fout, parts)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# 2905
|
||||||
if parts[0] == 'CHARACTERISTIC_AGGREGATE_FORMAT':
|
if parts[0] == 'CHARACTERISTIC_AGGREGATE_FORMAT':
|
||||||
parseCharacteristicAggregateFormat(fout, parts)
|
parseCharacteristicAggregateFormat(fout, parts)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# 2906
|
||||||
|
if parts[0] == 'VALID_RANGE':
|
||||||
|
print("WARNING: %s not implemented yet\n" % (parts[0]))
|
||||||
|
continue
|
||||||
|
|
||||||
|
# 2907
|
||||||
|
if parts[0] == 'EXTERNAL_REPORT_REFERENCE':
|
||||||
|
print("WARNING: %s not implemented yet\n" % (parts[0]))
|
||||||
|
continue
|
||||||
|
|
||||||
|
# 2908
|
||||||
|
if parts[0] == 'REPORT_REFERENCE':
|
||||||
|
parseReportReference(fout, parts)
|
||||||
|
continue
|
||||||
|
|
||||||
|
# 2909
|
||||||
|
if parts[0] == 'NUMBER_OF_DIGITALS':
|
||||||
|
parseNumberOfDigitals(fout, parts)
|
||||||
|
continue
|
||||||
|
|
||||||
|
# 290A
|
||||||
|
if parts[0] == 'VALUE_TRIGGER_SETTING':
|
||||||
|
print("WARNING: %s not implemented yet\n" % (parts[0]))
|
||||||
|
continue
|
||||||
|
|
||||||
|
# 290B
|
||||||
|
if parts[0] == 'ENVIRONMENTAL_SENSING_CONFIGURATION':
|
||||||
|
print("WARNING: %s not implemented yet\n" % (parts[0]))
|
||||||
|
continue
|
||||||
|
|
||||||
|
# 290C
|
||||||
|
if parts[0] == 'ENVIRONMENTAL_SENSING_MEASUREMENT':
|
||||||
|
print("WARNING: %s not implemented yet\n" % (parts[0]))
|
||||||
|
continue
|
||||||
|
|
||||||
|
# 290D
|
||||||
|
if parts[0] == 'ENVIRONMENTAL_SENSING_TRIGGER_SETTING':
|
||||||
|
print("WARNING: %s not implemented yet\n" % (parts[0]))
|
||||||
|
continue
|
||||||
|
|
||||||
|
# 2906
|
||||||
|
if parts[0] == 'VALID_RANGE':
|
||||||
|
print("WARNING: %s not implemented yet\n" % (parts[0]))
|
||||||
|
continue
|
||||||
|
|
||||||
print("WARNING: unknown token: %s\n" % (parts[0]))
|
print("WARNING: unknown token: %s\n" % (parts[0]))
|
||||||
|
|
||||||
write_indent(fout)
|
write_indent(fout)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user