mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-26 21:35:16 +00:00
hfp: reworking parser
This commit is contained in:
parent
529cedead0
commit
e99686bd56
@ -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;
|
||||
|
26
src/hfp_hf.c
26
src/hfp_hf.c
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user