avrcp_controller.c (45a58b3093f5320b8ffda59b52081d2b540d3217) | avrcp_controller.c (1c7ac872de4b58a718b614d8a2a5abc2c1310a57) |
---|---|
1/* 2 * Copyright (C) 2016 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 --- 315 unchanged lines hidden (view full) --- 324 } else { 325 event[pos++] = 0; 326 } 327 break; 328 default: 329 break; 330 } 331 event[data_len_pos] = pos - 2; | 1/* 2 * Copyright (C) 2016 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 --- 315 unchanged lines hidden (view full) --- 324 } else { 325 event[pos++] = 0; 326 } 327 break; 328 default: 329 break; 330 } 331 event[data_len_pos] = pos - 2; |
332 // printf("send attr len %d, value %s\n", value_len, value); | 332 // printf("Send attribute 0x%02x, len %u\n", attr_id, value_len); 333 // printf_hexdump(value, value_len); |
333 (*callback)(HCI_EVENT_PACKET, 0, event, pos); 334} 335 336static void avrcp_parser_process_byte(uint8_t byte, avrcp_connection_t * connection, avrcp_command_type_t ctype){ 337 uint16_t attribute_total_value_len; 338 uint32_t attribute_id; | 334 (*callback)(HCI_EVENT_PACKET, 0, event, pos); 335} 336 337static void avrcp_parser_process_byte(uint8_t byte, avrcp_connection_t * connection, avrcp_command_type_t ctype){ 338 uint16_t attribute_total_value_len; 339 uint32_t attribute_id; |
340 // printf("avrcp_parser_process_byte: %02x, state %02x\n", byte, connection->parser_state); |
|
339 switch(connection->parser_state){ 340 case AVRCP_PARSER_GET_ATTRIBUTE_HEADER: 341 connection->parser_attribute_header[connection->parser_attribute_header_pos++] = byte; 342 connection->list_offset++; 343 344 if (connection->parser_attribute_header_pos < AVRCP_ATTRIBUTE_HEADER_LEN) return; 345 346 attribute_total_value_len = big_endian_read_16(connection->parser_attribute_header, 6); --- 45 unchanged lines hidden (view full) --- 392 return; 393 } 394 395 // attribute fully read, check if more to come 396 if (connection->list_offset < connection->list_size){ 397 // more to come, reset parser 398 connection->parser_state = AVRCP_PARSER_GET_ATTRIBUTE_HEADER; 399 connection->parser_attribute_header_pos = 0; | 341 switch(connection->parser_state){ 342 case AVRCP_PARSER_GET_ATTRIBUTE_HEADER: 343 connection->parser_attribute_header[connection->parser_attribute_header_pos++] = byte; 344 connection->list_offset++; 345 346 if (connection->parser_attribute_header_pos < AVRCP_ATTRIBUTE_HEADER_LEN) return; 347 348 attribute_total_value_len = big_endian_read_16(connection->parser_attribute_header, 6); --- 45 unchanged lines hidden (view full) --- 394 return; 395 } 396 397 // attribute fully read, check if more to come 398 if (connection->list_offset < connection->list_size){ 399 // more to come, reset parser 400 connection->parser_state = AVRCP_PARSER_GET_ATTRIBUTE_HEADER; 401 connection->parser_attribute_header_pos = 0; |
402 connection->attribute_value_offset = 0; |
|
400 } else { 401 // fully done 402 avrcp_parser_reset(connection); 403 avrcp_controller_emit_now_playing_info_event_done(avrcp_controller_context.avrcp_callback, connection->avrcp_cid, ctype, 0); 404 } 405} 406 407static void avrcp_source_parse_and_emit_element_attrs(uint8_t * packet, uint16_t num_bytes_to_read, avrcp_connection_t * connection, avrcp_command_type_t ctype){ --- 1016 unchanged lines hidden --- | 403 } else { 404 // fully done 405 avrcp_parser_reset(connection); 406 avrcp_controller_emit_now_playing_info_event_done(avrcp_controller_context.avrcp_callback, connection->avrcp_cid, ctype, 0); 407 } 408} 409 410static void avrcp_source_parse_and_emit_element_attrs(uint8_t * packet, uint16_t num_bytes_to_read, avrcp_connection_t * connection, avrcp_command_type_t ctype){ --- 1016 unchanged lines hidden --- |