avrcp.c (3cfa40866d2d917c8660d26e1d90614a881b42aa) avrcp.c (f0af2234e6fbab0b8742ba30f1ae8aa909a18e9b)
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

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

66
67static void avrcp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
68
69static const char * default_avrcp_controller_service_name = "BTstack AVRCP Controller Service";
70static const char * default_avrcp_controller_service_provider_name = "BTstack AVRCP Controller Service Provider";
71static const char * default_avrcp_target_service_name = "BTstack AVRCP Target Service";
72static const char * default_avrcp_target_service_provider_name = "BTstack AVRCP Target Service Provider";
73
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

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

66
67static void avrcp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
68
69static const char * default_avrcp_controller_service_name = "BTstack AVRCP Controller Service";
70static const char * default_avrcp_controller_service_provider_name = "BTstack AVRCP Controller Service Provider";
71static const char * default_avrcp_target_service_name = "BTstack AVRCP Target Service";
72static const char * default_avrcp_target_service_provider_name = "BTstack AVRCP Target Service Provider";
73
74// default subunit info: single PANEL subunit
75static const uint8_t avrcp_default_subunit_info[] = { AVRCP_SUBUNIT_TYPE_PANEL << 3};
76
74static uint16_t avrcp_cid_counter;
75
76static btstack_context_callback_registration_t avrcp_handle_sdp_client_query_request;
77
78static avrcp_sdp_query_context_t sdp_query_context;
79
80static btstack_packet_handler_t avrcp_callback;
81

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

410 avrcp_cid_counter = 1;
411 } else {
412 avrcp_cid_counter++;
413 }
414 } while (avrcp_get_connection_for_avrcp_cid_for_role(role, avrcp_cid_counter) != NULL) ;
415 return avrcp_cid_counter;
416}
417
77static uint16_t avrcp_cid_counter;
78
79static btstack_context_callback_registration_t avrcp_handle_sdp_client_query_request;
80
81static avrcp_sdp_query_context_t sdp_query_context;
82
83static btstack_packet_handler_t avrcp_callback;
84

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

413 avrcp_cid_counter = 1;
414 } else {
415 avrcp_cid_counter++;
416 }
417 } while (avrcp_get_connection_for_avrcp_cid_for_role(role, avrcp_cid_counter) != NULL) ;
418 return avrcp_cid_counter;
419}
420
418
419static avrcp_connection_t * avrcp_create_connection(avrcp_role_t role, bd_addr_t remote_addr){
420 avrcp_connection_t * connection = btstack_memory_avrcp_connection_get();
421 if (!connection){
422 log_error("Not enough memory to create connection for role %d", role);
423 return NULL;
424 }
425
426 connection->state = AVCTP_CONNECTION_IDLE;
427 connection->role = role;
428
429 connection->transaction_id = 0xFF;
430 connection->transaction_id_counter = 0;
431
432 connection->max_num_fragments = 0xFF;
421static avrcp_connection_t * avrcp_create_connection(avrcp_role_t role, bd_addr_t remote_addr){
422 avrcp_connection_t * connection = btstack_memory_avrcp_connection_get();
423 if (!connection){
424 log_error("Not enough memory to create connection for role %d", role);
425 return NULL;
426 }
427
428 connection->state = AVCTP_CONNECTION_IDLE;
429 connection->role = role;
430
431 connection->transaction_id = 0xFF;
432 connection->transaction_id_counter = 0;
433
434 connection->max_num_fragments = 0xFF;
435
436 // setup default unit / subunit info
437 connection->company_id = 0xffffff;
438 connection->unit_type = AVRCP_SUBUNIT_TYPE_PANEL;
439 connection->subunit_info_data_size = sizeof(avrcp_default_subunit_info);
440 connection->subunit_info_data = avrcp_default_subunit_info;
441
433 log_info("avrcp_create_connection, role %d", role);
434 (void)memcpy(connection->remote_addr, remote_addr, 6);
435 btstack_linked_list_add(&connections, (btstack_linked_item_t *) connection);
436 return connection;
437}
438
439static void avrcp_finalize_connection(avrcp_connection_t * connection){
440 btstack_run_loop_remove_timer(&connection->retry_timer);

--- 600 unchanged lines hidden ---
442 log_info("avrcp_create_connection, role %d", role);
443 (void)memcpy(connection->remote_addr, remote_addr, 6);
444 btstack_linked_list_add(&connections, (btstack_linked_item_t *) connection);
445 return connection;
446}
447
448static void avrcp_finalize_connection(avrcp_connection_t * connection){
449 btstack_run_loop_remove_timer(&connection->retry_timer);

--- 600 unchanged lines hidden ---