Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -r9fcd1ad071bcce7a592833367c103e235e49654f -rf99f8b365af2274d68d7f424cc9be9815b4db19c --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 9fcd1ad071bcce7a592833367c103e235e49654f) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision f99f8b365af2274d68d7f424cc9be9815b4db19c) @@ -454,34 +454,6 @@ /*********************************************************************//** * @brief - * The sendConfirmationRequest function sends a confirmation request to UI - * @details /b Inputs: requestID, requestType, rejectReason - * @details /b Outputs: none - * @param requestID ID of confirmation request - * @param requestType Type of confirmation request command - * @param rejectReason Reject reason if applicable - * @return none - *************************************************************************/ -BOOL sendConfirmationRequest( GENERIC_CONFIRM_ID_T requestID, GENERIC_CONFIRM_COMMAND_T requestType, U32 rejectReason ) -{ - GENERIC_CONFIRMATION_REQUEST_T request; - - // Populate request structure - request.requestID = (U32)requestID; - request.requestType = (U32)requestType; - request.rejectReason = rejectReason; - // Optional payload defaults - request.genericPayload1 = 0; - request.genericPayload2 = 0; - request.genericPayload3 = 0; - request.genericPayload4 = 0; - - // Use generic message support helper for transmission. - return sendMessage( MSG_ID_TD_UI_CONFIRMATION_REQUEST, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08 *)&request, (U32)sizeof( GENERIC_CONFIRMATION_REQUEST_T ) ); -} - -/*********************************************************************//** - * @brief * The getConfirmationRequestStatus function returns the status of a confirmation request * @details \b Inputs: confirmRequests[] * @details \b Outputs: confirmRequests[] consumed/cleared if completed. @@ -494,6 +466,9 @@ U32 pendingIndex = 0; CONFIRMATION_REQUEST_STATUS_T status = CONFIRMATION_REQUEST_STATUS_PENDING; U32 i; + UI_OFF_BUTTON_PAYLOAD_T cmd; + cmd.id = 0; + cmd.reason = 0; for ( i = 0; i < MAX_PENDING_CONFIRM_REQUESTS; i++ ) { @@ -505,11 +480,13 @@ // Send UI clear if ( CONFIRMATION_REQUEST_STATUS_TIMEOUT == status ) { - sendConfirmationRequest( confirmRequests[ i ].requestID, GENERIC_CONFIRM_CMD_TIMEOUT_CLOSE, 0 ); + cmd.command = GENERIC_CONFIRM_CMD_TIMEOUT_CLOSE; + sendMessage( MSG_ID_TD_UI_GENERIC_CONFIRMATION_REQUEST, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08 *)&cmd, sizeof( UI_OFF_BUTTON_PAYLOAD_T ) ); } else { - sendConfirmationRequest( confirmRequests[ i ].requestID, GENERIC_CONFIRM_CMD_ACCEPT_CLOSE, 0 ); + cmd.command = GENERIC_CONFIRM_CMD_ACCEPT_CLOSE; + sendMessage( MSG_ID_TD_UI_GENERIC_CONFIRMATION_REQUEST, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08 *)&cmd, sizeof( UI_OFF_BUTTON_PAYLOAD_T ) ); } // Clear the confirmation request, it is done and consumed @@ -540,7 +517,8 @@ if ( ( CONFIRMATION_REQUEST_STATUS_PENDING != status ) && ( TRUE == pending ) ) { // Last confirmation cleared, pending request must be resent to UI - sendConfirmationRequest( confirmRequests[ pendingIndex ].requestID, confirmRequests[ pendingIndex ].requestType, 0 ); + cmd.command = confirmRequests[ pendingIndex ].requestType; + sendMessage( MSG_ID_TD_UI_GENERIC_CONFIRMATION_REQUEST, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08 *)&cmd, sizeof( UI_OFF_BUTTON_PAYLOAD_T ) ); } return status; @@ -581,37 +559,39 @@ *************************************************************************/ GENERIC_CONFIRM_ID_T addConfirmationRequest( GENERIC_CONFIRM_ID_T requestID, GENERIC_CONFIRM_COMMAND_T requestType, U32 rejectReason ) { - U32 i; - BOOL confirmAlreadyPending = FALSE; + U32 i; GENERIC_CONFIRM_ID_T newID = GENERIC_CONFIRM_ID_NONE; + UI_OFF_BUTTON_PAYLOAD_T cmd; - // Check to make sure specified confirmation is not already pending + // Check whether this confirmation is already pending for ( i = 0; i < MAX_PENDING_CONFIRM_REQUESTS; i++ ) { - if ( ( confirmRequests[ i ].requestID == requestID ) && - ( confirmRequests[ i ].status != CONFIRMATION_REQUEST_STATUS_UNUSED ) ) + if ( ( confirmRequests[i].requestID == requestID ) && + ( confirmRequests[i].status == CONFIRMATION_REQUEST_STATUS_PENDING ) ) { - confirmAlreadyPending = TRUE; - break; + return requestID; } } - // If not already pending, add confirmation to list of pending confirmations and send to UI to be displayed - if ( confirmAlreadyPending != TRUE ) + // Find an unused slot + for ( i = 0; i < MAX_PENDING_CONFIRM_REQUESTS; i++ ) { - for ( i = 0; i < MAX_PENDING_CONFIRM_REQUESTS; i++ ) + if ( confirmRequests[i].status == CONFIRMATION_REQUEST_STATUS_UNUSED ) { - if ( CONFIRMATION_REQUEST_STATUS_UNUSED == confirmRequests[ i ].status ) - { - // Save the confirmation request info - confirmRequests[ i ].requestID = requestID; - confirmRequests[ i ].requestType = requestType; - confirmRequests[ i ].timeStamp = getMSTimerCount(); - confirmRequests[ i ].status = CONFIRMATION_REQUEST_STATUS_PENDING; - newID = requestID; - sendConfirmationRequest( requestID, requestType, rejectReason ); - break; - } + confirmRequests[i].requestID = requestID; + confirmRequests[i].requestType = requestType; + confirmRequests[i].timeStamp = getMSTimerCount(); + confirmRequests[i].status = CONFIRMATION_REQUEST_STATUS_PENDING; + + newID = requestID; + + cmd.id = requestID; + cmd.command = requestType; + cmd.reason = rejectReason; + + sendMessage( MSG_ID_TD_UI_GENERIC_CONFIRMATION_REQUEST, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08 *)&cmd, sizeof( UI_OFF_BUTTON_PAYLOAD_T ) ); + + break; } } @@ -673,29 +653,6 @@ /*********************************************************************//** * @brief - * The handleUIVersionResponse function handles a response to request for - * UI version information. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle. - * @return none - *************************************************************************/ -BOOL handleUIVersionResponse( MESSAGE_T *message ) -{ - BOOL result = TRUE; - // Get UI version data and have it recorded - if ( sizeof(UI_VERSIONS_T) == message->hdr.payloadLen ) - { - UI_VERSIONS_T uiVersion; - - memcpy( &uiVersion, &message->payload[0], sizeof(UI_VERSIONS_T) ); - signalUIVersion( uiVersion ); - } - return result; -} - -/*********************************************************************//** - * @brief * The handleUIConfirmationResponse function handles a UI response for * confirmation request. * @details \b Inputs: none @@ -705,29 +662,20 @@ *************************************************************************/ BOOL handleUIConfirmationResponse( MESSAGE_T *message ) { - BOOL result; - U08* payloadPtr = message->payload; + BOOL result = FALSE; + U32 request_id; + U32 status; - if ( message->hdr.payloadLen == 2 * sizeof(U32) ) + if ( message->hdr.payloadLen == (2 * sizeof(U32)) ) { - U32 request_id; - U32 status; + memcpy( &request_id, &message->payload[0], sizeof(U32) ); + memcpy( &status, &message->payload[sizeof(U32)], sizeof(U32) ); - memcpy( &request_id, payloadPtr, sizeof(U32) ); - payloadPtr += sizeof(U32); - memcpy( &status, payloadPtr, sizeof(U32) ); - if ( CONFIRMATION_REQUEST_STATUS_REJECTED == status ) - { - userConfirmOffButton( OFF_BUTTON_RSP_USER_REJECTS_POWER_OFF ); - } - else if ( CONFIRMATION_REQUEST_STATUS_ACCEPTED == status ) - { - userConfirmOffButton( OFF_BUTTON_RSP_USER_CONFIRMS_POWER_OFF ); - } setConfirmationRequestStatus( (GENERIC_CONFIRM_ID_T)request_id, (CONFIRMATION_REQUEST_STATUS_T)status ); + + result = TRUE; } - result = sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_TD_2_UI, FALSE ); return result; }