Index: firmware/App/Services/NVMessagingDD.c =================================================================== diff -u -r1e742ba641458eaf36c8d953275a3e1c32b943d4 -r7b414857790dd5282137bf67d56688a703d4bfe7 --- firmware/App/Services/NVMessagingDD.c (.../NVMessagingDD.c) (revision 1e742ba641458eaf36c8d953275a3e1c32b943d4) +++ firmware/App/Services/NVMessagingDD.c (.../NVMessagingDD.c) (revision 7b414857790dd5282137bf67d56688a703d4bfe7) @@ -69,105 +69,52 @@ U32 mfgDateRejectReason; ///< Reason to reject System record parameter mfgDate }DD_NVM_SET_SYSTEM_REC_PAYLOAD_T; -/// DD NVM Get Service Record Response Payload +/// DD NVM Get FP Service Record Response Payload typedef struct { BOOL accepted; ///< Accepted/Rejected U32 rejectionReason; ///< Rejection reason if not accepted. - DD_SERVICE_RECORD_T data; ///< Data to be sent -}DD_NVM_GET_SERVICE_REC_PAYLOAD_T; + SERVICE_RECORD_FP_T data; ///< Data to be sent +}DD_NVM_GET_FP_SERVICE_REC_PAYLOAD_T; -/// DD NVM Set Service Record Response Payload +/// DD NVM Set FP Service Record Response Payload typedef struct { BOOL accepted; ///< Accepted/Rejected U32 rejectionReason; ///< Reason to reject the entire request - U32 isHDFOnlineFluidAvailableRejectReason; ///< Reason to reject Service record parameter isHDFOnlineFluidAvailable U32 waterRecoveryRejectReason; ///< Reason to reject Service record parameter waterRecovery + U32 primaryFilterReplacementDateRejectReason; ///< Reason to reject Service record parameter primaryFilterReplacementDate + U32 secondaryFilterReplacementDateRejectReason; ///< Reason to reject Service record parameter secondaryFilterReplacementDate + U32 ROMembraneReplacementDateRejectReason; ///< Reason to reject Service record parameter ROMembraneReplacementDate U32 serviceLocRejectReason; ///< Reason to reject Service record parameter serviceLoc U32 lastServiceEpochDateRejectReason; ///< Reason to reject Service record parameter lastServiceEpochDate U32 serviceIntervalSecondsRejectReason; ///< Reason to reject Service record parameter serviceIntervalSeconds U32 lastResetTimeEpochRejectReason; ///< Reason to reject Service record parameter lastResetTimeEpoch -}DD_NVM_SET_SERVICE_REC_PAYLOAD_T; +}DD_NVM_SET_FP_SERVICE_REC_PAYLOAD_T; -/// DD NVM Get Usage Info Record Response Payload +/// DD NVM Get DD Service Record Response Payload typedef struct { BOOL accepted; ///< Accepted/Rejected U32 rejectionReason; ///< Rejection reason if not accepted. - DD_USAGE_INFO_RECORD_T data; ///< Data to be sent -}DD_NVM_GET_USAGE_INFO_REC_PAYLOAD_T; + SERVICE_RECORD_DD_T data; ///< Data to be sent +}DD_NVM_GET_DD_SERVICE_REC_PAYLOAD_T; -/// DD NVM Set Usage Info Record Response Payload +/// DD NVM Set Service Record Response Payload typedef struct { BOOL accepted; ///< Accepted/Rejected U32 rejectionReason; ///< Reason to reject the entire request - U32 roWaterGenTotalLRejectReason; ///< Reason to reject Usage Info record parameter roWaterGenTotalL - U32 roWaterGenSinceLastServiceLRejectReason; ///< Reason to reject Usage Info record parameter roWaterGenSinceLastServiceL - U32 lastBasicFlushCompleteDateEpochRejectReason; ///< Reason to reject Usage Info record parameter lastBasicFlushCompleteDateEpoch - U32 lastHeatDisCompleteDateEpochRejectReason; ///< Reason to reject Usage Info record parameter lastHeatDisCompleteDateEpoch - U32 lastHeatActiveCoolCompleteDateEpochRejectReason; ///< Reason to reject Usage Info record parameter lastHeatActiveCoolCompleteDateEpoch - U32 lastFilterFlushCompleteDateEpochRejectReason; ///< Reason to reject Usage Info record parameter lastFilterFlushCompleteDateEpoch - U32 lastResetTimeEpochRejectReason; ///< Reason to reject Usage Info record parameter lastResetTimeEpoch -}DD_NVM_SET_USAGE_INFO_REC_PAYLOAD_T; + U32 isHDFOnlineFluidAvailableRejectReason; ///< Reason to reject Service record parameter isHDFOnlineFluidAvailable + U32 ultraFilter1ReplacementDateRejectReason; ///< Reason to reject Service record parameter ultraFilter1ReplacementDate + U32 ultraFilter2ReplacementDateRejectReason; ///< Reason to reject Service record parameter ultraFilter2ReplacementDate + U32 UFPumpTubingReplacementDateRejectReason; ///< Reason to reject Service record parameter UFPumpTubingReplacementDate + U32 serviceLocRejectReason; ///< Reason to reject Service record parameter serviceLoc + U32 lastServiceEpochDateRejectReason; ///< Reason to reject Service record parameter lastServiceEpochDate + U32 serviceIntervalSecondsRejectReason; ///< Reason to reject Service record parameter serviceIntervalSeconds + U32 lastResetTimeEpochRejectReason; ///< Reason to reject Service record parameter lastResetTimeEpoch +}DD_NVM_SET_DD_SERVICE_REC_PAYLOAD_T; -/// Institutional data reject reason structure. -typedef struct -{ - U32 minRejectReason; ///< Reason to reject Institutional record parameter min - U32 maxRejectReason; ///< Reason to reject Institutional record parameter max - U32 defRejectReason; ///< Reason to reject Institutional record parameter def -} INSTIT_DATA_REJECT_REASON_T; - -/// DD NVM Get Institutional Basic Record Response Payload -typedef struct -{ - BOOL accepted; ///< Accepted/Rejected - U32 rejectionReason; ///< Rejection reason if not accepted. - DD_INSTIT_BASIC_RECORD_T data; ///< Data to be sent -}DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T; - -/// DD NVM Set Institutional Basic Record Response Payload -typedef struct -{ - BOOL accepted; ///< Accepted/Rejected - U32 rejectionReason; ///< Reason to reject the entire request - INSTIT_DATA_REJECT_REASON_T param[ NUM_OF_INSTIT_BASIC ]; ///< Reject reasons for each param of basic institutional record. -}DD_NVM_SET_INSTIT_BASIC_REC_PAYLOAD_T; - -/// DD NVM Get Institutional Advanced Record Response Payload -typedef struct -{ - BOOL accepted; ///< Accepted/Rejected - U32 rejectionReason; ///< Rejection reason if not accepted. - DD_INSTIT_ADVANCED_RECORD_T data; ///< Data to be sent -}DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T; - -/// DD NVM Set Institutional Advanced Record Response Payload -typedef struct -{ - BOOL accepted; ///< Accepted/Rejected - U32 rejectionReason; ///< Reason to reject the entire request - INSTIT_DATA_REJECT_REASON_T param[ NUM_OF_INSTIT_ADVANCED ]; ///< Reject reasons for each param of advanced institutional record. -}DD_NVM_SET_INSTIT_ADVANCED_REC_PAYLOAD_T; - -/// DD NVM Get Institutional Additional Record Response Payload -typedef struct -{ - BOOL accepted; ///< Accepted/Rejected - U32 rejectionReason; ///< Rejection reason if not accepted. - DD_INSTIT_ADDITIONAL_RECORD_T data; ///< Data to be sent -}DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T; - -/// DD NVM Set Institutional Additional Record Response Payload -typedef struct -{ - BOOL accepted; ///< Accepted/Rejected - U32 rejectionReason; ///< Reason to reject the entire request - INSTIT_DATA_REJECT_REASON_T param[ NUM_OF_INSTIT_ADDITIONAL ]; ///< Reject reasons for each param of Additional institutional record. -}DD_NVM_SET_INSTIT_ADDITIONAL_REC_PAYLOAD_T; - /// Linear reject reason calibration structure typedef struct { @@ -337,6 +284,112 @@ U32 calibrationTimeRejectReason; ///< Reason to reject conductivity sensor calibration record parameter calibrationTime } DD_NVM_SET_CONDUCTIVITY_SENSOR_CAL_REC_PAYLOAD_T; +/// Institutional data reject reason structure. +typedef struct +{ + U32 minRejectReason; ///< Reason to reject Institutional record parameter min + U32 maxRejectReason; ///< Reason to reject Institutional record parameter max + U32 defRejectReason; ///< Reason to reject Institutional record parameter def +} INSTIT_DATA_REJECT_REASON_T; + +/// DD NVM Get Institutional Basic Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. + DD_INSTIT_BASIC_RECORD_T data; ///< Data to be sent +}DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T; + +/// DD NVM Set Institutional Basic Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + INSTIT_DATA_REJECT_REASON_T param[ NUM_OF_INSTIT_BASIC ]; ///< Reject reasons for each param of basic institutional record. +}DD_NVM_SET_INSTIT_BASIC_REC_PAYLOAD_T; + +/// DD NVM Get Institutional Advanced Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. + DD_INSTIT_ADVANCED_RECORD_T data; ///< Data to be sent +}DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T; + +/// DD NVM Set Institutional Advanced Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + INSTIT_DATA_REJECT_REASON_T param[ NUM_OF_INSTIT_ADVANCED ]; ///< Reject reasons for each param of advanced institutional record. +}DD_NVM_SET_INSTIT_ADVANCED_REC_PAYLOAD_T; + +/// DD NVM Get Institutional Additional Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. + DD_INSTIT_ADDITIONAL_RECORD_T data; ///< Data to be sent +}DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T; + +/// DD NVM Set Institutional Additional Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + INSTIT_DATA_REJECT_REASON_T param[ NUM_OF_INSTIT_ADDITIONAL ]; ///< Reject reasons for each param of Additional institutional record. +}DD_NVM_SET_INSTIT_ADDITIONAL_REC_PAYLOAD_T; + +/// DD NVM Get FP Usage Info Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. + USAGE_RECORD_FP_T data; ///< Data to be sent +}DD_NVM_GET_FP_USAGE_INFO_REC_PAYLOAD_T; + +/// DD NVM Set FP Usage Info Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + U32 primaryFilterTreatmentNumRejectReason; ///< Reason to reject Usage Info record parameter primaryFilterTreatmentNum + U32 primaryFilterDisinfectionNumRejectReason; ///< Reason to reject Usage Info record parameter primaryFilterDisinfectionNum + U32 secondaryFilterTreatmentNumRejectReason; ///< Reason to reject Usage Info record parameter secondaryFilterTreatmentNum + U32 secondaryFilterDisinfectionNumRejectReason; ///< Reason to reject Usage Info record parameter secondaryFilterDisinfectionNum + U32 ROMembraneTreatmentNumRejectReason; ///< Reason to reject Usage Info record parameter ROMembraneTreatmentNum + U32 ROMembraneDisinfectionNumRejectReason; ///< Reason to reject Usage Info record parameter ROMembraneDisinfectionNum + U32 lastResetTimeEpochRejectReason; ///< Reason to reject Usage Info record parameter lastResetTimeEpoch +}DD_NVM_SET_FP_USAGE_INFO_REC_PAYLOAD_T; + +/// DD NVM Get DD Usage Info Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. + USAGE_RECORD_DD_T data; ///< Data to be sent +}DD_NVM_GET_DD_USAGE_INFO_REC_PAYLOAD_T; + +/// DD NVM Set DD Usage Info Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + U32 roWaterGenTotalLRejectReason; ///< Reason to reject Usage Info record parameter roWaterGenTotalL + U32 roWaterGenSinceLastServiceLRejectReason; ///< Reason to reject Usage Info record parameter roWaterGenSinceLastServiceL + U32 ultraFilter1TreatmentNumRejectReason; ///< Reason to reject Usage Info record parameter ultraFilter1TreatmentNum + U32 ultraFilter1DisinfectionNumRejectReason; ///< Reason to reject Usage Info record parameter ultraFilter1DisinfectionNum + U32 ultraFilter2TreatmentNumRejectReason; ///< Reason to reject Usage Info record parameter ultraFilter2TreatmentNum + U32 ultraFilter2DisinfectionNumRejectReason; ///< Reason to reject Usage Info record parameter ultraFilter2DisinfectionNum + U32 UFPumpTubingTreatmentNumRejectReason; ///< Reason to reject Usage Info record parameter UFPumpTubingTreatmentNum + U32 UFPumpTubingDisinfectionNumRejectReason; ///< Reason to reject Usage Info record parameter UFPumpTubingDisinfectionNum + U32 lastBasicFlushCompleteDateEpochRejectReason; ///< Reason to reject Usage Info record parameter lastBasicFlushCompleteDateEpoch + U32 lastHeatDisCompleteDateEpochRejectReason; ///< Reason to reject Usage Info record parameter lastHeatDisCompleteDateEpoch + U32 lastHeatActiveCoolCompleteDateEpochRejectReason; ///< Reason to reject Usage Info record parameter lastHeatActiveCoolCompleteDateEpoch + U32 lastFilterFlushCompleteDateEpochRejectReason; ///< Reason to reject Usage Info record parameter lastFilterFlushCompleteDateEpoch + U32 lastResetTimeEpochRejectReason; ///< Reason to reject Usage Info record parameter lastResetTimeEpoch +}DD_NVM_SET_DD_USAGE_INFO_REC_PAYLOAD_T; + #pragma pack(pop) // ********** private data ********** @@ -355,11 +408,8 @@ static SEND_RECORD_STATE_T handleExecSendRecordSendState( void ); static SEND_RECORD_STATE_T handleSendDDSystemRecord( void ); +static SEND_RECORD_STATE_T handleSendFPServiceRecord( void ); static SEND_RECORD_STATE_T handleSendDDServiceRecord( void ); -static SEND_RECORD_STATE_T handleSendDDUsageInfoRecord( void ); -static SEND_RECORD_STATE_T handleSendDDInstitBasicRecord( void ); -static SEND_RECORD_STATE_T handleSendDDInstitAdvancedRecord( void ); -static SEND_RECORD_STATE_T handleSendDDInstitAdditionalRecord( void ); static SEND_RECORD_STATE_T handleSendPressureSensorCalRecord( void ); static SEND_RECORD_STATE_T handleSendTempSensorCalRecord( void ); static SEND_RECORD_STATE_T handleSendConcPumpCalRecord( void ); @@ -370,6 +420,11 @@ static SEND_RECORD_STATE_T handleSendAccelSensorCalRecord( void ); static SEND_RECORD_STATE_T handleSendBloodLeakSensorCalRecord( void ); static SEND_RECORD_STATE_T handleSendConductivitySensorCalRecord( void ); +static SEND_RECORD_STATE_T handleSendDDInstitBasicRecord( void ); +static SEND_RECORD_STATE_T handleSendDDInstitAdvancedRecord( void ); +static SEND_RECORD_STATE_T handleSendDDInstitAdditionalRecord( void ); +static SEND_RECORD_STATE_T handleSendFPUsageInfoRecord( void ); +static SEND_RECORD_STATE_T handleSendDDUsageInfoRecord( void ); static void monitorNewCalSignal( void ); @@ -531,7 +586,11 @@ state = handleSendDDSystemRecord(); break; - case NV_DD_DATA_SERVICE_RECORD: + case NV_DD_DATA_FP_SERVICE_RECORD: + state = handleSendFPServiceRecord(); + break; + + case NV_DD_DATA_DD_SERVICE_RECORD: state = handleSendDDServiceRecord(); break; @@ -587,7 +646,11 @@ state = handleSendDDInstitAdditionalRecord(); break; - case NV_DD_DATA_USAGE_INFO_RECORD: + case NV_DD_DATA_FP_USAGE_INFO_RECORD: + state = handleSendFPUsageInfoRecord(); + break; + + case NV_DD_DATA_DD_USAGE_INFO_RECORD: state = handleSendDDUsageInfoRecord(); break; @@ -640,31 +703,31 @@ /*********************************************************************//** * @brief - * The handleSendDDServiceRecord function sends the DD service record. + * The handleSendFPServiceRecord function sends the FP service record. * @details \b Inputs: None * @details \b Outputs: None * @return state next state of the state machine *************************************************************************/ -static SEND_RECORD_STATE_T handleSendDDServiceRecord( void ) +static SEND_RECORD_STATE_T handleSendFPServiceRecord( void ) { SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; - DD_NVM_GET_SERVICE_REC_PAYLOAD_T payload; + DD_NVM_GET_FP_SERVICE_REC_PAYLOAD_T payload; // Get the record - if ( TRUE == getNVMRecord( NV_DD_DATA_SERVICE_RECORD, + if ( TRUE == getNVMRecord( NV_DD_DATA_FP_SERVICE_RECORD, (U08*)&payload.data, - sizeof( DD_SERVICE_RECORD_T ) , + sizeof( SERVICE_RECORD_FP_T ) , 0, - ALARM_ID_DD_NVM_INVALID_SERVICE_RECORD_CRC ) ) + ALARM_ID_FP_NVM_INVALID_SERVICE_RECORD_CRC ) ) { payload.accepted = TRUE; payload.rejectionReason = 0; // Send the record - sendMessage( MSG_ID_DD_UI_NVM_GET_SERVICE_RECORD_RESPONSE, + sendMessage( MSG_ID_FP_UI_NVM_GET_SERVICE_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&payload, - ( sizeof( DD_NVM_GET_SERVICE_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); + ( sizeof( DD_NVM_GET_FP_SERVICE_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); } // Move to Send Idle State @@ -675,32 +738,31 @@ /*********************************************************************//** * @brief - * The handleSendDDUsageInfoRecord function sends the DD usage - * information record. + * The handleSendDDServiceRecord function sends the DD service record. * @details \b Inputs: None * @details \b Outputs: None * @return state next state of the state machine *************************************************************************/ -static SEND_RECORD_STATE_T handleSendDDUsageInfoRecord( void ) +static SEND_RECORD_STATE_T handleSendDDServiceRecord( void ) { - SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; - DD_NVM_GET_USAGE_INFO_REC_PAYLOAD_T payload; + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + DD_NVM_GET_DD_SERVICE_REC_PAYLOAD_T payload; // Get the record - if ( TRUE == getNVMRecord( NV_DD_DATA_USAGE_INFO_RECORD, + if ( TRUE == getNVMRecord( NV_DD_DATA_DD_SERVICE_RECORD, (U08*)&payload.data, - sizeof( DD_USAGE_INFO_RECORD_T ), + sizeof( SERVICE_RECORD_DD_T ) , 0, - ALARM_ID_DD_NVM_INVALID_USAGE_RECORD_CRC ) ) + ALARM_ID_DD_NVM_INVALID_SERVICE_RECORD_CRC ) ) { payload.accepted = TRUE; payload.rejectionReason = 0; // Send the record - sendMessage( MSG_ID_DD_UI_NVM_GET_USAGE_INFO_RECORD_RESPONSE, + sendMessage( MSG_ID_DD_UI_NVM_GET_SERVICE_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&payload, - ( sizeof( DD_NVM_GET_USAGE_INFO_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); + ( sizeof( DD_NVM_GET_DD_SERVICE_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); } // Move to Send Idle State @@ -711,114 +773,6 @@ /*********************************************************************//** * @brief - * The handleSendDDInstitBasicRecord function sends the DD basic - * institutional record. - * @details \b Inputs: None - * @details \b Outputs: None - * @return state next state of the state machine - *************************************************************************/ -static SEND_RECORD_STATE_T handleSendDDInstitBasicRecord( void ) -{ - SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; - DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T payload; - - // Get the record - if ( TRUE == getNVMRecord( NV_DD_DATA_INSTIT_BASIC_RECORD, - (U08*)&payload.data, - sizeof( DD_INSTIT_BASIC_RECORD_T ), - 0, - ALARM_ID_DD_NVM_INVALID_INSTIT_BASIC_RECORD_CRC ) ) - { - payload.accepted = TRUE; - payload.rejectionReason = 0; - - // Send the record - sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_BASIC_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08*)&payload, - ( sizeof( DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); - } - - // Move to Send Idle State - state = NVM_SEND_RECORD_STATE_IDLE; - - return state; -} - -/*********************************************************************//** - * @brief - * The handleSendDDInstitAdvancedRecord function sends the DD advanced - * institutional record. - * @details \b Inputs: None - * @details \b Outputs: None - * @return state next state of the state machine - *************************************************************************/ -static SEND_RECORD_STATE_T handleSendDDInstitAdvancedRecord( void ) -{ - SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; - DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T payload; - - // Get the record - if ( TRUE == getNVMRecord( NV_DD_DATA_INSTIT_ADVANCED_RECORD, - (U08*)&payload.data, - sizeof( DD_INSTIT_ADVANCED_RECORD_T ), - 0, - ALARM_ID_DD_NVM_INVALID_INSTIT_ADVANCED_RECORD_CRC ) ) - { - payload.accepted = TRUE; - payload.rejectionReason = 0; - - // Send the record - sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADVANCED_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08*)&payload, - ( sizeof( DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); - } - - // Move to Send Idle State - state = NVM_SEND_RECORD_STATE_IDLE; - - return state; -} - -/*********************************************************************//** - * @brief - * The handleSendDDInstitAdditionalRecord function sends the DD additional - * institutional record. - * @details \b Inputs: None - * @details \b Outputs: recordToPublish - * @return state next state of the state machine - *************************************************************************/ -static SEND_RECORD_STATE_T handleSendDDInstitAdditionalRecord( void ) -{ - SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; - DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T payload; - - // Get the record - if ( TRUE == getNVMRecord( NV_DD_DATA_INSTIT_ADDITIONAL_RECORD, - (U08*)&payload.data, - sizeof( DD_INSTIT_ADDITIONAL_RECORD_T ), - 0, - ALARM_ID_DD_NVM_INVALID_INSTIT_ADDITIONAL_RECORD_CRC ) ) - { - payload.accepted = TRUE; - payload.rejectionReason = 0; - - // Send the record - sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADDITIONAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08*)&payload, - ( sizeof( DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); - } - - // Move to Send Idle State - state = NVM_SEND_RECORD_STATE_IDLE; - - return state; -} - -/*********************************************************************//** - * @brief * The handleSendPressureSensorCalRecord function sends the calibration * record of the selected pressure sensor. * @details \b Inputs: sendCalIdx @@ -1201,6 +1155,186 @@ /*********************************************************************//** * @brief + * The handleSendDDInstitBasicRecord function sends the DD basic + * institutional record. + * @details \b Inputs: None + * @details \b Outputs: None + * @return state next state of the state machine + *************************************************************************/ +static SEND_RECORD_STATE_T handleSendDDInstitBasicRecord( void ) +{ + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T payload; + + // Get the record + if ( TRUE == getNVMRecord( NV_DD_DATA_INSTIT_BASIC_RECORD, + (U08*)&payload.data, + sizeof( DD_INSTIT_BASIC_RECORD_T ), + 0, + ALARM_ID_DD_NVM_INVALID_INSTIT_BASIC_RECORD_CRC ) ) + { + payload.accepted = TRUE; + payload.rejectionReason = 0; + + // Send the record + sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_BASIC_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&payload, + ( sizeof( DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); + } + + // Move to Send Idle State + state = NVM_SEND_RECORD_STATE_IDLE; + + return state; +} + +/*********************************************************************//** + * @brief + * The handleSendDDInstitAdvancedRecord function sends the DD advanced + * institutional record. + * @details \b Inputs: None + * @details \b Outputs: None + * @return state next state of the state machine + *************************************************************************/ +static SEND_RECORD_STATE_T handleSendDDInstitAdvancedRecord( void ) +{ + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T payload; + + // Get the record + if ( TRUE == getNVMRecord( NV_DD_DATA_INSTIT_ADVANCED_RECORD, + (U08*)&payload.data, + sizeof( DD_INSTIT_ADVANCED_RECORD_T ), + 0, + ALARM_ID_DD_NVM_INVALID_INSTIT_ADVANCED_RECORD_CRC ) ) + { + payload.accepted = TRUE; + payload.rejectionReason = 0; + + // Send the record + sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADVANCED_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&payload, + ( sizeof( DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); + } + + // Move to Send Idle State + state = NVM_SEND_RECORD_STATE_IDLE; + + return state; +} + +/*********************************************************************//** + * @brief + * The handleSendDDInstitAdditionalRecord function sends the DD additional + * institutional record. + * @details \b Inputs: None + * @details \b Outputs: recordToPublish + * @return state next state of the state machine + *************************************************************************/ +static SEND_RECORD_STATE_T handleSendDDInstitAdditionalRecord( void ) +{ + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T payload; + + // Get the record + if ( TRUE == getNVMRecord( NV_DD_DATA_INSTIT_ADDITIONAL_RECORD, + (U08*)&payload.data, + sizeof( DD_INSTIT_ADDITIONAL_RECORD_T ), + 0, + ALARM_ID_DD_NVM_INVALID_INSTIT_ADDITIONAL_RECORD_CRC ) ) + { + payload.accepted = TRUE; + payload.rejectionReason = 0; + + // Send the record + sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADDITIONAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&payload, + ( sizeof( DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); + } + + // Move to Send Idle State + state = NVM_SEND_RECORD_STATE_IDLE; + + return state; +} + +/*********************************************************************//** + * @brief + * The handleSendFPUsageInfoRecord function sends the FP usage + * information record. + * @details \b Inputs: None + * @details \b Outputs: None + * @return state next state of the state machine + *************************************************************************/ +static SEND_RECORD_STATE_T handleSendFPUsageInfoRecord( void ) +{ + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + DD_NVM_GET_FP_USAGE_INFO_REC_PAYLOAD_T payload; + + // Get the record + if ( TRUE == getNVMRecord( NV_DD_DATA_FP_USAGE_INFO_RECORD, + (U08*)&payload.data, + sizeof( USAGE_RECORD_FP_T ), + 0, + ALARM_ID_FP_NVM_INVALID_USAGE_RECORD_CRC ) ) + { + payload.accepted = TRUE; + payload.rejectionReason = 0; + + // Send the record + sendMessage( MSG_ID_FP_UI_NVM_GET_USAGE_INFO_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&payload, + ( sizeof( DD_NVM_GET_FP_USAGE_INFO_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); + } + + // Move to Send Idle State + state = NVM_SEND_RECORD_STATE_IDLE; + + return state; +} + +/*********************************************************************//** + * @brief + * The handleSendDDUsageInfoRecord function sends the DD usage + * information record. + * @details \b Inputs: None + * @details \b Outputs: None + * @return state next state of the state machine + *************************************************************************/ +static SEND_RECORD_STATE_T handleSendDDUsageInfoRecord( void ) +{ + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + DD_NVM_GET_DD_USAGE_INFO_REC_PAYLOAD_T payload; + + // Get the record + if ( TRUE == getNVMRecord( NV_DD_DATA_DD_USAGE_INFO_RECORD, + (U08*)&payload.data, + sizeof( USAGE_RECORD_DD_T ), + 0, + ALARM_ID_DD_NVM_INVALID_USAGE_RECORD_CRC ) ) + { + payload.accepted = TRUE; + payload.rejectionReason = 0; + + // Send the record + sendMessage( MSG_ID_DD_UI_NVM_GET_USAGE_INFO_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&payload, + ( sizeof( DD_NVM_GET_DD_USAGE_INFO_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); + } + + // Move to Send Idle State + state = NVM_SEND_RECORD_STATE_IDLE; + + return state; +} + +/*********************************************************************//** + * @brief * The monitorNewCalSignal function monitors the new calibration signal * and clears it when the timeout has elapsed. * @details \b Inputs: isNewCalRecordAvailable, @@ -1311,55 +1445,55 @@ /*********************************************************************//** * @brief - * The handleDDGetServicRecRequest function processes a request to - * publish the service record. If the NVM send state machine is idle, - * it schedules the service record for publishing; otherwise, it sends + * The handleFPGetServicRecRequest function processes a request to + * publish the FP service record. If the NVM msg queue is not full + * it schedules the FP service record for publishing; otherwise, it sends * a rejection response. - * @details \b Inputs: nvMExecSendRecordState - * @details \b Outputs: isPublishRecordRequested + * @details \b Inputs: None + * @details \b Outputs: None * @param message Pointer to the received message * @return TRUE if the request was accepted otherwise FALSE *************************************************************************/ -BOOL handleDDGetServicRecRequest( MESSAGE_T *message ) +BOOL handleFPGetServicRecRequest( MESSAGE_T *message ) { BOOL result = FALSE; - DD_NVM_GET_SERVICE_REC_PAYLOAD_T response = { 0 }; + DD_NVM_GET_FP_SERVICE_REC_PAYLOAD_T response = { 0 }; NVM_MSG_REQUEST_Q_T newRequest; newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; - newRequest.recordType = NV_DD_DATA_SERVICE_RECORD; + newRequest.recordType = NV_DD_DATA_FP_SERVICE_RECORD; newRequest.idx = 0; result = enqueueNVMsgRequest( newRequest ); if ( FALSE == result ) { response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; - sendMessage( MSG_ID_DD_UI_NVM_GET_SERVICE_RECORD_RESPONSE, + sendMessage( MSG_ID_FP_UI_NVM_GET_SERVICE_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, - sizeof( DD_NVM_GET_SERVICE_REC_PAYLOAD_T ) ); + sizeof( DD_NVM_GET_FP_SERVICE_REC_PAYLOAD_T ) ); } return result; } /*********************************************************************//** * @brief - * The handleDDSetServicRecRequest function processes a request to + * The handleFPSetServicRecRequest function processes a request to * update the service record. It validates the request format, updates * the record, schedules it for NV storage, and sends a response. * @details \b Inputs: none * @details \b Outputs: none * @param message Pointer to the received message * @return TRUE if the request was accepted otherwise FALSE *************************************************************************/ -BOOL handleDDSetServicRecRequest( MESSAGE_T *message ) +BOOL handleFPSetServicRecRequest( MESSAGE_T *message ) { - BOOL result = FALSE; - U08 expectedPayloadLen = sizeof( DD_SERVICE_RECORD_T ) - sizeof( U16 ); - DD_NVM_SET_SERVICE_REC_PAYLOAD_T response = { 0 }; - DD_SERVICE_RECORD_T record; + BOOL result = FALSE; + U08 expectedPayloadLen = sizeof( SERVICE_RECORD_FP_T ) - sizeof( U16 ); + DD_NVM_SET_FP_SERVICE_REC_PAYLOAD_T response = { 0 }; + SERVICE_RECORD_FP_T record; // Service record can be updated only in service mode if ( DD_MODE_SERV == getCurrentOperationMode() ) @@ -1368,7 +1502,7 @@ { memcpy( &record, message->payload, expectedPayloadLen ); record.crc = crc16( (U08*)&record, expectedPayloadLen ); - setNVMRecord( NV_DD_DATA_SERVICE_RECORD, (U08*)&record, 0 ); + setNVMRecord( NV_DD_DATA_FP_SERVICE_RECORD, (U08*)&record, 0 ); result = enqueueEraseAndWriteSector( NVM_SERVICE_RECORD ); if ( TRUE == result ) @@ -1391,344 +1525,104 @@ response.rejectionReason = REQUEST_REJECT_REASON_NVM_INVALID_OPERATION_MODE; } - sendMessage( MSG_ID_DD_UI_NVM_SET_SERVICE_RECORD_RESPONSE, + sendMessage( MSG_ID_FP_UI_NVM_SET_SERVICE_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, - sizeof( DD_NVM_SET_SERVICE_REC_PAYLOAD_T ) ); + sizeof( DD_NVM_SET_FP_SERVICE_REC_PAYLOAD_T ) ); return result; } /*********************************************************************//** * @brief - * The handleDDGetUsageInfoRecRequest function processes a request to - * publish the usage information record. If the NVM send state machine - * is idle, it schedules the usage information record for publishing; - * otherwise, it sends a rejection response. + * The handleDDGetServicRecRequest function processes a request to + * publish the service record. If the NVM send state machine is idle, + * it schedules the service record for publishing; otherwise, it sends + * a rejection response. * @details \b Inputs: nvMExecSendRecordState * @details \b Outputs: isPublishRecordRequested * @param message Pointer to the received message * @return TRUE if the request was accepted otherwise FALSE *************************************************************************/ -BOOL handleDDGetUsageInfoRecRequest( MESSAGE_T *message ) +BOOL handleDDGetServicRecRequest( MESSAGE_T *message ) { - BOOL result = FALSE; - DD_NVM_GET_USAGE_INFO_REC_PAYLOAD_T response = { 0 }; + BOOL result = FALSE; + DD_NVM_GET_DD_SERVICE_REC_PAYLOAD_T response = { 0 }; NVM_MSG_REQUEST_Q_T newRequest; newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; - newRequest.recordType = NV_DD_DATA_USAGE_INFO_RECORD; + newRequest.recordType = NV_DD_DATA_DD_SERVICE_RECORD; newRequest.idx = 0; result = enqueueNVMsgRequest( newRequest ); if ( FALSE == result ) { response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; - sendMessage( MSG_ID_DD_UI_NVM_GET_USAGE_INFO_RECORD_RESPONSE, + sendMessage( MSG_ID_DD_UI_NVM_GET_SERVICE_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, - sizeof( DD_NVM_GET_USAGE_INFO_REC_PAYLOAD_T ) ); + sizeof( DD_NVM_GET_DD_SERVICE_REC_PAYLOAD_T ) ); } return result; } /*********************************************************************//** * @brief - * The handleDDSetUsageInfoRecRequest function processes a request to - * update the usage information record. It validates the request - * format, updates the record, schedules it for NV storage, and sends - * a response. + * The handleDDSetServicRecRequest function processes a request to + * update the service record. It validates the request format, updates + * the record, schedules it for NV storage, and sends a response. * @details \b Inputs: none * @details \b Outputs: none * @param message Pointer to the received message * @return TRUE if the request was accepted otherwise FALSE *************************************************************************/ -BOOL handleDDSetUsageInfoRecRequest( MESSAGE_T *message ) +BOOL handleDDSetServicRecRequest( MESSAGE_T *message ) { - BOOL result = FALSE; - U08 expectedPayloadLen = sizeof( DD_USAGE_INFO_RECORD_T ) - sizeof( U16 ); - DD_NVM_SET_USAGE_INFO_REC_PAYLOAD_T response = { 0 }; - DD_USAGE_INFO_RECORD_T record; + BOOL result = FALSE; + U08 expectedPayloadLen = sizeof( SERVICE_RECORD_DD_T ) - sizeof( U16 ); + DD_NVM_SET_DD_SERVICE_REC_PAYLOAD_T response = { 0 }; + SERVICE_RECORD_DD_T record; - if ( message->hdr.payloadLen == expectedPayloadLen ) + // Service record can be updated only in service mode + if ( DD_MODE_SERV == getCurrentOperationMode() ) { - memcpy( &record, message->payload, expectedPayloadLen ); - record.crc = crc16( (U08*)&record, expectedPayloadLen ); - setNVMRecord( NV_DD_DATA_USAGE_INFO_RECORD, (U08*)&record, 0 ); - result = enqueueEraseAndWriteSector( NVM_USAGE_INFO_RECORD ); - - if ( TRUE == result ) + if ( message->hdr.payloadLen == expectedPayloadLen ) { - sendNVEvent( NVM_USAGE_INFO_RECORD, 0, 0 ); - response.accepted = TRUE; - } - else - { - response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; - } - } - else - { - response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; - } + memcpy( &record, message->payload, expectedPayloadLen ); + record.crc = crc16( (U08*)&record, expectedPayloadLen ); + setNVMRecord( NV_DD_DATA_DD_SERVICE_RECORD, (U08*)&record, 0 ); + result = enqueueEraseAndWriteSector( NVM_SERVICE_RECORD ); - sendMessage( MSG_ID_DD_UI_NVM_SET_USAGE_INFO_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, - sizeof( DD_NVM_SET_USAGE_INFO_REC_PAYLOAD_T ) ); - - return result; -} - -/*********************************************************************//** - * @brief - * The handleDDGetInstitBasicRecRequest function processes a request to - * publish the institutional basic record. If the NVM send state - * machine is idle, it schedules the institutional basic record for - * publishing; otherwise, it sends a rejection response. - * @details \b Inputs: nvMExecSendRecordState - * @details \b Outputs: isPublishRecordRequested - * @param message Pointer to the received message - * @return TRUE if the request was accepted otherwise FALSE - *************************************************************************/ -BOOL handleDDGetInstitBasicRecRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T response = { 0 }; - NVM_MSG_REQUEST_Q_T newRequest; - - newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; - newRequest.recordType = NV_DD_DATA_INSTIT_BASIC_RECORD; - newRequest.idx = 0; - result = enqueueNVMsgRequest( newRequest ); - - if ( FALSE == result ) - { - response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; - - sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_BASIC_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08*)&response, - sizeof( DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T ) ); - } - - return result; -} - -/*********************************************************************//** - * @brief - * The handleDDSetInstitBasicRecRequest function processes a request to - * update the institutional basic record. It validates the request - * format, updates the record, schedules it for NV storage, and sends - * a response. - * @details \b Inputs: none - * @details \b Outputs: none - * @param message Pointer to the received message - * @return TRUE if the request was accepted otherwise FALSE - *************************************************************************/ -BOOL handleDDSetInstitBasicRecRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - U08 expectedPayloadLen = sizeof( DD_INSTIT_BASIC_RECORD_T ) - sizeof( U16 ); - DD_NVM_SET_INSTIT_BASIC_REC_PAYLOAD_T response = { 0 }; - DD_INSTIT_BASIC_RECORD_T record; - - if ( message->hdr.payloadLen == expectedPayloadLen ) - { - memcpy( &record, message->payload, expectedPayloadLen ); - record.crc = crc16( (U08*)&record, expectedPayloadLen ); - setNVMRecord( NV_DD_DATA_INSTIT_BASIC_RECORD, (U08*)&record, 0 ); - result = enqueueEraseAndWriteSector( NVM_INSTITUTIONAL_RECORD ); - - if ( TRUE == result ) - { - sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); - response.accepted = TRUE; + if ( TRUE == result ) + { + sendNVEvent( NVM_SERVICE_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } } else { - response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; } } else { - response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_INVALID_OPERATION_MODE; } - sendMessage( MSG_ID_DD_UI_NVM_SET_INSTIT_BASIC_RECORD_RESPONSE, + sendMessage( MSG_ID_DD_UI_NVM_SET_SERVICE_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, - sizeof( DD_NVM_SET_INSTIT_BASIC_REC_PAYLOAD_T ) ); + sizeof( DD_NVM_SET_DD_SERVICE_REC_PAYLOAD_T ) ); return result; } /*********************************************************************//** * @brief - * The handleDDGetInstitAdvancedRecRequest function processes a request - * to publish the institutional advanced record. If the NVM send state - * machine is idle, it schedules the institutional advanced record for - * publishing; otherwise, it sends a rejection response. - * @details \b Inputs: nvMExecSendRecordState - * @details \b Outputs: isPublishRecordRequested - * @param message Pointer to the received message - * @return TRUE if the request was accepted otherwise FALSE - *************************************************************************/ -BOOL handleDDGetInstitAdvancedRecRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T response = { 0 }; - NVM_MSG_REQUEST_Q_T newRequest; - - newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; - newRequest.recordType = NV_DD_DATA_INSTIT_ADVANCED_RECORD; - newRequest.idx = 0; - result = enqueueNVMsgRequest( newRequest ); - - if ( FALSE == result ) - { - response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; - - sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADVANCED_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08*)&response, - sizeof( DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T ) ); - } - - return result; -} - -/*********************************************************************//** - * @brief - * The handleDDSetInstitAdvancedRecRequest function processes a request - * to update the institutional advanced record. It validates the - * request format, updates the record, schedules it for NV storage, - * and sends a response. - * @details \b Inputs: none - * @details \b Outputs: none - * @param message Pointer to the received message - * @return TRUE if the request was accepted otherwise FALSE - *************************************************************************/ -BOOL handleDDSetInstitAdvancedRecRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - U08 expectedPayloadLen = sizeof( DD_INSTIT_ADVANCED_RECORD_T ) - sizeof( U16 ); - DD_NVM_SET_INSTIT_ADVANCED_REC_PAYLOAD_T response = { 0 }; - DD_INSTIT_ADVANCED_RECORD_T record; - - if ( message->hdr.payloadLen == expectedPayloadLen ) - { - memcpy( &record, message->payload, expectedPayloadLen ); - record.crc = crc16( (U08*)&record, expectedPayloadLen ); - setNVMRecord( NV_DD_DATA_INSTIT_ADVANCED_RECORD, (U08*)&record, 0 ); - result = enqueueEraseAndWriteSector( NVM_INSTITUTIONAL_RECORD ); - - if ( TRUE == result ) - { - sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); - response.accepted = TRUE; - } - else - { - response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; - } - } - else - { - response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; - } - - sendMessage( MSG_ID_DD_UI_NVM_SET_INSTIT_ADVANCED_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, - sizeof( DD_NVM_SET_INSTIT_ADVANCED_REC_PAYLOAD_T ) ); - - return result; -} - -/*********************************************************************//** - * @brief - * The handleDDGetInstitAdditionalRecRequest function processes a - * request to publish the institutional additional record. If the NVM - * send state machine is idle, it schedules the institutional - * additional record for publishing; otherwise, it sends a rejection - * response. - * @details \b Inputs: nvMExecSendRecordState - * @details \b Outputs: isPublishRecordRequested - * @param message Pointer to the received message - * @return TRUE if the request was accepted otherwise FALSE - *************************************************************************/ -BOOL handleDDGetInstitAdditionalRecRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T response = { 0 }; - NVM_MSG_REQUEST_Q_T newRequest; - - newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; - newRequest.recordType = NV_DD_DATA_INSTIT_ADDITIONAL_RECORD; - newRequest.idx = 0; - result = enqueueNVMsgRequest( newRequest ); - - if ( FALSE == result ) - { - response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; - - sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADDITIONAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08*)&response, - sizeof( DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T ) ); - } - - return result; -} - -/*********************************************************************//** - * @brief - * The handleDDSetInstitAdditionalRecRequest function processes a - * request to update the institutional additional record. It validates - * the request format, updates the record, schedules it for NV storage, - * and sends a response. - * @details \b Inputs: none - * @details \b Outputs: none - * @param message Pointer to the received message - * @return TRUE if the request was accepted otherwise FALSE - *************************************************************************/ -BOOL handleDDSetInstitAdditionalRecRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - U08 expectedPayloadLen = sizeof( DD_INSTIT_ADDITIONAL_RECORD_T ) - sizeof( U16 ); - DD_NVM_SET_INSTIT_ADDITIONAL_REC_PAYLOAD_T response = { 0 }; - DD_INSTIT_ADDITIONAL_RECORD_T record; - - if ( message->hdr.payloadLen == expectedPayloadLen ) - { - memcpy( &record, message->payload, expectedPayloadLen ); - record.crc = crc16( (U08*)&record, expectedPayloadLen ); - setNVMRecord( NV_DD_DATA_INSTIT_ADDITIONAL_RECORD, (U08*)&record, 0 ); - result = enqueueEraseAndWriteSector( NVM_INSTITUTIONAL_RECORD ); - - if ( TRUE == result ) - { - sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); - response.accepted = TRUE; - } - else - { - response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; - } - } - else - { - response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; - } - - sendMessage( MSG_ID_DD_UI_NVM_SET_INSTIT_ADDITIONAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, - sizeof( DD_NVM_SET_INSTIT_ADDITIONAL_REC_PAYLOAD_T ) ); - - return result; -} - -/*********************************************************************//** - * @brief * The handleDDGetPressureSensorCalRecRequest function processes a * request to publish a pressure sensor calibration record. It validates * the request payload and sensor index before scheduling the record @@ -2671,7 +2565,417 @@ return result; } +/*********************************************************************//** + * @brief + * The handleDDGetInstitBasicRecRequest function processes a request to + * publish the institutional basic record. If the NVM send state + * machine is idle, it schedules the institutional basic record for + * publishing; otherwise, it sends a rejection response. + * @details \b Inputs: nvMExecSendRecordState + * @details \b Outputs: isPublishRecordRequested + * @param message Pointer to the received message + * @return TRUE if the request was accepted otherwise FALSE + *************************************************************************/ +BOOL handleDDGetInstitBasicRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T response = { 0 }; + NVM_MSG_REQUEST_Q_T newRequest; + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_INSTIT_BASIC_RECORD; + newRequest.idx = 0; + result = enqueueNVMsgRequest( newRequest ); + + if ( FALSE == result ) + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_BASIC_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&response, + sizeof( DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T ) ); + } + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDDSetInstitBasicRecRequest function processes a request to + * update the institutional basic record. It validates the request + * format, updates the record, schedules it for NV storage, and sends + * a response. + * @details \b Inputs: none + * @details \b Outputs: none + * @param message Pointer to the received message + * @return TRUE if the request was accepted otherwise FALSE + *************************************************************************/ +BOOL handleDDSetInstitBasicRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U08 expectedPayloadLen = sizeof( DD_INSTIT_BASIC_RECORD_T ) - sizeof( U16 ); + DD_NVM_SET_INSTIT_BASIC_REC_PAYLOAD_T response = { 0 }; + DD_INSTIT_BASIC_RECORD_T record; + + if ( message->hdr.payloadLen == expectedPayloadLen ) + { + memcpy( &record, message->payload, expectedPayloadLen ); + record.crc = crc16( (U08*)&record, expectedPayloadLen ); + setNVMRecord( NV_DD_DATA_INSTIT_BASIC_RECORD, (U08*)&record, 0 ); + result = enqueueEraseAndWriteSector( NVM_INSTITUTIONAL_RECORD ); + + if ( TRUE == result ) + { + sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + sendMessage( MSG_ID_DD_UI_NVM_SET_INSTIT_BASIC_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, + sizeof( DD_NVM_SET_INSTIT_BASIC_REC_PAYLOAD_T ) ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDDGetInstitAdvancedRecRequest function processes a request + * to publish the institutional advanced record. If the NVM send state + * machine is idle, it schedules the institutional advanced record for + * publishing; otherwise, it sends a rejection response. + * @details \b Inputs: nvMExecSendRecordState + * @details \b Outputs: isPublishRecordRequested + * @param message Pointer to the received message + * @return TRUE if the request was accepted otherwise FALSE + *************************************************************************/ +BOOL handleDDGetInstitAdvancedRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T response = { 0 }; + NVM_MSG_REQUEST_Q_T newRequest; + + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_INSTIT_ADVANCED_RECORD; + newRequest.idx = 0; + result = enqueueNVMsgRequest( newRequest ); + + if ( FALSE == result ) + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADVANCED_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&response, + sizeof( DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T ) ); + } + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDDSetInstitAdvancedRecRequest function processes a request + * to update the institutional advanced record. It validates the + * request format, updates the record, schedules it for NV storage, + * and sends a response. + * @details \b Inputs: none + * @details \b Outputs: none + * @param message Pointer to the received message + * @return TRUE if the request was accepted otherwise FALSE + *************************************************************************/ +BOOL handleDDSetInstitAdvancedRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U08 expectedPayloadLen = sizeof( DD_INSTIT_ADVANCED_RECORD_T ) - sizeof( U16 ); + DD_NVM_SET_INSTIT_ADVANCED_REC_PAYLOAD_T response = { 0 }; + DD_INSTIT_ADVANCED_RECORD_T record; + + if ( message->hdr.payloadLen == expectedPayloadLen ) + { + memcpy( &record, message->payload, expectedPayloadLen ); + record.crc = crc16( (U08*)&record, expectedPayloadLen ); + setNVMRecord( NV_DD_DATA_INSTIT_ADVANCED_RECORD, (U08*)&record, 0 ); + result = enqueueEraseAndWriteSector( NVM_INSTITUTIONAL_RECORD ); + + if ( TRUE == result ) + { + sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + sendMessage( MSG_ID_DD_UI_NVM_SET_INSTIT_ADVANCED_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, + sizeof( DD_NVM_SET_INSTIT_ADVANCED_REC_PAYLOAD_T ) ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDDGetInstitAdditionalRecRequest function processes a + * request to publish the institutional additional record. If the NVM + * send state machine is idle, it schedules the institutional + * additional record for publishing; otherwise, it sends a rejection + * response. + * @details \b Inputs: nvMExecSendRecordState + * @details \b Outputs: isPublishRecordRequested + * @param message Pointer to the received message + * @return TRUE if the request was accepted otherwise FALSE + *************************************************************************/ +BOOL handleDDGetInstitAdditionalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T response = { 0 }; + NVM_MSG_REQUEST_Q_T newRequest; + + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_INSTIT_ADDITIONAL_RECORD; + newRequest.idx = 0; + result = enqueueNVMsgRequest( newRequest ); + + if ( FALSE == result ) + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADDITIONAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&response, + sizeof( DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T ) ); + } + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDDSetInstitAdditionalRecRequest function processes a + * request to update the institutional additional record. It validates + * the request format, updates the record, schedules it for NV storage, + * and sends a response. + * @details \b Inputs: none + * @details \b Outputs: none + * @param message Pointer to the received message + * @return TRUE if the request was accepted otherwise FALSE + *************************************************************************/ +BOOL handleDDSetInstitAdditionalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U08 expectedPayloadLen = sizeof( DD_INSTIT_ADDITIONAL_RECORD_T ) - sizeof( U16 ); + DD_NVM_SET_INSTIT_ADDITIONAL_REC_PAYLOAD_T response = { 0 }; + DD_INSTIT_ADDITIONAL_RECORD_T record; + + if ( message->hdr.payloadLen == expectedPayloadLen ) + { + memcpy( &record, message->payload, expectedPayloadLen ); + record.crc = crc16( (U08*)&record, expectedPayloadLen ); + setNVMRecord( NV_DD_DATA_INSTIT_ADDITIONAL_RECORD, (U08*)&record, 0 ); + result = enqueueEraseAndWriteSector( NVM_INSTITUTIONAL_RECORD ); + + if ( TRUE == result ) + { + sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + sendMessage( MSG_ID_DD_UI_NVM_SET_INSTIT_ADDITIONAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, + sizeof( DD_NVM_SET_INSTIT_ADDITIONAL_REC_PAYLOAD_T ) ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleFPGetUsageInfoRecRequest function processes a request to + * publish the FP usage information record. If the NVM send state machine + * is idle, it schedules the usage information record for publishing; + * otherwise, it sends a rejection response. + * @details \b Inputs: nvMExecSendRecordState + * @details \b Outputs: isPublishRecordRequested + * @param message Pointer to the received message + * @return TRUE if the request was accepted otherwise FALSE + *************************************************************************/ +BOOL handleFPGetUsageInfoRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_FP_USAGE_INFO_REC_PAYLOAD_T response = { 0 }; + NVM_MSG_REQUEST_Q_T newRequest; + + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_FP_USAGE_INFO_RECORD; + newRequest.idx = 0; + result = enqueueNVMsgRequest( newRequest ); + + if ( FALSE == result ) + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_FP_UI_NVM_GET_USAGE_INFO_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&response, + sizeof( DD_NVM_GET_FP_USAGE_INFO_REC_PAYLOAD_T ) ); + } + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDDSetUsageInfoRecRequest function processes a request to + * update the FP usage information record. It validates the request + * format, updates the record, schedules it for NV storage, and sends + * a response. + * @details \b Inputs: none + * @details \b Outputs: none + * @param message Pointer to the received message + * @return TRUE if the request was accepted otherwise FALSE + *************************************************************************/ +BOOL handleFPSetUsageInfoRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U08 expectedPayloadLen = sizeof( USAGE_RECORD_FP_T ) - sizeof( U16 ); + DD_NVM_SET_FP_USAGE_INFO_REC_PAYLOAD_T response = { 0 }; + USAGE_RECORD_FP_T record; + + if ( message->hdr.payloadLen == expectedPayloadLen ) + { + memcpy( &record, message->payload, expectedPayloadLen ); + record.crc = crc16( (U08*)&record, expectedPayloadLen ); + setNVMRecord( NV_DD_DATA_FP_USAGE_INFO_RECORD, (U08*)&record, 0 ); + result = enqueueEraseAndWriteSector( NVM_USAGE_INFO_RECORD ); + + if ( TRUE == result ) + { + sendNVEvent( NVM_USAGE_INFO_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + sendMessage( MSG_ID_FP_UI_NVM_SET_USAGE_INFO_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, + sizeof( DD_NVM_SET_FP_USAGE_INFO_REC_PAYLOAD_T ) ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDDGetUsageInfoRecRequest function processes a request to + * publish the DD usage information record. If the NVM send state machine + * is idle, it schedules the usage information record for publishing; + * otherwise, it sends a rejection response. + * @details \b Inputs: nvMExecSendRecordState + * @details \b Outputs: isPublishRecordRequested + * @param message Pointer to the received message + * @return TRUE if the request was accepted otherwise FALSE + *************************************************************************/ +BOOL handleDDGetUsageInfoRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_DD_USAGE_INFO_REC_PAYLOAD_T response = { 0 }; + NVM_MSG_REQUEST_Q_T newRequest; + + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_DD_USAGE_INFO_RECORD; + newRequest.idx = 0; + result = enqueueNVMsgRequest( newRequest ); + + if ( FALSE == result ) + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_USAGE_INFO_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&response, + sizeof( DD_NVM_GET_DD_USAGE_INFO_REC_PAYLOAD_T ) ); + } + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDDSetUsageInfoRecRequest function processes a request to + * update the DD usage information record. It validates the request + * format, updates the record, schedules it for NV storage, and sends + * a response. + * @details \b Inputs: none + * @details \b Outputs: none + * @param message Pointer to the received message + * @return TRUE if the request was accepted otherwise FALSE + *************************************************************************/ +BOOL handleDDSetUsageInfoRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U08 expectedPayloadLen = sizeof( USAGE_RECORD_DD_T ) - sizeof( U16 ); + DD_NVM_SET_DD_USAGE_INFO_REC_PAYLOAD_T response = { 0 }; + USAGE_RECORD_DD_T record; + + if ( message->hdr.payloadLen == expectedPayloadLen ) + { + memcpy( &record, message->payload, expectedPayloadLen ); + record.crc = crc16( (U08*)&record, expectedPayloadLen ); + setNVMRecord( NV_DD_DATA_DD_USAGE_INFO_RECORD, (U08*)&record, 0 ); + result = enqueueEraseAndWriteSector( NVM_USAGE_INFO_RECORD ); + + if ( TRUE == result ) + { + sendNVEvent( NVM_USAGE_INFO_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + sendMessage( MSG_ID_DD_UI_NVM_SET_USAGE_INFO_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, + sizeof( DD_NVM_SET_DD_USAGE_INFO_REC_PAYLOAD_T ) ); + + return result; +} + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/