diff --git a/app/service/ocpp/command/boot-notification/boot.notification.ts b/app/service/ocpp/command/boot-notification/boot.notification.ts index ef09d93..a885fb3 100644 --- a/app/service/ocpp/command/boot-notification/boot.notification.ts +++ b/app/service/ocpp/command/boot-notification/boot.notification.ts @@ -61,15 +61,21 @@ function BootNotification( ); if (validation.length > 0) { - w.Write(CreateError(ErrorCode.PropertyConstraintViolation, validation)); + w.Write( + CreateError(ErrorCode.PropertyConstraintViolation, validation, frame.uuid) + ); return retry(w); } if (result.status == Status.PENDING) { w.Write( - CreateError(ErrorCode.NotSupported, { - err: 'Pending functionality is not supported', - }) + CreateError( + ErrorCode.NotSupported, + { + err: 'Pending functionality is not supported', + }, + frame.uuid + ) ); return retry(w); diff --git a/app/service/ocpp/command/remote/remote.start.transaction.ts b/app/service/ocpp/command/remote/remote.start.transaction.ts index b0d26d1..af31bf7 100644 --- a/app/service/ocpp/command/remote/remote.start.transaction.ts +++ b/app/service/ocpp/command/remote/remote.start.transaction.ts @@ -31,7 +31,13 @@ export function RemoteStartTransactionReq( ); if (validation.length > 0) { - w.Write(CreateError(ErrorCode.PropertyConstraintViolation, validation)); + w.Write( + CreateError( + ErrorCode.PropertyConstraintViolation, + validation, + frame.uuid + ) + ); return; } diff --git a/app/service/ocpp/command/remote/remote.stop.transaction.ts b/app/service/ocpp/command/remote/remote.stop.transaction.ts index 7d3a479..c5de746 100644 --- a/app/service/ocpp/command/remote/remote.stop.transaction.ts +++ b/app/service/ocpp/command/remote/remote.stop.transaction.ts @@ -30,7 +30,13 @@ export function RemoteStopTransactionReq( ); if (validation.length > 0) { - w.Write(CreateError(ErrorCode.PropertyConstraintViolation, validation)); + w.Write( + CreateError( + ErrorCode.PropertyConstraintViolation, + validation, + frame.uuid + ) + ); return; } @@ -38,9 +44,13 @@ export function RemoteStopTransactionReq( const session = GetSession(); if (session.transactionId != result.transactionId) { w.Write( - CreateError(ErrorCode.SecurityError, { - error: 'transaction id violation', - }) + CreateError( + ErrorCode.SecurityError, + { + error: 'transaction id violation', + }, + frame.uuid + ) ); return; } diff --git a/app/service/ocpp/ocpp.error.ts b/app/service/ocpp/ocpp.error.ts index 00a29e6..d200de7 100644 --- a/app/service/ocpp/ocpp.error.ts +++ b/app/service/ocpp/ocpp.error.ts @@ -17,7 +17,11 @@ enum ErrorCode { GenericError = 'A generic error has occurred', } -function CreateError(errCode: ErrorCode, details: ErrorDetails): ErrorTuple { +function CreateError( + errCode: ErrorCode, + details: ErrorDetails, + uuid?: string +): ErrorTuple { const keyValue = Object.entries(ErrorCode).find((v) => v[1] == errCode); let code = ''; @@ -29,7 +33,7 @@ function CreateError(errCode: ErrorCode, details: ErrorDetails): ErrorTuple { code = keyValue[0]; } - return [CallType.CALL_ERROR, v4(), code, errCode, details]; + return [CallType.CALL_ERROR, uuid ?? v4(), code, errCode, details]; } function GetError(payload: ErrorTuple | BaseTuple): IErrorFrame {