hfp.c (04cf3dd4b6f53dc619b9a68bb8d7e778aa9b8a15) hfp.c (f79a7821e6386b0942eb61f54ca37cb1adb2212e)
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 1296 unchanged lines hidden (view full) ---

1305 case '\n':
1306 case '\r':
1307 return true;
1308 default:
1309 return false;
1310 }
1311}
1312
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 1296 unchanged lines hidden (view full) ---

1305 case '\n':
1306 case '\r':
1307 return true;
1308 default:
1309 return false;
1310 }
1311}
1312
1313// returns true if received bytes was processed. Otherwise, functions will be called with same byte again
1314// this is used to for a one byte lookahead, where an unexpected byte is pushed back by returning false
1313static bool hfp_parse_byte(hfp_connection_t * hfp_connection, uint8_t byte, int isHandsFree){
1314
1315static bool hfp_parse_byte(hfp_connection_t * hfp_connection, uint8_t byte, int isHandsFree){
1316
1317#ifdef HFP_DEBUG
1318 if (byte >= ' '){
1319 printf("Parse '%c' - state %u, buffer %s\n", byte, hfp_connection->parser_state, hfp_connection->line_buffer);
1320 } else {
1321 printf("Parse 0x%02x - state %u, buffer %s\n", byte, hfp_connection->parser_state, hfp_connection->line_buffer);
1322 }
1323#endif
1324
1315 // handle doubles quotes
1316 if (byte == '"'){
1317 hfp_connection->parser_quoted = !hfp_connection->parser_quoted;
1318 return true;
1319 }
1320 if (hfp_connection->parser_quoted) {
1321 hfp_parser_store_byte(hfp_connection, byte);
1322 return true;

--- 56 unchanged lines hidden (view full) ---

1379
1380 log_info("command string '%s', handsfree %u -> cmd id %u", (char *)hfp_connection->line_buffer, isHandsFree, hfp_connection->command);
1381
1382 // store command id for custom command and just store rest of line
1383 if (hfp_connection->command == HFP_CMD_CUSTOM_MESSAGE){
1384 const hfp_custom_at_command_t * at_command = hfp_custom_command_lookup(isHandsFree, (const char *) hfp_connection->line_buffer);
1385 hfp_connection->custom_at_command_id = at_command->command_id;
1386 hfp_connection->parser_state = HFP_PARSER_CUSTOM_COMMAND;
1325 // handle doubles quotes
1326 if (byte == '"'){
1327 hfp_connection->parser_quoted = !hfp_connection->parser_quoted;
1328 return true;
1329 }
1330 if (hfp_connection->parser_quoted) {
1331 hfp_parser_store_byte(hfp_connection, byte);
1332 return true;

--- 56 unchanged lines hidden (view full) ---

1389
1390 log_info("command string '%s', handsfree %u -> cmd id %u", (char *)hfp_connection->line_buffer, isHandsFree, hfp_connection->command);
1391
1392 // store command id for custom command and just store rest of line
1393 if (hfp_connection->command == HFP_CMD_CUSTOM_MESSAGE){
1394 const hfp_custom_at_command_t * at_command = hfp_custom_command_lookup(isHandsFree, (const char *) hfp_connection->line_buffer);
1395 hfp_connection->custom_at_command_id = at_command->command_id;
1396 hfp_connection->parser_state = HFP_PARSER_CUSTOM_COMMAND;
1387 return true;
1397 return processed;
1388 }
1389
1390 // next state
1391 hfp_parser_reset_line_buffer(hfp_connection);
1392 hfp_connection->parser_state = HFP_PARSER_CMD_SEQUENCE;
1393
1394 return processed;
1395

--- 844 unchanged lines hidden ---
1398 }
1399
1400 // next state
1401 hfp_parser_reset_line_buffer(hfp_connection);
1402 hfp_connection->parser_state = HFP_PARSER_CMD_SEQUENCE;
1403
1404 return processed;
1405

--- 844 unchanged lines hidden ---