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 OCPPError from
'../../../exception/OCPPError';
12 import type { JsonObject
, JsonType
} from
'../../../types/JsonType';
13 import { OCPP16ChargePointErrorCode
} from
'../../../types/ocpp/1.6/ChargePointErrorCode';
14 import { OCPP16ChargePointStatus
} from
'../../../types/ocpp/1.6/ChargePointStatus';
16 ChargingProfilePurposeType
,
17 type OCPP16ChargingProfile
,
18 } from
'../../../types/ocpp/1.6/ChargingProfile';
20 OCPP16StandardParametersKey
,
21 OCPP16SupportedFeatureProfiles
,
22 } from
'../../../types/ocpp/1.6/Configuration';
23 import { OCPP16DiagnosticsStatus
} from
'../../../types/ocpp/1.6/DiagnosticsStatus';
25 type ChangeAvailabilityRequest
,
26 type ChangeConfigurationRequest
,
27 type ClearChargingProfileRequest
,
28 type GetConfigurationRequest
,
29 type GetDiagnosticsRequest
,
30 OCPP16AvailabilityType
,
31 type OCPP16BootNotificationRequest
,
32 type OCPP16ClearCacheRequest
,
33 type OCPP16DataTransferRequest
,
34 OCPP16DataTransferVendorId
,
35 type OCPP16DiagnosticsStatusNotificationRequest
,
37 type OCPP16FirmwareStatusNotificationRequest
,
38 type OCPP16HeartbeatRequest
,
39 OCPP16IncomingRequestCommand
,
42 type OCPP16StatusNotificationRequest
,
43 type OCPP16TriggerMessageRequest
,
44 type OCPP16UpdateFirmwareRequest
,
45 type RemoteStartTransactionRequest
,
46 type RemoteStopTransactionRequest
,
48 type SetChargingProfileRequest
,
49 type UnlockConnectorRequest
,
50 } from
'../../../types/ocpp/1.6/Requests';
52 type ChangeAvailabilityResponse
,
53 type ChangeConfigurationResponse
,
54 type ClearChargingProfileResponse
,
55 type GetConfigurationResponse
,
56 type GetDiagnosticsResponse
,
57 type OCPP16BootNotificationResponse
,
58 type OCPP16DataTransferResponse
,
59 OCPP16DataTransferStatus
,
60 type OCPP16DiagnosticsStatusNotificationResponse
,
61 type OCPP16FirmwareStatusNotificationResponse
,
62 type OCPP16HeartbeatResponse
,
63 type OCPP16StatusNotificationResponse
,
64 type OCPP16TriggerMessageResponse
,
65 type OCPP16UpdateFirmwareResponse
,
66 type SetChargingProfileResponse
,
67 type UnlockConnectorResponse
,
68 } from
'../../../types/ocpp/1.6/Responses';
70 OCPP16AuthorizationStatus
,
71 type OCPP16AuthorizeRequest
,
72 type OCPP16AuthorizeResponse
,
73 type OCPP16StartTransactionRequest
,
74 type OCPP16StartTransactionResponse
,
75 OCPP16StopTransactionReason
,
76 } from
'../../../types/ocpp/1.6/Transaction';
77 import type { OCPPConfigurationKey
} from
'../../../types/ocpp/Configuration';
78 import { ErrorType
} from
'../../../types/ocpp/ErrorType';
79 import { OCPPVersion
} from
'../../../types/ocpp/OCPPVersion';
80 import type { IncomingRequestHandler
} from
'../../../types/ocpp/Requests';
81 import type { DefaultResponse
} from
'../../../types/ocpp/Responses';
82 import Constants from
'../../../utils/Constants';
83 import logger from
'../../../utils/Logger';
84 import Utils from
'../../../utils/Utils';
85 import type ChargingStation from
'../../ChargingStation';
86 import { ChargingStationConfigurationUtils
} from
'../../ChargingStationConfigurationUtils';
87 import { ChargingStationUtils
} from
'../../ChargingStationUtils';
88 import OCPPConstants from
'../OCPPConstants';
89 import OCPPIncomingRequestService from
'../OCPPIncomingRequestService';
90 import { OCPP16ServiceUtils
} from
'./OCPP16ServiceUtils';
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
,
146 path
.dirname(fileURLToPath(import.meta
.url
)),
147 '../../../assets/json-schemas/ocpp/1.6/Reset.json'
151 ) as JSONSchemaType
<ResetRequest
>,
154 OCPP16IncomingRequestCommand
.CLEAR_CACHE
,
158 path
.dirname(fileURLToPath(import.meta
.url
)),
159 '../../../assets/json-schemas/ocpp/1.6/ClearCache.json'
163 ) as JSONSchemaType
<OCPP16ClearCacheRequest
>,
166 OCPP16IncomingRequestCommand
.UNLOCK_CONNECTOR
,
170 path
.dirname(fileURLToPath(import.meta
.url
)),
171 '../../../assets/json-schemas/ocpp/1.6/UnlockConnector.json'
175 ) as JSONSchemaType
<UnlockConnectorRequest
>,
178 OCPP16IncomingRequestCommand
.GET_CONFIGURATION
,
182 path
.dirname(fileURLToPath(import.meta
.url
)),
183 '../../../assets/json-schemas/ocpp/1.6/GetConfiguration.json'
187 ) as JSONSchemaType
<GetConfigurationRequest
>,
190 OCPP16IncomingRequestCommand
.CHANGE_CONFIGURATION
,
194 path
.dirname(fileURLToPath(import.meta
.url
)),
195 '../../../assets/json-schemas/ocpp/1.6/ChangeConfiguration.json'
199 ) as JSONSchemaType
<ChangeConfigurationRequest
>,
202 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
,
206 path
.dirname(fileURLToPath(import.meta
.url
)),
207 '../../../assets/json-schemas/ocpp/1.6/GetDiagnostics.json'
211 ) as JSONSchemaType
<GetDiagnosticsRequest
>,
214 OCPP16IncomingRequestCommand
.SET_CHARGING_PROFILE
,
218 path
.dirname(fileURLToPath(import.meta
.url
)),
219 '../../../assets/json-schemas/ocpp/1.6/SetChargingProfile.json'
223 ) as JSONSchemaType
<SetChargingProfileRequest
>,
226 OCPP16IncomingRequestCommand
.CLEAR_CHARGING_PROFILE
,
230 path
.dirname(fileURLToPath(import.meta
.url
)),
231 '../../../assets/json-schemas/ocpp/1.6/ClearChargingProfile.json'
235 ) as JSONSchemaType
<ClearChargingProfileRequest
>,
238 OCPP16IncomingRequestCommand
.CHANGE_AVAILABILITY
,
242 path
.dirname(fileURLToPath(import.meta
.url
)),
243 '../../../assets/json-schemas/ocpp/1.6/ChangeAvailability.json'
247 ) as JSONSchemaType
<ChangeAvailabilityRequest
>,
250 OCPP16IncomingRequestCommand
.REMOTE_START_TRANSACTION
,
254 path
.dirname(fileURLToPath(import.meta
.url
)),
255 '../../../assets/json-schemas/ocpp/1.6/RemoteStartTransaction.json'
259 ) as JSONSchemaType
<RemoteStartTransactionRequest
>,
262 OCPP16IncomingRequestCommand
.REMOTE_STOP_TRANSACTION
,
266 path
.dirname(fileURLToPath(import.meta
.url
)),
267 '../../../assets/json-schemas/ocpp/1.6/RemoteStopTransaction.json'
271 ) as JSONSchemaType
<RemoteStopTransactionRequest
>,
274 OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
,
278 path
.dirname(fileURLToPath(import.meta
.url
)),
279 '../../../assets/json-schemas/ocpp/1.6/TriggerMessage.json'
283 ) as JSONSchemaType
<OCPP16TriggerMessageRequest
>,
286 OCPP16IncomingRequestCommand
.DATA_TRANSFER
,
290 path
.dirname(fileURLToPath(import.meta
.url
)),
291 '../../../assets/json-schemas/ocpp/1.6/DataTransfer.json'
295 ) as JSONSchemaType
<OCPP16DataTransferRequest
>,
298 OCPP16IncomingRequestCommand
.UPDATE_FIRMWARE
,
302 path
.dirname(fileURLToPath(import.meta
.url
)),
303 '../../../assets/json-schemas/ocpp/1.6/UpdateFirmware.json'
307 ) as JSONSchemaType
<OCPP16UpdateFirmwareRequest
>,
310 this.validatePayload
.bind(this);
313 public async incomingRequestHandler(
314 chargingStation
: ChargingStation
,
316 commandName
: OCPP16IncomingRequestCommand
,
317 commandPayload
: JsonType
319 let response
: JsonType
;
321 chargingStation
.getOcppStrictCompliance() === true &&
322 chargingStation
.isInPendingState() === true &&
323 (commandName
=== OCPP16IncomingRequestCommand
.REMOTE_START_TRANSACTION
||
324 commandName
=== OCPP16IncomingRequestCommand
.REMOTE_STOP_TRANSACTION
)
327 ErrorType
.SECURITY_ERROR
,
328 `${commandName} cannot be issued to handle request PDU ${JSON.stringify(
332 )} while the charging station is in pending state on the central server`,
338 chargingStation
.isRegistered() === true ||
339 (chargingStation
.getOcppStrictCompliance() === false &&
340 chargingStation
.isInUnknownState() === true)
343 this.incomingRequestHandlers
.has(commandName
) === true &&
344 OCPP16ServiceUtils
.isIncomingRequestCommandSupported(chargingStation
, commandName
) === true
347 this.validatePayload(chargingStation
, commandName
, commandPayload
);
348 // Call the method to build the response
349 response
= await this.incomingRequestHandlers
.get(commandName
)(
356 `${chargingStation.logPrefix()} ${moduleName}.incomingRequestHandler: Handle incoming request error:`,
364 ErrorType
.NOT_IMPLEMENTED
,
365 `${commandName} is not implemented to handle request PDU ${JSON.stringify(
376 ErrorType
.SECURITY_ERROR
,
377 `${commandName} cannot be issued to handle request PDU ${JSON.stringify(
381 )} while the charging station is not registered on the central server.`,
386 // Send the built response
387 await chargingStation
.ocppRequestService
.sendResponse(
395 private validatePayload(
396 chargingStation
: ChargingStation
,
397 commandName
: OCPP16IncomingRequestCommand
,
398 commandPayload
: JsonType
400 if (this.jsonSchemas
.has(commandName
) === true) {
401 return this.validateIncomingRequestPayload(
404 this.jsonSchemas
.get(commandName
),
409 `${chargingStation.logPrefix()} ${moduleName}.validatePayload: No JSON schema found for command '${commandName}' PDU validation`
414 // Simulate charging station restart
415 private handleRequestReset(
416 chargingStation
: ChargingStation
,
417 commandPayload
: ResetRequest
421 chargingStation
.reset
.bind(chargingStation
) as (
422 this: ChargingStation
,
426 (commandPayload
.type + 'Reset') as OCPP16StopTransactionReason
429 /* This is intentional */
432 `${chargingStation.logPrefix()} ${
434 } reset command received, simulating it. The station will be back online in ${Utils.formatDurationMilliSeconds(
435 chargingStation.stationInfo.resetTime
438 return OCPPConstants
.OCPP_RESPONSE_ACCEPTED
;
441 private handleRequestClearCache(chargingStation
: ChargingStation
): DefaultResponse
{
442 chargingStation
.authorizedTagsCache
.deleteAuthorizedTags(
443 ChargingStationUtils
.getAuthorizationFile(chargingStation
.stationInfo
)
445 return OCPPConstants
.OCPP_RESPONSE_ACCEPTED
;
448 private async handleRequestUnlockConnector(
449 chargingStation
: ChargingStation
,
450 commandPayload
: UnlockConnectorRequest
451 ): Promise
<UnlockConnectorResponse
> {
452 const connectorId
= commandPayload
.connectorId
;
453 if (chargingStation
.connectors
.has(connectorId
) === false) {
455 `${chargingStation.logPrefix()} Trying to unlock a non existing connector Id ${connectorId.toString()}`
457 return OCPPConstants
.OCPP_RESPONSE_UNLOCK_NOT_SUPPORTED
;
459 if (connectorId
=== 0) {
461 chargingStation
.logPrefix() + ' Trying to unlock connector Id ' + connectorId
.toString()
463 return OCPPConstants
.OCPP_RESPONSE_UNLOCK_NOT_SUPPORTED
;
465 if (chargingStation
.getConnectorStatus(connectorId
)?.transactionStarted
=== true) {
466 const stopResponse
= await chargingStation
.stopTransactionOnConnector(
468 OCPP16StopTransactionReason
.UNLOCK_COMMAND
470 if (stopResponse
.idTagInfo
?.status === OCPP16AuthorizationStatus
.ACCEPTED
) {
471 return OCPPConstants
.OCPP_RESPONSE_UNLOCKED
;
473 return OCPPConstants
.OCPP_RESPONSE_UNLOCK_FAILED
;
475 await chargingStation
.ocppRequestService
.requestHandler
<
476 OCPP16StatusNotificationRequest
,
477 OCPP16StatusNotificationResponse
478 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
480 status: OCPP16ChargePointStatus
.AVAILABLE
,
481 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
483 chargingStation
.getConnectorStatus(connectorId
).status = OCPP16ChargePointStatus
.AVAILABLE
;
484 return OCPPConstants
.OCPP_RESPONSE_UNLOCKED
;
487 private handleRequestGetConfiguration(
488 chargingStation
: ChargingStation
,
489 commandPayload
: GetConfigurationRequest
490 ): GetConfigurationResponse
{
491 const configurationKey
: OCPPConfigurationKey
[] = [];
492 const unknownKey
: string[] = [];
493 if (Utils
.isEmptyArray(commandPayload
.key
) === true) {
494 for (const configuration
of chargingStation
.ocppConfiguration
.configurationKey
) {
495 if (Utils
.isUndefined(configuration
.visible
) === true) {
496 configuration
.visible
= true;
498 if (configuration
.visible
=== false) {
501 configurationKey
.push({
502 key
: configuration
.key
,
503 readonly: configuration
.readonly,
504 value
: configuration
.value
,
508 for (const key
of commandPayload
.key
) {
509 const keyFound
= ChargingStationConfigurationUtils
.getConfigurationKey(
514 if (Utils
.isUndefined(keyFound
.visible
) === true) {
515 keyFound
.visible
= true;
517 if (keyFound
.visible
=== false) {
520 configurationKey
.push({
522 readonly: keyFound
.readonly,
523 value
: keyFound
.value
,
526 unknownKey
.push(key
);
536 private handleRequestChangeConfiguration(
537 chargingStation
: ChargingStation
,
538 commandPayload
: ChangeConfigurationRequest
539 ): ChangeConfigurationResponse
{
540 const keyToChange
= ChargingStationConfigurationUtils
.getConfigurationKey(
546 return OCPPConstants
.OCPP_CONFIGURATION_RESPONSE_NOT_SUPPORTED
;
547 } else if (keyToChange
&& keyToChange
.readonly) {
548 return OCPPConstants
.OCPP_CONFIGURATION_RESPONSE_REJECTED
;
549 } else if (keyToChange
&& !keyToChange
.readonly) {
550 let valueChanged
= false;
551 if (keyToChange
.value
!== commandPayload
.value
) {
552 ChargingStationConfigurationUtils
.setConfigurationKeyValue(
555 commandPayload
.value
,
560 let triggerHeartbeatRestart
= false;
561 if (keyToChange
.key
=== OCPP16StandardParametersKey
.HeartBeatInterval
&& valueChanged
) {
562 ChargingStationConfigurationUtils
.setConfigurationKeyValue(
564 OCPP16StandardParametersKey
.HeartbeatInterval
,
567 triggerHeartbeatRestart
= true;
569 if (keyToChange
.key
=== OCPP16StandardParametersKey
.HeartbeatInterval
&& valueChanged
) {
570 ChargingStationConfigurationUtils
.setConfigurationKeyValue(
572 OCPP16StandardParametersKey
.HeartBeatInterval
,
575 triggerHeartbeatRestart
= true;
577 if (triggerHeartbeatRestart
) {
578 chargingStation
.restartHeartbeat();
580 if (keyToChange
.key
=== OCPP16StandardParametersKey
.WebSocketPingInterval
&& valueChanged
) {
581 chargingStation
.restartWebSocketPing();
583 if (keyToChange
.reboot
) {
584 return OCPPConstants
.OCPP_CONFIGURATION_RESPONSE_REBOOT_REQUIRED
;
586 return OCPPConstants
.OCPP_CONFIGURATION_RESPONSE_ACCEPTED
;
590 private handleRequestSetChargingProfile(
591 chargingStation
: ChargingStation
,
592 commandPayload
: SetChargingProfileRequest
593 ): SetChargingProfileResponse
{
595 OCPP16ServiceUtils
.checkFeatureProfile(
597 OCPP16SupportedFeatureProfiles
.SmartCharging
,
598 OCPP16IncomingRequestCommand
.SET_CHARGING_PROFILE
601 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_NOT_SUPPORTED
;
603 if (chargingStation
.connectors
.has(commandPayload
.connectorId
) === false) {
605 `${chargingStation.logPrefix()} Trying to set charging profile(s) to a non existing connector Id ${
606 commandPayload.connectorId
609 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED
;
612 commandPayload
.csChargingProfiles
.chargingProfilePurpose
===
613 ChargingProfilePurposeType
.CHARGE_POINT_MAX_PROFILE
&&
614 commandPayload
.connectorId
!== 0
616 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED
;
619 commandPayload
.csChargingProfiles
.chargingProfilePurpose
===
620 ChargingProfilePurposeType
.TX_PROFILE
&&
621 (commandPayload
.connectorId
=== 0 ||
622 chargingStation
.getConnectorStatus(commandPayload
.connectorId
)?.transactionStarted
===
626 `${chargingStation.logPrefix()} Trying to set transaction charging profile(s) on connector ${
627 commandPayload.connectorId
628 } without a started transaction`
630 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED
;
632 OCPP16ServiceUtils
.setChargingProfile(
634 commandPayload
.connectorId
,
635 commandPayload
.csChargingProfiles
638 `${chargingStation.logPrefix()} Charging profile(s) set on connector id ${
639 commandPayload.connectorId
640 }, dump their stack: %j`,
641 chargingStation
.getConnectorStatus(commandPayload
.connectorId
).chargingProfiles
643 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_ACCEPTED
;
646 private handleRequestClearChargingProfile(
647 chargingStation
: ChargingStation
,
648 commandPayload
: ClearChargingProfileRequest
649 ): ClearChargingProfileResponse
{
651 OCPP16ServiceUtils
.checkFeatureProfile(
653 OCPP16SupportedFeatureProfiles
.SmartCharging
,
654 OCPP16IncomingRequestCommand
.CLEAR_CHARGING_PROFILE
657 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN
;
659 if (chargingStation
.connectors
.has(commandPayload
.connectorId
) === false) {
661 `${chargingStation.logPrefix()} Trying to clear a charging profile(s) to a non existing connector Id ${
662 commandPayload.connectorId
665 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN
;
667 const connectorStatus
= chargingStation
.getConnectorStatus(commandPayload
.connectorId
);
668 if (commandPayload
.connectorId
&& !Utils
.isEmptyArray(connectorStatus
.chargingProfiles
)) {
669 connectorStatus
.chargingProfiles
= [];
671 `${chargingStation.logPrefix()} Charging profile(s) cleared on connector id ${
672 commandPayload.connectorId
673 }, dump their stack: %j`,
674 connectorStatus
.chargingProfiles
676 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_ACCEPTED
;
678 if (!commandPayload
.connectorId
) {
679 let clearedCP
= false;
680 for (const connectorId
of chargingStation
.connectors
.keys()) {
681 if (!Utils
.isEmptyArray(chargingStation
.getConnectorStatus(connectorId
).chargingProfiles
)) {
683 .getConnectorStatus(connectorId
)
684 .chargingProfiles
?.forEach((chargingProfile
: OCPP16ChargingProfile
, index
: number) => {
685 let clearCurrentCP
= false;
686 if (chargingProfile
.chargingProfileId
=== commandPayload
.id
) {
687 clearCurrentCP
= true;
690 !commandPayload
.chargingProfilePurpose
&&
691 chargingProfile
.stackLevel
=== commandPayload
.stackLevel
693 clearCurrentCP
= true;
696 !chargingProfile
.stackLevel
&&
697 chargingProfile
.chargingProfilePurpose
=== commandPayload
.chargingProfilePurpose
699 clearCurrentCP
= true;
702 chargingProfile
.stackLevel
=== commandPayload
.stackLevel
&&
703 chargingProfile
.chargingProfilePurpose
=== commandPayload
.chargingProfilePurpose
705 clearCurrentCP
= true;
707 if (clearCurrentCP
) {
708 connectorStatus
.chargingProfiles
.splice(index
, 1);
710 `${chargingStation.logPrefix()} Matching charging profile(s) cleared on connector id ${
711 commandPayload.connectorId
712 }, dump their stack: %j`,
713 connectorStatus
.chargingProfiles
721 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_ACCEPTED
;
724 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN
;
727 private async handleRequestChangeAvailability(
728 chargingStation
: ChargingStation
,
729 commandPayload
: ChangeAvailabilityRequest
730 ): Promise
<ChangeAvailabilityResponse
> {
731 const connectorId
: number = commandPayload
.connectorId
;
732 if (chargingStation
.connectors
.has(connectorId
) === false) {
734 `${chargingStation.logPrefix()} Trying to change the availability of a non existing connector Id ${connectorId.toString()}`
736 return OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_REJECTED
;
738 const chargePointStatus
: OCPP16ChargePointStatus
=
739 commandPayload
.type === OCPP16AvailabilityType
.OPERATIVE
740 ? OCPP16ChargePointStatus
.AVAILABLE
741 : OCPP16ChargePointStatus
.UNAVAILABLE
;
742 if (connectorId
=== 0) {
743 let response
: ChangeAvailabilityResponse
= OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_ACCEPTED
;
744 for (const id
of chargingStation
.connectors
.keys()) {
745 if (chargingStation
.getConnectorStatus(id
)?.transactionStarted
=== true) {
746 response
= OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_SCHEDULED
;
748 chargingStation
.getConnectorStatus(id
).availability
= commandPayload
.type;
749 if (response
=== OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_ACCEPTED
) {
750 await chargingStation
.ocppRequestService
.requestHandler
<
751 OCPP16StatusNotificationRequest
,
752 OCPP16StatusNotificationResponse
753 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
755 status: chargePointStatus
,
756 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
758 chargingStation
.getConnectorStatus(id
).status = chargePointStatus
;
764 (chargingStation
.isChargingStationAvailable() === true ||
765 (chargingStation
.isChargingStationAvailable() === false &&
766 commandPayload
.type === OCPP16AvailabilityType
.INOPERATIVE
))
768 if (chargingStation
.getConnectorStatus(connectorId
)?.transactionStarted
=== true) {
769 chargingStation
.getConnectorStatus(connectorId
).availability
= commandPayload
.type;
770 return OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_SCHEDULED
;
772 chargingStation
.getConnectorStatus(connectorId
).availability
= commandPayload
.type;
773 await chargingStation
.ocppRequestService
.requestHandler
<
774 OCPP16StatusNotificationRequest
,
775 OCPP16StatusNotificationResponse
776 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
778 status: chargePointStatus
,
779 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
781 chargingStation
.getConnectorStatus(connectorId
).status = chargePointStatus
;
782 return OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_ACCEPTED
;
784 return OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_REJECTED
;
787 private async handleRequestRemoteStartTransaction(
788 chargingStation
: ChargingStation
,
789 commandPayload
: RemoteStartTransactionRequest
790 ): Promise
<DefaultResponse
> {
791 const transactionConnectorId
= commandPayload
.connectorId
;
792 if (chargingStation
.connectors
.has(transactionConnectorId
) === true) {
793 const remoteStartTransactionLogMsg
=
794 chargingStation
.logPrefix() +
795 ' Transaction remotely STARTED on ' +
796 chargingStation
.stationInfo
.chargingStationId
+
798 transactionConnectorId
.toString() +
800 commandPayload
.idTag
+
802 await chargingStation
.ocppRequestService
.requestHandler
<
803 OCPP16StatusNotificationRequest
,
804 OCPP16StatusNotificationResponse
805 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
806 connectorId
: transactionConnectorId
,
807 status: OCPP16ChargePointStatus
.PREPARING
,
808 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
810 const connectorStatus
= chargingStation
.getConnectorStatus(transactionConnectorId
);
811 connectorStatus
.status = OCPP16ChargePointStatus
.PREPARING
;
812 if (chargingStation
.isChargingStationAvailable() === true) {
813 // Check if authorized
814 if (chargingStation
.getAuthorizeRemoteTxRequests() === true) {
815 let authorized
= false;
817 chargingStation
.getLocalAuthListEnabled() === true &&
818 chargingStation
.hasAuthorizedTags() === true &&
819 chargingStation
.authorizedTagsCache
821 ChargingStationUtils
.getAuthorizationFile(chargingStation
.stationInfo
)
823 .find((idTag
) => idTag
=== commandPayload
.idTag
)
825 connectorStatus
.localAuthorizeIdTag
= commandPayload
.idTag
;
826 connectorStatus
.idTagLocalAuthorized
= true;
828 } else if (chargingStation
.getMustAuthorizeAtRemoteStart() === true) {
829 connectorStatus
.authorizeIdTag
= commandPayload
.idTag
;
830 const authorizeResponse
: OCPP16AuthorizeResponse
=
831 await chargingStation
.ocppRequestService
.requestHandler
<
832 OCPP16AuthorizeRequest
,
833 OCPP16AuthorizeResponse
834 >(chargingStation
, OCPP16RequestCommand
.AUTHORIZE
, {
835 idTag
: commandPayload
.idTag
,
837 if (authorizeResponse
?.idTagInfo
?.status === OCPP16AuthorizationStatus
.ACCEPTED
) {
842 `${chargingStation.logPrefix()} The charging station configuration expects authorize at remote start transaction but local authorization or authorize isn't enabled`
845 if (authorized
=== true) {
846 // Authorization successful, start transaction
848 this.setRemoteStartTransactionChargingProfile(
850 transactionConnectorId
,
851 commandPayload
.chargingProfile
854 connectorStatus
.transactionRemoteStarted
= true;
857 await chargingStation
.ocppRequestService
.requestHandler
<
858 OCPP16StartTransactionRequest
,
859 OCPP16StartTransactionResponse
860 >(chargingStation
, OCPP16RequestCommand
.START_TRANSACTION
, {
861 connectorId
: transactionConnectorId
,
862 idTag
: commandPayload
.idTag
,
864 ).idTagInfo
.status === OCPP16AuthorizationStatus
.ACCEPTED
866 logger
.debug(remoteStartTransactionLogMsg
);
867 return OCPPConstants
.OCPP_RESPONSE_ACCEPTED
;
869 return this.notifyRemoteStartTransactionRejected(
871 transactionConnectorId
,
875 return this.notifyRemoteStartTransactionRejected(
877 transactionConnectorId
,
881 return this.notifyRemoteStartTransactionRejected(
883 transactionConnectorId
,
887 // No authorization check required, start transaction
889 this.setRemoteStartTransactionChargingProfile(
891 transactionConnectorId
,
892 commandPayload
.chargingProfile
895 connectorStatus
.transactionRemoteStarted
= true;
898 await chargingStation
.ocppRequestService
.requestHandler
<
899 OCPP16StartTransactionRequest
,
900 OCPP16StartTransactionResponse
901 >(chargingStation
, OCPP16RequestCommand
.START_TRANSACTION
, {
902 connectorId
: transactionConnectorId
,
903 idTag
: commandPayload
.idTag
,
905 ).idTagInfo
.status === OCPP16AuthorizationStatus
.ACCEPTED
907 logger
.debug(remoteStartTransactionLogMsg
);
908 return OCPPConstants
.OCPP_RESPONSE_ACCEPTED
;
910 return this.notifyRemoteStartTransactionRejected(
912 transactionConnectorId
,
916 return this.notifyRemoteStartTransactionRejected(
918 transactionConnectorId
,
922 return this.notifyRemoteStartTransactionRejected(
924 transactionConnectorId
,
928 return this.notifyRemoteStartTransactionRejected(
930 transactionConnectorId
,
935 private async notifyRemoteStartTransactionRejected(
936 chargingStation
: ChargingStation
,
939 ): Promise
<DefaultResponse
> {
941 chargingStation
.getConnectorStatus(connectorId
).status !== OCPP16ChargePointStatus
.AVAILABLE
943 await chargingStation
.ocppRequestService
.requestHandler
<
944 OCPP16StatusNotificationRequest
,
945 OCPP16StatusNotificationResponse
946 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
948 status: OCPP16ChargePointStatus
.AVAILABLE
,
949 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
951 chargingStation
.getConnectorStatus(connectorId
).status = OCPP16ChargePointStatus
.AVAILABLE
;
954 chargingStation
.logPrefix() +
955 ' Remote starting transaction REJECTED on connector Id ' +
956 connectorId
.toString() +
959 "', availability '" +
960 chargingStation
.getConnectorStatus(connectorId
).availability
+
962 chargingStation
.getConnectorStatus(connectorId
).status +
965 return OCPPConstants
.OCPP_RESPONSE_REJECTED
;
968 private setRemoteStartTransactionChargingProfile(
969 chargingStation
: ChargingStation
,
971 cp
: OCPP16ChargingProfile
973 if (cp
&& cp
.chargingProfilePurpose
=== ChargingProfilePurposeType
.TX_PROFILE
) {
974 OCPP16ServiceUtils
.setChargingProfile(chargingStation
, connectorId
, cp
);
976 `${chargingStation.logPrefix()} Charging profile(s) set at remote start transaction on connector id ${connectorId}, dump their stack: %j`,
977 chargingStation
.getConnectorStatus(connectorId
).chargingProfiles
980 } else if (cp
&& cp
.chargingProfilePurpose
!== ChargingProfilePurposeType
.TX_PROFILE
) {
982 `${chargingStation.logPrefix()} Not allowed to set ${
983 cp.chargingProfilePurpose
984 } charging profile(s) at remote start transaction`
992 private async handleRequestRemoteStopTransaction(
993 chargingStation
: ChargingStation
,
994 commandPayload
: RemoteStopTransactionRequest
995 ): Promise
<DefaultResponse
> {
996 const transactionId
= commandPayload
.transactionId
;
997 for (const connectorId
of chargingStation
.connectors
.keys()) {
1000 chargingStation
.getConnectorStatus(connectorId
)?.transactionId
=== transactionId
1002 await chargingStation
.ocppRequestService
.requestHandler
<
1003 OCPP16StatusNotificationRequest
,
1004 OCPP16StatusNotificationResponse
1005 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
1007 status: OCPP16ChargePointStatus
.FINISHING
,
1008 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
1010 chargingStation
.getConnectorStatus(connectorId
).status = OCPP16ChargePointStatus
.FINISHING
;
1011 const stopResponse
= await chargingStation
.stopTransactionOnConnector(
1013 OCPP16StopTransactionReason
.REMOTE
1015 if (stopResponse
.idTagInfo
?.status === OCPP16AuthorizationStatus
.ACCEPTED
) {
1016 return OCPPConstants
.OCPP_RESPONSE_ACCEPTED
;
1018 return OCPPConstants
.OCPP_RESPONSE_REJECTED
;
1022 chargingStation
.logPrefix() +
1023 ' Trying to remote stop a non existing transaction ' +
1024 transactionId
.toString()
1026 return OCPPConstants
.OCPP_RESPONSE_REJECTED
;
1029 private handleRequestUpdateFirmware(
1030 chargingStation
: ChargingStation
,
1031 commandPayload
: OCPP16UpdateFirmwareRequest
1032 ): OCPP16UpdateFirmwareResponse
{
1034 OCPP16ServiceUtils
.checkFeatureProfile(
1036 OCPP16SupportedFeatureProfiles
.FirmwareManagement
,
1037 OCPP16IncomingRequestCommand
.UPDATE_FIRMWARE
1040 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
1042 const retrieveDate
= Utils
.convertToDate(commandPayload
.retrieveDate
);
1043 if (retrieveDate
.getTime() <= Date.now()) {
1046 this.updateFirmware
.bind(this) as (
1047 this: OCPP16IncomingRequestService
,
1054 /* This is intentional */
1058 this.updateFirmware(chargingStation
).catch(() => {
1061 }, retrieveDate
.getTime() - Date.now());
1063 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
1066 private async updateFirmware(
1067 chargingStation
: ChargingStation
,
1071 chargingStation
.stopAutomaticTransactionGenerator();
1072 for (const connectorId
of chargingStation
.connectors
.keys()) {
1075 chargingStation
.getConnectorStatus(connectorId
).transactionStarted
=== false
1077 await chargingStation
.ocppRequestService
.requestHandler
<
1078 OCPP16StatusNotificationRequest
,
1079 OCPP16StatusNotificationResponse
1080 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
1082 status: OCPP16ChargePointStatus
.UNAVAILABLE
,
1083 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
1087 await chargingStation
.ocppRequestService
.requestHandler
<
1088 OCPP16FirmwareStatusNotificationRequest
,
1089 OCPP16FirmwareStatusNotificationResponse
1090 >(chargingStation
, OCPP16RequestCommand
.FIRMWARE_STATUS_NOTIFICATION
, {
1091 status: OCPP16FirmwareStatus
.Downloading
,
1093 chargingStation
.stationInfo
.firmwareStatus
= OCPP16FirmwareStatus
.Downloading
;
1094 await Utils
.sleep(Utils
.getRandomInteger(minDelay
, maxDelay
) * 1000);
1095 await chargingStation
.ocppRequestService
.requestHandler
<
1096 OCPP16FirmwareStatusNotificationRequest
,
1097 OCPP16FirmwareStatusNotificationResponse
1098 >(chargingStation
, OCPP16RequestCommand
.FIRMWARE_STATUS_NOTIFICATION
, {
1099 status: OCPP16FirmwareStatus
.Downloaded
,
1101 chargingStation
.stationInfo
.firmwareStatus
= OCPP16FirmwareStatus
.Downloaded
;
1102 await Utils
.sleep(Utils
.getRandomInteger(minDelay
, maxDelay
) * 1000);
1103 await chargingStation
.ocppRequestService
.requestHandler
<
1104 OCPP16FirmwareStatusNotificationRequest
,
1105 OCPP16FirmwareStatusNotificationResponse
1106 >(chargingStation
, OCPP16RequestCommand
.FIRMWARE_STATUS_NOTIFICATION
, {
1107 status: OCPP16FirmwareStatus
.Installing
,
1109 chargingStation
.stationInfo
.firmwareStatus
= OCPP16FirmwareStatus
.Installing
;
1110 await Utils
.sleep(Utils
.getRandomInteger(minDelay
, maxDelay
) * 1000);
1111 await chargingStation
.reset();
1114 private async handleRequestGetDiagnostics(
1115 chargingStation
: ChargingStation
,
1116 commandPayload
: GetDiagnosticsRequest
1117 ): Promise
<GetDiagnosticsResponse
> {
1119 OCPP16ServiceUtils
.checkFeatureProfile(
1121 OCPP16SupportedFeatureProfiles
.FirmwareManagement
,
1122 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
1125 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
1127 const uri
= new URL(commandPayload
.location
);
1128 if (uri
.protocol
.startsWith('ftp:')) {
1129 let ftpClient
: Client
;
1132 .readdirSync(path
.resolve(path
.dirname(fileURLToPath(import.meta
.url
)), '../../../../'))
1133 .filter((file
) => file
.endsWith('.log'))
1134 .map((file
) => path
.join('./', file
));
1135 const diagnosticsArchive
= chargingStation
.stationInfo
.chargingStationId
+ '_logs.tar.gz';
1136 tar
.create({ gzip
: true }, logFiles
).pipe(fs
.createWriteStream(diagnosticsArchive
));
1137 ftpClient
= new Client();
1138 const accessResponse
= await ftpClient
.access({
1140 ...(!Utils
.isEmptyString(uri
.port
) && { port
: Utils
.convertToInt(uri
.port
) }),
1141 ...(!Utils
.isEmptyString(uri
.username
) && { user
: uri
.username
}),
1142 ...(!Utils
.isEmptyString(uri
.password
) && { password
: uri
.password
}),
1144 let uploadResponse
: FTPResponse
;
1145 if (accessResponse
.code
=== 220) {
1146 // eslint-disable-next-line @typescript-eslint/no-misused-promises
1147 ftpClient
.trackProgress(async (info
) => {
1149 `${chargingStation.logPrefix()} ${
1151 } bytes transferred from diagnostics archive ${info.name}`
1153 await chargingStation
.ocppRequestService
.requestHandler
<
1154 OCPP16DiagnosticsStatusNotificationRequest
,
1155 OCPP16DiagnosticsStatusNotificationResponse
1156 >(chargingStation
, OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
, {
1157 status: OCPP16DiagnosticsStatus
.Uploading
,
1160 uploadResponse
= await ftpClient
.uploadFrom(
1162 path
.resolve(path
.dirname(fileURLToPath(import.meta
.url
)), '../../../../'),
1165 uri
.pathname
+ diagnosticsArchive
1167 if (uploadResponse
.code
=== 226) {
1168 await chargingStation
.ocppRequestService
.requestHandler
<
1169 OCPP16DiagnosticsStatusNotificationRequest
,
1170 OCPP16DiagnosticsStatusNotificationResponse
1171 >(chargingStation
, OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
, {
1172 status: OCPP16DiagnosticsStatus
.Uploaded
,
1177 return { fileName
: diagnosticsArchive
};
1179 throw new OCPPError(
1180 ErrorType
.GENERIC_ERROR
,
1181 `Diagnostics transfer failed with error code ${accessResponse.code.toString()}${
1182 uploadResponse?.code && '|' + uploadResponse?.code.toString()
1184 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
1187 throw new OCPPError(
1188 ErrorType
.GENERIC_ERROR
,
1189 `Diagnostics transfer failed with error code ${accessResponse.code.toString()}${
1190 uploadResponse?.code && '|' + uploadResponse?.code.toString()
1192 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
1195 await chargingStation
.ocppRequestService
.requestHandler
<
1196 OCPP16DiagnosticsStatusNotificationRequest
,
1197 OCPP16DiagnosticsStatusNotificationResponse
1198 >(chargingStation
, OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
, {
1199 status: OCPP16DiagnosticsStatus
.UploadFailed
,
1204 return this.handleIncomingRequestError(
1206 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
,
1208 { errorResponse
: OCPPConstants
.OCPP_RESPONSE_EMPTY
}
1213 `${chargingStation.logPrefix()} Unsupported protocol ${
1215 } to transfer the diagnostic logs archive`
1217 await chargingStation
.ocppRequestService
.requestHandler
<
1218 OCPP16DiagnosticsStatusNotificationRequest
,
1219 OCPP16DiagnosticsStatusNotificationResponse
1220 >(chargingStation
, OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
, {
1221 status: OCPP16DiagnosticsStatus
.UploadFailed
,
1223 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
1227 private handleRequestTriggerMessage(
1228 chargingStation
: ChargingStation
,
1229 commandPayload
: OCPP16TriggerMessageRequest
1230 ): OCPP16TriggerMessageResponse
{
1232 !OCPP16ServiceUtils
.checkFeatureProfile(
1234 OCPP16SupportedFeatureProfiles
.RemoteTrigger
,
1235 OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
1237 !OCPP16ServiceUtils
.isMessageTriggerSupported(
1239 commandPayload
.requestedMessage
1242 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED
;
1245 !OCPP16ServiceUtils
.isConnectorIdValid(
1247 OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
,
1248 commandPayload
.connectorId
1251 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED
;
1254 switch (commandPayload
.requestedMessage
) {
1255 case OCPP16MessageTrigger
.BootNotification
:
1257 chargingStation
.ocppRequestService
1258 .requestHandler
<OCPP16BootNotificationRequest
, OCPP16BootNotificationResponse
>(
1260 OCPP16RequestCommand
.BOOT_NOTIFICATION
,
1261 chargingStation
.bootNotificationRequest
,
1262 { skipBufferingOnError
: true, triggerMessage
: true }
1264 .then((response
) => {
1265 chargingStation
.bootNotificationResponse
= response
;
1268 /* This is intentional */
1270 }, Constants
.OCPP_TRIGGER_MESSAGE_DELAY
);
1271 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED
;
1272 case OCPP16MessageTrigger
.Heartbeat
:
1274 chargingStation
.ocppRequestService
1275 .requestHandler
<OCPP16HeartbeatRequest
, OCPP16HeartbeatResponse
>(
1277 OCPP16RequestCommand
.HEARTBEAT
,
1280 triggerMessage
: true,
1284 /* This is intentional */
1286 }, Constants
.OCPP_TRIGGER_MESSAGE_DELAY
);
1287 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED
;
1288 case OCPP16MessageTrigger
.StatusNotification
:
1290 if (commandPayload
?.connectorId
) {
1291 chargingStation
.ocppRequestService
1292 .requestHandler
<OCPP16StatusNotificationRequest
, OCPP16StatusNotificationResponse
>(
1294 OCPP16RequestCommand
.STATUS_NOTIFICATION
,
1296 connectorId
: commandPayload
.connectorId
,
1297 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
1298 status: chargingStation
.getConnectorStatus(commandPayload
.connectorId
).status,
1301 triggerMessage
: true,
1305 /* This is intentional */
1308 for (const connectorId
of chargingStation
.connectors
.keys()) {
1309 chargingStation
.ocppRequestService
1311 OCPP16StatusNotificationRequest
,
1312 OCPP16StatusNotificationResponse
1315 OCPP16RequestCommand
.STATUS_NOTIFICATION
,
1318 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
1319 status: chargingStation
.getConnectorStatus(connectorId
).status,
1322 triggerMessage
: true,
1326 /* This is intentional */
1330 }, Constants
.OCPP_TRIGGER_MESSAGE_DELAY
);
1331 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED
;
1333 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED
;
1336 return this.handleIncomingRequestError(
1338 OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
,
1340 { errorResponse
: OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED
}
1345 private handleRequestDataTransfer(
1346 chargingStation
: ChargingStation
,
1347 commandPayload
: OCPP16DataTransferRequest
1348 ): OCPP16DataTransferResponse
{
1350 if (Object.values(OCPP16DataTransferVendorId
).includes(commandPayload
.vendorId
)) {
1352 status: OCPP16DataTransferStatus
.ACCEPTED
,
1356 status: OCPP16DataTransferStatus
.UNKNOWN_VENDOR_ID
,
1359 return this.handleIncomingRequestError(
1361 OCPP16IncomingRequestCommand
.DATA_TRANSFER
,
1363 { errorResponse
: OCPPConstants
.OCPP_DATA_TRANSFER_RESPONSE_REJECTED
}