hfp: reworking parser

This commit is contained in:
Milanka Ringwald 2015-07-19 14:40:00 +02:00
parent 529cedead0
commit e99686bd56
2 changed files with 30 additions and 2 deletions

View File

@ -98,6 +98,7 @@ extern "C" {
#define HFP_MAX_NUM_CODECS 20
#define HFP_MAX_NUM_INDICATORS 20
#define HFP_MAX_INDICATOR_DESC_SIZE 200 // TODO: change to 10
#define HFP_SUPPORTED_FEATURES "+BRSF"
#define HFP_AVAILABLE_CODECS "+BAC"
@ -185,8 +186,9 @@ typedef struct hfp_connection {
linked_item_t item;
hfp_state_t state;
uint32_t line_size;
uint8_t line_buffer[200];
int line_size;
uint8_t line_buffer[HFP_MAX_INDICATOR_DESC_SIZE];
uint8_t line_state;
bd_addr_t remote_addr;
uint16_t con_handle;

View File

@ -473,6 +473,32 @@ static void hfp_parse(hfp_connection_t * context, uint8_t byte){
context->line_size = 0;
}
static void hfp_parse2(hfp_connection_t * context, uint8_t byte){
if (byte == '\n' || byte == '\r') return;
switch (context->line_state){
case 0: // header
if (byte == ':') {
context->line_state = 1;
return;
}
context->line_buffer[context->line_size] = byte;
context->line_size++;
break;
case 1: // values
if (byte == '"'){ // indicators
context->line_state = 2;
return;
}
if (byte == '('){ // tuple sepparated mit comma
context->line_state = 5;
}
case 2:
break;
}
}
static void hfp_handle_rfcomm_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
hfp_connection_t * context = provide_hfp_connection_context_for_rfcomm_cid(channel);
if (!context) return;