Index: firmware/App/Modes/StateTxBloodPrime.c =================================================================== diff -u -r35eaef35568eefc648519dab7e1d8e289dca2f8b -rd3300cbbef016455ac32c08c444087f5a9a1c4c0 --- firmware/App/Modes/StateTxBloodPrime.c (.../StateTxBloodPrime.c) (revision 35eaef35568eefc648519dab7e1d8e289dca2f8b) +++ firmware/App/Modes/StateTxBloodPrime.c (.../StateTxBloodPrime.c) (revision d3300cbbef016455ac32c08c444087f5a9a1c4c0) @@ -439,23 +439,24 @@ *************************************************************************/ BOOL bloodPrimeHandleBloodFlowChangeRequest( MESSAGE_T *message ) { - BOOL result = FALSE; - BOOL accepted = FALSE; + BOOL result = FALSE; + U32 requestedRate = 0; REQUEST_REJECT_REASON_CODE_T rejReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + UI_RESPONSE_PAYLOAD_T response; + // Verify message payload length if ( sizeof(U32) == message->hdr.payloadLen ) { - U32 requestedRate; - memcpy( &requestedRate, message->payload, sizeof(U32) ); - result = TRUE; - - if ( ( BLOOD_PRIME_RAMP_STATE == bloodPrimeState ) || ( BLOOD_PRIME_RUN_STATE == bloodPrimeState ) ) + memcpy( &requestedRate, message->payload, sizeof( U32 ) ); + if ( ( BLOOD_PRIME_RAMP_STATE == bloodPrimeState ) || ( BLOOD_PRIME_RUN_STATE == bloodPrimeState ) || ( BLOOD_PRIME_PAUSED_STATE == bloodPrimeState ) ) { - if ( ( requestedRate >= 50 ) && ( requestedRate <= 500 ) ) + U32 lowerLimit = getU32TreatmentParamLowerRangeLimit( TREATMENT_PARAM_BLOOD_FLOW ); + U32 upperLimit = getU32TreatmentParamUpperRangeLimit( TREATMENT_PARAM_BLOOD_FLOW ); + if ( ( requestedRate >= lowerLimit ) && ( requestedRate <= upperLimit ) ) { requestedBloodFlowRate_mL_min = requestedRate; pendingFlowChangeRequest = TRUE; - accepted = TRUE; + result = TRUE; rejReason = REQUEST_REJECT_REASON_NONE; } else @@ -465,16 +466,15 @@ } else { - rejReason = REQUEST_REJECT_REASON_INVALID_COMMAND; + rejReason = REQUEST_REJECT_REASON_INVALID_TREATMENT_STATE; } } - { - UI_RESPONSE_PAYLOAD_T respPayload; - respPayload.accepted = accepted; - respPayload.rejectionReason = rejReason; - sendMessage( MSG_ID_TD_TREATMENT_SET_POINT_BLOOD_FLOW_CHANGE_RESPONSE, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08*)(&respPayload), sizeof(UI_RESPONSE_PAYLOAD_T) ); - } + // Respond to request + response.accepted = result; + response.rejectionReason = rejReason; + sendMessage( MSG_ID_TD_TREATMENT_SET_POINT_BLOOD_FLOW_CHANGE_RESPONSE, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08*)(&response), sizeof( UI_RESPONSE_PAYLOAD_T ) ); + return result; }