More strict boolean checks
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / 1.6 / OCPP16IncomingRequestService.ts
1 // Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
2
3 import fs from 'fs';
4 import path from 'path';
5 import { URL, fileURLToPath } from 'url';
6
7 import type { JSONSchemaType } from 'ajv';
8 import { Client, FTPResponse } from 'basic-ftp';
9 import tar from 'tar';
10
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';
15 import {
16 ChargingProfilePurposeType,
17 OCPP16ChargingProfile,
18 } from '../../../types/ocpp/1.6/ChargingProfile';
19 import {
20 OCPP16StandardParametersKey,
21 OCPP16SupportedFeatureProfiles,
22 } from '../../../types/ocpp/1.6/Configuration';
23 import { OCPP16DiagnosticsStatus } from '../../../types/ocpp/1.6/DiagnosticsStatus';
24 import {
25 ChangeAvailabilityRequest,
26 ChangeConfigurationRequest,
27 ClearChargingProfileRequest,
28 DiagnosticsStatusNotificationRequest,
29 GetConfigurationRequest,
30 GetDiagnosticsRequest,
31 MessageTrigger,
32 OCPP16AvailabilityType,
33 OCPP16BootNotificationRequest,
34 OCPP16ClearCacheRequest,
35 OCPP16HeartbeatRequest,
36 OCPP16IncomingRequestCommand,
37 OCPP16RequestCommand,
38 OCPP16StatusNotificationRequest,
39 OCPP16TriggerMessageRequest,
40 RemoteStartTransactionRequest,
41 RemoteStopTransactionRequest,
42 ResetRequest,
43 SetChargingProfileRequest,
44 UnlockConnectorRequest,
45 } from '../../../types/ocpp/1.6/Requests';
46 import type {
47 ChangeAvailabilityResponse,
48 ChangeConfigurationResponse,
49 ClearChargingProfileResponse,
50 DiagnosticsStatusNotificationResponse,
51 GetConfigurationResponse,
52 GetDiagnosticsResponse,
53 OCPP16BootNotificationResponse,
54 OCPP16HeartbeatResponse,
55 OCPP16StatusNotificationResponse,
56 OCPP16TriggerMessageResponse,
57 SetChargingProfileResponse,
58 UnlockConnectorResponse,
59 } from '../../../types/ocpp/1.6/Responses';
60 import {
61 OCPP16AuthorizationStatus,
62 OCPP16AuthorizeRequest,
63 OCPP16AuthorizeResponse,
64 OCPP16StartTransactionRequest,
65 OCPP16StartTransactionResponse,
66 OCPP16StopTransactionReason,
67 } from '../../../types/ocpp/1.6/Transaction';
68 import type { OCPPConfigurationKey } from '../../../types/ocpp/Configuration';
69 import { ErrorType } from '../../../types/ocpp/ErrorType';
70 import type { IncomingRequestHandler } from '../../../types/ocpp/Requests';
71 import type { DefaultResponse } from '../../../types/ocpp/Responses';
72 import Constants from '../../../utils/Constants';
73 import logger from '../../../utils/Logger';
74 import Utils from '../../../utils/Utils';
75 import type ChargingStation from '../../ChargingStation';
76 import { ChargingStationConfigurationUtils } from '../../ChargingStationConfigurationUtils';
77 import { ChargingStationUtils } from '../../ChargingStationUtils';
78 import OCPPIncomingRequestService from '../OCPPIncomingRequestService';
79 import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';
80
81 const moduleName = 'OCPP16IncomingRequestService';
82
83 export default class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
84 private incomingRequestHandlers: Map<OCPP16IncomingRequestCommand, IncomingRequestHandler>;
85 private jsonSchemas: Map<OCPP16IncomingRequestCommand, JSONSchemaType<JsonObject>>;
86
87 public constructor() {
88 if (new.target?.name === moduleName) {
89 throw new TypeError(`Cannot construct ${new.target?.name} instances directly`);
90 }
91 super();
92 this.incomingRequestHandlers = new Map<OCPP16IncomingRequestCommand, IncomingRequestHandler>([
93 [OCPP16IncomingRequestCommand.RESET, this.handleRequestReset.bind(this)],
94 [OCPP16IncomingRequestCommand.CLEAR_CACHE, this.handleRequestClearCache.bind(this)],
95 [OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR, this.handleRequestUnlockConnector.bind(this)],
96 [
97 OCPP16IncomingRequestCommand.GET_CONFIGURATION,
98 this.handleRequestGetConfiguration.bind(this),
99 ],
100 [
101 OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION,
102 this.handleRequestChangeConfiguration.bind(this),
103 ],
104 [
105 OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE,
106 this.handleRequestSetChargingProfile.bind(this),
107 ],
108 [
109 OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE,
110 this.handleRequestClearChargingProfile.bind(this),
111 ],
112 [
113 OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY,
114 this.handleRequestChangeAvailability.bind(this),
115 ],
116 [
117 OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION,
118 this.handleRequestRemoteStartTransaction.bind(this),
119 ],
120 [
121 OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION,
122 this.handleRequestRemoteStopTransaction.bind(this),
123 ],
124 [OCPP16IncomingRequestCommand.GET_DIAGNOSTICS, this.handleRequestGetDiagnostics.bind(this)],
125 [OCPP16IncomingRequestCommand.TRIGGER_MESSAGE, this.handleRequestTriggerMessage.bind(this)],
126 ]);
127 this.jsonSchemas = new Map<OCPP16IncomingRequestCommand, JSONSchemaType<JsonObject>>([
128 [
129 OCPP16IncomingRequestCommand.RESET,
130 JSON.parse(
131 fs.readFileSync(
132 path.resolve(
133 path.dirname(fileURLToPath(import.meta.url)),
134 '../../../assets/json-schemas/ocpp/1.6/Reset.json'
135 ),
136 'utf8'
137 )
138 ) as JSONSchemaType<ResetRequest>,
139 ],
140 [
141 OCPP16IncomingRequestCommand.CLEAR_CACHE,
142 JSON.parse(
143 fs.readFileSync(
144 path.resolve(
145 path.dirname(fileURLToPath(import.meta.url)),
146 '../../../assets/json-schemas/ocpp/1.6/ClearCache.json'
147 ),
148 'utf8'
149 )
150 ) as JSONSchemaType<OCPP16ClearCacheRequest>,
151 ],
152 [
153 OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR,
154 JSON.parse(
155 fs.readFileSync(
156 path.resolve(
157 path.dirname(fileURLToPath(import.meta.url)),
158 '../../../assets/json-schemas/ocpp/1.6/UnlockConnector.json'
159 ),
160 'utf8'
161 )
162 ) as JSONSchemaType<UnlockConnectorRequest>,
163 ],
164 [
165 OCPP16IncomingRequestCommand.GET_CONFIGURATION,
166 JSON.parse(
167 fs.readFileSync(
168 path.resolve(
169 path.dirname(fileURLToPath(import.meta.url)),
170 '../../../assets/json-schemas/ocpp/1.6/GetConfiguration.json'
171 ),
172 'utf8'
173 )
174 ) as JSONSchemaType<GetConfigurationRequest>,
175 ],
176 [
177 OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION,
178 JSON.parse(
179 fs.readFileSync(
180 path.resolve(
181 path.dirname(fileURLToPath(import.meta.url)),
182 '../../../assets/json-schemas/ocpp/1.6/ChangeConfiguration.json'
183 ),
184 'utf8'
185 )
186 ) as JSONSchemaType<ChangeConfigurationRequest>,
187 ],
188 [
189 OCPP16IncomingRequestCommand.GET_DIAGNOSTICS,
190 JSON.parse(
191 fs.readFileSync(
192 path.resolve(
193 path.dirname(fileURLToPath(import.meta.url)),
194 '../../../assets/json-schemas/ocpp/1.6/GetDiagnostics.json'
195 ),
196 'utf8'
197 )
198 ) as JSONSchemaType<GetDiagnosticsRequest>,
199 ],
200 [
201 OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE,
202 JSON.parse(
203 fs.readFileSync(
204 path.resolve(
205 path.dirname(fileURLToPath(import.meta.url)),
206 '../../../assets/json-schemas/ocpp/1.6/SetChargingProfile.json'
207 ),
208 'utf8'
209 )
210 ) as JSONSchemaType<SetChargingProfileRequest>,
211 ],
212 [
213 OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE,
214 JSON.parse(
215 fs.readFileSync(
216 path.resolve(
217 path.dirname(fileURLToPath(import.meta.url)),
218 '../../../assets/json-schemas/ocpp/1.6/ClearChargingProfile.json'
219 ),
220 'utf8'
221 )
222 ) as JSONSchemaType<ClearChargingProfileRequest>,
223 ],
224 [
225 OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY,
226 JSON.parse(
227 fs.readFileSync(
228 path.resolve(
229 path.dirname(fileURLToPath(import.meta.url)),
230 '../../../assets/json-schemas/ocpp/1.6/ChangeAvailability.json'
231 ),
232 'utf8'
233 )
234 ) as JSONSchemaType<ChangeAvailabilityRequest>,
235 ],
236 [
237 OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION,
238 JSON.parse(
239 fs.readFileSync(
240 path.resolve(
241 path.dirname(fileURLToPath(import.meta.url)),
242 '../../../assets/json-schemas/ocpp/1.6/RemoteStartTransaction.json'
243 ),
244 'utf8'
245 )
246 ) as JSONSchemaType<RemoteStartTransactionRequest>,
247 ],
248 [
249 OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION,
250 JSON.parse(
251 fs.readFileSync(
252 path.resolve(
253 path.dirname(fileURLToPath(import.meta.url)),
254 '../../../assets/json-schemas/ocpp/1.6/RemoteStopTransaction.json'
255 ),
256 'utf8'
257 )
258 ) as JSONSchemaType<RemoteStopTransactionRequest>,
259 ],
260 [
261 OCPP16IncomingRequestCommand.TRIGGER_MESSAGE,
262 JSON.parse(
263 fs.readFileSync(
264 path.resolve(
265 path.dirname(fileURLToPath(import.meta.url)),
266 '../../../assets/json-schemas/ocpp/1.6/TriggerMessage.json'
267 ),
268 'utf8'
269 )
270 ) as JSONSchemaType<OCPP16TriggerMessageRequest>,
271 ],
272 ]);
273 this.validatePayload.bind(this);
274 }
275
276 public async incomingRequestHandler(
277 chargingStation: ChargingStation,
278 messageId: string,
279 commandName: OCPP16IncomingRequestCommand,
280 commandPayload: JsonType
281 ): Promise<void> {
282 let response: JsonType;
283 if (
284 chargingStation.getOcppStrictCompliance() &&
285 chargingStation.isInPendingState() &&
286 (commandName === OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION ||
287 commandName === OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION)
288 ) {
289 throw new OCPPError(
290 ErrorType.SECURITY_ERROR,
291 `${commandName} cannot be issued to handle request PDU ${JSON.stringify(
292 commandPayload,
293 null,
294 2
295 )} while the charging station is in pending state on the central server`,
296 commandName,
297 commandPayload
298 );
299 }
300 if (
301 chargingStation.isRegistered() === true ||
302 (chargingStation.getOcppStrictCompliance() === false &&
303 chargingStation.isInUnknownState() === true)
304 ) {
305 if (
306 this.incomingRequestHandlers.has(commandName) === true &&
307 OCPP16ServiceUtils.isIncomingRequestCommandSupported(chargingStation, commandName) === true
308 ) {
309 try {
310 this.validatePayload(chargingStation, commandName, commandPayload);
311 // Call the method to build the response
312 response = await this.incomingRequestHandlers.get(commandName)(
313 chargingStation,
314 commandPayload
315 );
316 } catch (error) {
317 // Log
318 logger.error(
319 `${chargingStation.logPrefix()} ${moduleName}.incomingRequestHandler: Handle incoming request error:`,
320 error
321 );
322 throw error;
323 }
324 } else {
325 // Throw exception
326 throw new OCPPError(
327 ErrorType.NOT_IMPLEMENTED,
328 `${commandName} is not implemented to handle request PDU ${JSON.stringify(
329 commandPayload,
330 null,
331 2
332 )}`,
333 commandName,
334 commandPayload
335 );
336 }
337 } else {
338 throw new OCPPError(
339 ErrorType.SECURITY_ERROR,
340 `${commandName} cannot be issued to handle request PDU ${JSON.stringify(
341 commandPayload,
342 null,
343 2
344 )} while the charging station is not registered on the central server.`,
345 commandName,
346 commandPayload
347 );
348 }
349 // Send the built response
350 await chargingStation.ocppRequestService.sendResponse(
351 chargingStation,
352 messageId,
353 response,
354 commandName
355 );
356 }
357
358 private validatePayload(
359 chargingStation: ChargingStation,
360 commandName: OCPP16IncomingRequestCommand,
361 commandPayload: JsonType
362 ): boolean {
363 if (this.jsonSchemas.has(commandName)) {
364 return this.validateIncomingRequestPayload(
365 chargingStation,
366 commandName,
367 this.jsonSchemas.get(commandName),
368 commandPayload
369 );
370 }
371 logger.warn(
372 `${chargingStation.logPrefix()} ${moduleName}.validatePayload: No JSON schema found for command ${commandName} PDU validation`
373 );
374 return false;
375 }
376
377 // Simulate charging station restart
378 private handleRequestReset(
379 chargingStation: ChargingStation,
380 commandPayload: ResetRequest
381 ): DefaultResponse {
382 this.asyncResource.runInAsyncScope(
383 chargingStation.reset.bind(chargingStation) as (
384 this: ChargingStation,
385 ...args: any[]
386 ) => void,
387 chargingStation,
388 (commandPayload.type + 'Reset') as OCPP16StopTransactionReason
389 );
390 logger.info(
391 `${chargingStation.logPrefix()} ${
392 commandPayload.type
393 } reset command received, simulating it. The station will be back online in ${Utils.formatDurationMilliSeconds(
394 chargingStation.stationInfo.resetTime
395 )}`
396 );
397 return Constants.OCPP_RESPONSE_ACCEPTED;
398 }
399
400 private handleRequestClearCache(chargingStation: ChargingStation): DefaultResponse {
401 chargingStation.authorizedTagsCache.deleteAuthorizedTags(
402 ChargingStationUtils.getAuthorizationFile(chargingStation.stationInfo)
403 );
404 return Constants.OCPP_RESPONSE_ACCEPTED;
405 }
406
407 private async handleRequestUnlockConnector(
408 chargingStation: ChargingStation,
409 commandPayload: UnlockConnectorRequest
410 ): Promise<UnlockConnectorResponse> {
411 const connectorId = commandPayload.connectorId;
412 if (connectorId === 0) {
413 logger.error(
414 chargingStation.logPrefix() + ' Trying to unlock connector ' + connectorId.toString()
415 );
416 return Constants.OCPP_RESPONSE_UNLOCK_NOT_SUPPORTED;
417 }
418 if (chargingStation.getConnectorStatus(connectorId)?.transactionStarted === true) {
419 const stopResponse = await chargingStation.stopTransactionOnConnector(
420 connectorId,
421 OCPP16StopTransactionReason.UNLOCK_COMMAND
422 );
423 if (stopResponse.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED) {
424 return Constants.OCPP_RESPONSE_UNLOCKED;
425 }
426 return Constants.OCPP_RESPONSE_UNLOCK_FAILED;
427 }
428 await chargingStation.ocppRequestService.requestHandler<
429 OCPP16StatusNotificationRequest,
430 OCPP16StatusNotificationResponse
431 >(chargingStation, OCPP16RequestCommand.STATUS_NOTIFICATION, {
432 connectorId,
433 status: OCPP16ChargePointStatus.AVAILABLE,
434 errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
435 });
436 chargingStation.getConnectorStatus(connectorId).status = OCPP16ChargePointStatus.AVAILABLE;
437 return Constants.OCPP_RESPONSE_UNLOCKED;
438 }
439
440 private handleRequestGetConfiguration(
441 chargingStation: ChargingStation,
442 commandPayload: GetConfigurationRequest
443 ): GetConfigurationResponse {
444 const configurationKey: OCPPConfigurationKey[] = [];
445 const unknownKey: string[] = [];
446 if (Utils.isEmptyArray(commandPayload.key) === true) {
447 for (const configuration of chargingStation.ocppConfiguration.configurationKey) {
448 if (Utils.isUndefined(configuration.visible) === true) {
449 configuration.visible = true;
450 }
451 if (configuration.visible === false) {
452 continue;
453 }
454 configurationKey.push({
455 key: configuration.key,
456 readonly: configuration.readonly,
457 value: configuration.value,
458 });
459 }
460 } else {
461 for (const key of commandPayload.key) {
462 const keyFound = ChargingStationConfigurationUtils.getConfigurationKey(
463 chargingStation,
464 key
465 );
466 if (keyFound) {
467 if (Utils.isUndefined(keyFound.visible) === true) {
468 keyFound.visible = true;
469 }
470 if (keyFound.visible === false) {
471 continue;
472 }
473 configurationKey.push({
474 key: keyFound.key,
475 readonly: keyFound.readonly,
476 value: keyFound.value,
477 });
478 } else {
479 unknownKey.push(key);
480 }
481 }
482 }
483 return {
484 configurationKey,
485 unknownKey,
486 };
487 }
488
489 private handleRequestChangeConfiguration(
490 chargingStation: ChargingStation,
491 commandPayload: ChangeConfigurationRequest
492 ): ChangeConfigurationResponse {
493 const keyToChange = ChargingStationConfigurationUtils.getConfigurationKey(
494 chargingStation,
495 commandPayload.key,
496 true
497 );
498 if (!keyToChange) {
499 return Constants.OCPP_CONFIGURATION_RESPONSE_NOT_SUPPORTED;
500 } else if (keyToChange && keyToChange.readonly) {
501 return Constants.OCPP_CONFIGURATION_RESPONSE_REJECTED;
502 } else if (keyToChange && !keyToChange.readonly) {
503 let valueChanged = false;
504 if (keyToChange.value !== commandPayload.value) {
505 ChargingStationConfigurationUtils.setConfigurationKeyValue(
506 chargingStation,
507 commandPayload.key,
508 commandPayload.value,
509 true
510 );
511 valueChanged = true;
512 }
513 let triggerHeartbeatRestart = false;
514 if (keyToChange.key === OCPP16StandardParametersKey.HeartBeatInterval && valueChanged) {
515 ChargingStationConfigurationUtils.setConfigurationKeyValue(
516 chargingStation,
517 OCPP16StandardParametersKey.HeartbeatInterval,
518 commandPayload.value
519 );
520 triggerHeartbeatRestart = true;
521 }
522 if (keyToChange.key === OCPP16StandardParametersKey.HeartbeatInterval && valueChanged) {
523 ChargingStationConfigurationUtils.setConfigurationKeyValue(
524 chargingStation,
525 OCPP16StandardParametersKey.HeartBeatInterval,
526 commandPayload.value
527 );
528 triggerHeartbeatRestart = true;
529 }
530 if (triggerHeartbeatRestart) {
531 chargingStation.restartHeartbeat();
532 }
533 if (keyToChange.key === OCPP16StandardParametersKey.WebSocketPingInterval && valueChanged) {
534 chargingStation.restartWebSocketPing();
535 }
536 if (keyToChange.reboot) {
537 return Constants.OCPP_CONFIGURATION_RESPONSE_REBOOT_REQUIRED;
538 }
539 return Constants.OCPP_CONFIGURATION_RESPONSE_ACCEPTED;
540 }
541 }
542
543 private handleRequestSetChargingProfile(
544 chargingStation: ChargingStation,
545 commandPayload: SetChargingProfileRequest
546 ): SetChargingProfileResponse {
547 if (
548 OCPP16ServiceUtils.checkFeatureProfile(
549 chargingStation,
550 OCPP16SupportedFeatureProfiles.SmartCharging,
551 OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE
552 ) === false
553 ) {
554 return Constants.OCPP_SET_CHARGING_PROFILE_RESPONSE_NOT_SUPPORTED;
555 }
556 if (chargingStation.connectors.has(commandPayload.connectorId) === false) {
557 logger.error(
558 `${chargingStation.logPrefix()} Trying to set charging profile(s) to a non existing connector Id ${
559 commandPayload.connectorId
560 }`
561 );
562 return Constants.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED;
563 }
564 if (
565 commandPayload.csChargingProfiles.chargingProfilePurpose ===
566 ChargingProfilePurposeType.CHARGE_POINT_MAX_PROFILE &&
567 commandPayload.connectorId !== 0
568 ) {
569 return Constants.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED;
570 }
571 if (
572 commandPayload.csChargingProfiles.chargingProfilePurpose ===
573 ChargingProfilePurposeType.TX_PROFILE &&
574 (commandPayload.connectorId === 0 ||
575 chargingStation.getConnectorStatus(commandPayload.connectorId)?.transactionStarted ===
576 false)
577 ) {
578 return Constants.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED;
579 }
580 OCPP16ServiceUtils.setChargingProfile(
581 chargingStation,
582 commandPayload.connectorId,
583 commandPayload.csChargingProfiles
584 );
585 logger.debug(
586 `${chargingStation.logPrefix()} Charging profile(s) set on connector id ${
587 commandPayload.connectorId
588 }, dump their stack: %j`,
589 chargingStation.getConnectorStatus(commandPayload.connectorId).chargingProfiles
590 );
591 return Constants.OCPP_SET_CHARGING_PROFILE_RESPONSE_ACCEPTED;
592 }
593
594 private handleRequestClearChargingProfile(
595 chargingStation: ChargingStation,
596 commandPayload: ClearChargingProfileRequest
597 ): ClearChargingProfileResponse {
598 if (
599 OCPP16ServiceUtils.checkFeatureProfile(
600 chargingStation,
601 OCPP16SupportedFeatureProfiles.SmartCharging,
602 OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE
603 ) === false
604 ) {
605 return Constants.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN;
606 }
607 if (chargingStation.connectors.has(commandPayload.connectorId) === false) {
608 logger.error(
609 `${chargingStation.logPrefix()} Trying to clear a charging profile(s) to a non existing connector Id ${
610 commandPayload.connectorId
611 }`
612 );
613 return Constants.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN;
614 }
615 const connectorStatus = chargingStation.getConnectorStatus(commandPayload.connectorId);
616 if (commandPayload.connectorId && !Utils.isEmptyArray(connectorStatus.chargingProfiles)) {
617 connectorStatus.chargingProfiles = [];
618 logger.debug(
619 `${chargingStation.logPrefix()} Charging profile(s) cleared on connector id ${
620 commandPayload.connectorId
621 }, dump their stack: %j`,
622 connectorStatus.chargingProfiles
623 );
624 return Constants.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_ACCEPTED;
625 }
626 if (!commandPayload.connectorId) {
627 let clearedCP = false;
628 for (const connectorId of chargingStation.connectors.keys()) {
629 if (!Utils.isEmptyArray(chargingStation.getConnectorStatus(connectorId).chargingProfiles)) {
630 chargingStation
631 .getConnectorStatus(connectorId)
632 .chargingProfiles?.forEach((chargingProfile: OCPP16ChargingProfile, index: number) => {
633 let clearCurrentCP = false;
634 if (chargingProfile.chargingProfileId === commandPayload.id) {
635 clearCurrentCP = true;
636 }
637 if (
638 !commandPayload.chargingProfilePurpose &&
639 chargingProfile.stackLevel === commandPayload.stackLevel
640 ) {
641 clearCurrentCP = true;
642 }
643 if (
644 !chargingProfile.stackLevel &&
645 chargingProfile.chargingProfilePurpose === commandPayload.chargingProfilePurpose
646 ) {
647 clearCurrentCP = true;
648 }
649 if (
650 chargingProfile.stackLevel === commandPayload.stackLevel &&
651 chargingProfile.chargingProfilePurpose === commandPayload.chargingProfilePurpose
652 ) {
653 clearCurrentCP = true;
654 }
655 if (clearCurrentCP) {
656 connectorStatus.chargingProfiles.splice(index, 1);
657 logger.debug(
658 `${chargingStation.logPrefix()} Matching charging profile(s) cleared on connector id ${
659 commandPayload.connectorId
660 }, dump their stack: %j`,
661 connectorStatus.chargingProfiles
662 );
663 clearedCP = true;
664 }
665 });
666 }
667 }
668 if (clearedCP) {
669 return Constants.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_ACCEPTED;
670 }
671 }
672 return Constants.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN;
673 }
674
675 private async handleRequestChangeAvailability(
676 chargingStation: ChargingStation,
677 commandPayload: ChangeAvailabilityRequest
678 ): Promise<ChangeAvailabilityResponse> {
679 const connectorId: number = commandPayload.connectorId;
680 if (!chargingStation.getConnectorStatus(connectorId)) {
681 logger.error(
682 `${chargingStation.logPrefix()} Trying to change the availability of a non existing connector Id ${connectorId.toString()}`
683 );
684 return Constants.OCPP_AVAILABILITY_RESPONSE_REJECTED;
685 }
686 const chargePointStatus: OCPP16ChargePointStatus =
687 commandPayload.type === OCPP16AvailabilityType.OPERATIVE
688 ? OCPP16ChargePointStatus.AVAILABLE
689 : OCPP16ChargePointStatus.UNAVAILABLE;
690 if (connectorId === 0) {
691 let response: ChangeAvailabilityResponse = Constants.OCPP_AVAILABILITY_RESPONSE_ACCEPTED;
692 for (const id of chargingStation.connectors.keys()) {
693 if (chargingStation.getConnectorStatus(id)?.transactionStarted === true) {
694 response = Constants.OCPP_AVAILABILITY_RESPONSE_SCHEDULED;
695 }
696 chargingStation.getConnectorStatus(id).availability = commandPayload.type;
697 if (response === Constants.OCPP_AVAILABILITY_RESPONSE_ACCEPTED) {
698 await chargingStation.ocppRequestService.requestHandler<
699 OCPP16StatusNotificationRequest,
700 OCPP16StatusNotificationResponse
701 >(chargingStation, OCPP16RequestCommand.STATUS_NOTIFICATION, {
702 connectorId: id,
703 status: chargePointStatus,
704 errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
705 });
706 chargingStation.getConnectorStatus(id).status = chargePointStatus;
707 }
708 }
709 return response;
710 } else if (
711 connectorId > 0 &&
712 (chargingStation.isChargingStationAvailable() === true ||
713 (chargingStation.isChargingStationAvailable() === false &&
714 commandPayload.type === OCPP16AvailabilityType.INOPERATIVE))
715 ) {
716 if (chargingStation.getConnectorStatus(connectorId)?.transactionStarted === true) {
717 chargingStation.getConnectorStatus(connectorId).availability = commandPayload.type;
718 return Constants.OCPP_AVAILABILITY_RESPONSE_SCHEDULED;
719 }
720 chargingStation.getConnectorStatus(connectorId).availability = commandPayload.type;
721 await chargingStation.ocppRequestService.requestHandler<
722 OCPP16StatusNotificationRequest,
723 OCPP16StatusNotificationResponse
724 >(chargingStation, OCPP16RequestCommand.STATUS_NOTIFICATION, {
725 connectorId,
726 status: chargePointStatus,
727 errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
728 });
729 chargingStation.getConnectorStatus(connectorId).status = chargePointStatus;
730 return Constants.OCPP_AVAILABILITY_RESPONSE_ACCEPTED;
731 }
732 return Constants.OCPP_AVAILABILITY_RESPONSE_REJECTED;
733 }
734
735 private async handleRequestRemoteStartTransaction(
736 chargingStation: ChargingStation,
737 commandPayload: RemoteStartTransactionRequest
738 ): Promise<DefaultResponse> {
739 const transactionConnectorId = commandPayload.connectorId;
740 if (chargingStation.connectors.has(transactionConnectorId) === true) {
741 const remoteStartTransactionLogMsg =
742 chargingStation.logPrefix() +
743 ' Transaction remotely STARTED on ' +
744 chargingStation.stationInfo.chargingStationId +
745 '#' +
746 transactionConnectorId.toString() +
747 " for idTag '" +
748 commandPayload.idTag +
749 "'";
750 await chargingStation.ocppRequestService.requestHandler<
751 OCPP16StatusNotificationRequest,
752 OCPP16StatusNotificationResponse
753 >(chargingStation, OCPP16RequestCommand.STATUS_NOTIFICATION, {
754 connectorId: transactionConnectorId,
755 status: OCPP16ChargePointStatus.PREPARING,
756 errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
757 });
758 const connectorStatus = chargingStation.getConnectorStatus(transactionConnectorId);
759 connectorStatus.status = OCPP16ChargePointStatus.PREPARING;
760 if (chargingStation.isChargingStationAvailable() === true) {
761 // Check if authorized
762 if (chargingStation.getAuthorizeRemoteTxRequests() === true) {
763 let authorized = false;
764 if (
765 chargingStation.getLocalAuthListEnabled() === true &&
766 chargingStation.hasAuthorizedTags() === true &&
767 chargingStation.authorizedTagsCache
768 .getAuthorizedTags(
769 ChargingStationUtils.getAuthorizationFile(chargingStation.stationInfo)
770 )
771 .find((idTag) => idTag === commandPayload.idTag)
772 ) {
773 connectorStatus.localAuthorizeIdTag = commandPayload.idTag;
774 connectorStatus.idTagLocalAuthorized = true;
775 authorized = true;
776 } else if (chargingStation.getMustAuthorizeAtRemoteStart() === true) {
777 connectorStatus.authorizeIdTag = commandPayload.idTag;
778 const authorizeResponse: OCPP16AuthorizeResponse =
779 await chargingStation.ocppRequestService.requestHandler<
780 OCPP16AuthorizeRequest,
781 OCPP16AuthorizeResponse
782 >(chargingStation, OCPP16RequestCommand.AUTHORIZE, {
783 idTag: commandPayload.idTag,
784 });
785 if (authorizeResponse?.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED) {
786 authorized = true;
787 }
788 } else {
789 logger.warn(
790 `${chargingStation.logPrefix()} The charging station configuration expects authorize at remote start transaction but local authorization or authorize isn't enabled`
791 );
792 }
793 if (authorized === true) {
794 // Authorization successful, start transaction
795 if (
796 this.setRemoteStartTransactionChargingProfile(
797 chargingStation,
798 transactionConnectorId,
799 commandPayload.chargingProfile
800 ) === true
801 ) {
802 connectorStatus.transactionRemoteStarted = true;
803 if (
804 (
805 await chargingStation.ocppRequestService.requestHandler<
806 OCPP16StartTransactionRequest,
807 OCPP16StartTransactionResponse
808 >(chargingStation, OCPP16RequestCommand.START_TRANSACTION, {
809 connectorId: transactionConnectorId,
810 idTag: commandPayload.idTag,
811 })
812 ).idTagInfo.status === OCPP16AuthorizationStatus.ACCEPTED
813 ) {
814 logger.debug(remoteStartTransactionLogMsg);
815 return Constants.OCPP_RESPONSE_ACCEPTED;
816 }
817 return this.notifyRemoteStartTransactionRejected(
818 chargingStation,
819 transactionConnectorId,
820 commandPayload.idTag
821 );
822 }
823 return this.notifyRemoteStartTransactionRejected(
824 chargingStation,
825 transactionConnectorId,
826 commandPayload.idTag
827 );
828 }
829 return this.notifyRemoteStartTransactionRejected(
830 chargingStation,
831 transactionConnectorId,
832 commandPayload.idTag
833 );
834 }
835 // No authorization check required, start transaction
836 if (
837 this.setRemoteStartTransactionChargingProfile(
838 chargingStation,
839 transactionConnectorId,
840 commandPayload.chargingProfile
841 ) === true
842 ) {
843 connectorStatus.transactionRemoteStarted = true;
844 if (
845 (
846 await chargingStation.ocppRequestService.requestHandler<
847 OCPP16StartTransactionRequest,
848 OCPP16StartTransactionResponse
849 >(chargingStation, OCPP16RequestCommand.START_TRANSACTION, {
850 connectorId: transactionConnectorId,
851 idTag: commandPayload.idTag,
852 })
853 ).idTagInfo.status === OCPP16AuthorizationStatus.ACCEPTED
854 ) {
855 logger.debug(remoteStartTransactionLogMsg);
856 return Constants.OCPP_RESPONSE_ACCEPTED;
857 }
858 return this.notifyRemoteStartTransactionRejected(
859 chargingStation,
860 transactionConnectorId,
861 commandPayload.idTag
862 );
863 }
864 return this.notifyRemoteStartTransactionRejected(
865 chargingStation,
866 transactionConnectorId,
867 commandPayload.idTag
868 );
869 }
870 return this.notifyRemoteStartTransactionRejected(
871 chargingStation,
872 transactionConnectorId,
873 commandPayload.idTag
874 );
875 }
876 return this.notifyRemoteStartTransactionRejected(
877 chargingStation,
878 transactionConnectorId,
879 commandPayload.idTag
880 );
881 }
882
883 private async notifyRemoteStartTransactionRejected(
884 chargingStation: ChargingStation,
885 connectorId: number,
886 idTag: string
887 ): Promise<DefaultResponse> {
888 if (
889 chargingStation.getConnectorStatus(connectorId).status !== OCPP16ChargePointStatus.AVAILABLE
890 ) {
891 await chargingStation.ocppRequestService.requestHandler<
892 OCPP16StatusNotificationRequest,
893 OCPP16StatusNotificationResponse
894 >(chargingStation, OCPP16RequestCommand.STATUS_NOTIFICATION, {
895 connectorId,
896 status: OCPP16ChargePointStatus.AVAILABLE,
897 errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
898 });
899 chargingStation.getConnectorStatus(connectorId).status = OCPP16ChargePointStatus.AVAILABLE;
900 }
901 logger.warn(
902 chargingStation.logPrefix() +
903 ' Remote starting transaction REJECTED on connector Id ' +
904 connectorId.toString() +
905 ", idTag '" +
906 idTag +
907 "', availability '" +
908 chargingStation.getConnectorStatus(connectorId).availability +
909 "', status '" +
910 chargingStation.getConnectorStatus(connectorId).status +
911 "'"
912 );
913 return Constants.OCPP_RESPONSE_REJECTED;
914 }
915
916 private setRemoteStartTransactionChargingProfile(
917 chargingStation: ChargingStation,
918 connectorId: number,
919 cp: OCPP16ChargingProfile
920 ): boolean {
921 if (cp && cp.chargingProfilePurpose === ChargingProfilePurposeType.TX_PROFILE) {
922 OCPP16ServiceUtils.setChargingProfile(chargingStation, connectorId, cp);
923 logger.debug(
924 `${chargingStation.logPrefix()} Charging profile(s) set at remote start transaction on connector id ${connectorId}, dump their stack: %j`,
925 chargingStation.getConnectorStatus(connectorId).chargingProfiles
926 );
927 return true;
928 } else if (cp && cp.chargingProfilePurpose !== ChargingProfilePurposeType.TX_PROFILE) {
929 logger.warn(
930 `${chargingStation.logPrefix()} Not allowed to set ${
931 cp.chargingProfilePurpose
932 } charging profile(s) at remote start transaction`
933 );
934 return false;
935 } else if (!cp) {
936 return true;
937 }
938 }
939
940 private async handleRequestRemoteStopTransaction(
941 chargingStation: ChargingStation,
942 commandPayload: RemoteStopTransactionRequest
943 ): Promise<DefaultResponse> {
944 const transactionId = commandPayload.transactionId;
945 for (const connectorId of chargingStation.connectors.keys()) {
946 if (
947 connectorId > 0 &&
948 chargingStation.getConnectorStatus(connectorId)?.transactionId === transactionId
949 ) {
950 await chargingStation.ocppRequestService.requestHandler<
951 OCPP16StatusNotificationRequest,
952 OCPP16StatusNotificationResponse
953 >(chargingStation, OCPP16RequestCommand.STATUS_NOTIFICATION, {
954 connectorId,
955 status: OCPP16ChargePointStatus.FINISHING,
956 errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
957 });
958 chargingStation.getConnectorStatus(connectorId).status = OCPP16ChargePointStatus.FINISHING;
959 const stopResponse = await chargingStation.stopTransactionOnConnector(
960 connectorId,
961 OCPP16StopTransactionReason.REMOTE
962 );
963 if (stopResponse.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED) {
964 return Constants.OCPP_RESPONSE_ACCEPTED;
965 }
966 return Constants.OCPP_RESPONSE_REJECTED;
967 }
968 }
969 logger.warn(
970 chargingStation.logPrefix() +
971 ' Trying to remote stop a non existing transaction ' +
972 transactionId.toString()
973 );
974 return Constants.OCPP_RESPONSE_REJECTED;
975 }
976
977 private async handleRequestGetDiagnostics(
978 chargingStation: ChargingStation,
979 commandPayload: GetDiagnosticsRequest
980 ): Promise<GetDiagnosticsResponse> {
981 if (
982 OCPP16ServiceUtils.checkFeatureProfile(
983 chargingStation,
984 OCPP16SupportedFeatureProfiles.FirmwareManagement,
985 OCPP16IncomingRequestCommand.GET_DIAGNOSTICS
986 ) === false
987 ) {
988 return Constants.OCPP_RESPONSE_EMPTY;
989 }
990 logger.debug(
991 chargingStation.logPrefix() +
992 ' ' +
993 OCPP16IncomingRequestCommand.GET_DIAGNOSTICS +
994 ' request received: %j',
995 commandPayload
996 );
997 const uri = new URL(commandPayload.location);
998 if (uri.protocol.startsWith('ftp:')) {
999 let ftpClient: Client;
1000 try {
1001 const logFiles = fs
1002 .readdirSync(path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../'))
1003 .filter((file) => file.endsWith('.log'))
1004 .map((file) => path.join('./', file));
1005 const diagnosticsArchive = chargingStation.stationInfo.chargingStationId + '_logs.tar.gz';
1006 tar.create({ gzip: true }, logFiles).pipe(fs.createWriteStream(diagnosticsArchive));
1007 ftpClient = new Client();
1008 const accessResponse = await ftpClient.access({
1009 host: uri.host,
1010 ...(!Utils.isEmptyString(uri.port) && { port: Utils.convertToInt(uri.port) }),
1011 ...(!Utils.isEmptyString(uri.username) && { user: uri.username }),
1012 ...(!Utils.isEmptyString(uri.password) && { password: uri.password }),
1013 });
1014 let uploadResponse: FTPResponse;
1015 if (accessResponse.code === 220) {
1016 // eslint-disable-next-line @typescript-eslint/no-misused-promises
1017 ftpClient.trackProgress(async (info) => {
1018 logger.info(
1019 `${chargingStation.logPrefix()} ${
1020 info.bytes / 1024
1021 } bytes transferred from diagnostics archive ${info.name}`
1022 );
1023 await chargingStation.ocppRequestService.requestHandler<
1024 DiagnosticsStatusNotificationRequest,
1025 DiagnosticsStatusNotificationResponse
1026 >(chargingStation, OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, {
1027 status: OCPP16DiagnosticsStatus.Uploading,
1028 });
1029 });
1030 uploadResponse = await ftpClient.uploadFrom(
1031 path.join(
1032 path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../'),
1033 diagnosticsArchive
1034 ),
1035 uri.pathname + diagnosticsArchive
1036 );
1037 if (uploadResponse.code === 226) {
1038 await chargingStation.ocppRequestService.requestHandler<
1039 DiagnosticsStatusNotificationRequest,
1040 DiagnosticsStatusNotificationResponse
1041 >(chargingStation, OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, {
1042 status: OCPP16DiagnosticsStatus.Uploaded,
1043 });
1044 if (ftpClient) {
1045 ftpClient.close();
1046 }
1047 return { fileName: diagnosticsArchive };
1048 }
1049 throw new OCPPError(
1050 ErrorType.GENERIC_ERROR,
1051 `Diagnostics transfer failed with error code ${accessResponse.code.toString()}${
1052 uploadResponse?.code && '|' + uploadResponse?.code.toString()
1053 }`,
1054 OCPP16IncomingRequestCommand.GET_DIAGNOSTICS
1055 );
1056 }
1057 throw new OCPPError(
1058 ErrorType.GENERIC_ERROR,
1059 `Diagnostics transfer failed with error code ${accessResponse.code.toString()}${
1060 uploadResponse?.code && '|' + uploadResponse?.code.toString()
1061 }`,
1062 OCPP16IncomingRequestCommand.GET_DIAGNOSTICS
1063 );
1064 } catch (error) {
1065 await chargingStation.ocppRequestService.requestHandler<
1066 DiagnosticsStatusNotificationRequest,
1067 DiagnosticsStatusNotificationResponse
1068 >(chargingStation, OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, {
1069 status: OCPP16DiagnosticsStatus.UploadFailed,
1070 });
1071 if (ftpClient) {
1072 ftpClient.close();
1073 }
1074 return this.handleIncomingRequestError(
1075 chargingStation,
1076 OCPP16IncomingRequestCommand.GET_DIAGNOSTICS,
1077 error as Error,
1078 { errorResponse: Constants.OCPP_RESPONSE_EMPTY }
1079 );
1080 }
1081 } else {
1082 logger.error(
1083 `${chargingStation.logPrefix()} Unsupported protocol ${
1084 uri.protocol
1085 } to transfer the diagnostic logs archive`
1086 );
1087 await chargingStation.ocppRequestService.requestHandler<
1088 DiagnosticsStatusNotificationRequest,
1089 DiagnosticsStatusNotificationResponse
1090 >(chargingStation, OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, {
1091 status: OCPP16DiagnosticsStatus.UploadFailed,
1092 });
1093 return Constants.OCPP_RESPONSE_EMPTY;
1094 }
1095 }
1096
1097 private handleRequestTriggerMessage(
1098 chargingStation: ChargingStation,
1099 commandPayload: OCPP16TriggerMessageRequest
1100 ): OCPP16TriggerMessageResponse {
1101 if (
1102 !OCPP16ServiceUtils.checkFeatureProfile(
1103 chargingStation,
1104 OCPP16SupportedFeatureProfiles.RemoteTrigger,
1105 OCPP16IncomingRequestCommand.TRIGGER_MESSAGE
1106 )
1107 ) {
1108 return Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED;
1109 }
1110 // TODO: factor out the check on connector id
1111 if (commandPayload?.connectorId < 0) {
1112 logger.warn(
1113 `${chargingStation.logPrefix()} ${
1114 OCPP16IncomingRequestCommand.TRIGGER_MESSAGE
1115 } incoming request received with invalid connectorId ${commandPayload.connectorId}`
1116 );
1117 return Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED;
1118 }
1119 try {
1120 switch (commandPayload.requestedMessage) {
1121 case MessageTrigger.BootNotification:
1122 setTimeout(() => {
1123 chargingStation.ocppRequestService
1124 .requestHandler<OCPP16BootNotificationRequest, OCPP16BootNotificationResponse>(
1125 chargingStation,
1126 OCPP16RequestCommand.BOOT_NOTIFICATION,
1127 chargingStation.bootNotificationRequest,
1128 { skipBufferingOnError: true, triggerMessage: true }
1129 )
1130 .then((response) => {
1131 chargingStation.bootNotificationResponse = response;
1132 })
1133 .catch(() => {
1134 /* This is intentional */
1135 });
1136 }, Constants.OCPP_TRIGGER_MESSAGE_DELAY);
1137 return Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED;
1138 case MessageTrigger.Heartbeat:
1139 setTimeout(() => {
1140 chargingStation.ocppRequestService
1141 .requestHandler<OCPP16HeartbeatRequest, OCPP16HeartbeatResponse>(
1142 chargingStation,
1143 OCPP16RequestCommand.HEARTBEAT,
1144 null,
1145 {
1146 triggerMessage: true,
1147 }
1148 )
1149 .catch(() => {
1150 /* This is intentional */
1151 });
1152 }, Constants.OCPP_TRIGGER_MESSAGE_DELAY);
1153 return Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED;
1154 case MessageTrigger.StatusNotification:
1155 setTimeout(() => {
1156 if (commandPayload?.connectorId) {
1157 chargingStation.ocppRequestService
1158 .requestHandler<OCPP16StatusNotificationRequest, OCPP16StatusNotificationResponse>(
1159 chargingStation,
1160 OCPP16RequestCommand.STATUS_NOTIFICATION,
1161 {
1162 connectorId: commandPayload.connectorId,
1163 errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
1164 status: chargingStation.getConnectorStatus(commandPayload.connectorId).status,
1165 },
1166 {
1167 triggerMessage: true,
1168 }
1169 )
1170 .catch(() => {
1171 /* This is intentional */
1172 });
1173 } else {
1174 for (const connectorId of chargingStation.connectors.keys()) {
1175 chargingStation.ocppRequestService
1176 .requestHandler<
1177 OCPP16StatusNotificationRequest,
1178 OCPP16StatusNotificationResponse
1179 >(
1180 chargingStation,
1181 OCPP16RequestCommand.STATUS_NOTIFICATION,
1182 {
1183 connectorId,
1184 errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
1185 status: chargingStation.getConnectorStatus(connectorId).status,
1186 },
1187 {
1188 triggerMessage: true,
1189 }
1190 )
1191 .catch(() => {
1192 /* This is intentional */
1193 });
1194 }
1195 }
1196 }, Constants.OCPP_TRIGGER_MESSAGE_DELAY);
1197 return Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED;
1198 default:
1199 return Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED;
1200 }
1201 } catch (error) {
1202 return this.handleIncomingRequestError(
1203 chargingStation,
1204 OCPP16IncomingRequestCommand.TRIGGER_MESSAGE,
1205 error as Error,
1206 { errorResponse: Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED }
1207 );
1208 }
1209 }
1210 }