]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commit
feat(ocpp2): OCPP 2.0.1 Core certification readiness (#1712)
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 12 Mar 2026 18:57:32 +0000 (19:57 +0100)
committerGitHub <noreply@github.com>
Thu, 12 Mar 2026 18:57:32 +0000 (19:57 +0100)
commitefa6368be0d7d89e50917ec489a8c5e4f467e359
tree2686486ce2bc03813cc260df5d078b68cb5efca1
parent85851c6f5c5ef45fc6d26c3238adc0e1700a8b91
feat(ocpp2): OCPP 2.0.1 Core certification readiness (#1712)

* feat(ocpp2): add type definitions and validator configs for OCPP 2.0.1 Core certification commands

* feat(ocpp2): implement DataTransfer reject handler

* feat(ocpp2): implement SetNetworkProfile reject handler

* feat(ocpp2): implement GetTransactionStatus handler

* feat(ocpp2): implement CustomerInformation clear handler

* feat(ocpp2): implement SecurityEventNotification outgoing command

* fix(ocpp2): handle TransactionEvent response idTokenInfo status

* feat(ocpp2): implement ChangeAvailability handler

* feat(ocpp2): implement standalone MeterValues outgoing command

* feat(ocpp2): implement UpdateFirmware and FirmwareStatusNotification

Add UpdateFirmware (CSMS→CS) incoming request handler with simulated
firmware update lifecycle state machine (Downloading → Downloaded →
SignatureVerified → Installing → Installed) and FirmwareStatusNotification
(CS→CSMS) outgoing command.

- Handle UPDATE_FIRMWARE incoming request, return Accepted status
- Simulate firmware update lifecycle via chained setTimeout calls
- Send FirmwareStatusNotification at each state transition
- Check firmware.signature presence for SignatureVerified state
- Add testable interfaces for both handler and request service
- Add 8 tests (5 for UpdateFirmware, 3 for FirmwareStatusNotification)

* feat(ocpp2): implement GetLog and LogStatusNotification

- Add GetLog incoming request handler with simulated upload lifecycle
  (Uploading → Uploaded via chained setTimeout)
- Add LogStatusNotification outgoing command in RequestService
- Register handleResponseLogStatusNotification in ResponseService
- Update testable interfaces with new handler and request method
- Add 4 GetLog tests (DiagnosticsLog, SecurityLog, requestId, retries)
- Add 3 LogStatusNotification tests (Uploading, requestId, empty response)
- All quality gates pass: lint, typecheck, build, 1737 tests

* feat(ocpp2): expand TriggerMessage handler with new trigger types

* docs: update README with OCPP 2.0.1 Core certification commands

* style(ocpp2): fix space-before-function-paren in TriggerMessage handler and test

* fix(ocpp2): add missing case branches in buildRequestPayload for new commands

buildRequestPayload throws NOT_SUPPORTED for FirmwareStatusNotification,
LogStatusNotification, MeterValues, NotifyCustomerInformation, and
SecurityEventNotification since they have no case branches. This causes
guaranteed runtime failures when TriggerMessage invokes requestHandler
for these commands.

Add pass-through case branches matching the existing pattern used by
other notification commands.

* fix(ocpp2): use zero-based seqNo in NotifyCustomerInformation per OCPP 2.0.1 spec

* fix(ocpp2): stop only specific transaction in handleResponseTransactionEvent

handleResponseTransactionEvent was stopping ALL active transactions when
any rejected idTokenInfo.status arrived. Per OCPP 2.0.1 spec (D01/D05),
only the specific transaction referenced by the TransactionEvent request
should be stopped.

Extract the transactionId from the request payload and use
getConnectorIdByTransactionId/getEvseIdByTransactionId to find and stop
only the affected transaction.

* fix(ocpp2): set idle EVSEs Inoperative immediately on CS-level ChangeAvailability per G03.FR.04

* fix(ocpp2): add firmware lifecycle delay, JSDoc, and consistent handler patterns

- Add delay between Downloaded and SignatureVerified in firmware update lifecycle per J01
- Add missing JSDoc for requestLogStatusNotification in testable interface
- Convert 4 arrow function handlers to regular methods for consistency with pre-existing handlers

* refactor(ocpp2): resolve SonarCloud quality gate findings

- Replace duplicated delay() functions with shared sleep() utility
- Extract handleEvseChangeAvailability and handleCsLevelInoperative to
  reduce cognitive complexity of handleRequestChangeAvailability
- Extract hasAnyActiveTransaction to eliminate nested loops
- Fix negated conditions and nested template literals

* refactor(ocpp2): deduplicate validator configs via shared schema name maps

- Extract incomingRequestSchemaNames and outgoingRequestSchemaNames as
  single source of truth for command-to-schema mappings
- Generate request/response configs from shared maps, eliminating 96
  lines of structural duplication flagged by SonarCloud
- Fix remaining negated conditions in ternary expressions

* fix(test): deduplicate MeterValues call, add multi-EVSE isolation test

* fix(ocpp2): eliminate double status notification, document messagesInQueue

* test(ocpp2): align test files with TEST_STYLE_GUIDE conventions

* fix: comply with E14.FR.06 and harmonize statusInfo
26 files changed:
README.md
eslint.config.js
src/charging-station/ocpp/2.0/OCPP20Constants.ts
src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts
src/charging-station/ocpp/2.0/OCPP20RequestService.ts
src/charging-station/ocpp/2.0/OCPP20ResponseService.ts
src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts
src/charging-station/ocpp/2.0/__testable__/OCPP20RequestServiceTestable.ts
src/charging-station/ocpp/2.0/__testable__/index.ts
src/types/index.ts
src/types/ocpp/2.0/Common.ts
src/types/ocpp/2.0/Requests.ts
src/types/ocpp/2.0/Responses.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-ChangeAvailability.test.ts [new file with mode: 0644]
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-CustomerInformation.test.ts [new file with mode: 0644]
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-DataTransfer.test.ts [new file with mode: 0644]
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetLog.test.ts [new file with mode: 0644]
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetTransactionStatus.test.ts [new file with mode: 0644]
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-SetNetworkProfile.test.ts [new file with mode: 0644]
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-TriggerMessage.test.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-UpdateFirmware.test.ts [new file with mode: 0644]
tests/charging-station/ocpp/2.0/OCPP20RequestService-FirmwareStatusNotification.test.ts [new file with mode: 0644]
tests/charging-station/ocpp/2.0/OCPP20RequestService-LogStatusNotification.test.ts [new file with mode: 0644]
tests/charging-station/ocpp/2.0/OCPP20RequestService-MeterValues.test.ts [new file with mode: 0644]
tests/charging-station/ocpp/2.0/OCPP20RequestService-SecurityEventNotification.test.ts [new file with mode: 0644]
tests/charging-station/ocpp/2.0/OCPP20ResponseService-TransactionEvent.test.ts