/**************************************************************************** *NAME * avrcpHandleNextContinuationPacket * *DESCRIPTION * Prepare to send the next packet of fragmented data, that the CT * has requested. * *PARAMETERS * avrcp - AVRCP Entity * ind - Internal request for next Continuation packet. *****************************************************************************/ void avrcpHandleNextContinuationPacket(AVRCP *avrcp, const AVRCP_INTERNAL_NEXT_CONTINUATION_PACKET_T *ind) { /* The next fragment has been requested, so send it. */ uint16 data_length = avrcp->av_max_data_size; avrcp_packet_type packet_type = avrcp_packet_type_continue; if (ind->param_length < data_length) { /* This is the last fragment to be sent. */ data_length = ind->param_length; packet_type = avrcp_packet_type_end; avrcp->continuation_pdu = ind->pdu_id; } else { /* There are more fragments to be sent, store the data for the following fragments. */ avrcpStoreNextContinuationPacket(avrcp, ind->data, ind->param_length - data_length, ind->pdu_id, ind->response); } /* This is a fragmented response. */ avrcpSendMetadataResponse(avrcp, ind->response, ind->pdu_id, ind->data, packet_type, data_length, 0, 0); }
void avrcpHandleInternalGetPlayStatusResponse(AVRCP *avrcp, AVRCP_INTERNAL_GET_PLAY_STATUS_RES_T *res) { uint16 size_mandatory_data = 1; uint8 mandatory_data[9]; uint16 param_length = 1; mandatory_data[0] = avrcpGetErrorStatusCode(&res->response, AVRCP0_CTYPE_STATUS); if (res->response == avctp_response_stable) { size_mandatory_data = 9; param_length = size_mandatory_data; /* Insert the mandatory data */ convertUint32ToUint8Values(&mandatory_data[0], res->song_length); convertUint32ToUint8Values(&mandatory_data[4], res->song_elapsed); mandatory_data[8] = res->play_status; } avrcpSendMetadataResponse(avrcp, res->response, AVRCP_GET_PLAY_STATUS_PDU_ID, 0, avrcp_packet_type_single, param_length, size_mandatory_data, mandatory_data); }
/**************************************************************************** *NAME * avrcpHandleInternalAbortContinuingResponse * *DESCRIPTION * Prepare to send abort continuing response to the CT. * *PARAMETERS * avrcp - AVRCP Entity * res - Internal request Abort Continuation response. *****************************************************************************/ void avrcpHandleInternalAbortContinuingResponse(AVRCP *avrcp, const AVRCP_INTERNAL_ABORT_CONTINUING_RES_T *res) { /* Send a response to the abort continuing request. */ avrcpSendMetadataResponse(avrcp, res->response, AVRCP_ABORT_CONTINUING_RESPONSE_PDU_ID, 0, avrcp_packet_type_single, 0, 0, 0); }
/**************************************************************************** *NAME * avrcpHandleInternalSetAppValueResponse * *DESCRIPTION * Send SetPlayerApplicationValues response to CT. * *PARAMETERS * AVRCP - AVRCP Instance * res - Application response. ****************************************************************************/ void avrcpHandleInternalSetAppValueResponse(AVRCP *avrcp, AVRCP_INTERNAL_SET_APP_VALUE_RES_T *res) { uint8 mandatory_data[1]; mandatory_data[0] = avrcpGetErrorStatusCode(&res->response, AVRCP0_CTYPE_CONTROL); avrcpSendMetadataResponse(avrcp, res->response, AVRCP_SET_APP_VALUE_PDU_ID, 0, avrcp_packet_type_single, AVRCP_ERROR_CODE_SIZE, AVRCP_ERROR_CODE_SIZE, mandatory_data); }
void sendRegisterNotificationResponse( AVRCP *avrcp, avrcp_response_type resp, uint16 size_mandatory, uint8 *mandatory, uint16 size_attributes, Source attributes) { /* 1 byte error status code as data for rejected response */ uint8 error_data[1]; uint16 param_length = 1; avrcp_packet_type metadata_packet_type = avrcp_packet_type_single; /* Get the error status code */ error_data[0] = avrcpGetErrorStatusCode(&resp, AVRCP0_CTYPE_NOTIFY); if ((resp == avctp_response_interim) || (resp == avctp_response_changed)) { param_length = size_mandatory + size_attributes; } else { size_mandatory = 1; /* 1 octet length only for error code */ mandatory = &error_data[0]; } if (param_length > AVRCP_AVC_MAX_DATA_SIZE) { /* There are more fragments to be sent, store the data for the following fragments. */ /* madatory[0] contains the event ID */ avrcpStoreNextContinuationPacket(avrcp, attributes, param_length-AVRCP_AVC_MAX_DATA_SIZE, AVRCP_REGISTER_NOTIFICATION_PDU_ID, resp, GetNotificationTransaction(avrcp, mandatory[0])); param_length = AVRCP_AVC_MAX_DATA_SIZE; metadata_packet_type = avrcp_packet_type_start; } avrcpSendMetadataResponse(avrcp, resp, AVRCP_REGISTER_NOTIFICATION_PDU_ID, attributes, metadata_packet_type, param_length, size_mandatory, mandatory); }
/**************************************************************************** *NAME * sendRegisterNotificationResponse * *DESCRIPTION * This function is used by the TG to send Register Notification response. * *PARAMETERS * avrcp - AVRCP instance * resp - Response code * size_mandatory - Data length in mandatory * mandatory - It contains the library added response format header * size_attributes - Data length in attributes * attributes - Application provided response data. ****************************************************************************/ void sendRegisterNotificationResponse( AVRCP *avrcp, avrcp_response_type resp, uint16 size_mandatory, uint8 *mandatory, uint16 size_attributes, Source attributes) { /* 1 byte event and 1 byte error status code as data for rejected response */ uint8 error_data[AVRCP_DEFAULT_EVENT_DATA_SIZE]; avrcp_packet_type metadata_packet_type = avrcp_packet_type_single; uint16 param_length=1; /* Clear the Notification if response is not interim*/ if (resp != avctp_response_interim) { clearRegisterNotification(avrcp, mandatory[0]); } /* Standardise the response code */ error_data[0] = avrcpGetErrorStatusCode(&resp, AVRCP0_CTYPE_NOTIFY); if(resp == avctp_response_rejected) { size_mandatory = param_length; size_attributes = 0; error_data[1] = mandatory[0]; /* PDU ID will not be sent to the peer */ mandatory = &error_data[0]; } else { param_length = size_mandatory + size_attributes; if (param_length > avrcp->av_max_data_size) { /* Not expecting a event notification response with Fragmenetation */ Panic(); } } avrcpSendMetadataResponse(avrcp, resp, AVRCP_REGISTER_NOTIFICATION_PDU_ID, attributes, metadata_packet_type, param_length, size_mandatory, mandatory); }
/**************************************************************************** *NAME * avrcpHandleInternalAbsoluteVolumeRsp * *DESCRIPTION * Internal function at TG to send the notification for EVENT_VOLUME_CHANGED * *PARAMETERS * avrcp - Task * res - response * *RETURN ******************************************************************************/ void avrcpHandleInternalAbsoluteVolumeRsp(AVRCP *avrcp, const AVRCP_INTERNAL_SET_ABSOLUTE_VOL_RES_T *res) { uint8 mandatory_data[AVRCP_ERROR_CODE_SIZE]; /* 1 byte */ avrcp_response_type response = res->response; /* Get the error status code */ mandatory_data[0] = avrcpGetErrorStatusCode(&response,AVRCP0_CTYPE_CONTROL); if(response != avctp_response_rejected) { /* Not failure. Insert Volume instead */ mandatory_data[0] = res->volume; } /* Send a response to this PDU now. */ avrcpSendMetadataResponse(avrcp, response, AVRCP_SET_ABSOLUTE_VOLUME_PDU_ID, 0, avrcp_packet_type_single, AVRCP_ERROR_CODE_SIZE , AVRCP_ERROR_CODE_SIZE, mandatory_data); }