1 // Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
3 import fs from
'node:fs';
4 import path from
'node:path';
5 import { URL
, fileURLToPath
} from
'node:url';
7 import type { JSONSchemaType
} from
'ajv';
8 import { Client
, type FTPResponse
} from
'basic-ftp';
13 ChargingStationConfigurationUtils
,
15 } from
'../../../charging-station';
16 import { OCPPError
} from
'../../../exception';
18 type ChangeAvailabilityRequest
,
19 type ChangeAvailabilityResponse
,
20 type ChangeConfigurationRequest
,
21 type ChangeConfigurationResponse
,
22 ChargingProfilePurposeType
,
23 type ClearChargingProfileRequest
,
24 type ClearChargingProfileResponse
,
27 type GetConfigurationRequest
,
28 type GetConfigurationResponse
,
29 type GetDiagnosticsRequest
,
30 type GetDiagnosticsResponse
,
31 type IncomingRequestHandler
,
34 OCPP16AuthorizationStatus
,
35 type OCPP16AuthorizeRequest
,
36 type OCPP16AuthorizeResponse
,
37 OCPP16AvailabilityType
,
38 type OCPP16BootNotificationRequest
,
39 type OCPP16BootNotificationResponse
,
40 OCPP16ChargePointErrorCode
,
41 OCPP16ChargePointStatus
,
42 type OCPP16ChargingProfile
,
43 type OCPP16ClearCacheRequest
,
44 type OCPP16DataTransferRequest
,
45 type OCPP16DataTransferResponse
,
46 OCPP16DataTransferStatus
,
47 OCPP16DataTransferVendorId
,
48 OCPP16DiagnosticsStatus
,
49 type OCPP16DiagnosticsStatusNotificationRequest
,
50 type OCPP16DiagnosticsStatusNotificationResponse
,
52 type OCPP16FirmwareStatusNotificationRequest
,
53 type OCPP16FirmwareStatusNotificationResponse
,
54 type OCPP16HeartbeatRequest
,
55 type OCPP16HeartbeatResponse
,
56 OCPP16IncomingRequestCommand
,
59 OCPP16StandardParametersKey
,
60 type OCPP16StartTransactionRequest
,
61 type OCPP16StartTransactionResponse
,
62 type OCPP16StatusNotificationRequest
,
63 type OCPP16StatusNotificationResponse
,
64 OCPP16StopTransactionReason
,
65 OCPP16SupportedFeatureProfiles
,
66 type OCPP16TriggerMessageRequest
,
67 type OCPP16TriggerMessageResponse
,
68 type OCPP16UpdateFirmwareRequest
,
69 type OCPP16UpdateFirmwareResponse
,
70 type OCPPConfigurationKey
,
72 type RemoteStartTransactionRequest
,
73 type RemoteStopTransactionRequest
,
75 type SetChargingProfileRequest
,
76 type SetChargingProfileResponse
,
77 type UnlockConnectorRequest
,
78 type UnlockConnectorResponse
,
79 } from
'../../../types';
80 import { Constants
, Utils
, logger
} from
'../../../utils';
81 import { OCPP16ServiceUtils
, OCPPConstants
, OCPPIncomingRequestService
} from
'../internal';
83 const moduleName
= 'OCPP16IncomingRequestService';
85 export class OCPP16IncomingRequestService
extends OCPPIncomingRequestService
{
86 protected jsonSchemas
: Map
<OCPP16IncomingRequestCommand
, JSONSchemaType
<JsonObject
>>;
87 private incomingRequestHandlers
: Map
<OCPP16IncomingRequestCommand
, IncomingRequestHandler
>;
89 public constructor() {
90 if (new.target
?.name
=== moduleName
) {
91 throw new TypeError(`Cannot construct ${new.target?.name} instances directly`);
93 super(OCPPVersion
.VERSION_16
);
94 this.incomingRequestHandlers
= new Map
<OCPP16IncomingRequestCommand
, IncomingRequestHandler
>([
95 [OCPP16IncomingRequestCommand
.RESET
, this.handleRequestReset
.bind(this)],
96 [OCPP16IncomingRequestCommand
.CLEAR_CACHE
, this.handleRequestClearCache
.bind(this)],
97 [OCPP16IncomingRequestCommand
.UNLOCK_CONNECTOR
, this.handleRequestUnlockConnector
.bind(this)],
99 OCPP16IncomingRequestCommand
.GET_CONFIGURATION
,
100 this.handleRequestGetConfiguration
.bind(this),
103 OCPP16IncomingRequestCommand
.CHANGE_CONFIGURATION
,
104 this.handleRequestChangeConfiguration
.bind(this),
107 OCPP16IncomingRequestCommand
.SET_CHARGING_PROFILE
,
108 this.handleRequestSetChargingProfile
.bind(this),
111 OCPP16IncomingRequestCommand
.CLEAR_CHARGING_PROFILE
,
112 this.handleRequestClearChargingProfile
.bind(this),
115 OCPP16IncomingRequestCommand
.CHANGE_AVAILABILITY
,
116 this.handleRequestChangeAvailability
.bind(this),
119 OCPP16IncomingRequestCommand
.REMOTE_START_TRANSACTION
,
120 this.handleRequestRemoteStartTransaction
.bind(this),
123 OCPP16IncomingRequestCommand
.REMOTE_STOP_TRANSACTION
,
124 this.handleRequestRemoteStopTransaction
.bind(this),
126 [OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
, this.handleRequestGetDiagnostics
.bind(this)],
127 [OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
, this.handleRequestTriggerMessage
.bind(this)],
128 [OCPP16IncomingRequestCommand
.DATA_TRANSFER
, this.handleRequestDataTransfer
.bind(this)],
129 [OCPP16IncomingRequestCommand
.UPDATE_FIRMWARE
, this.handleRequestUpdateFirmware
.bind(this)],
131 this.jsonSchemas
= new Map
<OCPP16IncomingRequestCommand
, JSONSchemaType
<JsonObject
>>([
133 OCPP16IncomingRequestCommand
.RESET
,
134 OCPP16ServiceUtils
.parseJsonSchemaFile
<ResetRequest
>(
135 '../../../assets/json-schemas/ocpp/1.6/Reset.json',
141 OCPP16IncomingRequestCommand
.CLEAR_CACHE
,
142 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16ClearCacheRequest
>(
143 '../../../assets/json-schemas/ocpp/1.6/ClearCache.json',
149 OCPP16IncomingRequestCommand
.UNLOCK_CONNECTOR
,
150 OCPP16ServiceUtils
.parseJsonSchemaFile
<UnlockConnectorRequest
>(
151 '../../../assets/json-schemas/ocpp/1.6/UnlockConnector.json',
157 OCPP16IncomingRequestCommand
.GET_CONFIGURATION
,
158 OCPP16ServiceUtils
.parseJsonSchemaFile
<GetConfigurationRequest
>(
159 '../../../assets/json-schemas/ocpp/1.6/GetConfiguration.json',
165 OCPP16IncomingRequestCommand
.CHANGE_CONFIGURATION
,
166 OCPP16ServiceUtils
.parseJsonSchemaFile
<ChangeConfigurationRequest
>(
167 '../../../assets/json-schemas/ocpp/1.6/ChangeConfiguration.json',
173 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
,
174 OCPP16ServiceUtils
.parseJsonSchemaFile
<GetDiagnosticsRequest
>(
175 '../../../assets/json-schemas/ocpp/1.6/GetDiagnostics.json',
181 OCPP16IncomingRequestCommand
.SET_CHARGING_PROFILE
,
182 OCPP16ServiceUtils
.parseJsonSchemaFile
<SetChargingProfileRequest
>(
183 '../../../assets/json-schemas/ocpp/1.6/SetChargingProfile.json',
189 OCPP16IncomingRequestCommand
.CLEAR_CHARGING_PROFILE
,
190 OCPP16ServiceUtils
.parseJsonSchemaFile
<ClearChargingProfileRequest
>(
191 '../../../assets/json-schemas/ocpp/1.6/ClearChargingProfile.json',
197 OCPP16IncomingRequestCommand
.CHANGE_AVAILABILITY
,
198 OCPP16ServiceUtils
.parseJsonSchemaFile
<ChangeAvailabilityRequest
>(
199 '../../../assets/json-schemas/ocpp/1.6/ChangeAvailability.json',
205 OCPP16IncomingRequestCommand
.REMOTE_START_TRANSACTION
,
206 OCPP16ServiceUtils
.parseJsonSchemaFile
<RemoteStartTransactionRequest
>(
207 '../../../assets/json-schemas/ocpp/1.6/RemoteStartTransaction.json',
213 OCPP16IncomingRequestCommand
.REMOTE_STOP_TRANSACTION
,
214 OCPP16ServiceUtils
.parseJsonSchemaFile
<RemoteStopTransactionRequest
>(
215 '../../../assets/json-schemas/ocpp/1.6/RemoteStopTransaction.json',
221 OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
,
222 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16TriggerMessageRequest
>(
223 '../../../assets/json-schemas/ocpp/1.6/TriggerMessage.json',
229 OCPP16IncomingRequestCommand
.DATA_TRANSFER
,
230 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16DataTransferRequest
>(
231 '../../../assets/json-schemas/ocpp/1.6/DataTransfer.json',
237 OCPP16IncomingRequestCommand
.UPDATE_FIRMWARE
,
238 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16UpdateFirmwareRequest
>(
239 '../../../assets/json-schemas/ocpp/1.6/UpdateFirmware.json',
245 this.validatePayload
.bind(this);
248 public async incomingRequestHandler(
249 chargingStation
: ChargingStation
,
251 commandName
: OCPP16IncomingRequestCommand
,
252 commandPayload
: JsonType
254 let response
: JsonType
;
256 chargingStation
.getOcppStrictCompliance() === true &&
257 chargingStation
.isInPendingState() === true &&
258 (commandName
=== OCPP16IncomingRequestCommand
.REMOTE_START_TRANSACTION
||
259 commandName
=== OCPP16IncomingRequestCommand
.REMOTE_STOP_TRANSACTION
)
262 ErrorType
.SECURITY_ERROR
,
263 `${commandName} cannot be issued to handle request PDU ${JSON.stringify(
267 )} while the charging station is in pending state on the central server`,
273 chargingStation
.isRegistered() === true ||
274 (chargingStation
.getOcppStrictCompliance() === false &&
275 chargingStation
.isInUnknownState() === true)
278 this.incomingRequestHandlers
.has(commandName
) === true &&
279 OCPP16ServiceUtils
.isIncomingRequestCommandSupported(chargingStation
, commandName
) === true
282 this.validatePayload(chargingStation
, commandName
, commandPayload
);
283 // Call the method to build the response
284 response
= await this.incomingRequestHandlers
.get(commandName
)(
291 `${chargingStation.logPrefix()} ${moduleName}.incomingRequestHandler: Handle incoming request error:`,
299 ErrorType
.NOT_IMPLEMENTED
,
300 `${commandName} is not implemented to handle request PDU ${JSON.stringify(
311 ErrorType
.SECURITY_ERROR
,
312 `${commandName} cannot be issued to handle request PDU ${JSON.stringify(
316 )} while the charging station is not registered on the central server.`,
321 // Send the built response
322 await chargingStation
.ocppRequestService
.sendResponse(
330 private validatePayload(
331 chargingStation
: ChargingStation
,
332 commandName
: OCPP16IncomingRequestCommand
,
333 commandPayload
: JsonType
335 if (this.jsonSchemas
.has(commandName
) === true) {
336 return this.validateIncomingRequestPayload(
339 this.jsonSchemas
.get(commandName
),
344 `${chargingStation.logPrefix()} ${moduleName}.validatePayload: No JSON schema found for command '${commandName}' PDU validation`
349 // Simulate charging station restart
350 private handleRequestReset(
351 chargingStation
: ChargingStation
,
352 commandPayload
: ResetRequest
354 this.runInAsyncScope(
355 chargingStation
.reset
.bind(chargingStation
) as (
356 this: ChargingStation
,
360 `${commandPayload.type}Reset` as OCPP16StopTransactionReason
362 /* This is intentional */
365 `${chargingStation.logPrefix()} ${
367 } reset command received, simulating it. The station will be back online in ${Utils.formatDurationMilliSeconds(
368 chargingStation.stationInfo.resetTime
371 return OCPPConstants
.OCPP_RESPONSE_ACCEPTED
;
374 private async handleRequestUnlockConnector(
375 chargingStation
: ChargingStation
,
376 commandPayload
: UnlockConnectorRequest
377 ): Promise
<UnlockConnectorResponse
> {
378 const connectorId
= commandPayload
.connectorId
;
379 if (chargingStation
.connectors
.has(connectorId
) === false) {
381 `${chargingStation.logPrefix()} Trying to unlock a non existing connector Id ${connectorId.toString()}`
383 return OCPPConstants
.OCPP_RESPONSE_UNLOCK_NOT_SUPPORTED
;
385 if (connectorId
=== 0) {
387 `${chargingStation.logPrefix()} Trying to unlock connector Id ${connectorId.toString()}`
389 return OCPPConstants
.OCPP_RESPONSE_UNLOCK_NOT_SUPPORTED
;
391 if (chargingStation
.getConnectorStatus(connectorId
)?.transactionStarted
=== true) {
392 const stopResponse
= await chargingStation
.stopTransactionOnConnector(
394 OCPP16StopTransactionReason
.UNLOCK_COMMAND
396 if (stopResponse
.idTagInfo
?.status === OCPP16AuthorizationStatus
.ACCEPTED
) {
397 return OCPPConstants
.OCPP_RESPONSE_UNLOCKED
;
399 return OCPPConstants
.OCPP_RESPONSE_UNLOCK_FAILED
;
401 await chargingStation
.ocppRequestService
.requestHandler
<
402 OCPP16StatusNotificationRequest
,
403 OCPP16StatusNotificationResponse
404 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
406 status: OCPP16ChargePointStatus
.AVAILABLE
,
407 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
409 chargingStation
.getConnectorStatus(connectorId
).status = OCPP16ChargePointStatus
.AVAILABLE
;
410 return OCPPConstants
.OCPP_RESPONSE_UNLOCKED
;
413 private handleRequestGetConfiguration(
414 chargingStation
: ChargingStation
,
415 commandPayload
: GetConfigurationRequest
416 ): GetConfigurationResponse
{
417 const configurationKey
: OCPPConfigurationKey
[] = [];
418 const unknownKey
: string[] = [];
419 if (Utils
.isUndefined(commandPayload
.key
) === true) {
420 for (const configuration
of chargingStation
.ocppConfiguration
.configurationKey
) {
421 if (Utils
.isUndefined(configuration
.visible
) === true) {
422 configuration
.visible
= true;
424 if (configuration
.visible
=== false) {
427 configurationKey
.push({
428 key
: configuration
.key
,
429 readonly: configuration
.readonly,
430 value
: configuration
.value
,
433 } else if (Utils
.isNotEmptyArray(commandPayload
.key
) === true) {
434 for (const key
of commandPayload
.key
) {
435 const keyFound
= ChargingStationConfigurationUtils
.getConfigurationKey(
441 if (Utils
.isUndefined(keyFound
.visible
) === true) {
442 keyFound
.visible
= true;
444 if (keyFound
.visible
=== false) {
447 configurationKey
.push({
449 readonly: keyFound
.readonly,
450 value
: keyFound
.value
,
453 unknownKey
.push(key
);
463 private handleRequestChangeConfiguration(
464 chargingStation
: ChargingStation
,
465 commandPayload
: ChangeConfigurationRequest
466 ): ChangeConfigurationResponse
{
467 const keyToChange
= ChargingStationConfigurationUtils
.getConfigurationKey(
473 return OCPPConstants
.OCPP_CONFIGURATION_RESPONSE_NOT_SUPPORTED
;
474 } else if (keyToChange
&& keyToChange
.readonly) {
475 return OCPPConstants
.OCPP_CONFIGURATION_RESPONSE_REJECTED
;
476 } else if (keyToChange
&& !keyToChange
.readonly) {
477 let valueChanged
= false;
478 if (keyToChange
.value
!== commandPayload
.value
) {
479 ChargingStationConfigurationUtils
.setConfigurationKeyValue(
482 commandPayload
.value
,
487 let triggerHeartbeatRestart
= false;
488 if (keyToChange
.key
=== OCPP16StandardParametersKey
.HeartBeatInterval
&& valueChanged
) {
489 ChargingStationConfigurationUtils
.setConfigurationKeyValue(
491 OCPP16StandardParametersKey
.HeartbeatInterval
,
494 triggerHeartbeatRestart
= true;
496 if (keyToChange
.key
=== OCPP16StandardParametersKey
.HeartbeatInterval
&& valueChanged
) {
497 ChargingStationConfigurationUtils
.setConfigurationKeyValue(
499 OCPP16StandardParametersKey
.HeartBeatInterval
,
502 triggerHeartbeatRestart
= true;
504 if (triggerHeartbeatRestart
) {
505 chargingStation
.restartHeartbeat();
507 if (keyToChange
.key
=== OCPP16StandardParametersKey
.WebSocketPingInterval
&& valueChanged
) {
508 chargingStation
.restartWebSocketPing();
510 if (keyToChange
.reboot
) {
511 return OCPPConstants
.OCPP_CONFIGURATION_RESPONSE_REBOOT_REQUIRED
;
513 return OCPPConstants
.OCPP_CONFIGURATION_RESPONSE_ACCEPTED
;
517 private handleRequestSetChargingProfile(
518 chargingStation
: ChargingStation
,
519 commandPayload
: SetChargingProfileRequest
520 ): SetChargingProfileResponse
{
522 OCPP16ServiceUtils
.checkFeatureProfile(
524 OCPP16SupportedFeatureProfiles
.SmartCharging
,
525 OCPP16IncomingRequestCommand
.SET_CHARGING_PROFILE
528 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_NOT_SUPPORTED
;
530 if (chargingStation
.connectors
.has(commandPayload
.connectorId
) === false) {
532 `${chargingStation.logPrefix()} Trying to set charging profile(s) to a non existing connector Id ${
533 commandPayload.connectorId
536 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED
;
539 commandPayload
.csChargingProfiles
.chargingProfilePurpose
===
540 ChargingProfilePurposeType
.CHARGE_POINT_MAX_PROFILE
&&
541 commandPayload
.connectorId
!== 0
543 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED
;
546 commandPayload
.csChargingProfiles
.chargingProfilePurpose
===
547 ChargingProfilePurposeType
.TX_PROFILE
&&
548 (commandPayload
.connectorId
=== 0 ||
549 chargingStation
.getConnectorStatus(commandPayload
.connectorId
)?.transactionStarted
===
553 `${chargingStation.logPrefix()} Trying to set transaction charging profile(s) on connector ${
554 commandPayload.connectorId
555 } without a started transaction`
557 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED
;
559 OCPP16ServiceUtils
.setChargingProfile(
561 commandPayload
.connectorId
,
562 commandPayload
.csChargingProfiles
565 `${chargingStation.logPrefix()} Charging profile(s) set on connector id ${
566 commandPayload.connectorId
568 commandPayload
.csChargingProfiles
570 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_ACCEPTED
;
573 private handleRequestClearChargingProfile(
574 chargingStation
: ChargingStation
,
575 commandPayload
: ClearChargingProfileRequest
576 ): ClearChargingProfileResponse
{
578 OCPP16ServiceUtils
.checkFeatureProfile(
580 OCPP16SupportedFeatureProfiles
.SmartCharging
,
581 OCPP16IncomingRequestCommand
.CLEAR_CHARGING_PROFILE
584 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN
;
586 if (chargingStation
.connectors
.has(commandPayload
.connectorId
) === false) {
588 `${chargingStation.logPrefix()} Trying to clear a charging profile(s) to a non existing connector Id ${
589 commandPayload.connectorId
592 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN
;
594 const connectorStatus
= chargingStation
.getConnectorStatus(commandPayload
.connectorId
);
596 !Utils
.isNullOrUndefined(commandPayload
.connectorId
) &&
597 Utils
.isNotEmptyArray(connectorStatus
?.chargingProfiles
)
599 connectorStatus
.chargingProfiles
= [];
601 `${chargingStation.logPrefix()} Charging profile(s) cleared on connector id ${
602 commandPayload.connectorId
605 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_ACCEPTED
;
607 if (Utils
.isNullOrUndefined(commandPayload
.connectorId
)) {
608 let clearedCP
= false;
609 for (const connectorId
of chargingStation
.connectors
.keys()) {
611 Utils
.isNotEmptyArray(chargingStation
.getConnectorStatus(connectorId
)?.chargingProfiles
)
614 .getConnectorStatus(connectorId
)
615 ?.chargingProfiles
?.forEach((chargingProfile
: OCPP16ChargingProfile
, index
: number) => {
616 let clearCurrentCP
= false;
617 if (chargingProfile
.chargingProfileId
=== commandPayload
.id
) {
618 clearCurrentCP
= true;
621 !commandPayload
.chargingProfilePurpose
&&
622 chargingProfile
.stackLevel
=== commandPayload
.stackLevel
624 clearCurrentCP
= true;
627 !chargingProfile
.stackLevel
&&
628 chargingProfile
.chargingProfilePurpose
=== commandPayload
.chargingProfilePurpose
630 clearCurrentCP
= true;
633 chargingProfile
.stackLevel
=== commandPayload
.stackLevel
&&
634 chargingProfile
.chargingProfilePurpose
=== commandPayload
.chargingProfilePurpose
636 clearCurrentCP
= true;
638 if (clearCurrentCP
) {
639 connectorStatus
?.chargingProfiles
?.splice(index
, 1);
641 `${chargingStation.logPrefix()} Matching charging profile(s) cleared: %j`,
650 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_ACCEPTED
;
653 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN
;
656 private async handleRequestChangeAvailability(
657 chargingStation
: ChargingStation
,
658 commandPayload
: ChangeAvailabilityRequest
659 ): Promise
<ChangeAvailabilityResponse
> {
660 const connectorId
: number = commandPayload
.connectorId
;
661 if (chargingStation
.connectors
.has(connectorId
) === false) {
663 `${chargingStation.logPrefix()} Trying to change the availability of a non existing connector Id ${connectorId.toString()}`
665 return OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_REJECTED
;
667 const chargePointStatus
: OCPP16ChargePointStatus
=
668 commandPayload
.type === OCPP16AvailabilityType
.OPERATIVE
669 ? OCPP16ChargePointStatus
.AVAILABLE
670 : OCPP16ChargePointStatus
.UNAVAILABLE
;
671 if (connectorId
=== 0) {
672 let response
: ChangeAvailabilityResponse
= OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_ACCEPTED
;
673 for (const id
of chargingStation
.connectors
.keys()) {
674 if (chargingStation
.getConnectorStatus(id
)?.transactionStarted
=== true) {
675 response
= OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_SCHEDULED
;
677 chargingStation
.getConnectorStatus(id
).availability
= commandPayload
.type;
678 if (response
=== OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_ACCEPTED
) {
679 await chargingStation
.ocppRequestService
.requestHandler
<
680 OCPP16StatusNotificationRequest
,
681 OCPP16StatusNotificationResponse
682 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
684 status: chargePointStatus
,
685 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
687 chargingStation
.getConnectorStatus(id
).status = chargePointStatus
;
693 (chargingStation
.isChargingStationAvailable() === true ||
694 (chargingStation
.isChargingStationAvailable() === false &&
695 commandPayload
.type === OCPP16AvailabilityType
.INOPERATIVE
))
697 if (chargingStation
.getConnectorStatus(connectorId
)?.transactionStarted
=== true) {
698 chargingStation
.getConnectorStatus(connectorId
).availability
= commandPayload
.type;
699 return OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_SCHEDULED
;
701 chargingStation
.getConnectorStatus(connectorId
).availability
= commandPayload
.type;
702 await chargingStation
.ocppRequestService
.requestHandler
<
703 OCPP16StatusNotificationRequest
,
704 OCPP16StatusNotificationResponse
705 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
707 status: chargePointStatus
,
708 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
710 chargingStation
.getConnectorStatus(connectorId
).status = chargePointStatus
;
711 return OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_ACCEPTED
;
713 return OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_REJECTED
;
716 private async handleRequestRemoteStartTransaction(
717 chargingStation
: ChargingStation
,
718 commandPayload
: RemoteStartTransactionRequest
719 ): Promise
<GenericResponse
> {
720 const transactionConnectorId
= commandPayload
.connectorId
;
721 if (chargingStation
.connectors
.has(transactionConnectorId
) === true) {
722 const remoteStartTransactionLogMsg
= `${chargingStation.logPrefix()} Transaction remotely STARTED on ${
723 chargingStation.stationInfo.chargingStationId
724 }#${transactionConnectorId.toString()} for idTag '${commandPayload.idTag}'`;
725 await chargingStation
.ocppRequestService
.requestHandler
<
726 OCPP16StatusNotificationRequest
,
727 OCPP16StatusNotificationResponse
728 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
729 connectorId
: transactionConnectorId
,
730 status: OCPP16ChargePointStatus
.PREPARING
,
731 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
733 const connectorStatus
= chargingStation
.getConnectorStatus(transactionConnectorId
);
734 connectorStatus
.status = OCPP16ChargePointStatus
.PREPARING
;
735 if (chargingStation
.isChargingStationAvailable() === true) {
736 // Check if authorized
737 if (chargingStation
.getAuthorizeRemoteTxRequests() === true) {
738 let authorized
= false;
740 chargingStation
.getLocalAuthListEnabled() === true &&
741 chargingStation
.hasAuthorizedTags() === true &&
742 Utils
.isNotEmptyString(
743 chargingStation
.authorizedTagsCache
745 ChargingStationUtils
.getAuthorizationFile(chargingStation
.stationInfo
)
747 ?.find((idTag
) => idTag
=== commandPayload
.idTag
)
750 connectorStatus
.localAuthorizeIdTag
= commandPayload
.idTag
;
751 connectorStatus
.idTagLocalAuthorized
= true;
753 } else if (chargingStation
.getMustAuthorizeAtRemoteStart() === true) {
754 connectorStatus
.authorizeIdTag
= commandPayload
.idTag
;
755 const authorizeResponse
: OCPP16AuthorizeResponse
=
756 await chargingStation
.ocppRequestService
.requestHandler
<
757 OCPP16AuthorizeRequest
,
758 OCPP16AuthorizeResponse
759 >(chargingStation
, OCPP16RequestCommand
.AUTHORIZE
, {
760 idTag
: commandPayload
.idTag
,
762 if (authorizeResponse
?.idTagInfo
?.status === OCPP16AuthorizationStatus
.ACCEPTED
) {
767 `${chargingStation.logPrefix()} The charging station configuration expects authorize at remote start transaction but local authorization or authorize isn't enabled`
770 if (authorized
=== true) {
771 // Authorization successful, start transaction
773 this.setRemoteStartTransactionChargingProfile(
775 transactionConnectorId
,
776 commandPayload
.chargingProfile
779 connectorStatus
.transactionRemoteStarted
= true;
782 await chargingStation
.ocppRequestService
.requestHandler
<
783 OCPP16StartTransactionRequest
,
784 OCPP16StartTransactionResponse
785 >(chargingStation
, OCPP16RequestCommand
.START_TRANSACTION
, {
786 connectorId
: transactionConnectorId
,
787 idTag
: commandPayload
.idTag
,
789 ).idTagInfo
.status === OCPP16AuthorizationStatus
.ACCEPTED
791 logger
.debug(remoteStartTransactionLogMsg
);
792 return OCPPConstants
.OCPP_RESPONSE_ACCEPTED
;
794 return this.notifyRemoteStartTransactionRejected(
796 transactionConnectorId
,
800 return this.notifyRemoteStartTransactionRejected(
802 transactionConnectorId
,
806 return this.notifyRemoteStartTransactionRejected(
808 transactionConnectorId
,
812 // No authorization check required, start transaction
814 this.setRemoteStartTransactionChargingProfile(
816 transactionConnectorId
,
817 commandPayload
.chargingProfile
820 connectorStatus
.transactionRemoteStarted
= true;
823 await chargingStation
.ocppRequestService
.requestHandler
<
824 OCPP16StartTransactionRequest
,
825 OCPP16StartTransactionResponse
826 >(chargingStation
, OCPP16RequestCommand
.START_TRANSACTION
, {
827 connectorId
: transactionConnectorId
,
828 idTag
: commandPayload
.idTag
,
830 ).idTagInfo
.status === OCPP16AuthorizationStatus
.ACCEPTED
832 logger
.debug(remoteStartTransactionLogMsg
);
833 return OCPPConstants
.OCPP_RESPONSE_ACCEPTED
;
835 return this.notifyRemoteStartTransactionRejected(
837 transactionConnectorId
,
841 return this.notifyRemoteStartTransactionRejected(
843 transactionConnectorId
,
847 return this.notifyRemoteStartTransactionRejected(
849 transactionConnectorId
,
853 return this.notifyRemoteStartTransactionRejected(
855 transactionConnectorId
,
860 private async notifyRemoteStartTransactionRejected(
861 chargingStation
: ChargingStation
,
864 ): Promise
<GenericResponse
> {
866 chargingStation
.getConnectorStatus(connectorId
)?.status !== OCPP16ChargePointStatus
.AVAILABLE
868 await chargingStation
.ocppRequestService
.requestHandler
<
869 OCPP16StatusNotificationRequest
,
870 OCPP16StatusNotificationResponse
871 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
873 status: OCPP16ChargePointStatus
.AVAILABLE
,
874 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
876 chargingStation
.getConnectorStatus(connectorId
).status = OCPP16ChargePointStatus
.AVAILABLE
;
879 `${chargingStation.logPrefix()} Remote starting transaction REJECTED on connector Id ${connectorId.toString()}, idTag '${idTag}', availability '${
880 chargingStation.getConnectorStatus(connectorId)?.availability
881 }', status '${chargingStation.getConnectorStatus(connectorId)?.status}'`
883 return OCPPConstants
.OCPP_RESPONSE_REJECTED
;
886 private setRemoteStartTransactionChargingProfile(
887 chargingStation
: ChargingStation
,
889 cp
: OCPP16ChargingProfile
891 if (cp
&& cp
.chargingProfilePurpose
=== ChargingProfilePurposeType
.TX_PROFILE
) {
892 OCPP16ServiceUtils
.setChargingProfile(chargingStation
, connectorId
, cp
);
894 `${chargingStation.logPrefix()} Charging profile(s) set at remote start transaction on connector id ${connectorId}: %j`,
898 } else if (cp
&& cp
.chargingProfilePurpose
!== ChargingProfilePurposeType
.TX_PROFILE
) {
900 `${chargingStation.logPrefix()} Not allowed to set ${
901 cp.chargingProfilePurpose
902 } charging profile(s) at remote start transaction`
910 private async handleRequestRemoteStopTransaction(
911 chargingStation
: ChargingStation
,
912 commandPayload
: RemoteStopTransactionRequest
913 ): Promise
<GenericResponse
> {
914 const transactionId
= commandPayload
.transactionId
;
915 for (const connectorId
of chargingStation
.connectors
.keys()) {
918 chargingStation
.getConnectorStatus(connectorId
)?.transactionId
=== transactionId
920 await chargingStation
.ocppRequestService
.requestHandler
<
921 OCPP16StatusNotificationRequest
,
922 OCPP16StatusNotificationResponse
923 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
925 status: OCPP16ChargePointStatus
.FINISHING
,
926 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
928 chargingStation
.getConnectorStatus(connectorId
).status = OCPP16ChargePointStatus
.FINISHING
;
929 const stopResponse
= await chargingStation
.stopTransactionOnConnector(
931 OCPP16StopTransactionReason
.REMOTE
933 if (stopResponse
.idTagInfo
?.status === OCPP16AuthorizationStatus
.ACCEPTED
) {
934 return OCPPConstants
.OCPP_RESPONSE_ACCEPTED
;
936 return OCPPConstants
.OCPP_RESPONSE_REJECTED
;
940 `${chargingStation.logPrefix()} Trying to remote stop a non existing transaction ${transactionId.toString()}`
942 return OCPPConstants
.OCPP_RESPONSE_REJECTED
;
945 private handleRequestUpdateFirmware(
946 chargingStation
: ChargingStation
,
947 commandPayload
: OCPP16UpdateFirmwareRequest
948 ): OCPP16UpdateFirmwareResponse
{
950 OCPP16ServiceUtils
.checkFeatureProfile(
952 OCPP16SupportedFeatureProfiles
.FirmwareManagement
,
953 OCPP16IncomingRequestCommand
.UPDATE_FIRMWARE
957 `${chargingStation.logPrefix()} ${moduleName}.handleRequestUpdateFirmware: Cannot simulate firmware update: feature profile not supported`
959 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
962 !Utils
.isNullOrUndefined(chargingStation
.stationInfo
.firmwareStatus
) &&
963 chargingStation
.stationInfo
.firmwareStatus
!== OCPP16FirmwareStatus
.Installed
966 `${chargingStation.logPrefix()} ${moduleName}.handleRequestUpdateFirmware: Cannot simulate firmware update: firmware update is already in progress`
968 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
970 const retrieveDate
= Utils
.convertToDate(commandPayload
.retrieveDate
);
971 const now
= Date.now();
972 if (retrieveDate
?.getTime() <= now
) {
973 this.runInAsyncScope(
974 this.updateFirmware
.bind(this) as (
975 this: OCPP16IncomingRequestService
,
981 /* This is intentional */
985 this.updateFirmware(chargingStation
).catch(() => {
988 }, retrieveDate
?.getTime() - now
);
990 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
993 private async updateFirmware(
994 chargingStation
: ChargingStation
,
998 chargingStation
.stopAutomaticTransactionGenerator();
999 for (const connectorId
of chargingStation
.connectors
.keys()) {
1002 chargingStation
.getConnectorStatus(connectorId
)?.transactionStarted
=== false
1004 await chargingStation
.ocppRequestService
.requestHandler
<
1005 OCPP16StatusNotificationRequest
,
1006 OCPP16StatusNotificationResponse
1007 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
1009 status: OCPP16ChargePointStatus
.UNAVAILABLE
,
1010 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
1012 chargingStation
.getConnectorStatus(connectorId
).status =
1013 OCPP16ChargePointStatus
.UNAVAILABLE
;
1017 chargingStation
.stationInfo
?.firmwareUpgrade
?.failureStatus
&&
1018 Utils
.isNotEmptyString(chargingStation
.stationInfo
?.firmwareUpgrade
?.failureStatus
)
1020 await chargingStation
.ocppRequestService
.requestHandler
<
1021 OCPP16FirmwareStatusNotificationRequest
,
1022 OCPP16FirmwareStatusNotificationResponse
1023 >(chargingStation
, OCPP16RequestCommand
.FIRMWARE_STATUS_NOTIFICATION
, {
1024 status: chargingStation
.stationInfo
?.firmwareUpgrade
?.failureStatus
,
1028 await chargingStation
.ocppRequestService
.requestHandler
<
1029 OCPP16FirmwareStatusNotificationRequest
,
1030 OCPP16FirmwareStatusNotificationResponse
1031 >(chargingStation
, OCPP16RequestCommand
.FIRMWARE_STATUS_NOTIFICATION
, {
1032 status: OCPP16FirmwareStatus
.Downloading
,
1034 chargingStation
.stationInfo
.firmwareStatus
= OCPP16FirmwareStatus
.Downloading
;
1035 await Utils
.sleep(Utils
.getRandomInteger(maxDelay
, minDelay
) * 1000);
1036 await chargingStation
.ocppRequestService
.requestHandler
<
1037 OCPP16FirmwareStatusNotificationRequest
,
1038 OCPP16FirmwareStatusNotificationResponse
1039 >(chargingStation
, OCPP16RequestCommand
.FIRMWARE_STATUS_NOTIFICATION
, {
1040 status: OCPP16FirmwareStatus
.Downloaded
,
1042 chargingStation
.stationInfo
.firmwareStatus
= OCPP16FirmwareStatus
.Downloaded
;
1043 await Utils
.sleep(Utils
.getRandomInteger(maxDelay
, minDelay
) * 1000);
1044 await chargingStation
.ocppRequestService
.requestHandler
<
1045 OCPP16FirmwareStatusNotificationRequest
,
1046 OCPP16FirmwareStatusNotificationResponse
1047 >(chargingStation
, OCPP16RequestCommand
.FIRMWARE_STATUS_NOTIFICATION
, {
1048 status: OCPP16FirmwareStatus
.Installing
,
1050 chargingStation
.stationInfo
.firmwareStatus
= OCPP16FirmwareStatus
.Installing
;
1051 if (chargingStation
.stationInfo
?.firmwareUpgrade
?.reset
=== true) {
1052 await Utils
.sleep(Utils
.getRandomInteger(maxDelay
, minDelay
) * 1000);
1053 await chargingStation
.reset(OCPP16StopTransactionReason
.REBOOT
);
1057 private async handleRequestGetDiagnostics(
1058 chargingStation
: ChargingStation
,
1059 commandPayload
: GetDiagnosticsRequest
1060 ): Promise
<GetDiagnosticsResponse
> {
1062 OCPP16ServiceUtils
.checkFeatureProfile(
1064 OCPP16SupportedFeatureProfiles
.FirmwareManagement
,
1065 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
1069 `${chargingStation.logPrefix()} ${moduleName}.handleRequestGetDiagnostics: Cannot get diagnostics: feature profile not supported`
1071 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
1073 const uri
= new URL(commandPayload
.location
);
1074 if (uri
.protocol
.startsWith('ftp:')) {
1075 let ftpClient
: Client
;
1078 .readdirSync(path
.resolve(path
.dirname(fileURLToPath(import.meta
.url
)), '../../../../'))
1079 .filter((file
) => file
.endsWith('.log'))
1080 .map((file
) => path
.join('./', file
));
1081 const diagnosticsArchive
= `${chargingStation.stationInfo.chargingStationId}_logs.tar.gz`;
1082 tar
.create({ gzip
: true }, logFiles
).pipe(fs
.createWriteStream(diagnosticsArchive
));
1083 ftpClient
= new Client();
1084 const accessResponse
= await ftpClient
.access({
1086 ...(Utils
.isNotEmptyString(uri
.port
) && { port
: Utils
.convertToInt(uri
.port
) }),
1087 ...(Utils
.isNotEmptyString(uri
.username
) && { user
: uri
.username
}),
1088 ...(Utils
.isNotEmptyString(uri
.password
) && { password
: uri
.password
}),
1090 let uploadResponse
: FTPResponse
;
1091 if (accessResponse
.code
=== 220) {
1092 ftpClient
.trackProgress((info
) => {
1094 `${chargingStation.logPrefix()} ${
1096 } bytes transferred from diagnostics archive ${info.name}`
1098 chargingStation
.ocppRequestService
1100 OCPP16DiagnosticsStatusNotificationRequest
,
1101 OCPP16DiagnosticsStatusNotificationResponse
1102 >(chargingStation
, OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
, {
1103 status: OCPP16DiagnosticsStatus
.Uploading
,
1107 `${chargingStation.logPrefix()} ${moduleName}.handleRequestGetDiagnostics: Error while sending '${
1108 OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION
1114 uploadResponse
= await ftpClient
.uploadFrom(
1116 path
.resolve(path
.dirname(fileURLToPath(import.meta
.url
)), '../../../../'),
1119 `${uri.pathname}${diagnosticsArchive}`
1121 if (uploadResponse
.code
=== 226) {
1122 await chargingStation
.ocppRequestService
.requestHandler
<
1123 OCPP16DiagnosticsStatusNotificationRequest
,
1124 OCPP16DiagnosticsStatusNotificationResponse
1125 >(chargingStation
, OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
, {
1126 status: OCPP16DiagnosticsStatus
.Uploaded
,
1131 return { fileName
: diagnosticsArchive
};
1133 throw new OCPPError(
1134 ErrorType
.GENERIC_ERROR
,
1135 `Diagnostics transfer failed with error code ${accessResponse.code.toString()}${
1136 uploadResponse?.code && `|${uploadResponse?.code.toString()}
`
1138 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
1141 throw new OCPPError(
1142 ErrorType
.GENERIC_ERROR
,
1143 `Diagnostics transfer failed with error code ${accessResponse.code.toString()}${
1144 uploadResponse?.code && `|${uploadResponse?.code.toString()}
`
1146 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
1149 await chargingStation
.ocppRequestService
.requestHandler
<
1150 OCPP16DiagnosticsStatusNotificationRequest
,
1151 OCPP16DiagnosticsStatusNotificationResponse
1152 >(chargingStation
, OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
, {
1153 status: OCPP16DiagnosticsStatus
.UploadFailed
,
1158 return this.handleIncomingRequestError(
1160 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
,
1162 { errorResponse
: OCPPConstants
.OCPP_RESPONSE_EMPTY
}
1167 `${chargingStation.logPrefix()} Unsupported protocol ${
1169 } to transfer the diagnostic logs archive`
1171 await chargingStation
.ocppRequestService
.requestHandler
<
1172 OCPP16DiagnosticsStatusNotificationRequest
,
1173 OCPP16DiagnosticsStatusNotificationResponse
1174 >(chargingStation
, OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
, {
1175 status: OCPP16DiagnosticsStatus
.UploadFailed
,
1177 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
1181 private handleRequestTriggerMessage(
1182 chargingStation
: ChargingStation
,
1183 commandPayload
: OCPP16TriggerMessageRequest
1184 ): OCPP16TriggerMessageResponse
{
1186 !OCPP16ServiceUtils
.checkFeatureProfile(
1188 OCPP16SupportedFeatureProfiles
.RemoteTrigger
,
1189 OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
1191 !OCPP16ServiceUtils
.isMessageTriggerSupported(
1193 commandPayload
.requestedMessage
1196 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED
;
1199 !OCPP16ServiceUtils
.isConnectorIdValid(
1201 OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
,
1202 commandPayload
.connectorId
1205 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED
;
1208 switch (commandPayload
.requestedMessage
) {
1209 case OCPP16MessageTrigger
.BootNotification
:
1211 chargingStation
.ocppRequestService
1212 .requestHandler
<OCPP16BootNotificationRequest
, OCPP16BootNotificationResponse
>(
1214 OCPP16RequestCommand
.BOOT_NOTIFICATION
,
1215 chargingStation
.bootNotificationRequest
,
1216 { skipBufferingOnError
: true, triggerMessage
: true }
1218 .then((response
) => {
1219 chargingStation
.bootNotificationResponse
= response
;
1222 /* This is intentional */
1224 }, Constants
.OCPP_TRIGGER_MESSAGE_DELAY
);
1225 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED
;
1226 case OCPP16MessageTrigger
.Heartbeat
:
1228 chargingStation
.ocppRequestService
1229 .requestHandler
<OCPP16HeartbeatRequest
, OCPP16HeartbeatResponse
>(
1231 OCPP16RequestCommand
.HEARTBEAT
,
1234 triggerMessage
: true,
1238 /* This is intentional */
1240 }, Constants
.OCPP_TRIGGER_MESSAGE_DELAY
);
1241 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED
;
1242 case OCPP16MessageTrigger
.StatusNotification
:
1244 if (!Utils
.isNullOrUndefined(commandPayload
?.connectorId
)) {
1245 chargingStation
.ocppRequestService
1246 .requestHandler
<OCPP16StatusNotificationRequest
, OCPP16StatusNotificationResponse
>(
1248 OCPP16RequestCommand
.STATUS_NOTIFICATION
,
1250 connectorId
: commandPayload
.connectorId
,
1251 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
1252 status: chargingStation
.getConnectorStatus(commandPayload
.connectorId
)?.status,
1255 triggerMessage
: true,
1259 /* This is intentional */
1262 for (const connectorId
of chargingStation
.connectors
.keys()) {
1263 chargingStation
.ocppRequestService
1265 OCPP16StatusNotificationRequest
,
1266 OCPP16StatusNotificationResponse
1269 OCPP16RequestCommand
.STATUS_NOTIFICATION
,
1272 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
1273 status: chargingStation
.getConnectorStatus(connectorId
)?.status,
1276 triggerMessage
: true,
1280 /* This is intentional */
1284 }, Constants
.OCPP_TRIGGER_MESSAGE_DELAY
);
1285 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED
;
1287 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED
;
1290 return this.handleIncomingRequestError(
1292 OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
,
1294 { errorResponse
: OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED
}
1299 private handleRequestDataTransfer(
1300 chargingStation
: ChargingStation
,
1301 commandPayload
: OCPP16DataTransferRequest
1302 ): OCPP16DataTransferResponse
{
1304 if (Object.values(OCPP16DataTransferVendorId
).includes(commandPayload
.vendorId
)) {
1306 status: OCPP16DataTransferStatus
.ACCEPTED
,
1310 status: OCPP16DataTransferStatus
.UNKNOWN_VENDOR_ID
,
1313 return this.handleIncomingRequestError(
1315 OCPP16IncomingRequestCommand
.DATA_TRANSFER
,
1317 { errorResponse
: OCPPConstants
.OCPP_DATA_TRANSFER_RESPONSE_REJECTED
}