Skip to content

Commit

Permalink
fix miss match uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
Nasar165 committed May 27, 2024
1 parent 805736c commit 9cef693
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
14 changes: 10 additions & 4 deletions app/service/ocpp/command/boot-notification/boot.notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 7 additions & 1 deletion app/service/ocpp/command/remote/remote.start.transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
18 changes: 14 additions & 4 deletions app/service/ocpp/command/remote/remote.stop.transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,27 @@ export function RemoteStopTransactionReq(
);

if (validation.length > 0) {
w.Write(CreateError(ErrorCode.PropertyConstraintViolation, validation));
w.Write(
CreateError(
ErrorCode.PropertyConstraintViolation,
validation,
frame.uuid
)
);
return;
}

status.status = Status.ACCEPTED;
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;
}
Expand Down
8 changes: 6 additions & 2 deletions app/service/ocpp/ocpp.error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';

Expand All @@ -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 {
Expand Down

0 comments on commit 9cef693

Please sign in to comment.