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';
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 OCPP16ServiceUtils
.parseJsonSchemaFile
<ResetRequest
>(
144 '../../../assets/json-schemas/ocpp/1.6/Reset.json'
148 OCPP16IncomingRequestCommand
.CLEAR_CACHE
,
149 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16ClearCacheRequest
>(
150 '../../../assets/json-schemas/ocpp/1.6/ClearCache.json'
154 OCPP16IncomingRequestCommand
.UNLOCK_CONNECTOR
,
155 OCPP16ServiceUtils
.parseJsonSchemaFile
<UnlockConnectorRequest
>(
156 '../../../assets/json-schemas/ocpp/1.6/UnlockConnector.json'
160 OCPP16IncomingRequestCommand
.GET_CONFIGURATION
,
161 OCPP16ServiceUtils
.parseJsonSchemaFile
<GetConfigurationRequest
>(
162 '../../../assets/json-schemas/ocpp/1.6/GetConfiguration.json'
166 OCPP16IncomingRequestCommand
.CHANGE_CONFIGURATION
,
167 OCPP16ServiceUtils
.parseJsonSchemaFile
<ChangeConfigurationRequest
>(
168 '../../../assets/json-schemas/ocpp/1.6/ChangeConfiguration.json'
172 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
,
173 OCPP16ServiceUtils
.parseJsonSchemaFile
<GetDiagnosticsRequest
>(
174 '../../../assets/json-schemas/ocpp/1.6/GetDiagnostics.json'
178 OCPP16IncomingRequestCommand
.SET_CHARGING_PROFILE
,
179 OCPP16ServiceUtils
.parseJsonSchemaFile
<SetChargingProfileRequest
>(
180 '../../../assets/json-schemas/ocpp/1.6/SetChargingProfile.json'
184 OCPP16IncomingRequestCommand
.CLEAR_CHARGING_PROFILE
,
185 OCPP16ServiceUtils
.parseJsonSchemaFile
<ClearChargingProfileRequest
>(
186 '../../../assets/json-schemas/ocpp/1.6/ClearChargingProfile.json'
190 OCPP16IncomingRequestCommand
.CHANGE_AVAILABILITY
,
191 OCPP16ServiceUtils
.parseJsonSchemaFile
<ChangeAvailabilityRequest
>(
192 '../../../assets/json-schemas/ocpp/1.6/ChangeAvailability.json'
196 OCPP16IncomingRequestCommand
.REMOTE_START_TRANSACTION
,
197 OCPP16ServiceUtils
.parseJsonSchemaFile
<RemoteStartTransactionRequest
>(
198 '../../../assets/json-schemas/ocpp/1.6/RemoteStartTransaction.json'
202 OCPP16IncomingRequestCommand
.REMOTE_STOP_TRANSACTION
,
203 OCPP16ServiceUtils
.parseJsonSchemaFile
<RemoteStopTransactionRequest
>(
204 '../../../assets/json-schemas/ocpp/1.6/RemoteStopTransaction.json'
208 OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
,
209 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16TriggerMessageRequest
>(
210 '../../../assets/json-schemas/ocpp/1.6/TriggerMessage.json'
214 OCPP16IncomingRequestCommand
.DATA_TRANSFER
,
215 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16DataTransferRequest
>(
216 '../../../assets/json-schemas/ocpp/1.6/DataTransfer.json'
220 OCPP16IncomingRequestCommand
.UPDATE_FIRMWARE
,
221 OCPP16ServiceUtils
.parseJsonSchemaFile
<OCPP16UpdateFirmwareRequest
>(
222 '../../../assets/json-schemas/ocpp/1.6/UpdateFirmware.json'
226 this.validatePayload
.bind(this);
229 public async incomingRequestHandler(
230 chargingStation
: ChargingStation
,
232 commandName
: OCPP16IncomingRequestCommand
,
233 commandPayload
: JsonType
235 let response
: JsonType
;
237 chargingStation
.getOcppStrictCompliance() === true &&
238 chargingStation
.isInPendingState() === true &&
239 (commandName
=== OCPP16IncomingRequestCommand
.REMOTE_START_TRANSACTION
||
240 commandName
=== OCPP16IncomingRequestCommand
.REMOTE_STOP_TRANSACTION
)
243 ErrorType
.SECURITY_ERROR
,
244 `${commandName} cannot be issued to handle request PDU ${JSON.stringify(
248 )} while the charging station is in pending state on the central server`,
254 chargingStation
.isRegistered() === true ||
255 (chargingStation
.getOcppStrictCompliance() === false &&
256 chargingStation
.isInUnknownState() === true)
259 this.incomingRequestHandlers
.has(commandName
) === true &&
260 OCPP16ServiceUtils
.isIncomingRequestCommandSupported(chargingStation
, commandName
) === true
263 this.validatePayload(chargingStation
, commandName
, commandPayload
);
264 // Call the method to build the response
265 response
= await this.incomingRequestHandlers
.get(commandName
)(
272 `${chargingStation.logPrefix()} ${moduleName}.incomingRequestHandler: Handle incoming request error:`,
280 ErrorType
.NOT_IMPLEMENTED
,
281 `${commandName} is not implemented to handle request PDU ${JSON.stringify(
292 ErrorType
.SECURITY_ERROR
,
293 `${commandName} cannot be issued to handle request PDU ${JSON.stringify(
297 )} while the charging station is not registered on the central server.`,
302 // Send the built response
303 await chargingStation
.ocppRequestService
.sendResponse(
311 private validatePayload(
312 chargingStation
: ChargingStation
,
313 commandName
: OCPP16IncomingRequestCommand
,
314 commandPayload
: JsonType
316 if (this.jsonSchemas
.has(commandName
) === true) {
317 return this.validateIncomingRequestPayload(
320 this.jsonSchemas
.get(commandName
),
325 `${chargingStation.logPrefix()} ${moduleName}.validatePayload: No JSON schema found for command '${commandName}' PDU validation`
330 // Simulate charging station restart
331 private handleRequestReset(
332 chargingStation
: ChargingStation
,
333 commandPayload
: ResetRequest
337 chargingStation
.reset
.bind(chargingStation
) as (
338 this: ChargingStation
,
342 `${commandPayload.type}Reset` as OCPP16StopTransactionReason
345 /* This is intentional */
348 `${chargingStation.logPrefix()} ${
350 } reset command received, simulating it. The station will be back online in ${Utils.formatDurationMilliSeconds(
351 chargingStation.stationInfo.resetTime
354 return OCPPConstants
.OCPP_RESPONSE_ACCEPTED
;
357 private async handleRequestUnlockConnector(
358 chargingStation
: ChargingStation
,
359 commandPayload
: UnlockConnectorRequest
360 ): Promise
<UnlockConnectorResponse
> {
361 const connectorId
= commandPayload
.connectorId
;
362 if (chargingStation
.connectors
.has(connectorId
) === false) {
364 `${chargingStation.logPrefix()} Trying to unlock a non existing connector Id ${connectorId.toString()}`
366 return OCPPConstants
.OCPP_RESPONSE_UNLOCK_NOT_SUPPORTED
;
368 if (connectorId
=== 0) {
370 `${chargingStation.logPrefix()} Trying to unlock connector Id ${connectorId.toString()}`
372 return OCPPConstants
.OCPP_RESPONSE_UNLOCK_NOT_SUPPORTED
;
374 if (chargingStation
.getConnectorStatus(connectorId
)?.transactionStarted
=== true) {
375 const stopResponse
= await chargingStation
.stopTransactionOnConnector(
377 OCPP16StopTransactionReason
.UNLOCK_COMMAND
379 if (stopResponse
.idTagInfo
?.status === OCPP16AuthorizationStatus
.ACCEPTED
) {
380 return OCPPConstants
.OCPP_RESPONSE_UNLOCKED
;
382 return OCPPConstants
.OCPP_RESPONSE_UNLOCK_FAILED
;
384 await chargingStation
.ocppRequestService
.requestHandler
<
385 OCPP16StatusNotificationRequest
,
386 OCPP16StatusNotificationResponse
387 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
389 status: OCPP16ChargePointStatus
.AVAILABLE
,
390 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
392 chargingStation
.getConnectorStatus(connectorId
).status = OCPP16ChargePointStatus
.AVAILABLE
;
393 return OCPPConstants
.OCPP_RESPONSE_UNLOCKED
;
396 private handleRequestGetConfiguration(
397 chargingStation
: ChargingStation
,
398 commandPayload
: GetConfigurationRequest
399 ): GetConfigurationResponse
{
400 const configurationKey
: OCPPConfigurationKey
[] = [];
401 const unknownKey
: string[] = [];
402 if (Utils
.isEmptyArray(commandPayload
.key
) === true) {
403 for (const configuration
of chargingStation
.ocppConfiguration
.configurationKey
) {
404 if (Utils
.isUndefined(configuration
.visible
) === true) {
405 configuration
.visible
= true;
407 if (configuration
.visible
=== false) {
410 configurationKey
.push({
411 key
: configuration
.key
,
412 readonly: configuration
.readonly,
413 value
: configuration
.value
,
417 for (const key
of commandPayload
.key
) {
418 const keyFound
= ChargingStationConfigurationUtils
.getConfigurationKey(
423 if (Utils
.isUndefined(keyFound
.visible
) === true) {
424 keyFound
.visible
= true;
426 if (keyFound
.visible
=== false) {
429 configurationKey
.push({
431 readonly: keyFound
.readonly,
432 value
: keyFound
.value
,
435 unknownKey
.push(key
);
445 private handleRequestChangeConfiguration(
446 chargingStation
: ChargingStation
,
447 commandPayload
: ChangeConfigurationRequest
448 ): ChangeConfigurationResponse
{
449 const keyToChange
= ChargingStationConfigurationUtils
.getConfigurationKey(
455 return OCPPConstants
.OCPP_CONFIGURATION_RESPONSE_NOT_SUPPORTED
;
456 } else if (keyToChange
&& keyToChange
.readonly) {
457 return OCPPConstants
.OCPP_CONFIGURATION_RESPONSE_REJECTED
;
458 } else if (keyToChange
&& !keyToChange
.readonly) {
459 let valueChanged
= false;
460 if (keyToChange
.value
!== commandPayload
.value
) {
461 ChargingStationConfigurationUtils
.setConfigurationKeyValue(
464 commandPayload
.value
,
469 let triggerHeartbeatRestart
= false;
470 if (keyToChange
.key
=== OCPP16StandardParametersKey
.HeartBeatInterval
&& valueChanged
) {
471 ChargingStationConfigurationUtils
.setConfigurationKeyValue(
473 OCPP16StandardParametersKey
.HeartbeatInterval
,
476 triggerHeartbeatRestart
= true;
478 if (keyToChange
.key
=== OCPP16StandardParametersKey
.HeartbeatInterval
&& valueChanged
) {
479 ChargingStationConfigurationUtils
.setConfigurationKeyValue(
481 OCPP16StandardParametersKey
.HeartBeatInterval
,
484 triggerHeartbeatRestart
= true;
486 if (triggerHeartbeatRestart
) {
487 chargingStation
.restartHeartbeat();
489 if (keyToChange
.key
=== OCPP16StandardParametersKey
.WebSocketPingInterval
&& valueChanged
) {
490 chargingStation
.restartWebSocketPing();
492 if (keyToChange
.reboot
) {
493 return OCPPConstants
.OCPP_CONFIGURATION_RESPONSE_REBOOT_REQUIRED
;
495 return OCPPConstants
.OCPP_CONFIGURATION_RESPONSE_ACCEPTED
;
499 private handleRequestSetChargingProfile(
500 chargingStation
: ChargingStation
,
501 commandPayload
: SetChargingProfileRequest
502 ): SetChargingProfileResponse
{
504 OCPP16ServiceUtils
.checkFeatureProfile(
506 OCPP16SupportedFeatureProfiles
.SmartCharging
,
507 OCPP16IncomingRequestCommand
.SET_CHARGING_PROFILE
510 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_NOT_SUPPORTED
;
512 if (chargingStation
.connectors
.has(commandPayload
.connectorId
) === false) {
514 `${chargingStation.logPrefix()} Trying to set charging profile(s) to a non existing connector Id ${
515 commandPayload.connectorId
518 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED
;
521 commandPayload
.csChargingProfiles
.chargingProfilePurpose
===
522 ChargingProfilePurposeType
.CHARGE_POINT_MAX_PROFILE
&&
523 commandPayload
.connectorId
!== 0
525 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED
;
528 commandPayload
.csChargingProfiles
.chargingProfilePurpose
===
529 ChargingProfilePurposeType
.TX_PROFILE
&&
530 (commandPayload
.connectorId
=== 0 ||
531 chargingStation
.getConnectorStatus(commandPayload
.connectorId
)?.transactionStarted
===
535 `${chargingStation.logPrefix()} Trying to set transaction charging profile(s) on connector ${
536 commandPayload.connectorId
537 } without a started transaction`
539 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED
;
541 OCPP16ServiceUtils
.setChargingProfile(
543 commandPayload
.connectorId
,
544 commandPayload
.csChargingProfiles
547 `${chargingStation.logPrefix()} Charging profile(s) set on connector id ${
548 commandPayload.connectorId
550 commandPayload
.csChargingProfiles
552 return OCPPConstants
.OCPP_SET_CHARGING_PROFILE_RESPONSE_ACCEPTED
;
555 private handleRequestClearChargingProfile(
556 chargingStation
: ChargingStation
,
557 commandPayload
: ClearChargingProfileRequest
558 ): ClearChargingProfileResponse
{
560 OCPP16ServiceUtils
.checkFeatureProfile(
562 OCPP16SupportedFeatureProfiles
.SmartCharging
,
563 OCPP16IncomingRequestCommand
.CLEAR_CHARGING_PROFILE
566 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN
;
568 if (chargingStation
.connectors
.has(commandPayload
.connectorId
) === false) {
570 `${chargingStation.logPrefix()} Trying to clear a charging profile(s) to a non existing connector Id ${
571 commandPayload.connectorId
574 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN
;
576 const connectorStatus
= chargingStation
.getConnectorStatus(commandPayload
.connectorId
);
578 !Utils
.isNullOrUndefined(commandPayload
.connectorId
) &&
579 !Utils
.isEmptyArray(connectorStatus
?.chargingProfiles
)
581 connectorStatus
.chargingProfiles
= [];
583 `${chargingStation.logPrefix()} Charging profile(s) cleared on connector id ${
584 commandPayload.connectorId
587 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_ACCEPTED
;
589 if (Utils
.isNullOrUndefined(commandPayload
.connectorId
)) {
590 let clearedCP
= false;
591 for (const connectorId
of chargingStation
.connectors
.keys()) {
593 !Utils
.isEmptyArray(chargingStation
.getConnectorStatus(connectorId
)?.chargingProfiles
)
596 .getConnectorStatus(connectorId
)
597 ?.chargingProfiles
?.forEach((chargingProfile
: OCPP16ChargingProfile
, index
: number) => {
598 let clearCurrentCP
= false;
599 if (chargingProfile
.chargingProfileId
=== commandPayload
.id
) {
600 clearCurrentCP
= true;
603 !commandPayload
.chargingProfilePurpose
&&
604 chargingProfile
.stackLevel
=== commandPayload
.stackLevel
606 clearCurrentCP
= true;
609 !chargingProfile
.stackLevel
&&
610 chargingProfile
.chargingProfilePurpose
=== commandPayload
.chargingProfilePurpose
612 clearCurrentCP
= true;
615 chargingProfile
.stackLevel
=== commandPayload
.stackLevel
&&
616 chargingProfile
.chargingProfilePurpose
=== commandPayload
.chargingProfilePurpose
618 clearCurrentCP
= true;
620 if (clearCurrentCP
) {
621 connectorStatus
?.chargingProfiles
?.splice(index
, 1);
623 `${chargingStation.logPrefix()} Matching charging profile(s) cleared: %j`,
632 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_ACCEPTED
;
635 return OCPPConstants
.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN
;
638 private async handleRequestChangeAvailability(
639 chargingStation
: ChargingStation
,
640 commandPayload
: ChangeAvailabilityRequest
641 ): Promise
<ChangeAvailabilityResponse
> {
642 const connectorId
: number = commandPayload
.connectorId
;
643 if (chargingStation
.connectors
.has(connectorId
) === false) {
645 `${chargingStation.logPrefix()} Trying to change the availability of a non existing connector Id ${connectorId.toString()}`
647 return OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_REJECTED
;
649 const chargePointStatus
: OCPP16ChargePointStatus
=
650 commandPayload
.type === OCPP16AvailabilityType
.OPERATIVE
651 ? OCPP16ChargePointStatus
.AVAILABLE
652 : OCPP16ChargePointStatus
.UNAVAILABLE
;
653 if (connectorId
=== 0) {
654 let response
: ChangeAvailabilityResponse
= OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_ACCEPTED
;
655 for (const id
of chargingStation
.connectors
.keys()) {
656 if (chargingStation
.getConnectorStatus(id
)?.transactionStarted
=== true) {
657 response
= OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_SCHEDULED
;
659 chargingStation
.getConnectorStatus(id
).availability
= commandPayload
.type;
660 if (response
=== OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_ACCEPTED
) {
661 await chargingStation
.ocppRequestService
.requestHandler
<
662 OCPP16StatusNotificationRequest
,
663 OCPP16StatusNotificationResponse
664 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
666 status: chargePointStatus
,
667 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
669 chargingStation
.getConnectorStatus(id
).status = chargePointStatus
;
675 (chargingStation
.isChargingStationAvailable() === true ||
676 (chargingStation
.isChargingStationAvailable() === false &&
677 commandPayload
.type === OCPP16AvailabilityType
.INOPERATIVE
))
679 if (chargingStation
.getConnectorStatus(connectorId
)?.transactionStarted
=== true) {
680 chargingStation
.getConnectorStatus(connectorId
).availability
= commandPayload
.type;
681 return OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_SCHEDULED
;
683 chargingStation
.getConnectorStatus(connectorId
).availability
= commandPayload
.type;
684 await chargingStation
.ocppRequestService
.requestHandler
<
685 OCPP16StatusNotificationRequest
,
686 OCPP16StatusNotificationResponse
687 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
689 status: chargePointStatus
,
690 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
692 chargingStation
.getConnectorStatus(connectorId
).status = chargePointStatus
;
693 return OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_ACCEPTED
;
695 return OCPPConstants
.OCPP_AVAILABILITY_RESPONSE_REJECTED
;
698 private async handleRequestRemoteStartTransaction(
699 chargingStation
: ChargingStation
,
700 commandPayload
: RemoteStartTransactionRequest
701 ): Promise
<GenericResponse
> {
702 const transactionConnectorId
= commandPayload
.connectorId
;
703 if (chargingStation
.connectors
.has(transactionConnectorId
) === true) {
704 const remoteStartTransactionLogMsg
= `${chargingStation.logPrefix()} Transaction remotely STARTED on ${
705 chargingStation.stationInfo.chargingStationId
706 }#${transactionConnectorId.toString()} for idTag '${commandPayload.idTag}'`;
707 await chargingStation
.ocppRequestService
.requestHandler
<
708 OCPP16StatusNotificationRequest
,
709 OCPP16StatusNotificationResponse
710 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
711 connectorId
: transactionConnectorId
,
712 status: OCPP16ChargePointStatus
.PREPARING
,
713 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
715 const connectorStatus
= chargingStation
.getConnectorStatus(transactionConnectorId
);
716 connectorStatus
.status = OCPP16ChargePointStatus
.PREPARING
;
717 if (chargingStation
.isChargingStationAvailable() === true) {
718 // Check if authorized
719 if (chargingStation
.getAuthorizeRemoteTxRequests() === true) {
720 let authorized
= false;
722 chargingStation
.getLocalAuthListEnabled() === true &&
723 chargingStation
.hasAuthorizedTags() === true &&
724 !Utils
.isEmptyString(
725 chargingStation
.authorizedTagsCache
727 ChargingStationUtils
.getAuthorizationFile(chargingStation
.stationInfo
)
729 ?.find((idTag
) => idTag
=== commandPayload
.idTag
)
732 connectorStatus
.localAuthorizeIdTag
= commandPayload
.idTag
;
733 connectorStatus
.idTagLocalAuthorized
= true;
735 } else if (chargingStation
.getMustAuthorizeAtRemoteStart() === true) {
736 connectorStatus
.authorizeIdTag
= commandPayload
.idTag
;
737 const authorizeResponse
: OCPP16AuthorizeResponse
=
738 await chargingStation
.ocppRequestService
.requestHandler
<
739 OCPP16AuthorizeRequest
,
740 OCPP16AuthorizeResponse
741 >(chargingStation
, OCPP16RequestCommand
.AUTHORIZE
, {
742 idTag
: commandPayload
.idTag
,
744 if (authorizeResponse
?.idTagInfo
?.status === OCPP16AuthorizationStatus
.ACCEPTED
) {
749 `${chargingStation.logPrefix()} The charging station configuration expects authorize at remote start transaction but local authorization or authorize isn't enabled`
752 if (authorized
=== true) {
753 // Authorization successful, start transaction
755 this.setRemoteStartTransactionChargingProfile(
757 transactionConnectorId
,
758 commandPayload
.chargingProfile
761 connectorStatus
.transactionRemoteStarted
= true;
764 await chargingStation
.ocppRequestService
.requestHandler
<
765 OCPP16StartTransactionRequest
,
766 OCPP16StartTransactionResponse
767 >(chargingStation
, OCPP16RequestCommand
.START_TRANSACTION
, {
768 connectorId
: transactionConnectorId
,
769 idTag
: commandPayload
.idTag
,
771 ).idTagInfo
.status === OCPP16AuthorizationStatus
.ACCEPTED
773 logger
.debug(remoteStartTransactionLogMsg
);
774 return OCPPConstants
.OCPP_RESPONSE_ACCEPTED
;
776 return this.notifyRemoteStartTransactionRejected(
778 transactionConnectorId
,
782 return this.notifyRemoteStartTransactionRejected(
784 transactionConnectorId
,
788 return this.notifyRemoteStartTransactionRejected(
790 transactionConnectorId
,
794 // No authorization check required, start transaction
796 this.setRemoteStartTransactionChargingProfile(
798 transactionConnectorId
,
799 commandPayload
.chargingProfile
802 connectorStatus
.transactionRemoteStarted
= true;
805 await chargingStation
.ocppRequestService
.requestHandler
<
806 OCPP16StartTransactionRequest
,
807 OCPP16StartTransactionResponse
808 >(chargingStation
, OCPP16RequestCommand
.START_TRANSACTION
, {
809 connectorId
: transactionConnectorId
,
810 idTag
: commandPayload
.idTag
,
812 ).idTagInfo
.status === OCPP16AuthorizationStatus
.ACCEPTED
814 logger
.debug(remoteStartTransactionLogMsg
);
815 return OCPPConstants
.OCPP_RESPONSE_ACCEPTED
;
817 return this.notifyRemoteStartTransactionRejected(
819 transactionConnectorId
,
823 return this.notifyRemoteStartTransactionRejected(
825 transactionConnectorId
,
829 return this.notifyRemoteStartTransactionRejected(
831 transactionConnectorId
,
835 return this.notifyRemoteStartTransactionRejected(
837 transactionConnectorId
,
842 private async notifyRemoteStartTransactionRejected(
843 chargingStation
: ChargingStation
,
846 ): Promise
<GenericResponse
> {
848 chargingStation
.getConnectorStatus(connectorId
)?.status !== OCPP16ChargePointStatus
.AVAILABLE
850 await chargingStation
.ocppRequestService
.requestHandler
<
851 OCPP16StatusNotificationRequest
,
852 OCPP16StatusNotificationResponse
853 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
855 status: OCPP16ChargePointStatus
.AVAILABLE
,
856 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
858 chargingStation
.getConnectorStatus(connectorId
).status = OCPP16ChargePointStatus
.AVAILABLE
;
861 `${chargingStation.logPrefix()} Remote starting transaction REJECTED on connector Id ${connectorId.toString()}, idTag '${idTag}', availability '${
862 chargingStation.getConnectorStatus(connectorId)?.availability
863 }', status '${chargingStation.getConnectorStatus(connectorId)?.status}'`
865 return OCPPConstants
.OCPP_RESPONSE_REJECTED
;
868 private setRemoteStartTransactionChargingProfile(
869 chargingStation
: ChargingStation
,
871 cp
: OCPP16ChargingProfile
873 if (cp
&& cp
.chargingProfilePurpose
=== ChargingProfilePurposeType
.TX_PROFILE
) {
874 OCPP16ServiceUtils
.setChargingProfile(chargingStation
, connectorId
, cp
);
876 `${chargingStation.logPrefix()} Charging profile(s) set at remote start transaction on connector id ${connectorId}: %j`,
880 } else if (cp
&& cp
.chargingProfilePurpose
!== ChargingProfilePurposeType
.TX_PROFILE
) {
882 `${chargingStation.logPrefix()} Not allowed to set ${
883 cp.chargingProfilePurpose
884 } charging profile(s) at remote start transaction`
892 private async handleRequestRemoteStopTransaction(
893 chargingStation
: ChargingStation
,
894 commandPayload
: RemoteStopTransactionRequest
895 ): Promise
<GenericResponse
> {
896 const transactionId
= commandPayload
.transactionId
;
897 for (const connectorId
of chargingStation
.connectors
.keys()) {
900 chargingStation
.getConnectorStatus(connectorId
)?.transactionId
=== transactionId
902 await chargingStation
.ocppRequestService
.requestHandler
<
903 OCPP16StatusNotificationRequest
,
904 OCPP16StatusNotificationResponse
905 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
907 status: OCPP16ChargePointStatus
.FINISHING
,
908 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
910 chargingStation
.getConnectorStatus(connectorId
).status = OCPP16ChargePointStatus
.FINISHING
;
911 const stopResponse
= await chargingStation
.stopTransactionOnConnector(
913 OCPP16StopTransactionReason
.REMOTE
915 if (stopResponse
.idTagInfo
?.status === OCPP16AuthorizationStatus
.ACCEPTED
) {
916 return OCPPConstants
.OCPP_RESPONSE_ACCEPTED
;
918 return OCPPConstants
.OCPP_RESPONSE_REJECTED
;
922 `${chargingStation.logPrefix()} Trying to remote stop a non existing transaction ${transactionId.toString()}`
924 return OCPPConstants
.OCPP_RESPONSE_REJECTED
;
927 private handleRequestUpdateFirmware(
928 chargingStation
: ChargingStation
,
929 commandPayload
: OCPP16UpdateFirmwareRequest
930 ): OCPP16UpdateFirmwareResponse
{
932 OCPP16ServiceUtils
.checkFeatureProfile(
934 OCPP16SupportedFeatureProfiles
.FirmwareManagement
,
935 OCPP16IncomingRequestCommand
.UPDATE_FIRMWARE
939 `${chargingStation.logPrefix()} ${moduleName}.handleRequestUpdateFirmware: Cannot simulate firmware update: feature profile not supported`
941 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
944 !Utils
.isNullOrUndefined(chargingStation
.stationInfo
.firmwareStatus
) &&
945 chargingStation
.stationInfo
.firmwareStatus
!== OCPP16FirmwareStatus
.Installed
948 `${chargingStation.logPrefix()} ${moduleName}.handleRequestUpdateFirmware: Cannot simulate firmware update: firmware update is already in progress`
950 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
952 const retrieveDate
= Utils
.convertToDate(commandPayload
.retrieveDate
);
953 const now
= Date.now();
954 if (retrieveDate
?.getTime() <= now
) {
957 this.updateFirmware
.bind(this) as (
958 this: OCPP16IncomingRequestService
,
965 /* This is intentional */
969 this.updateFirmware(chargingStation
).catch(() => {
972 }, retrieveDate
?.getTime() - now
);
974 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
977 private async updateFirmware(
978 chargingStation
: ChargingStation
,
982 chargingStation
.stopAutomaticTransactionGenerator();
983 for (const connectorId
of chargingStation
.connectors
.keys()) {
986 chargingStation
.getConnectorStatus(connectorId
)?.transactionStarted
=== false
988 await chargingStation
.ocppRequestService
.requestHandler
<
989 OCPP16StatusNotificationRequest
,
990 OCPP16StatusNotificationResponse
991 >(chargingStation
, OCPP16RequestCommand
.STATUS_NOTIFICATION
, {
993 status: OCPP16ChargePointStatus
.UNAVAILABLE
,
994 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
996 chargingStation
.getConnectorStatus(connectorId
).status =
997 OCPP16ChargePointStatus
.UNAVAILABLE
;
1001 chargingStation
.stationInfo
?.firmwareUpgrade
?.failureStatus
&&
1002 !Utils
.isEmptyString(chargingStation
.stationInfo
?.firmwareUpgrade
?.failureStatus
)
1004 await chargingStation
.ocppRequestService
.requestHandler
<
1005 OCPP16FirmwareStatusNotificationRequest
,
1006 OCPP16FirmwareStatusNotificationResponse
1007 >(chargingStation
, OCPP16RequestCommand
.FIRMWARE_STATUS_NOTIFICATION
, {
1008 status: chargingStation
.stationInfo
?.firmwareUpgrade
?.failureStatus
,
1012 await chargingStation
.ocppRequestService
.requestHandler
<
1013 OCPP16FirmwareStatusNotificationRequest
,
1014 OCPP16FirmwareStatusNotificationResponse
1015 >(chargingStation
, OCPP16RequestCommand
.FIRMWARE_STATUS_NOTIFICATION
, {
1016 status: OCPP16FirmwareStatus
.Downloading
,
1018 chargingStation
.stationInfo
.firmwareStatus
= OCPP16FirmwareStatus
.Downloading
;
1019 await Utils
.sleep(Utils
.getRandomInteger(maxDelay
, minDelay
) * 1000);
1020 await chargingStation
.ocppRequestService
.requestHandler
<
1021 OCPP16FirmwareStatusNotificationRequest
,
1022 OCPP16FirmwareStatusNotificationResponse
1023 >(chargingStation
, OCPP16RequestCommand
.FIRMWARE_STATUS_NOTIFICATION
, {
1024 status: OCPP16FirmwareStatus
.Downloaded
,
1026 chargingStation
.stationInfo
.firmwareStatus
= OCPP16FirmwareStatus
.Downloaded
;
1027 await Utils
.sleep(Utils
.getRandomInteger(maxDelay
, minDelay
) * 1000);
1028 await chargingStation
.ocppRequestService
.requestHandler
<
1029 OCPP16FirmwareStatusNotificationRequest
,
1030 OCPP16FirmwareStatusNotificationResponse
1031 >(chargingStation
, OCPP16RequestCommand
.FIRMWARE_STATUS_NOTIFICATION
, {
1032 status: OCPP16FirmwareStatus
.Installing
,
1034 chargingStation
.stationInfo
.firmwareStatus
= OCPP16FirmwareStatus
.Installing
;
1035 if (chargingStation
.stationInfo
?.firmwareUpgrade
?.reset
=== true) {
1036 await Utils
.sleep(Utils
.getRandomInteger(maxDelay
, minDelay
) * 1000);
1037 await chargingStation
.reset(OCPP16StopTransactionReason
.REBOOT
);
1041 private async handleRequestGetDiagnostics(
1042 chargingStation
: ChargingStation
,
1043 commandPayload
: GetDiagnosticsRequest
1044 ): Promise
<GetDiagnosticsResponse
> {
1046 OCPP16ServiceUtils
.checkFeatureProfile(
1048 OCPP16SupportedFeatureProfiles
.FirmwareManagement
,
1049 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
1053 `${chargingStation.logPrefix()} ${moduleName}.handleRequestGetDiagnostics: Cannot get diagnostics: feature profile not supported`
1055 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
1057 const uri
= new URL(commandPayload
.location
);
1058 if (uri
.protocol
.startsWith('ftp:')) {
1059 let ftpClient
: Client
;
1062 .readdirSync(path
.resolve(path
.dirname(fileURLToPath(import.meta
.url
)), '../../../../'))
1063 .filter((file
) => file
.endsWith('.log'))
1064 .map((file
) => path
.join('./', file
));
1065 const diagnosticsArchive
= `${chargingStation.stationInfo.chargingStationId}_logs.tar.gz`;
1066 tar
.create({ gzip
: true }, logFiles
).pipe(fs
.createWriteStream(diagnosticsArchive
));
1067 ftpClient
= new Client();
1068 const accessResponse
= await ftpClient
.access({
1070 ...(!Utils
.isEmptyString(uri
.port
) && { port
: Utils
.convertToInt(uri
.port
) }),
1071 ...(!Utils
.isEmptyString(uri
.username
) && { user
: uri
.username
}),
1072 ...(!Utils
.isEmptyString(uri
.password
) && { password
: uri
.password
}),
1074 let uploadResponse
: FTPResponse
;
1075 if (accessResponse
.code
=== 220) {
1076 ftpClient
.trackProgress((info
) => {
1078 `${chargingStation.logPrefix()} ${
1080 } bytes transferred from diagnostics archive ${info.name}`
1082 chargingStation
.ocppRequestService
1084 OCPP16DiagnosticsStatusNotificationRequest
,
1085 OCPP16DiagnosticsStatusNotificationResponse
1086 >(chargingStation
, OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
, {
1087 status: OCPP16DiagnosticsStatus
.Uploading
,
1091 `${chargingStation.logPrefix()} ${moduleName}.handleRequestGetDiagnostics: Error while sending '${
1092 OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION
1098 uploadResponse
= await ftpClient
.uploadFrom(
1100 path
.resolve(path
.dirname(fileURLToPath(import.meta
.url
)), '../../../../'),
1103 `${uri.pathname}${diagnosticsArchive}`
1105 if (uploadResponse
.code
=== 226) {
1106 await chargingStation
.ocppRequestService
.requestHandler
<
1107 OCPP16DiagnosticsStatusNotificationRequest
,
1108 OCPP16DiagnosticsStatusNotificationResponse
1109 >(chargingStation
, OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
, {
1110 status: OCPP16DiagnosticsStatus
.Uploaded
,
1115 return { fileName
: diagnosticsArchive
};
1117 throw new OCPPError(
1118 ErrorType
.GENERIC_ERROR
,
1119 `Diagnostics transfer failed with error code ${accessResponse.code.toString()}${
1120 uploadResponse?.code && `|${uploadResponse?.code.toString()}
`
1122 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
1125 throw new OCPPError(
1126 ErrorType
.GENERIC_ERROR
,
1127 `Diagnostics transfer failed with error code ${accessResponse.code.toString()}${
1128 uploadResponse?.code && `|${uploadResponse?.code.toString()}
`
1130 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
1133 await chargingStation
.ocppRequestService
.requestHandler
<
1134 OCPP16DiagnosticsStatusNotificationRequest
,
1135 OCPP16DiagnosticsStatusNotificationResponse
1136 >(chargingStation
, OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
, {
1137 status: OCPP16DiagnosticsStatus
.UploadFailed
,
1142 return this.handleIncomingRequestError(
1144 OCPP16IncomingRequestCommand
.GET_DIAGNOSTICS
,
1146 { errorResponse
: OCPPConstants
.OCPP_RESPONSE_EMPTY
}
1151 `${chargingStation.logPrefix()} Unsupported protocol ${
1153 } to transfer the diagnostic logs archive`
1155 await chargingStation
.ocppRequestService
.requestHandler
<
1156 OCPP16DiagnosticsStatusNotificationRequest
,
1157 OCPP16DiagnosticsStatusNotificationResponse
1158 >(chargingStation
, OCPP16RequestCommand
.DIAGNOSTICS_STATUS_NOTIFICATION
, {
1159 status: OCPP16DiagnosticsStatus
.UploadFailed
,
1161 return OCPPConstants
.OCPP_RESPONSE_EMPTY
;
1165 private handleRequestTriggerMessage(
1166 chargingStation
: ChargingStation
,
1167 commandPayload
: OCPP16TriggerMessageRequest
1168 ): OCPP16TriggerMessageResponse
{
1170 !OCPP16ServiceUtils
.checkFeatureProfile(
1172 OCPP16SupportedFeatureProfiles
.RemoteTrigger
,
1173 OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
1175 !OCPP16ServiceUtils
.isMessageTriggerSupported(
1177 commandPayload
.requestedMessage
1180 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED
;
1183 !OCPP16ServiceUtils
.isConnectorIdValid(
1185 OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
,
1186 commandPayload
.connectorId
1189 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED
;
1192 switch (commandPayload
.requestedMessage
) {
1193 case OCPP16MessageTrigger
.BootNotification
:
1195 chargingStation
.ocppRequestService
1196 .requestHandler
<OCPP16BootNotificationRequest
, OCPP16BootNotificationResponse
>(
1198 OCPP16RequestCommand
.BOOT_NOTIFICATION
,
1199 chargingStation
.bootNotificationRequest
,
1200 { skipBufferingOnError
: true, triggerMessage
: true }
1202 .then((response
) => {
1203 chargingStation
.bootNotificationResponse
= response
;
1206 /* This is intentional */
1208 }, Constants
.OCPP_TRIGGER_MESSAGE_DELAY
);
1209 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED
;
1210 case OCPP16MessageTrigger
.Heartbeat
:
1212 chargingStation
.ocppRequestService
1213 .requestHandler
<OCPP16HeartbeatRequest
, OCPP16HeartbeatResponse
>(
1215 OCPP16RequestCommand
.HEARTBEAT
,
1218 triggerMessage
: true,
1222 /* This is intentional */
1224 }, Constants
.OCPP_TRIGGER_MESSAGE_DELAY
);
1225 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED
;
1226 case OCPP16MessageTrigger
.StatusNotification
:
1228 if (!Utils
.isNullOrUndefined(commandPayload
?.connectorId
)) {
1229 chargingStation
.ocppRequestService
1230 .requestHandler
<OCPP16StatusNotificationRequest
, OCPP16StatusNotificationResponse
>(
1232 OCPP16RequestCommand
.STATUS_NOTIFICATION
,
1234 connectorId
: commandPayload
.connectorId
,
1235 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
1236 status: chargingStation
.getConnectorStatus(commandPayload
.connectorId
)?.status,
1239 triggerMessage
: true,
1243 /* This is intentional */
1246 for (const connectorId
of chargingStation
.connectors
.keys()) {
1247 chargingStation
.ocppRequestService
1249 OCPP16StatusNotificationRequest
,
1250 OCPP16StatusNotificationResponse
1253 OCPP16RequestCommand
.STATUS_NOTIFICATION
,
1256 errorCode
: OCPP16ChargePointErrorCode
.NO_ERROR
,
1257 status: chargingStation
.getConnectorStatus(connectorId
)?.status,
1260 triggerMessage
: true,
1264 /* This is intentional */
1268 }, Constants
.OCPP_TRIGGER_MESSAGE_DELAY
);
1269 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED
;
1271 return OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED
;
1274 return this.handleIncomingRequestError(
1276 OCPP16IncomingRequestCommand
.TRIGGER_MESSAGE
,
1278 { errorResponse
: OCPPConstants
.OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED
}
1283 private handleRequestDataTransfer(
1284 chargingStation
: ChargingStation
,
1285 commandPayload
: OCPP16DataTransferRequest
1286 ): OCPP16DataTransferResponse
{
1288 if (Object.values(OCPP16DataTransferVendorId
).includes(commandPayload
.vendorId
)) {
1290 status: OCPP16DataTransferStatus
.ACCEPTED
,
1294 status: OCPP16DataTransferStatus
.UNKNOWN_VENDOR_ID
,
1297 return this.handleIncomingRequestError(
1299 OCPP16IncomingRequestCommand
.DATA_TRANSFER
,
1301 { errorResponse
: OCPPConstants
.OCPP_DATA_TRANSFER_RESPONSE_REJECTED
}