Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rb6b733b8d1f25bc2dbe2a94c620cd80aa3ae06f7 -r401c4027b0e59182771f0c620465b34579f203f5 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision b6b733b8d1f25bc2dbe2a94c620cd80aa3ae06f7) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 401c4027b0e59182771f0c620465b34579f203f5) @@ -30,6 +30,7 @@ #include "ModeTreatmentParams.h" #include "PresOccl.h" #include "RTC.h" +#include "SampleWater.h" #include "SafetyShutdown.h" #include "SystemComm.h" #include "SystemCommMessages.h" @@ -471,8 +472,64 @@ result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); return result; -} +} +/*********************************************************************//** + * @brief + * The handleSampleWaterCmd function handles a sample water user action command + * message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none. + *************************************************************************/ +void handleSampleWaterCmd( MESSAGE_T *message ) +{ + if ( sizeof( U32 ) == message->hdr.payloadLen ) + { + U32 cmd; + + memcpy( &cmd, &message->payload[0], sizeof( U32 ) ); + + signalSampleWaterUserAction( (REQUESTED_SAMPLE_WATER_USER_ACTIONS_T)cmd ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The sendSampleWaterCmdResponse function constructs a sample water user action + * response to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Sample water command response msg constructed and queued. + * @param accepted T/F - was sample water request accepted? + * @param rejReason reason why request was rejected (or zero if accepted) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendSampleWaterCmdResponse( BOOL accepted, U32 rejReason ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SAMPLE_WATER_CMD_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &rejReason, sizeof( U32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); + + return result; +} + /*********************************************************************//** * @brief * The sendDialysateTempTargetsToDG function constructs a dialysate temperature