hfp: handle multiple commands/responses in single rfcomm data packet

This commit is contained in:
Matthias Ringwald 2018-11-30 11:23:01 +01:00
parent 0cef86faed
commit e0d09929fa
2 changed files with 14 additions and 0 deletions

View File

@ -1826,6 +1826,10 @@ static hfp_generic_status_indicator_t *get_hf_indicator_by_number(int number){
return NULL;
}
static int hfp_parser_is_end_of_line(uint8_t byte){
return byte == '\n' || byte == '\r';
}
static void hfp_ag_handle_rfcomm_data(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
UNUSED(packet_type); // ok: only called with RFCOMM_DATA_PACKET
@ -1842,6 +1846,9 @@ static void hfp_ag_handle_rfcomm_data(uint8_t packet_type, uint16_t channel, uin
for (pos = 0; pos < size ; pos++){
hfp_parse(hfp_connection, packet[pos], 0);
// parse until end of line
if (!hfp_parser_is_end_of_line(packet[pos])) continue;
int value;
hfp_generic_status_indicator_t * indicator;
switch(hfp_connection->command){

View File

@ -983,6 +983,10 @@ static void hfp_hf_switch_on_ok(hfp_connection_t *hfp_connection){
hfp_connection->command = HFP_CMD_NONE;
}
static int hfp_parser_is_end_of_line(uint8_t byte){
return byte == '\n' || byte == '\r';
}
static void hfp_hf_handle_rfcomm_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
UNUSED(packet_type); // ok: only called with RFCOMM_DATA_PACKET
@ -999,6 +1003,9 @@ static void hfp_hf_handle_rfcomm_event(uint8_t packet_type, uint16_t channel, ui
for (pos = 0; pos < size ; pos++){
hfp_parse(hfp_connection, packet[pos], 1);
// parse until end of line
if (!hfp_parser_is_end_of_line(packet[pos])) continue;
int value;
int i;
switch (hfp_connection->command){