1 // Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
4 import path from
'path';
5 import { URL
, fileURLToPath
} from
'url';
7 import type { JSONSchemaType
} from
'ajv';
8 import { Client
, type FTPResponse
} from
'basic-ftp';
11 import { OCPP16ServiceUtils
} from
'./OCPP16ServiceUtils';
12 import OCPPError from
'../../../exception/OCPPError';
13 import type { JsonObject
, JsonType
} from
'../../../types/JsonType';
14 import { OCPP16ChargePointErrorCode
} from
'../../../types/ocpp/1.6/ChargePointErrorCode';
15 import { OCPP16ChargePointStatus
} from
'../../../types/ocpp/1.6/ChargePointStatus';
17 ChargingProfilePurposeType
,
18 type OCPP16ChargingProfile
,
19 } from
'../../../types/ocpp/1.6/ChargingProfile';
21 OCPP16StandardParametersKey
,
22 OCPP16SupportedFeatureProfiles
,
23 } from
'../../../types/ocpp/1.6/Configuration';
24 import { OCPP16DiagnosticsStatus
} from
'../../../types/ocpp/1.6/DiagnosticsStatus';
26 type ChangeAvailabilityRequest
,
27 type ChangeConfigurationRequest
,
28 type ClearChargingProfileRequest
,
29 type GetConfigurationRequest
,
30 type GetDiagnosticsRequest
,
31 OCPP16AvailabilityType
,
32 type OCPP16BootNotificationRequest
,
33 type OCPP16ClearCacheRequest
,
34 type OCPP16DataTransferRequest
,
35 OCPP16DataTransferVendorId
,
36 type OCPP16DiagnosticsStatusNotificationRequest
,
38 type OCPP16FirmwareStatusNotificationRequest
,
39 type OCPP16HeartbeatRequest
,
40 OCPP16IncomingRequestCommand
,
43 type OCPP16StatusNotificationRequest
,
44 type OCPP16TriggerMessageRequest
,
45 type OCPP16UpdateFirmwareRequest
,
46 type RemoteStartTransactionRequest
,
47 type RemoteStopTransactionRequest
,
49 type SetChargingProfileRequest
,
50 type UnlockConnectorRequest
,
51 } from
'../../../types/ocpp/1.6/Requests';
53 type ChangeAvailabilityResponse
,
54 type ChangeConfigurationResponse
,
55 type ClearChargingProfileResponse
,
56 type GetConfigurationResponse
,
57 type GetDiagnosticsResponse
,
58 type OCPP16BootNotificationResponse
,
59 type OCPP16DataTransferResponse
,
60 OCPP16DataTransferStatus
,
61 type OCPP16DiagnosticsStatusNotificationResponse
,
62 type OCPP16FirmwareStatusNotificationResponse
,
63 type OCPP16HeartbeatResponse
,
64 type OCPP16StatusNotificationResponse
,
65 type OCPP16TriggerMessageResponse
,
66 type OCPP16UpdateFirmwareResponse
,
67 type SetChargingProfileResponse
,
68 type UnlockConnectorResponse
,
69 } from
'../../../types/ocpp/1.6/Responses';
71 OCPP16AuthorizationStatus
,
72 type OCPP16AuthorizeRequest
,
73 type OCPP16AuthorizeResponse
,
74 type OCPP16StartTransactionRequest
,
75 type OCPP16StartTransactionResponse
,
76 OCPP16StopTransactionReason
,
77 } from
'../../../types/ocpp/1.6/Transaction';
78 import type { OCPPConfigurationKey
} from
'../../../types/ocpp/Configuration';
79 import { ErrorType
} from
'../../../types/ocpp/ErrorType';
80 import { OCPPVersion
} from
'../../../types/ocpp/OCPPVersion';
81 import type { IncomingRequestHandler
} from
'../../../types/ocpp/Requests';
82 import type { GenericResponse
} from
'../../../types/ocpp/Responses';
83 import Constants from
'../../../utils/Constants';
84 import logger from
'../../../utils/Logger';
85 import Utils from
'../../../utils/Utils';
86 import type ChargingStation from
'../../ChargingStation';
87 import { ChargingStationConfigurationUtils
} from
'../../ChargingStationConfigurationUtils';
88 import { ChargingStationUtils
} from
'../../ChargingStationUtils';
89 import OCPPConstants from
'../OCPPConstants';
90 import OCPPIncomingRequestService from
'../OCPPIncomingRequestService';
92 const moduleName
= 'OCPP16IncomingRequestService';
94 export default class OCPP16IncomingRequestService
extends OCPPIncomingRequestService
{
95 protected jsonSchemas
: Map
<OCPP16IncomingRequestCommand
, JSONSchemaType
<JsonObject
>>;
96 private incomingRequestHandlers
: Map
<OCPP16IncomingRequestCommand
, IncomingRequestHandler
>;
98 public constructor() {
99 if (new.target
?.name
=== moduleName
) {
100 throw new TypeError(`Cannot construct ${new.target?.name} instances directly`);
102 super(OCPPVersion
.VERSION_16
);
103 this.incomingRequestHandlers
= new Map
<OCPP16IncomingRequestCommand
, IncomingRequestHandler
>([
104 [OCPP16IncomingRequestCommand
.RESET
, this.handleRequestReset
.bind(this)],
105 [OCPP16IncomingRequestCommand
.CLEAR_CACHE
, this.handleRequestClearCache
.bind(this)],
106 [OCPP16IncomingRequestCommand
.UNLOCK_CONNECTOR
, this.handleRequestUnlockConnector
.bind(this)],
108 OCPP16IncomingRequestCommand
.GET_CONFIGURATION
,
109 this.handleRequestGetConfiguration
.bind(this),
112 OCPP16IncomingRequestCommand
.CHANGE_CONFIGURATION
,
113 this.handleRequestChangeConfiguration
.bind(this),
116 OCPP16IncomingRequestCommand
.SET_CHARGING_PROFILE
,
117 this.handleRequestSetChargingProfile
.bind(this),
120 OCPP16IncomingRequestCommand
.CLEAR_CHARGING_PROFILE
,
121 this.handleRequestClearChargingProfile
.bind(this),
124 OCPP16IncomingRequestCommand
.CHANGE_AVAILABILITY
,
125 this.handleRequestChangeAvailability
.bind(this),
128 OCPP16IncomingRequestCommand
.REMOTE_START_TRANSACTION
,
129 this.handleRequestRemoteStartTransaction
.bind(this),
132 OCPP16IncomingRequestCommand
.REMOTE_STOP_TRANSACTION
,
133 this.handleRequestRemoteStopTransaction
.bind(this),
135 [OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
, this.handleRequestGetDiagnostics
.bind(this)],
136 [OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
, this.handleRequestTriggerMessage
.bind(this)],
137 [OCPP16IncomingRequestCommand
.DATA_TRANSFER
, this.handleRequestDataTransfer
.bind(this)],
138 [OCPP16IncomingRequestCommand
.UPDATE_FIRMWARE
, this.handleRequestUpdateFirmware
.bind(this)],
140 this.jsonSchemas
= new Map
<OCPP16IncomingRequestCommand
, JSONSchemaType
<JsonObject
>>([
142 OCPP16IncomingRequestCommand
.RESET
,
143 this.parseJsonSchemaFile
<ResetRequest
>('../../../assets/json-schemas/ocpp/1.6/Reset.json'),
146 OCPP16IncomingRequestCommand
.CLEAR_CACHE
,
147 this.parseJsonSchemaFile
<OCPP16ClearCacheRequest
>(
148 '../../../assets/json-schemas/ocpp/1.6/ClearCache.json'
152 OCPP16IncomingRequestCommand
.UNLOCK_CONNECTOR
,
153 this.parseJsonSchemaFile
<UnlockConnectorRequest
>(
154 '../../../assets/json-schemas/ocpp/1.6/UnlockConnector.json'
158 OCPP16IncomingRequestCommand
.GET_CONFIGURATION
,
159 this.parseJsonSchemaFile
<GetConfigurationRequest
>(
160 '../../../assets/json-schemas/ocpp/1.6/GetConfiguration.json'
164 OCPP16IncomingRequestCommand
.CHANGE_CONFIGURATION
,
165 this.parseJsonSchemaFile
<ChangeConfigurationRequest
>(
166 '../../../assets/json-schemas/ocpp/1.6/ChangeConfiguration.json'
170 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
,
171 this.parseJsonSchemaFile
<GetDiagnosticsRequest
>(
172 '../../../assets/json-schemas/ocpp/1.6/GetDiagnostics.json'
176 OCPP16IncomingRequestCommand
.SET_CHARGING_PROFILE
,
177 this.parseJsonSchemaFile
<SetChargingProfileRequest
>(
178 '../../../assets/json-schemas/ocpp/1.6/SetChargingProfile.json'
182 OCPP16IncomingRequestCommand
.CLEAR_CHARGING_PROFILE
,
183 this.parseJsonSchemaFile
<ClearChargingProfileRequest
>(
184 '../../../assets/json-schemas/ocpp/1.6/ClearChargingProfile.json'
188 OCPP16IncomingRequestCommand
.CHANGE_AVAILABILITY
,
189 this.parseJsonSchemaFile
<ChangeAvailabilityRequest
>(
190 '../../../assets/json-schemas/ocpp/1.6/ChangeAvailability.json'
194 OCPP16IncomingRequestCommand
.REMOTE_START_TRANSACTION
,
195 this.parseJsonSchemaFile
<RemoteStartTransactionRequest
>(
196 '../../../assets/json-schemas/ocpp/1.6/RemoteStartTransaction.json'
200 OCPP16IncomingRequestCommand
.REMOTE_STOP_TRANSACTION
,
201 this.parseJsonSchemaFile
<RemoteStopTransactionRequest
>(
202 '../../../assets/json-schemas/ocpp/1.6/RemoteStopTransaction.json'
206 OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
,
207 this.parseJsonSchemaFile
<OCPP16TriggerMessageRequest
>(
208 '../../../assets/json-schemas/ocpp/1.6/TriggerMessage.json'
212 OCPP16IncomingRequestCommand
.DATA_TRANSFER
,
213 this.parseJsonSchemaFile
<OCPP16DataTransferRequest
>(
214 '../../../assets/json-schemas/ocpp/1.6/DataTransfer.json'
218 OCPP16IncomingRequestCommand
.UPDATE_FIRMWARE
,
219 this.parseJsonSchemaFile
<OCPP16UpdateFirmwareRequest
>(
220 '../../../assets/json-schemas/ocpp/1.6/UpdateFirmware.json'
224 this.validatePayload
.bind(this);
227 public async incomingRequestHandler(
228 chargingStation
: ChargingStation
,
230 commandName
: OCPP16IncomingRequestCommand
,
231 commandPayload
: JsonType
233 let response
: JsonType
;
235 chargingStation
.getOcppStrictCompliance() === true &&
236 chargingStation
.isInPendingState() === true &&
237 (commandName
=== OCPP16IncomingRequestCommand
.REMOTE_START_TRANSACTION
||
238 commandName
=== OCPP16IncomingRequestCommand
.REMOTE_STOP_TRANSACTION
)
241 ErrorType
.SECURITY_ERROR
,
242 `${commandName} cannot be issued to handle request PDU ${JSON.stringify(
246 )} while the charging station is in pending state on the central server`,
252 chargingStation
.isRegistered() === true ||
253 (chargingStation
.getOcppStrictCompliance() === false &&
254 chargingStation
.isInUnknownState() === true)
257 this.incomingRequestHandlers
.has(commandName
) === true &&
258 OCPP16ServiceUtils
.isIncomingRequestCommandSupported(chargingStation
, commandName
) === true
261 this.validatePayload(chargingStation
, commandName
, commandPayload
);
262 // Call the method to build the response
263 response
= await this.incomingRequestHandlers
.get(commandName
)(
270 `${chargingStation.logPrefix()} ${moduleName}.incomingRequestHandler: Handle incoming request error:`,
278 ErrorType
.NOT_IMPLEMENTED
,
279 `${commandName} is not implemented to handle request PDU ${JSON.stringify(
290 ErrorType
.SECURITY_ERROR
,
291 `${commandName} cannot be issued to handle request PDU ${JSON.stringify(
295 )} while the charging station is not registered on the central server.`,
300 // Send the built response
301 await chargingStation
.ocppRequestService
.sendResponse(
309 private validatePayload(
310 chargingStation
: ChargingStation
,
311 commandName
: OCPP16IncomingRequestCommand
,
312 commandPayload
: JsonType
314 if (this.jsonSchemas
.has(commandName
) === true) {
315 return this.validateIncomingRequestPayload(
318 this.jsonSchemas
.get(commandName
),
323 `${chargingStation.logPrefix()} ${moduleName}.validatePayload: No JSON schema found for command '${commandName}' PDU validation`
328 // Simulate charging station restart
329 private handleRequestReset(
330 chargingStation
: ChargingStation
,
331 commandPayload
: ResetRequest
335 chargingStation
.reset
.bind(chargingStation
) as (
336 this: ChargingStation
,
340 `${commandPayload.type}Reset` as OCPP16StopTransactionReason
343 /* This is intentional */
346 `${chargingStation.logPrefix()} ${
348 } reset command received, simulating it. The station will be back online in ${Utils.formatDurationMilliSeconds(
349 chargingStation.stationInfo.resetTime
352 return OCPPConstants
.OCPP_RESPONSE_ACCEPTED
;
355 private async handleRequestUnlockConnector(
356 chargingStation
: ChargingStation
,
357 commandPayload
: UnlockConnectorRequest
358 ): Promise
<UnlockConnectorResponse
> {
359 const connectorId
= commandPayload
.connectorId
;
360 if (chargingStation
.connectors
.has(connectorId
) === false) {
362 `${chargingStation.logPrefix()} Trying to unlock a non existing connector Id ${connectorId.toString()}`
364 return OCPPConstants
.OCPP_RESPONSE_UNLOCK_NOT_SUPPORTED
;
366 if (connectorId
=== 0) {
368 `${chargingStation.logPrefix()} Trying to unlock connector Id ${connectorId.toString()}`
370 return OCPPConstants
.OCPP_RESPONSE_UNLOCK_NOT_SUPPORTED
;
372 if (chargingStation
.getConnectorStatus(connectorId
)?.transactionStarted
=== true) {
373 const stopResponse
= await chargingStation
.stopTransactionOnConnector(
375 OCPP16StopTransactionReason
.UNLOCK_COMMAND
377 if (stopResponse
.idTagInfo
?.status === OCPP16AuthorizationStatus
.ACCEPTED
) {
378 return OCPPConstants
.OCPP_RESPONSE_UNLOCKED
;
380 return OCPPConstants
.OCPP_RESPONSE_UNLOCK_FAILED
;
382 await chargingStation
.ocppRequestService
.requestHandler
<
383 OCPP16StatusNotificationRequest
,
384 OCPP16StatusNotificationResponse
385 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
387 status: OCPP16ChargePointStatus
.AVAILABLE
,
388 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
390 chargingStation
.getConnectorStatus(connectorId
).status = OCPP16ChargePointStatus
.AVAILABLE
;
391 return OCPPConstants
.OCPP_RESPONSE_UNLOCKED
;
394 private handleRequestGetConfiguration(
395 chargingStation
: ChargingStation
,
396 commandPayload
: GetConfigurationRequest
397 ): GetConfigurationResponse
{
398 const configurationKey
: OCPPConfigurationKey
[] = [];
399 const unknownKey
: string[] = [];
400 if (Utils
.isEmptyArray(commandPayload
.key
) === true) {
401 for (const configuration
of chargingStation
.ocppConfiguration
.configurationKey
) {
402 if (Utils
.isUndefined(configuration
.visible
) === true) {
403 configuration
.visible
= true;
405 if (configuration
.visible
=== false) {
408 configurationKey
.push({
409 key
: configuration
.key
,
410 readonly: configuration
.readonly,
411 value
: configuration
.value
,
415 for (const key
of commandPayload
.key
) {
416 const keyFound
= ChargingStationConfigurationUtils
.getConfigurationKey(
421 if (Utils
.isUndefined(keyFound
.visible
) === true) {
422 keyFound
.visible
= true;
424 if (keyFound
.visible
=== false) {
427 configurationKey
.push({
429 readonly: keyFound
.readonly,
430 value
: keyFound
.value
,
433 unknownKey
.push(key
);
443 private handleRequestChangeConfiguration(
444 chargingStation
: ChargingStation
,
445 commandPayload
: ChangeConfigurationRequest
446 ): ChangeConfigurationResponse
{
447 const keyToChange
= ChargingStationConfigurationUtils
.getConfigurationKey(
453 return OCPPConstants
.OCPP_CONFIGURATION_RESPONSE_NOT_SUPPORTED
;
454 } else if (keyToChange
&& keyToChange
.readonly) {
455 return OCPPConstants
.OCPP_CONFIGURATION_RESPONSE_REJECTED
;
456 } else if (keyToChange
&& !keyToChange
.readonly) {
457 let valueChanged
= false;
458 if (keyToChange
.value
!== commandPayload
.value
) {
459 ChargingStationConfigurationUtils
.setConfigurationKeyValue(
462 commandPayload
.value
,
467 let triggerHeartbeatRestart
= false;
468 if (keyToChange
.key
=== OCPP16StandardParametersKey
.HeartBeatInterval
&& valueChanged
) {
469 ChargingStationConfigurationUtils
.setConfigurationKeyValue(
471 OCPP16StandardParametersKey
.HeartbeatInterval
,
474 triggerHeartbeatRestart
= true;
476 if (keyToChange
.key
=== OCPP16StandardParametersKey
.HeartbeatInterval
&& valueChanged
) {
477 ChargingStationConfigurationUtils
.setConfigurationKeyValue(
479 OCPP16StandardParametersKey
.HeartBeatInterval
,
482 triggerHeartbeatRestart
= true;
484 if (triggerHeartbeatRestart
) {
485 chargingStation
.restartHeartbeat();
487 if (keyToChange
.key
=== OCPP16StandardParametersKey
.WebSocketPingInterval
&& valueChanged
) {
488 chargingStation
.restartWebSocketPing();
490 if (keyToChange
.reboot
) {
491 return OCPPConstants
.OCPP_CONFIGURATION_RESPONSE_REBOOT_REQUIRED
;
493 return OCPPConstants
.OCPP_CONFIGURATION_RESPONSE_ACCEPTED
;
497 private handleRequestSetChargingProfile(
498 chargingStation
: ChargingStation
,
499 commandPayload
: SetChargingProfileRequest
500 ): SetChargingProfileResponse
{
502 OCPP16ServiceUtils
.checkFeatureProfile(
504 OCPP16SupportedFeatureProfiles
.SmartCharging
,
505 OCPP16IncomingRequestCommand
.SET_CHARGING_PROFILE
508 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_NOT_SUPPORTED
;
510 if (chargingStation
.connectors
.has(commandPayload
.connectorId
) === false) {
512 `${chargingStation.logPrefix()} Trying to set charging profile(s) to a non existing connector Id ${
513 commandPayload.connectorId
516 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED
;
519 commandPayload
.csChargingProfiles
.chargingProfilePurpose
===
520 ChargingProfilePurposeType
.CHARGE_POINT_MAX_PROFILE
&&
521 commandPayload
.connectorId
!== 0
523 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED
;
526 commandPayload
.csChargingProfiles
.chargingProfilePurpose
===
527 ChargingProfilePurposeType
.TX_PROFILE
&&
528 (commandPayload
.connectorId
=== 0 ||
529 chargingStation
.getConnectorStatus(commandPayload
.connectorId
)?.transactionStarted
===
533 `${chargingStation.logPrefix()} Trying to set transaction charging profile(s) on connector ${
534 commandPayload.connectorId
535 } without a started transaction`
537 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED
;
539 OCPP16ServiceUtils
.setChargingProfile(
541 commandPayload
.connectorId
,
542 commandPayload
.csChargingProfiles
545 `${chargingStation.logPrefix()} Charging profile(s) set on connector id ${
546 commandPayload.connectorId
548 commandPayload
.csChargingProfiles
550 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_ACCEPTED
;
553 private handleRequestClearChargingProfile(
554 chargingStation
: ChargingStation
,
555 commandPayload
: ClearChargingProfileRequest
556 ): ClearChargingProfileResponse
{
558 OCPP16ServiceUtils
.checkFeatureProfile(
560 OCPP16SupportedFeatureProfiles
.SmartCharging
,
561 OCPP16IncomingRequestCommand
.CLEAR_CHARGING_PROFILE
564 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN
;
566 if (chargingStation
.connectors
.has(commandPayload
.connectorId
) === false) {
568 `${chargingStation.logPrefix()} Trying to clear a charging profile(s) to a non existing connector Id ${
569 commandPayload.connectorId
572 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN
;
574 const connectorStatus
= chargingStation
.getConnectorStatus(commandPayload
.connectorId
);
575 if (commandPayload
.connectorId
&& !Utils
.isEmptyArray(connectorStatus
.chargingProfiles
)) {
576 connectorStatus
.chargingProfiles
= [];
578 `${chargingStation.logPrefix()} Charging profile(s) cleared on connector id ${
579 commandPayload.connectorId
582 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_ACCEPTED
;
584 if (!commandPayload
.connectorId
) {
585 let clearedCP
= false;
586 for (const connectorId
of chargingStation
.connectors
.keys()) {
587 if (!Utils
.isEmptyArray(chargingStation
.getConnectorStatus(connectorId
).chargingProfiles
)) {
589 .getConnectorStatus(connectorId
)
590 .chargingProfiles
?.forEach((chargingProfile
: OCPP16ChargingProfile
, index
: number) => {
591 let clearCurrentCP
= false;
592 if (chargingProfile
.chargingProfileId
=== commandPayload
.id
) {
593 clearCurrentCP
= true;
596 !commandPayload
.chargingProfilePurpose
&&
597 chargingProfile
.stackLevel
=== commandPayload
.stackLevel
599 clearCurrentCP
= true;
602 !chargingProfile
.stackLevel
&&
603 chargingProfile
.chargingProfilePurpose
=== commandPayload
.chargingProfilePurpose
605 clearCurrentCP
= true;
608 chargingProfile
.stackLevel
=== commandPayload
.stackLevel
&&
609 chargingProfile
.chargingProfilePurpose
=== commandPayload
.chargingProfilePurpose
611 clearCurrentCP
= true;
613 if (clearCurrentCP
) {
614 connectorStatus
.chargingProfiles
.splice(index
, 1);
616 `${chargingStation.logPrefix()} Matching charging profile(s) cleared: %j`,
625 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_ACCEPTED
;
628 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN
;
631 private async handleRequestChangeAvailability(
632 chargingStation
: ChargingStation
,
633 commandPayload
: ChangeAvailabilityRequest
634 ): Promise
<ChangeAvailabilityResponse
> {
635 const connectorId
: number = commandPayload
.connectorId
;
636 if (chargingStation
.connectors
.has(connectorId
) === false) {
638 `${chargingStation.logPrefix()} Trying to change the availability of a non existing connector Id ${connectorId.toString()}`
640 return OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_REJECTED
;
642 const chargePointStatus
: OCPP16ChargePointStatus
=
643 commandPayload
.type === OCPP16AvailabilityType
.OPERATIVE
644 ? OCPP16ChargePointStatus
.AVAILABLE
645 : OCPP16ChargePointStatus
.UNAVAILABLE
;
646 if (connectorId
=== 0) {
647 let response
: ChangeAvailabilityResponse
= OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_ACCEPTED
;
648 for (const id
of chargingStation
.connectors
.keys()) {
649 if (chargingStation
.getConnectorStatus(id
)?.transactionStarted
=== true) {
650 response
= OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_SCHEDULED
;
652 chargingStation
.getConnectorStatus(id
).availability
= commandPayload
.type;
653 if (response
=== OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_ACCEPTED
) {
654 await chargingStation
.ocppRequestService
.requestHandler
<
655 OCPP16StatusNotificationRequest
,
656 OCPP16StatusNotificationResponse
657 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
659 status: chargePointStatus
,
660 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
662 chargingStation
.getConnectorStatus(id
).status = chargePointStatus
;
668 (chargingStation
.isChargingStationAvailable() === true ||
669 (chargingStation
.isChargingStationAvailable() === false &&
670 commandPayload
.type === OCPP16AvailabilityType
.INOPERATIVE
))
672 if (chargingStation
.getConnectorStatus(connectorId
)?.transactionStarted
=== true) {
673 chargingStation
.getConnectorStatus(connectorId
).availability
= commandPayload
.type;
674 return OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_SCHEDULED
;
676 chargingStation
.getConnectorStatus(connectorId
).availability
= commandPayload
.type;
677 await chargingStation
.ocppRequestService
.requestHandler
<
678 OCPP16StatusNotificationRequest
,
679 OCPP16StatusNotificationResponse
680 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
682 status: chargePointStatus
,
683 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
685 chargingStation
.getConnectorStatus(connectorId
).status = chargePointStatus
;
686 return OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_ACCEPTED
;
688 return OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_REJECTED
;
691 private async handleRequestRemoteStartTransaction(
692 chargingStation
: ChargingStation
,
693 commandPayload
: RemoteStartTransactionRequest
694 ): Promise
<GenericResponse
> {
695 const transactionConnectorId
= commandPayload
.connectorId
;
696 if (chargingStation
.connectors
.has(transactionConnectorId
) === true) {
697 const remoteStartTransactionLogMsg
= `${chargingStation.logPrefix()} Transaction remotely STARTED on ${
698 chargingStation.stationInfo.chargingStationId
699 }#${transactionConnectorId.toString()} for idTag '${commandPayload.idTag}'`;
700 await chargingStation
.ocppRequestService
.requestHandler
<
701 OCPP16StatusNotificationRequest
,
702 OCPP16StatusNotificationResponse
703 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
704 connectorId
: transactionConnectorId
,
705 status: OCPP16ChargePointStatus
.PREPARING
,
706 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
708 const connectorStatus
= chargingStation
.getConnectorStatus(transactionConnectorId
);
709 connectorStatus
.status = OCPP16ChargePointStatus
.PREPARING
;
710 if (chargingStation
.isChargingStationAvailable() === true) {
711 // Check if authorized
712 if (chargingStation
.getAuthorizeRemoteTxRequests() === true) {
713 let authorized
= false;
715 chargingStation
.getLocalAuthListEnabled() === true &&
716 chargingStation
.hasAuthorizedTags() === true &&
717 chargingStation
.authorizedTagsCache
719 ChargingStationUtils
.getAuthorizationFile(chargingStation
.stationInfo
)
721 .find((idTag
) => idTag
=== commandPayload
.idTag
)
723 connectorStatus
.localAuthorizeIdTag
= commandPayload
.idTag
;
724 connectorStatus
.idTagLocalAuthorized
= true;
726 } else if (chargingStation
.getMustAuthorizeAtRemoteStart() === true) {
727 connectorStatus
.authorizeIdTag
= commandPayload
.idTag
;
728 const authorizeResponse
: OCPP16AuthorizeResponse
=
729 await chargingStation
.ocppRequestService
.requestHandler
<
730 OCPP16AuthorizeRequest
,
731 OCPP16AuthorizeResponse
732 >(chargingStation
, OCPP16RequestCommand
.AUTHORIZE
, {
733 idTag
: commandPayload
.idTag
,
735 if (authorizeResponse
?.idTagInfo
?.status === OCPP16AuthorizationStatus
.ACCEPTED
) {
740 `${chargingStation.logPrefix()} The charging station configuration expects authorize at remote start transaction but local authorization or authorize isn't enabled`
743 if (authorized
=== true) {
744 // Authorization successful, start transaction
746 this.setRemoteStartTransactionChargingProfile(
748 transactionConnectorId
,
749 commandPayload
.chargingProfile
752 connectorStatus
.transactionRemoteStarted
= true;
755 await chargingStation
.ocppRequestService
.requestHandler
<
756 OCPP16StartTransactionRequest
,
757 OCPP16StartTransactionResponse
758 >(chargingStation
, OCPP16RequestCommand
.START_TRANSACTION
, {
759 connectorId
: transactionConnectorId
,
760 idTag
: commandPayload
.idTag
,
762 ).idTagInfo
.status === OCPP16AuthorizationStatus
.ACCEPTED
764 logger
.debug(remoteStartTransactionLogMsg
);
765 return OCPPConstants
.OCPP_RESPONSE_ACCEPTED
;
767 return this.notifyRemoteStartTransactionRejected(
769 transactionConnectorId
,
773 return this.notifyRemoteStartTransactionRejected(
775 transactionConnectorId
,
779 return this.notifyRemoteStartTransactionRejected(
781 transactionConnectorId
,
785 // No authorization check required, start transaction
787 this.setRemoteStartTransactionChargingProfile(
789 transactionConnectorId
,
790 commandPayload
.chargingProfile
793 connectorStatus
.transactionRemoteStarted
= true;
796 await chargingStation
.ocppRequestService
.requestHandler
<
797 OCPP16StartTransactionRequest
,
798 OCPP16StartTransactionResponse
799 >(chargingStation
, OCPP16RequestCommand
.START_TRANSACTION
, {
800 connectorId
: transactionConnectorId
,
801 idTag
: commandPayload
.idTag
,
803 ).idTagInfo
.status === OCPP16AuthorizationStatus
.ACCEPTED
805 logger
.debug(remoteStartTransactionLogMsg
);
806 return OCPPConstants
.OCPP_RESPONSE_ACCEPTED
;
808 return this.notifyRemoteStartTransactionRejected(
810 transactionConnectorId
,
814 return this.notifyRemoteStartTransactionRejected(
816 transactionConnectorId
,
820 return this.notifyRemoteStartTransactionRejected(
822 transactionConnectorId
,
826 return this.notifyRemoteStartTransactionRejected(
828 transactionConnectorId
,
833 private async notifyRemoteStartTransactionRejected(
834 chargingStation
: ChargingStation
,
837 ): Promise
<GenericResponse
> {
839 chargingStation
.getConnectorStatus(connectorId
).status !== OCPP16ChargePointStatus
.AVAILABLE
841 await chargingStation
.ocppRequestService
.requestHandler
<
842 OCPP16StatusNotificationRequest
,
843 OCPP16StatusNotificationResponse
844 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
846 status: OCPP16ChargePointStatus
.AVAILABLE
,
847 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
849 chargingStation
.getConnectorStatus(connectorId
).status = OCPP16ChargePointStatus
.AVAILABLE
;
852 `${chargingStation.logPrefix()} Remote starting transaction REJECTED on connector Id ${connectorId.toString()}, idTag '${idTag}', availability '${
853 chargingStation.getConnectorStatus(connectorId).availability
854 }', status '${chargingStation.getConnectorStatus(connectorId).status}'`
856 return OCPPConstants
.OCPP_RESPONSE_REJECTED
;
859 private setRemoteStartTransactionChargingProfile(
860 chargingStation
: ChargingStation
,
862 cp
: OCPP16ChargingProfile
864 if (cp
&& cp
.chargingProfilePurpose
=== ChargingProfilePurposeType
.TX_PROFILE
) {
865 OCPP16ServiceUtils
.setChargingProfile(chargingStation
, connectorId
, cp
);
867 `${chargingStation.logPrefix()} Charging profile(s) set at remote start transaction on connector id ${connectorId}: %j`,
871 } else if (cp
&& cp
.chargingProfilePurpose
!== ChargingProfilePurposeType
.TX_PROFILE
) {
873 `${chargingStation.logPrefix()} Not allowed to set ${
874 cp.chargingProfilePurpose
875 } charging profile(s) at remote start transaction`
883 private async handleRequestRemoteStopTransaction(
884 chargingStation
: ChargingStation
,
885 commandPayload
: RemoteStopTransactionRequest
886 ): Promise
<GenericResponse
> {
887 const transactionId
= commandPayload
.transactionId
;
888 for (const connectorId
of chargingStation
.connectors
.keys()) {
891 chargingStation
.getConnectorStatus(connectorId
)?.transactionId
=== transactionId
893 await chargingStation
.ocppRequestService
.requestHandler
<
894 OCPP16StatusNotificationRequest
,
895 OCPP16StatusNotificationResponse
896 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
898 status: OCPP16ChargePointStatus
.FINISHING
,
899 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
901 chargingStation
.getConnectorStatus(connectorId
).status = OCPP16ChargePointStatus
.FINISHING
;
902 const stopResponse
= await chargingStation
.stopTransactionOnConnector(
904 OCPP16StopTransactionReason
.REMOTE
906 if (stopResponse
.idTagInfo
?.status === OCPP16AuthorizationStatus
.ACCEPTED
) {
907 return OCPPConstants
.OCPP_RESPONSE_ACCEPTED
;
909 return OCPPConstants
.OCPP_RESPONSE_REJECTED
;
913 `${chargingStation.logPrefix()} Trying to remote stop a non existing transaction ${transactionId.toString()}`
915 return OCPPConstants
.OCPP_RESPONSE_REJECTED
;
918 private handleRequestUpdateFirmware(
919 chargingStation
: ChargingStation
,
920 commandPayload
: OCPP16UpdateFirmwareRequest
921 ): OCPP16UpdateFirmwareResponse
{
923 OCPP16ServiceUtils
.checkFeatureProfile(
925 OCPP16SupportedFeatureProfiles
.FirmwareManagement
,
926 OCPP16IncomingRequestCommand
.UPDATE_FIRMWARE
930 `${chargingStation.logPrefix()} ${moduleName}.handleRequestUpdateFirmware: Cannot simulate firmware update: feature profile not supported`
932 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
935 !Utils
.isNullOrUndefined(chargingStation
.stationInfo
.firmwareStatus
) &&
936 chargingStation
.stationInfo
.firmwareStatus
!== OCPP16FirmwareStatus
.Installed
939 `${chargingStation.logPrefix()} ${moduleName}.handleRequestUpdateFirmware: Cannot simulate firmware update: firmware update is already in progress`
941 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
943 const retrieveDate
= Utils
.convertToDate(commandPayload
.retrieveDate
);
944 const now
= Date.now();
945 if (retrieveDate
.getTime() <= now
) {
948 this.updateFirmware
.bind(this) as (
949 this: OCPP16IncomingRequestService
,
956 /* This is intentional */
960 this.updateFirmware(chargingStation
).catch(() => {
963 }, retrieveDate
.getTime() - now
);
965 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
968 private async updateFirmware(
969 chargingStation
: ChargingStation
,
973 chargingStation
.stopAutomaticTransactionGenerator();
974 for (const connectorId
of chargingStation
.connectors
.keys()) {
977 chargingStation
.getConnectorStatus(connectorId
).transactionStarted
=== false
979 await chargingStation
.ocppRequestService
.requestHandler
<
980 OCPP16StatusNotificationRequest
,
981 OCPP16StatusNotificationResponse
982 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
984 status: OCPP16ChargePointStatus
.UNAVAILABLE
,
985 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
987 chargingStation
.getConnectorStatus(connectorId
).status =
988 OCPP16ChargePointStatus
.UNAVAILABLE
;
992 chargingStation
.stationInfo
?.firmwareUpgrade
?.failureStatus
&&
993 !Utils
.isEmptyString(chargingStation
.stationInfo
?.firmwareUpgrade
?.failureStatus
)
995 await chargingStation
.ocppRequestService
.requestHandler
<
996 OCPP16FirmwareStatusNotificationRequest
,
997 OCPP16FirmwareStatusNotificationResponse
998 >(chargingStation
, OCPP16RequestCommand
.FIRMWARE_STATUS_NOTIFICATION
, {
999 status: chargingStation
.stationInfo
?.firmwareUpgrade
?.failureStatus
,
1003 await chargingStation
.ocppRequestService
.requestHandler
<
1004 OCPP16FirmwareStatusNotificationRequest
,
1005 OCPP16FirmwareStatusNotificationResponse
1006 >(chargingStation
, OCPP16RequestCommand
.FIRMWARE_STATUS_NOTIFICATION
, {
1007 status: OCPP16FirmwareStatus
.Downloading
,
1009 chargingStation
.stationInfo
.firmwareStatus
= OCPP16FirmwareStatus
.Downloading
;
1010 await Utils
.sleep(Utils
.getRandomInteger(maxDelay
, minDelay
) * 1000);
1011 await chargingStation
.ocppRequestService
.requestHandler
<
1012 OCPP16FirmwareStatusNotificationRequest
,
1013 OCPP16FirmwareStatusNotificationResponse
1014 >(chargingStation
, OCPP16RequestCommand
.FIRMWARE_STATUS_NOTIFICATION
, {
1015 status: OCPP16FirmwareStatus
.Downloaded
,
1017 chargingStation
.stationInfo
.firmwareStatus
= OCPP16FirmwareStatus
.Downloaded
;
1018 await Utils
.sleep(Utils
.getRandomInteger(maxDelay
, minDelay
) * 1000);
1019 await chargingStation
.ocppRequestService
.requestHandler
<
1020 OCPP16FirmwareStatusNotificationRequest
,
1021 OCPP16FirmwareStatusNotificationResponse
1022 >(chargingStation
, OCPP16RequestCommand
.FIRMWARE_STATUS_NOTIFICATION
, {
1023 status: OCPP16FirmwareStatus
.Installing
,
1025 chargingStation
.stationInfo
.firmwareStatus
= OCPP16FirmwareStatus
.Installing
;
1026 if (chargingStation
.stationInfo
?.firmwareUpgrade
?.reset
=== true) {
1027 await Utils
.sleep(Utils
.getRandomInteger(maxDelay
, minDelay
) * 1000);
1028 await chargingStation
.reset(OCPP16StopTransactionReason
.REBOOT
);
1032 private async handleRequestGetDiagnostics(
1033 chargingStation
: ChargingStation
,
1034 commandPayload
: GetDiagnosticsRequest
1035 ): Promise
<GetDiagnosticsResponse
> {
1037 OCPP16ServiceUtils
.checkFeatureProfile(
1039 OCPP16SupportedFeatureProfiles
.FirmwareManagement
,
1040 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
1044 `${chargingStation.logPrefix()} ${moduleName}.handleRequestGetDiagnostics: Cannot get diagnostics: feature profile not supported`
1046 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
1048 const uri
= new URL(commandPayload
.location
);
1049 if (uri
.protocol
.startsWith('ftp:')) {
1050 let ftpClient
: Client
;
1053 .readdirSync(path
.resolve(path
.dirname(fileURLToPath(import.meta
.url
)), '../../../../'))
1054 .filter((file
) => file
.endsWith('.log'))
1055 .map((file
) => path
.join('./', file
));
1056 const diagnosticsArchive
= `${chargingStation.stationInfo.chargingStationId}_logs.tar.gz`;
1057 tar
.create({ gzip
: true }, logFiles
).pipe(fs
.createWriteStream(diagnosticsArchive
));
1058 ftpClient
= new Client();
1059 const accessResponse
= await ftpClient
.access({
1061 ...(!Utils
.isEmptyString(uri
.port
) && { port
: Utils
.convertToInt(uri
.port
) }),
1062 ...(!Utils
.isEmptyString(uri
.username
) && { user
: uri
.username
}),
1063 ...(!Utils
.isEmptyString(uri
.password
) && { password
: uri
.password
}),
1065 let uploadResponse
: FTPResponse
;
1066 if (accessResponse
.code
=== 220) {
1067 ftpClient
.trackProgress((info
) => {
1069 `${chargingStation.logPrefix()} ${
1071 } bytes transferred from diagnostics archive ${info.name}`
1073 chargingStation
.ocppRequestService
1075 OCPP16DiagnosticsStatusNotificationRequest
,
1076 OCPP16DiagnosticsStatusNotificationResponse
1077 >(chargingStation
, OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
, {
1078 status: OCPP16DiagnosticsStatus
.Uploading
,
1082 `${chargingStation.logPrefix()} ${moduleName}.handleRequestGetDiagnostics: Error while sending '${
1083 OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION
1089 uploadResponse
= await ftpClient
.uploadFrom(
1091 path
.resolve(path
.dirname(fileURLToPath(import.meta
.url
)), '../../../../'),
1094 `${uri.pathname}${diagnosticsArchive}`
1096 if (uploadResponse
.code
=== 226) {
1097 await chargingStation
.ocppRequestService
.requestHandler
<
1098 OCPP16DiagnosticsStatusNotificationRequest
,
1099 OCPP16DiagnosticsStatusNotificationResponse
1100 >(chargingStation
, OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
, {
1101 status: OCPP16DiagnosticsStatus
.Uploaded
,
1106 return { fileName
: diagnosticsArchive
};
1108 throw new OCPPError(
1109 ErrorType
.GENERIC_ERROR
,
1110 `Diagnostics transfer failed with error code ${accessResponse.code.toString()}${
1111 uploadResponse?.code && `|${uploadResponse?.code.toString()}
`
1113 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
1116 throw new OCPPError(
1117 ErrorType
.GENERIC_ERROR
,
1118 `Diagnostics transfer failed with error code ${accessResponse.code.toString()}${
1119 uploadResponse?.code && `|${uploadResponse?.code.toString()}
`
1121 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
1124 await chargingStation
.ocppRequestService
.requestHandler
<
1125 OCPP16DiagnosticsStatusNotificationRequest
,
1126 OCPP16DiagnosticsStatusNotificationResponse
1127 >(chargingStation
, OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
, {
1128 status: OCPP16DiagnosticsStatus
.UploadFailed
,
1133 return this.handleIncomingRequestError(
1135 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
,
1137 { errorResponse
: OCPPConstants
.OCPP_RESPONSE_EMPTY
}
1142 `${chargingStation.logPrefix()} Unsupported protocol ${
1144 } to transfer the diagnostic logs archive`
1146 await chargingStation
.ocppRequestService
.requestHandler
<
1147 OCPP16DiagnosticsStatusNotificationRequest
,
1148 OCPP16DiagnosticsStatusNotificationResponse
1149 >(chargingStation
, OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
, {
1150 status: OCPP16DiagnosticsStatus
.UploadFailed
,
1152 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
1156 private handleRequestTriggerMessage(
1157 chargingStation
: ChargingStation
,
1158 commandPayload
: OCPP16TriggerMessageRequest
1159 ): OCPP16TriggerMessageResponse
{
1161 !OCPP16ServiceUtils
.checkFeatureProfile(
1163 OCPP16SupportedFeatureProfiles
.RemoteTrigger
,
1164 OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
1166 !OCPP16ServiceUtils
.isMessageTriggerSupported(
1168 commandPayload
.requestedMessage
1171 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED
;
1174 !OCPP16ServiceUtils
.isConnectorIdValid(
1176 OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
,
1177 commandPayload
.connectorId
1180 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED
;
1183 switch (commandPayload
.requestedMessage
) {
1184 case OCPP16MessageTrigger
.BootNotification
:
1186 chargingStation
.ocppRequestService
1187 .requestHandler
<OCPP16BootNotificationRequest
, OCPP16BootNotificationResponse
>(
1189 OCPP16RequestCommand
.BOOT_NOTIFICATION
,
1190 chargingStation
.bootNotificationRequest
,
1191 { skipBufferingOnError
: true, triggerMessage
: true }
1193 .then((response
) => {
1194 chargingStation
.bootNotificationResponse
= response
;
1197 /* This is intentional */
1199 }, Constants
.OCPP_TRIGGER_MESSAGE_DELAY
);
1200 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED
;
1201 case OCPP16MessageTrigger
.Heartbeat
:
1203 chargingStation
.ocppRequestService
1204 .requestHandler
<OCPP16HeartbeatRequest
, OCPP16HeartbeatResponse
>(
1206 OCPP16RequestCommand
.HEARTBEAT
,
1209 triggerMessage
: true,
1213 /* This is intentional */
1215 }, Constants
.OCPP_TRIGGER_MESSAGE_DELAY
);
1216 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED
;
1217 case OCPP16MessageTrigger
.StatusNotification
:
1219 if (commandPayload
?.connectorId
) {
1220 chargingStation
.ocppRequestService
1221 .requestHandler
<OCPP16StatusNotificationRequest
, OCPP16StatusNotificationResponse
>(
1223 OCPP16RequestCommand
.STATUS_NOTIFICATION
,
1225 connectorId
: commandPayload
.connectorId
,
1226 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
1227 status: chargingStation
.getConnectorStatus(commandPayload
.connectorId
).status,
1230 triggerMessage
: true,
1234 /* This is intentional */
1237 for (const connectorId
of chargingStation
.connectors
.keys()) {
1238 chargingStation
.ocppRequestService
1240 OCPP16StatusNotificationRequest
,
1241 OCPP16StatusNotificationResponse
1244 OCPP16RequestCommand
.STATUS_NOTIFICATION
,
1247 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
1248 status: chargingStation
.getConnectorStatus(connectorId
).status,
1251 triggerMessage
: true,
1255 /* This is intentional */
1259 }, Constants
.OCPP_TRIGGER_MESSAGE_DELAY
);
1260 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED
;
1262 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED
;
1265 return this.handleIncomingRequestError(
1267 OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
,
1269 { errorResponse
: OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED
}
1274 private handleRequestDataTransfer(
1275 chargingStation
: ChargingStation
,
1276 commandPayload
: OCPP16DataTransferRequest
1277 ): OCPP16DataTransferResponse
{
1279 if (Object.values(OCPP16DataTransferVendorId
).includes(commandPayload
.vendorId
)) {
1281 status: OCPP16DataTransferStatus
.ACCEPTED
,
1285 status: OCPP16DataTransferStatus
.UNKNOWN_VENDOR_ID
,
1288 return this.handleIncomingRequestError(
1290 OCPP16IncomingRequestCommand
.DATA_TRANSFER
,
1292 { errorResponse
: OCPPConstants
.OCPP_DATA_TRANSFER_RESPONSE_REJECTED
}
1297 private parseJsonSchemaFile
<T
extends JsonType
>(relativePath
: string): JSONSchemaType
<T
> {
1300 path
.resolve(path
.dirname(fileURLToPath(import.meta
.url
)), relativePath
),
1303 ) as JSONSchemaType
<T
>;