diff --git a/src/classic/avrcp_controller.c b/src/classic/avrcp_controller.c index f0cfc0c79..a0636b42d 100644 --- a/src/classic/avrcp_controller.c +++ b/src/classic/avrcp_controller.c @@ -49,6 +49,15 @@ // made public in avrcp_controller.h avrcp_context_t avrcp_controller_context; +static uint16_t transaction_id_counter = 0; + +static uint8_t avrcp_controller_get_next_transaction_label(void){ + transaction_id_counter++; + if (transaction_id_counter == 16){ + transaction_id_counter = 1; + } + return transaction_id_counter; +} static uint16_t avrcp_get_max_payload_size_for_packet_type(avrcp_packet_type_t packet_type){ switch (packet_type){ @@ -474,7 +483,7 @@ static int avrcp_send_register_notification(avrcp_connection_t * connection, uin uint8_t command[18]; uint16_t pos = 0; // transport header : transaction label | Packet_type | C/R | IPID (1 == invalid profile identifier) - connection->transaction_label++; + connection->transaction_label = avrcp_controller_get_next_transaction_label(); command[pos++] = (connection->transaction_label << 4) | (AVRCP_SINGLE_PACKET << 2) | (AVRCP_COMMAND_FRAME << 1) | 0; command[pos++] = BLUETOOTH_SERVICE_CLASS_AV_REMOTE_CONTROL >> 8; @@ -524,7 +533,7 @@ static uint8_t avrcp_controller_request_pass_through_release_control_cmd(avrcp_c avrcp_press_and_hold_timer_stop(connection); } connection->cmd_operands[0] = 0x80 | connection->cmd_operands[0]; - connection->transaction_label++; + connection->transaction_label = avrcp_controller_get_next_transaction_label(); avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid); return ERROR_CODE_SUCCESS; } @@ -561,7 +570,7 @@ static inline uint8_t avrcp_controller_request_pass_through_press_control_cmd(ui avrcp_press_and_hold_timer_start(connection); } - connection->transaction_label++; + connection->transaction_label = avrcp_controller_get_next_transaction_label(); avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid); return ERROR_CODE_SUCCESS; } @@ -585,7 +594,7 @@ static int avrcp_controller_register_notification(avrcp_connection_t * connectio static uint8_t avrcp_controller_request_abort_continuation(avrcp_connection_t * connection){ connection->state = AVCTP_W2_SEND_COMMAND; - connection->transaction_label++; + connection->transaction_label = avrcp_controller_get_next_transaction_label(); connection->command_opcode = AVRCP_CMD_OPCODE_VENDOR_DEPENDENT; connection->command_type = AVRCP_CTYPE_CONTROL; connection->subunit_type = AVRCP_SUBUNIT_TYPE_PANEL; @@ -607,7 +616,7 @@ static uint8_t avrcp_controller_request_abort_continuation(avrcp_connection_t * static uint8_t avrcp_controller_request_continue_response(avrcp_connection_t * connection){ connection->state = AVCTP_W2_SEND_COMMAND; - connection->transaction_label++; + connection->transaction_label = avrcp_controller_get_next_transaction_label(); connection->command_opcode = AVRCP_CMD_OPCODE_VENDOR_DEPENDENT; connection->command_type = AVRCP_CTYPE_CONTROL; connection->subunit_type = AVRCP_SUBUNIT_TYPE_PANEL; @@ -1153,7 +1162,7 @@ uint8_t avrcp_controller_unit_info(uint16_t avrcp_cid){ if (connection->state != AVCTP_CONNECTION_OPENED) return ERROR_CODE_COMMAND_DISALLOWED; connection->state = AVCTP_W2_SEND_COMMAND; - connection->transaction_label++; + connection->transaction_label = avrcp_controller_get_next_transaction_label(); connection->command_opcode = AVRCP_CMD_OPCODE_UNIT_INFO; connection->command_type = AVRCP_CTYPE_STATUS; connection->subunit_type = AVRCP_SUBUNIT_TYPE_UNIT; //vendor unique @@ -1173,7 +1182,7 @@ uint8_t avrcp_controller_subunit_info(uint16_t avrcp_cid){ if (connection->state != AVCTP_CONNECTION_OPENED) return ERROR_CODE_COMMAND_DISALLOWED; connection->state = AVCTP_W2_SEND_COMMAND; - connection->transaction_label++; + connection->transaction_label = avrcp_controller_get_next_transaction_label(); connection->command_opcode = AVRCP_CMD_OPCODE_SUBUNIT_INFO; connection->command_type = AVRCP_CTYPE_STATUS; connection->subunit_type = AVRCP_SUBUNIT_TYPE_UNIT; //vendor unique @@ -1194,7 +1203,7 @@ static uint8_t avrcp_controller_get_capabilities(uint16_t avrcp_cid, uint8_t cap if (connection->state != AVCTP_CONNECTION_OPENED) return ERROR_CODE_COMMAND_DISALLOWED; connection->state = AVCTP_W2_SEND_COMMAND; - connection->transaction_label++; + connection->transaction_label = avrcp_controller_get_next_transaction_label(); connection->command_opcode = AVRCP_CMD_OPCODE_VENDOR_DEPENDENT; connection->command_type = AVRCP_CTYPE_STATUS; connection->subunit_type = AVRCP_SUBUNIT_TYPE_PANEL; @@ -1225,7 +1234,7 @@ uint8_t avrcp_controller_get_play_status(uint16_t avrcp_cid){ } if (connection->state != AVCTP_CONNECTION_OPENED) return ERROR_CODE_COMMAND_DISALLOWED; connection->state = AVCTP_W2_SEND_COMMAND; - connection->transaction_label++; + connection->transaction_label = avrcp_controller_get_next_transaction_label(); connection->command_opcode = AVRCP_CMD_OPCODE_VENDOR_DEPENDENT; connection->command_type = AVRCP_CTYPE_STATUS; connection->subunit_type = AVRCP_SUBUNIT_TYPE_PANEL; @@ -1248,7 +1257,7 @@ uint8_t avrcp_controller_set_addressed_player(uint16_t avrcp_cid, uint16_t addre if (connection->state != AVCTP_CONNECTION_OPENED) return ERROR_CODE_COMMAND_DISALLOWED; connection->state = AVCTP_W2_SEND_COMMAND; - connection->transaction_label++; + connection->transaction_label = avrcp_controller_get_next_transaction_label(); connection->command_opcode = AVRCP_CMD_OPCODE_VENDOR_DEPENDENT; connection->command_type = AVRCP_CTYPE_CONTROL; connection->subunit_type = AVRCP_SUBUNIT_TYPE_PANEL; @@ -1280,7 +1289,7 @@ uint8_t avrcp_controller_get_now_playing_info(uint16_t avrcp_cid){ if (connection->state != AVCTP_CONNECTION_OPENED) return ERROR_CODE_COMMAND_DISALLOWED; connection->state = AVCTP_W2_SEND_COMMAND; - connection->transaction_label++; + connection->transaction_label = avrcp_controller_get_next_transaction_label(); connection->command_opcode = AVRCP_CMD_OPCODE_VENDOR_DEPENDENT; connection->command_type = AVRCP_CTYPE_STATUS; connection->subunit_type = AVRCP_SUBUNIT_TYPE_PANEL; @@ -1316,7 +1325,7 @@ uint8_t avrcp_controller_set_absolute_volume(uint16_t avrcp_cid, uint8_t volume) if (connection->state != AVCTP_CONNECTION_OPENED) return ERROR_CODE_COMMAND_DISALLOWED; connection->state = AVCTP_W2_SEND_COMMAND; - connection->transaction_label++; + connection->transaction_label = avrcp_controller_get_next_transaction_label(); connection->command_opcode = AVRCP_CMD_OPCODE_VENDOR_DEPENDENT; connection->command_type = AVRCP_CTYPE_CONTROL; connection->subunit_type = AVRCP_SUBUNIT_TYPE_PANEL; @@ -1346,7 +1355,7 @@ uint8_t avrcp_controller_query_shuffle_and_repeat_modes(uint16_t avrcp_cid){ if (connection->state != AVCTP_CONNECTION_OPENED) return ERROR_CODE_COMMAND_DISALLOWED; connection->state = AVCTP_W2_SEND_COMMAND; - connection->transaction_label++; + connection->transaction_label = avrcp_controller_get_next_transaction_label(); connection->command_opcode = AVRCP_CMD_OPCODE_VENDOR_DEPENDENT; connection->command_type = AVRCP_CTYPE_STATUS; connection->subunit_type = AVRCP_SUBUNIT_TYPE_PANEL; @@ -1375,7 +1384,7 @@ static uint8_t avrcp_controller_set_current_player_application_setting_value(uin if (connection->state != AVCTP_CONNECTION_OPENED) return ERROR_CODE_COMMAND_DISALLOWED; connection->state = AVCTP_W2_SEND_COMMAND; - connection->transaction_label++; + connection->transaction_label = avrcp_controller_get_next_transaction_label(); connection->command_opcode = AVRCP_CMD_OPCODE_VENDOR_DEPENDENT; connection->command_type = AVRCP_CTYPE_CONTROL; connection->subunit_type = AVRCP_SUBUNIT_TYPE_PANEL; @@ -1419,7 +1428,7 @@ uint8_t avrcp_controller_play_item_for_scope(uint16_t avrcp_cid, uint8_t * uid, } connection->state = AVCTP_W2_SEND_COMMAND; - connection->transaction_label++; + connection->transaction_label = avrcp_controller_get_next_transaction_label(); connection->command_type = AVRCP_CTYPE_CONTROL; connection->subunit_type = AVRCP_SUBUNIT_TYPE_PANEL; connection->subunit_id = AVRCP_SUBUNIT_ID; @@ -1459,7 +1468,7 @@ uint8_t avrcp_controller_add_item_from_scope_to_now_playing_list(uint16_t avrcp_ } connection->state = AVCTP_W2_SEND_COMMAND; - connection->transaction_label++; + connection->transaction_label = avrcp_controller_get_next_transaction_label(); connection->command_type = AVRCP_CTYPE_CONTROL; connection->subunit_type = AVRCP_SUBUNIT_TYPE_PANEL; connection->subunit_id = AVRCP_SUBUNIT_ID; @@ -1507,7 +1516,7 @@ uint8_t avrcp_controller_send_custom_command(uint16_t avrcp_cid, avrcp_command_t if (connection->state != AVCTP_CONNECTION_OPENED) return ERROR_CODE_COMMAND_DISALLOWED; connection->state = AVCTP_W2_SEND_FRAGMENTED_COMMAND; - connection->transaction_label++; + connection->transaction_label = avrcp_controller_get_next_transaction_label(); connection->command_opcode = command_opcode; connection->command_type = command_type; connection->subunit_type = subunit_type;