mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-28 19:20:54 +00:00
hfp: add mandatory field to ag indicators
This commit is contained in:
parent
f959fc613b
commit
abe6e271cb
24
src/hfp.c
24
src/hfp.c
@ -94,22 +94,22 @@ static const char * hfp_ag_features[] = {
|
||||
};
|
||||
|
||||
static int hfp_generic_status_indicators_nr = 0;
|
||||
static hfp_generic_status_indicators_t hfp_generic_status_indicators[HFP_MAX_NUM_HF_INDICATORS];
|
||||
static hfp_generic_status_indicator_t hfp_generic_status_indicators[HFP_MAX_NUM_HF_INDICATORS];
|
||||
|
||||
static linked_list_t hfp_connections = NULL;
|
||||
|
||||
hfp_generic_status_indicators_t * get_hfp_generic_status_indicators(){
|
||||
return (hfp_generic_status_indicators_t *) &hfp_generic_status_indicators;
|
||||
hfp_generic_status_indicator_t * get_hfp_generic_status_indicators(){
|
||||
return (hfp_generic_status_indicator_t *) &hfp_generic_status_indicators;
|
||||
}
|
||||
|
||||
int get_hfp_generic_status_indicators_nr(){
|
||||
return hfp_generic_status_indicators_nr;
|
||||
}
|
||||
|
||||
void set_hfp_generic_status_indicators(hfp_generic_status_indicators_t * indicators, int indicator_nr){
|
||||
void set_hfp_generic_status_indicators(hfp_generic_status_indicator_t * indicators, int indicator_nr){
|
||||
if (indicator_nr > HFP_MAX_NUM_HF_INDICATORS) return;
|
||||
hfp_generic_status_indicators_nr = indicator_nr;
|
||||
memcpy(hfp_generic_status_indicators, indicators, indicator_nr * sizeof(hfp_generic_status_indicators_t));
|
||||
memcpy(hfp_generic_status_indicators, indicators, indicator_nr * sizeof(hfp_generic_status_indicator_t));
|
||||
}
|
||||
|
||||
const char * hfp_hf_feature(int index){
|
||||
@ -255,7 +255,7 @@ static hfp_connection_t * create_hfp_connection_context(){
|
||||
context->enable_status_update_for_ag_indicators = 0xFF;
|
||||
|
||||
context->generic_status_indicators_nr = hfp_generic_status_indicators_nr;
|
||||
memcpy(context->generic_status_indicators, hfp_generic_status_indicators, hfp_generic_status_indicators_nr * sizeof(hfp_generic_status_indicators_t));
|
||||
memcpy(context->generic_status_indicators, hfp_generic_status_indicators, hfp_generic_status_indicators_nr * sizeof(hfp_generic_status_indicator_t));
|
||||
|
||||
linked_list_add(&hfp_connections, (linked_item_t*)context);
|
||||
return context;
|
||||
@ -586,14 +586,16 @@ void hfp_parse(hfp_connection_t * context, uint8_t byte){
|
||||
case HFP_CMD_GENERIC_STATUS_INDICATOR_STATE:
|
||||
// HF parses inital AG gen. ind. state
|
||||
printf("Parsed List generic status indicator %s state: ", context->line_buffer);
|
||||
context->parser_state = HFP_PARSER_CMD_INITITAL_STATE_GENERIC_STATUS_INDICATORS;
|
||||
context->parser_state = HFP_PARSER_CMD_INITITAL_STATE_GENERIC_STATUS_INDICATOR;
|
||||
context->generic_status_indicator_state_index = (uint8_t)atoi((char*)context->line_buffer);
|
||||
break;
|
||||
case HFP_CMD_ENABLE_INDIVIDUAL_INDICATOR_STATUS_UPDATE:
|
||||
case HFP_CMD_ENABLE_INDIVIDUAL_AG_INDICATOR_STATUS_UPDATE:
|
||||
// AG parses new gen. ind. state
|
||||
printf("Parsed Enable generic status indicator state: %s\n", context->line_buffer);
|
||||
printf("Parsed Enable ag indicator state: %s\n", context->line_buffer);
|
||||
value = atoi((char *)&context->line_buffer[0]);
|
||||
context->generic_status_indicators[context->parser_item_index].state = value;
|
||||
if (!context->ag_indicators[context->parser_item_index].mandatory){
|
||||
context->ag_indicators[context->parser_item_index].enabled = value;
|
||||
}
|
||||
context->parser_item_index++;
|
||||
break;
|
||||
default:
|
||||
@ -611,7 +613,7 @@ void hfp_parse(hfp_connection_t * context, uint8_t byte){
|
||||
}
|
||||
context->line_buffer[context->line_size++] = byte;
|
||||
break;
|
||||
case HFP_PARSER_CMD_INITITAL_STATE_GENERIC_STATUS_INDICATORS:
|
||||
case HFP_PARSER_CMD_INITITAL_STATE_GENERIC_STATUS_INDICATOR:
|
||||
context->line_buffer[context->line_size] = 0;
|
||||
if (byte == ',') break;
|
||||
if (byte == '\n' || byte == '\r'){
|
||||
|
@ -125,7 +125,7 @@ typedef enum {
|
||||
HFP_CMD_INDICATOR,
|
||||
HFP_CMD_INDICATOR_STATUS, // 5
|
||||
HFP_CMD_ENABLE_INDICATOR_STATUS_UPDATE,
|
||||
HFP_CMD_ENABLE_INDIVIDUAL_INDICATOR_STATUS_UPDATE,
|
||||
HFP_CMD_ENABLE_INDIVIDUAL_AG_INDICATOR_STATUS_UPDATE,
|
||||
HFP_CMD_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES,
|
||||
HFP_CMD_LIST_GENERIC_STATUS_INDICATOR,
|
||||
HFP_CMD_GENERIC_STATUS_INDICATOR, // 10
|
||||
@ -138,7 +138,7 @@ typedef enum {
|
||||
HFP_PARSER_CMD_INDICATOR_NAME,
|
||||
HFP_PARSER_CMD_INDICATOR_MIN_RANGE,
|
||||
HFP_PARSER_CMD_INDICATOR_MAX_RANGE,
|
||||
HFP_PARSER_CMD_INITITAL_STATE_GENERIC_STATUS_INDICATORS
|
||||
HFP_PARSER_CMD_INITITAL_STATE_GENERIC_STATUS_INDICATOR
|
||||
} hfp_parser_state_t;
|
||||
|
||||
|
||||
@ -188,7 +188,7 @@ typedef void (*hfp_callback_t)(uint8_t * event, uint16_t event_size);
|
||||
typedef struct{
|
||||
uint16_t uuid;
|
||||
uint8_t state; // enabled
|
||||
} hfp_generic_status_indicators_t;
|
||||
} hfp_generic_status_indicator_t;
|
||||
|
||||
typedef struct{
|
||||
uint8_t index;
|
||||
@ -196,6 +196,7 @@ typedef struct{
|
||||
uint8_t min_range;
|
||||
uint8_t max_range;
|
||||
uint8_t status;
|
||||
uint8_t mandatory;
|
||||
uint8_t enabled;
|
||||
} hfp_ag_indicator_t;
|
||||
|
||||
@ -232,7 +233,7 @@ typedef struct hfp_connection {
|
||||
|
||||
// TODO: use bitmap.
|
||||
int generic_status_indicators_nr;
|
||||
hfp_generic_status_indicators_t generic_status_indicators[HFP_MAX_INDICATOR_DESC_SIZE];
|
||||
hfp_generic_status_indicator_t generic_status_indicators[HFP_MAX_INDICATOR_DESC_SIZE];
|
||||
uint8_t generic_status_indicator_state_index;
|
||||
uint8_t enable_status_update_for_ag_indicators;
|
||||
|
||||
|
31
src/hfp_ag.c
31
src/hfp_ag.c
@ -75,20 +75,18 @@ static hfp_callback_t hfp_callback;
|
||||
|
||||
static void packet_handler(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||
|
||||
hfp_generic_status_indicators_t * get_hfp_generic_status_indicators();
|
||||
hfp_generic_status_indicator_t * get_hfp_generic_status_indicators();
|
||||
int get_hfp_generic_status_indicators_nr();
|
||||
void set_hfp_generic_status_indicators(hfp_generic_status_indicators_t * indicators, int indicator_nr);
|
||||
void set_hfp_generic_status_indicators(hfp_generic_status_indicator_t * indicators, int indicator_nr);
|
||||
|
||||
static void set_ag_indicators(hfp_ag_indicator_t * indicators, int indicator_nr){
|
||||
int i;
|
||||
if (indicator_nr > HFP_MAX_NUM_AG_INDICATORS) return;
|
||||
for (i = 0; i<indicator_nr; i++){
|
||||
hfp_ag_indicators[i].status = indicators[i].status;
|
||||
hfp_ag_indicators[i].min_range = indicators[i].min_range;
|
||||
hfp_ag_indicators[i].max_range = indicators[i].max_range;
|
||||
strcpy(hfp_ag_indicators[i].name, indicators[i].name);
|
||||
|
||||
}
|
||||
hfp_ag_indicator_t * get_hfp_ag_indicators(){
|
||||
return (hfp_ag_indicator_t *)&hfp_ag_indicators;
|
||||
}
|
||||
int get_hfp_ag_indicators_nr(){
|
||||
return hfp_ag_indicators_nr;
|
||||
}
|
||||
void set_hfp_ag_indicators(hfp_ag_indicator_t * indicators, int indicator_nr){
|
||||
memcpy(hfp_ag_indicators, indicators, indicator_nr * sizeof(hfp_ag_indicator_t));
|
||||
hfp_ag_indicators_nr = indicator_nr;
|
||||
}
|
||||
|
||||
@ -310,7 +308,7 @@ void update_command(hfp_connection_t * context){
|
||||
}
|
||||
|
||||
if (strncmp((char *)context->line_buffer+2, HFP_UPDATE_ENABLE_STATUS_FOR_INDIVIDUAL_AG_INDICATORS, strlen(HFP_UPDATE_ENABLE_STATUS_FOR_INDIVIDUAL_AG_INDICATORS)) == 0){
|
||||
context->command = HFP_CMD_ENABLE_INDIVIDUAL_INDICATOR_STATUS_UPDATE;
|
||||
context->command = HFP_CMD_ENABLE_INDIVIDUAL_AG_INDICATOR_STATUS_UPDATE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -422,10 +420,7 @@ void hfp_run_for_context(hfp_connection_t *context){
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case HFP_CMD_ENABLE_INDIVIDUAL_INDICATOR_STATUS_UPDATE:
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case HFP_CMD_NONE:
|
||||
switch(context->state){
|
||||
case HFP_W2_DISCONNECT_RFCOMM:
|
||||
@ -489,7 +484,7 @@ static void packet_handler(void * connection, uint8_t packet_type, uint16_t chan
|
||||
void hfp_ag_init(uint16_t rfcomm_channel_nr, uint32_t supported_features,
|
||||
uint8_t * codecs, int codecs_nr,
|
||||
hfp_ag_indicator_t * ag_indicators, int ag_indicators_nr,
|
||||
hfp_generic_status_indicators_t * hf_indicators, int hf_indicators_nr,
|
||||
hfp_generic_status_indicator_t * hf_indicators, int hf_indicators_nr,
|
||||
char *call_hold_services[], int call_hold_services_nr){
|
||||
if (codecs_nr > HFP_MAX_NUM_CODECS){
|
||||
log_error("hfp_init: codecs_nr (%d) > HFP_MAX_NUM_CODECS (%d)", codecs_nr, HFP_MAX_NUM_CODECS);
|
||||
|
@ -67,7 +67,7 @@ void hfp_ag_create_sdp_record(uint8_t * service, int rfcomm_channel_nr, const ch
|
||||
void hfp_ag_init(uint16_t rfcomm_channel_nr, uint32_t supported_features,
|
||||
uint8_t * codecs, int codecs_nr,
|
||||
hfp_ag_indicator_t * ag_indicators, int ag_indicators_nr,
|
||||
hfp_generic_status_indicators_t * hf_indicators, int hf_indicators_nr,
|
||||
hfp_generic_status_indicator_t * hf_indicators, int hf_indicators_nr,
|
||||
char *call_hold_services[], int call_hold_services_nr);
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user