Hook the OCPP 2.0 stack into the main code
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / 1.6 / OCPP16IncomingRequestService.ts
index 64314475c8b42ea7ff6e90fd8a854b2d808e7540..420edf86b5e5f1af369b354e6540eb178716e9ca 100644 (file)
@@ -1,20 +1,20 @@
-// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
 import fs from 'fs';
 import path from 'path';
 import { URL, fileURLToPath } from 'url';
 
-import { JSONSchemaType } from 'ajv';
-import { Client, FTPResponse } from 'basic-ftp';
+import type { JSONSchemaType } from 'ajv';
+import { Client, type FTPResponse } from 'basic-ftp';
 import tar from 'tar';
 
 import OCPPError from '../../../exception/OCPPError';
-import { JsonType } from '../../../types/JsonType';
+import type { JsonObject, JsonType } from '../../../types/JsonType';
 import { OCPP16ChargePointErrorCode } from '../../../types/ocpp/1.6/ChargePointErrorCode';
 import { OCPP16ChargePointStatus } from '../../../types/ocpp/1.6/ChargePointStatus';
 import {
   ChargingProfilePurposeType,
-  OCPP16ChargingProfile,
+  type OCPP16ChargingProfile,
 } from '../../../types/ocpp/1.6/ChargingProfile';
 import {
   OCPP16StandardParametersKey,
@@ -22,59 +22,59 @@ import {
 } from '../../../types/ocpp/1.6/Configuration';
 import { OCPP16DiagnosticsStatus } from '../../../types/ocpp/1.6/DiagnosticsStatus';
 import {
-  OCPP16MeterValuesRequest,
-  OCPP16MeterValuesResponse,
-} from '../../../types/ocpp/1.6/MeterValues';
-import {
-  ChangeAvailabilityRequest,
-  ChangeConfigurationRequest,
-  ClearChargingProfileRequest,
-  DiagnosticsStatusNotificationRequest,
-  GetConfigurationRequest,
-  GetDiagnosticsRequest,
-  MessageTrigger,
+  type ChangeAvailabilityRequest,
+  type ChangeConfigurationRequest,
+  type ClearChargingProfileRequest,
+  type DiagnosticsStatusNotificationRequest,
+  type GetConfigurationRequest,
+  type GetDiagnosticsRequest,
   OCPP16AvailabilityType,
-  OCPP16BootNotificationRequest,
-  OCPP16ClearCacheRequest,
-  OCPP16HeartbeatRequest,
+  type OCPP16BootNotificationRequest,
+  type OCPP16ClearCacheRequest,
+  type OCPP16DataTransferRequest,
+  OCPP16DataTransferVendorId,
+  type OCPP16HeartbeatRequest,
   OCPP16IncomingRequestCommand,
+  OCPP16MessageTrigger,
   OCPP16RequestCommand,
-  OCPP16StatusNotificationRequest,
-  OCPP16TriggerMessageRequest,
-  RemoteStartTransactionRequest,
-  RemoteStopTransactionRequest,
-  ResetRequest,
-  SetChargingProfileRequest,
-  UnlockConnectorRequest,
+  type OCPP16StatusNotificationRequest,
+  type OCPP16TriggerMessageRequest,
+  type OCPP16UpdateFirmwareRequest,
+  type RemoteStartTransactionRequest,
+  type RemoteStopTransactionRequest,
+  type ResetRequest,
+  type SetChargingProfileRequest,
+  type UnlockConnectorRequest,
 } from '../../../types/ocpp/1.6/Requests';
 import {
-  ChangeAvailabilityResponse,
-  ChangeConfigurationResponse,
-  ClearChargingProfileResponse,
-  DiagnosticsStatusNotificationResponse,
-  GetConfigurationResponse,
-  GetDiagnosticsResponse,
-  OCPP16BootNotificationResponse,
-  OCPP16HeartbeatResponse,
-  OCPP16StatusNotificationResponse,
-  OCPP16TriggerMessageResponse,
-  SetChargingProfileResponse,
-  UnlockConnectorResponse,
+  type ChangeAvailabilityResponse,
+  type ChangeConfigurationResponse,
+  type ClearChargingProfileResponse,
+  type DiagnosticsStatusNotificationResponse,
+  type GetConfigurationResponse,
+  type GetDiagnosticsResponse,
+  type OCPP16BootNotificationResponse,
+  type OCPP16DataTransferResponse,
+  OCPP16DataTransferStatus,
+  type OCPP16HeartbeatResponse,
+  type OCPP16StatusNotificationResponse,
+  type OCPP16TriggerMessageResponse,
+  type OCPP16UpdateFirmwareResponse,
+  type SetChargingProfileResponse,
+  type UnlockConnectorResponse,
 } from '../../../types/ocpp/1.6/Responses';
 import {
   OCPP16AuthorizationStatus,
-  OCPP16AuthorizeRequest,
-  OCPP16AuthorizeResponse,
-  OCPP16StartTransactionRequest,
-  OCPP16StartTransactionResponse,
+  type OCPP16AuthorizeRequest,
+  type OCPP16AuthorizeResponse,
+  type OCPP16StartTransactionRequest,
+  type OCPP16StartTransactionResponse,
   OCPP16StopTransactionReason,
-  OCPP16StopTransactionRequest,
-  OCPP16StopTransactionResponse,
 } from '../../../types/ocpp/1.6/Transaction';
-import { OCPPConfigurationKey } from '../../../types/ocpp/Configuration';
+import type { OCPPConfigurationKey } from '../../../types/ocpp/Configuration';
 import { ErrorType } from '../../../types/ocpp/ErrorType';
-import { IncomingRequestHandler } from '../../../types/ocpp/Requests';
-import { DefaultResponse } from '../../../types/ocpp/Responses';
+import type { IncomingRequestHandler } from '../../../types/ocpp/Requests';
+import type { DefaultResponse } from '../../../types/ocpp/Responses';
 import Constants from '../../../utils/Constants';
 import logger from '../../../utils/Logger';
 import Utils from '../../../utils/Utils';
@@ -88,18 +88,7 @@ const moduleName = 'OCPP16IncomingRequestService';
 
 export default class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
   private incomingRequestHandlers: Map<OCPP16IncomingRequestCommand, IncomingRequestHandler>;
-  private resetJsonSchema: JSONSchemaType<ResetRequest>;
-  private clearCacheJsonSchema: JSONSchemaType<OCPP16ClearCacheRequest>;
-  private getConfigurationJsonSchema: JSONSchemaType<GetConfigurationRequest>;
-  private changeConfigurationJsonSchema: JSONSchemaType<ChangeConfigurationRequest>;
-  private unlockConnectorJsonSchema: JSONSchemaType<UnlockConnectorRequest>;
-  private getDiagnosticsJsonSchema: JSONSchemaType<GetDiagnosticsRequest>;
-  private setChargingProfileJsonSchema: JSONSchemaType<SetChargingProfileRequest>;
-  private clearChargingProfileJsonSchema: JSONSchemaType<ClearChargingProfileRequest>;
-  private changeAvailabilityJsonSchema: JSONSchemaType<ChangeAvailabilityRequest>;
-  private remoteStartTransactionJsonSchema: JSONSchemaType<RemoteStartTransactionRequest>;
-  private remoteStopTransactionJsonSchema: JSONSchemaType<RemoteStopTransactionRequest>;
-  private triggerMessageJsonSchema: JSONSchemaType<OCPP16TriggerMessageRequest>;
+  private jsonSchemas: Map<OCPP16IncomingRequestCommand, JSONSchemaType<JsonObject>>;
 
   public constructor() {
     if (new.target?.name === moduleName) {
@@ -140,115 +129,168 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
       ],
       [OCPP16IncomingRequestCommand.GET_DIAGNOSTICS, this.handleRequestGetDiagnostics.bind(this)],
       [OCPP16IncomingRequestCommand.TRIGGER_MESSAGE, this.handleRequestTriggerMessage.bind(this)],
+      [OCPP16IncomingRequestCommand.DATA_TRANSFER, this.handleRequestDataTransfer.bind(this)],
+      // [OCPP16IncomingRequestCommand.UPDATE_FIRMWARE, this.handleRequestUpdateFirmware.bind(this)],
     ]);
-    this.resetJsonSchema = JSON.parse(
-      fs.readFileSync(
-        path.resolve(
-          path.dirname(fileURLToPath(import.meta.url)),
-          '../../../assets/json-schemas/ocpp/1.6/Reset.json'
-        ),
-        'utf8'
-      )
-    ) as JSONSchemaType<ResetRequest>;
-    this.clearCacheJsonSchema = JSON.parse(
-      fs.readFileSync(
-        path.resolve(
-          path.dirname(fileURLToPath(import.meta.url)),
-          '../../../assets/json-schemas/ocpp/1.6/ClearCache.json'
-        ),
-        'utf8'
-      )
-    ) as JSONSchemaType<OCPP16ClearCacheRequest>;
-    this.getConfigurationJsonSchema = JSON.parse(
-      fs.readFileSync(
-        path.resolve(
-          path.dirname(fileURLToPath(import.meta.url)),
-          '../../../assets/json-schemas/ocpp/1.6/GetConfiguration.json'
-        ),
-        'utf8'
-      )
-    ) as JSONSchemaType<GetConfigurationRequest>;
-    this.changeConfigurationJsonSchema = JSON.parse(
-      fs.readFileSync(
-        path.resolve(
-          path.dirname(fileURLToPath(import.meta.url)),
-          '../../../assets/json-schemas/ocpp/1.6/ChangeConfiguration.json'
-        ),
-        'utf8'
-      )
-    ) as JSONSchemaType<ChangeConfigurationRequest>;
-    this.unlockConnectorJsonSchema = JSON.parse(
-      fs.readFileSync(
-        path.resolve(
-          path.dirname(fileURLToPath(import.meta.url)),
-          '../../../assets/json-schemas/ocpp/1.6/UnlockConnector.json'
-        ),
-        'utf8'
-      )
-    ) as JSONSchemaType<UnlockConnectorRequest>;
-    this.getDiagnosticsJsonSchema = JSON.parse(
-      fs.readFileSync(
-        path.resolve(
-          path.dirname(fileURLToPath(import.meta.url)),
-          '../../../assets/json-schemas/ocpp/1.6/GetDiagnostics.json'
-        ),
-        'utf8'
-      )
-    ) as JSONSchemaType<GetDiagnosticsRequest>;
-    this.setChargingProfileJsonSchema = JSON.parse(
-      fs.readFileSync(
-        path.resolve(
-          path.dirname(fileURLToPath(import.meta.url)),
-          '../../../assets/json-schemas/ocpp/1.6/SetChargingProfile.json'
-        ),
-        'utf8'
-      )
-    ) as JSONSchemaType<SetChargingProfileRequest>;
-    this.clearChargingProfileJsonSchema = JSON.parse(
-      fs.readFileSync(
-        path.resolve(
-          path.dirname(fileURLToPath(import.meta.url)),
-          '../../../assets/json-schemas/ocpp/1.6/ClearChargingProfile.json'
-        ),
-        'utf8'
-      )
-    ) as JSONSchemaType<ClearChargingProfileRequest>;
-    this.changeAvailabilityJsonSchema = JSON.parse(
-      fs.readFileSync(
-        path.resolve(
-          path.dirname(fileURLToPath(import.meta.url)),
-          '../../../assets/json-schemas/ocpp/1.6/ChangeAvailability.json'
-        ),
-        'utf8'
-      )
-    ) as JSONSchemaType<ChangeAvailabilityRequest>;
-    this.remoteStartTransactionJsonSchema = JSON.parse(
-      fs.readFileSync(
-        path.resolve(
-          path.dirname(fileURLToPath(import.meta.url)),
-          '../../../assets/json-schemas/ocpp/1.6/RemoteStartTransaction.json'
-        ),
-        'utf8'
-      )
-    ) as JSONSchemaType<RemoteStartTransactionRequest>;
-    this.remoteStopTransactionJsonSchema = JSON.parse(
-      fs.readFileSync(
-        path.resolve(
-          path.dirname(fileURLToPath(import.meta.url)),
-          '../../../assets/json-schemas/ocpp/1.6/RemoteStopTransaction.json'
-        ),
-        'utf8'
-      )
-    ) as JSONSchemaType<RemoteStopTransactionRequest>;
-    this.triggerMessageJsonSchema = JSON.parse(
-      fs.readFileSync(
-        path.resolve(
-          path.dirname(fileURLToPath(import.meta.url)),
-          '../../../assets/json-schemas/ocpp/1.6/TriggerMessage.json'
-        ),
-        'utf8'
-      )
-    ) as JSONSchemaType<OCPP16TriggerMessageRequest>;
+    this.jsonSchemas = new Map<OCPP16IncomingRequestCommand, JSONSchemaType<JsonObject>>([
+      [
+        OCPP16IncomingRequestCommand.RESET,
+        JSON.parse(
+          fs.readFileSync(
+            path.resolve(
+              path.dirname(fileURLToPath(import.meta.url)),
+              '../../../assets/json-schemas/ocpp/1.6/Reset.json'
+            ),
+            'utf8'
+          )
+        ) as JSONSchemaType<ResetRequest>,
+      ],
+      [
+        OCPP16IncomingRequestCommand.CLEAR_CACHE,
+        JSON.parse(
+          fs.readFileSync(
+            path.resolve(
+              path.dirname(fileURLToPath(import.meta.url)),
+              '../../../assets/json-schemas/ocpp/1.6/ClearCache.json'
+            ),
+            'utf8'
+          )
+        ) as JSONSchemaType<OCPP16ClearCacheRequest>,
+      ],
+      [
+        OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR,
+        JSON.parse(
+          fs.readFileSync(
+            path.resolve(
+              path.dirname(fileURLToPath(import.meta.url)),
+              '../../../assets/json-schemas/ocpp/1.6/UnlockConnector.json'
+            ),
+            'utf8'
+          )
+        ) as JSONSchemaType<UnlockConnectorRequest>,
+      ],
+      [
+        OCPP16IncomingRequestCommand.GET_CONFIGURATION,
+        JSON.parse(
+          fs.readFileSync(
+            path.resolve(
+              path.dirname(fileURLToPath(import.meta.url)),
+              '../../../assets/json-schemas/ocpp/1.6/GetConfiguration.json'
+            ),
+            'utf8'
+          )
+        ) as JSONSchemaType<GetConfigurationRequest>,
+      ],
+      [
+        OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION,
+        JSON.parse(
+          fs.readFileSync(
+            path.resolve(
+              path.dirname(fileURLToPath(import.meta.url)),
+              '../../../assets/json-schemas/ocpp/1.6/ChangeConfiguration.json'
+            ),
+            'utf8'
+          )
+        ) as JSONSchemaType<ChangeConfigurationRequest>,
+      ],
+      [
+        OCPP16IncomingRequestCommand.GET_DIAGNOSTICS,
+        JSON.parse(
+          fs.readFileSync(
+            path.resolve(
+              path.dirname(fileURLToPath(import.meta.url)),
+              '../../../assets/json-schemas/ocpp/1.6/GetDiagnostics.json'
+            ),
+            'utf8'
+          )
+        ) as JSONSchemaType<GetDiagnosticsRequest>,
+      ],
+      [
+        OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE,
+        JSON.parse(
+          fs.readFileSync(
+            path.resolve(
+              path.dirname(fileURLToPath(import.meta.url)),
+              '../../../assets/json-schemas/ocpp/1.6/SetChargingProfile.json'
+            ),
+            'utf8'
+          )
+        ) as JSONSchemaType<SetChargingProfileRequest>,
+      ],
+      [
+        OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE,
+        JSON.parse(
+          fs.readFileSync(
+            path.resolve(
+              path.dirname(fileURLToPath(import.meta.url)),
+              '../../../assets/json-schemas/ocpp/1.6/ClearChargingProfile.json'
+            ),
+            'utf8'
+          )
+        ) as JSONSchemaType<ClearChargingProfileRequest>,
+      ],
+      [
+        OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY,
+        JSON.parse(
+          fs.readFileSync(
+            path.resolve(
+              path.dirname(fileURLToPath(import.meta.url)),
+              '../../../assets/json-schemas/ocpp/1.6/ChangeAvailability.json'
+            ),
+            'utf8'
+          )
+        ) as JSONSchemaType<ChangeAvailabilityRequest>,
+      ],
+      [
+        OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION,
+        JSON.parse(
+          fs.readFileSync(
+            path.resolve(
+              path.dirname(fileURLToPath(import.meta.url)),
+              '../../../assets/json-schemas/ocpp/1.6/RemoteStartTransaction.json'
+            ),
+            'utf8'
+          )
+        ) as JSONSchemaType<RemoteStartTransactionRequest>,
+      ],
+      [
+        OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION,
+        JSON.parse(
+          fs.readFileSync(
+            path.resolve(
+              path.dirname(fileURLToPath(import.meta.url)),
+              '../../../assets/json-schemas/ocpp/1.6/RemoteStopTransaction.json'
+            ),
+            'utf8'
+          )
+        ) as JSONSchemaType<RemoteStopTransactionRequest>,
+      ],
+      [
+        OCPP16IncomingRequestCommand.TRIGGER_MESSAGE,
+        JSON.parse(
+          fs.readFileSync(
+            path.resolve(
+              path.dirname(fileURLToPath(import.meta.url)),
+              '../../../assets/json-schemas/ocpp/1.6/TriggerMessage.json'
+            ),
+            'utf8'
+          )
+        ) as JSONSchemaType<OCPP16TriggerMessageRequest>,
+      ],
+      [
+        OCPP16IncomingRequestCommand.DATA_TRANSFER,
+        JSON.parse(
+          fs.readFileSync(
+            path.resolve(
+              path.dirname(fileURLToPath(import.meta.url)),
+              '../../../assets/json-schemas/ocpp/1.6/DataTransfer.json'
+            ),
+            'utf8'
+          )
+        ) as JSONSchemaType<OCPP16DataTransferRequest>,
+      ],
+    ]);
+    this.validatePayload.bind(this);
   }
 
   public async incomingRequestHandler(
@@ -259,8 +301,8 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
   ): Promise<void> {
     let response: JsonType;
     if (
-      chargingStation.getOcppStrictCompliance() &&
-      chargingStation.isInPendingState() &&
+      chargingStation.getOcppStrictCompliance() === true &&
+      chargingStation.isInPendingState() === true &&
       (commandName === OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION ||
         commandName === OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION)
     ) {
@@ -276,14 +318,16 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
       );
     }
     if (
-      chargingStation.isRegistered() ||
-      (!chargingStation.getOcppStrictCompliance() && chargingStation.isInUnknownState())
+      chargingStation.isRegistered() === true ||
+      (chargingStation.getOcppStrictCompliance() === false &&
+        chargingStation.isInUnknownState() === true)
     ) {
       if (
-        this.incomingRequestHandlers.has(commandName) &&
-        ChargingStationUtils.isIncomingRequestCommandSupported(commandName, chargingStation)
+        this.incomingRequestHandlers.has(commandName) === true &&
+        OCPP16ServiceUtils.isIncomingRequestCommandSupported(chargingStation, commandName) === true
       ) {
         try {
+          this.validatePayload(chargingStation, commandName, commandPayload);
           // Call the method to build the response
           response = await this.incomingRequestHandlers.get(commandName)(
             chargingStation,
@@ -291,7 +335,10 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
           );
         } catch (error) {
           // Log
-          logger.error(chargingStation.logPrefix() + ' Handle request error: %j', error);
+          logger.error(
+            `${chargingStation.logPrefix()} ${moduleName}.incomingRequestHandler: Handle incoming request error:`,
+            error
+          );
           throw error;
         }
       } else {
@@ -328,21 +375,42 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
     );
   }
 
+  private validatePayload(
+    chargingStation: ChargingStation,
+    commandName: OCPP16IncomingRequestCommand,
+    commandPayload: JsonType
+  ): boolean {
+    if (this.jsonSchemas.has(commandName)) {
+      return this.validateIncomingRequestPayload(
+        chargingStation,
+        commandName,
+        this.jsonSchemas.get(commandName),
+        commandPayload
+      );
+    }
+    logger.warn(
+      `${chargingStation.logPrefix()} ${moduleName}.validatePayload: No JSON schema found for command ${commandName} PDU validation`
+    );
+    return false;
+  }
+
   // Simulate charging station restart
   private handleRequestReset(
     chargingStation: ChargingStation,
     commandPayload: ResetRequest
   ): DefaultResponse {
-    this.validateIncomingRequestPayload(
-      chargingStation,
-      OCPP16IncomingRequestCommand.RESET,
-      this.resetJsonSchema,
-      commandPayload
-    );
-    // eslint-disable-next-line @typescript-eslint/no-misused-promises
-    setImmediate(async (): Promise<void> => {
-      await chargingStation.reset((commandPayload.type + 'Reset') as OCPP16StopTransactionReason);
-    });
+    this.asyncResource
+      .runInAsyncScope(
+        chargingStation.reset.bind(chargingStation) as (
+          this: ChargingStation,
+          ...args: any[]
+        ) => Promise<void>,
+        chargingStation,
+        (commandPayload.type + 'Reset') as OCPP16StopTransactionReason
+      )
+      .catch(() => {
+        /* This is intentional */
+      });
     logger.info(
       `${chargingStation.logPrefix()} ${
         commandPayload.type
@@ -353,15 +421,9 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
     return Constants.OCPP_RESPONSE_ACCEPTED;
   }
 
-  private handleRequestClearCache(
-    chargingStation: ChargingStation,
-    commandPayload: OCPP16ClearCacheRequest
-  ): DefaultResponse {
-    this.validateIncomingRequestPayload(
-      chargingStation,
-      OCPP16IncomingRequestCommand.CLEAR_CACHE,
-      this.clearCacheJsonSchema,
-      commandPayload
+  private handleRequestClearCache(chargingStation: ChargingStation): DefaultResponse {
+    chargingStation.authorizedTagsCache.deleteAuthorizedTags(
+      ChargingStationUtils.getAuthorizationFile(chargingStation.stationInfo)
     );
     return Constants.OCPP_RESPONSE_ACCEPTED;
   }
@@ -370,50 +432,24 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
     chargingStation: ChargingStation,
     commandPayload: UnlockConnectorRequest
   ): Promise<UnlockConnectorResponse> {
-    this.validateIncomingRequestPayload(
-      chargingStation,
-      OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR,
-      this.unlockConnectorJsonSchema,
-      commandPayload
-    );
     const connectorId = commandPayload.connectorId;
+    if (chargingStation.connectors.has(connectorId) === false) {
+      logger.error(
+        `${chargingStation.logPrefix()} Trying to unlock a non existing connector Id ${connectorId.toString()}`
+      );
+      return Constants.OCPP_RESPONSE_UNLOCK_NOT_SUPPORTED;
+    }
     if (connectorId === 0) {
       logger.error(
-        chargingStation.logPrefix() + ' Trying to unlock connector ' + connectorId.toString()
+        chargingStation.logPrefix() + ' Trying to unlock connector Id ' + connectorId.toString()
       );
       return Constants.OCPP_RESPONSE_UNLOCK_NOT_SUPPORTED;
     }
-    if (chargingStation.getConnectorStatus(connectorId)?.transactionStarted) {
-      const transactionId = chargingStation.getConnectorStatus(connectorId).transactionId;
-      if (
-        chargingStation.getBeginEndMeterValues() &&
-        chargingStation.getOcppStrictCompliance() &&
-        !chargingStation.getOutOfOrderEndMeterValues()
-      ) {
-        // FIXME: Implement OCPP version agnostic helpers
-        const transactionEndMeterValue = OCPP16ServiceUtils.buildTransactionEndMeterValue(
-          chargingStation,
-          connectorId,
-          chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId)
-        );
-        await chargingStation.ocppRequestService.requestHandler<
-          OCPP16MeterValuesRequest,
-          OCPP16MeterValuesResponse
-        >(chargingStation, OCPP16RequestCommand.METER_VALUES, {
-          connectorId,
-          transactionId,
-          meterValue: [transactionEndMeterValue],
-        });
-      }
-      const stopResponse = await chargingStation.ocppRequestService.requestHandler<
-        OCPP16StopTransactionRequest,
-        OCPP16StopTransactionResponse
-      >(chargingStation, OCPP16RequestCommand.STOP_TRANSACTION, {
-        transactionId,
-        meterStop: chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId),
-        idTag: chargingStation.getTransactionIdTag(transactionId),
-        reason: OCPP16StopTransactionReason.UNLOCK_COMMAND,
-      });
+    if (chargingStation.getConnectorStatus(connectorId)?.transactionStarted === true) {
+      const stopResponse = await chargingStation.stopTransactionOnConnector(
+        connectorId,
+        OCPP16StopTransactionReason.UNLOCK_COMMAND
+      );
       if (stopResponse.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED) {
         return Constants.OCPP_RESPONSE_UNLOCKED;
       }
@@ -435,20 +471,14 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
     chargingStation: ChargingStation,
     commandPayload: GetConfigurationRequest
   ): GetConfigurationResponse {
-    this.validateIncomingRequestPayload(
-      chargingStation,
-      OCPP16IncomingRequestCommand.GET_CONFIGURATION,
-      this.getConfigurationJsonSchema,
-      commandPayload
-    );
     const configurationKey: OCPPConfigurationKey[] = [];
     const unknownKey: string[] = [];
-    if (Utils.isEmptyArray(commandPayload.key)) {
+    if (Utils.isEmptyArray(commandPayload.key) === true) {
       for (const configuration of chargingStation.ocppConfiguration.configurationKey) {
-        if (Utils.isUndefined(configuration.visible)) {
+        if (Utils.isUndefined(configuration.visible) === true) {
           configuration.visible = true;
         }
-        if (!configuration.visible) {
+        if (configuration.visible === false) {
           continue;
         }
         configurationKey.push({
@@ -464,10 +494,10 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
           key
         );
         if (keyFound) {
-          if (Utils.isUndefined(keyFound.visible)) {
+          if (Utils.isUndefined(keyFound.visible) === true) {
             keyFound.visible = true;
           }
-          if (!keyFound.visible) {
+          if (keyFound.visible === false) {
             continue;
           }
           configurationKey.push({
@@ -490,12 +520,6 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
     chargingStation: ChargingStation,
     commandPayload: ChangeConfigurationRequest
   ): ChangeConfigurationResponse {
-    this.validateIncomingRequestPayload(
-      chargingStation,
-      OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION,
-      this.changeConfigurationJsonSchema,
-      commandPayload
-    );
     const keyToChange = ChargingStationConfigurationUtils.getConfigurationKey(
       chargingStation,
       commandPayload.key,
@@ -550,22 +574,16 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
     chargingStation: ChargingStation,
     commandPayload: SetChargingProfileRequest
   ): SetChargingProfileResponse {
-    this.validateIncomingRequestPayload(
-      chargingStation,
-      OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE,
-      this.setChargingProfileJsonSchema,
-      commandPayload
-    );
     if (
-      !OCPP16ServiceUtils.checkFeatureProfile(
+      OCPP16ServiceUtils.checkFeatureProfile(
         chargingStation,
         OCPP16SupportedFeatureProfiles.SmartCharging,
         OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE
-      )
+      ) === false
     ) {
       return Constants.OCPP_SET_CHARGING_PROFILE_RESPONSE_NOT_SUPPORTED;
     }
-    if (!chargingStation.getConnectorStatus(commandPayload.connectorId)) {
+    if (chargingStation.connectors.has(commandPayload.connectorId) === false) {
       logger.error(
         `${chargingStation.logPrefix()} Trying to set charging profile(s) to a non existing connector Id ${
           commandPayload.connectorId
@@ -584,11 +602,18 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
       commandPayload.csChargingProfiles.chargingProfilePurpose ===
         ChargingProfilePurposeType.TX_PROFILE &&
       (commandPayload.connectorId === 0 ||
-        !chargingStation.getConnectorStatus(commandPayload.connectorId)?.transactionStarted)
+        chargingStation.getConnectorStatus(commandPayload.connectorId)?.transactionStarted ===
+          false)
     ) {
+      logger.error(
+        `${chargingStation.logPrefix()} Trying to set transaction charging profile(s) on connector ${
+          commandPayload.connectorId
+        } without a started transaction`
+      );
       return Constants.OCPP_SET_CHARGING_PROFILE_RESPONSE_REJECTED;
     }
-    chargingStation.setChargingProfile(
+    OCPP16ServiceUtils.setChargingProfile(
+      chargingStation,
       commandPayload.connectorId,
       commandPayload.csChargingProfiles
     );
@@ -605,23 +630,16 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
     chargingStation: ChargingStation,
     commandPayload: ClearChargingProfileRequest
   ): ClearChargingProfileResponse {
-    this.validateIncomingRequestPayload(
-      chargingStation,
-      OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE,
-      this.clearChargingProfileJsonSchema,
-      commandPayload
-    );
     if (
-      !OCPP16ServiceUtils.checkFeatureProfile(
+      OCPP16ServiceUtils.checkFeatureProfile(
         chargingStation,
         OCPP16SupportedFeatureProfiles.SmartCharging,
         OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE
-      )
+      ) === false
     ) {
       return Constants.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN;
     }
-    const connectorStatus = chargingStation.getConnectorStatus(commandPayload.connectorId);
-    if (!connectorStatus) {
+    if (chargingStation.connectors.has(commandPayload.connectorId) === false) {
       logger.error(
         `${chargingStation.logPrefix()} Trying to clear a charging profile(s) to a non existing connector Id ${
           commandPayload.connectorId
@@ -629,6 +647,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
       );
       return Constants.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN;
     }
+    const connectorStatus = chargingStation.getConnectorStatus(commandPayload.connectorId);
     if (commandPayload.connectorId && !Utils.isEmptyArray(connectorStatus.chargingProfiles)) {
       connectorStatus.chargingProfiles = [];
       logger.debug(
@@ -692,14 +711,8 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
     chargingStation: ChargingStation,
     commandPayload: ChangeAvailabilityRequest
   ): Promise<ChangeAvailabilityResponse> {
-    this.validateIncomingRequestPayload(
-      chargingStation,
-      OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY,
-      this.changeAvailabilityJsonSchema,
-      commandPayload
-    );
     const connectorId: number = commandPayload.connectorId;
-    if (!chargingStation.getConnectorStatus(connectorId)) {
+    if (chargingStation.connectors.has(connectorId) === false) {
       logger.error(
         `${chargingStation.logPrefix()} Trying to change the availability of a non existing connector Id ${connectorId.toString()}`
       );
@@ -712,7 +725,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
     if (connectorId === 0) {
       let response: ChangeAvailabilityResponse = Constants.OCPP_AVAILABILITY_RESPONSE_ACCEPTED;
       for (const id of chargingStation.connectors.keys()) {
-        if (chargingStation.getConnectorStatus(id)?.transactionStarted) {
+        if (chargingStation.getConnectorStatus(id)?.transactionStarted === true) {
           response = Constants.OCPP_AVAILABILITY_RESPONSE_SCHEDULED;
         }
         chargingStation.getConnectorStatus(id).availability = commandPayload.type;
@@ -731,12 +744,11 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
       return response;
     } else if (
       connectorId > 0 &&
-      (chargingStation.getConnectorStatus(0).availability === OCPP16AvailabilityType.OPERATIVE ||
-        (chargingStation.getConnectorStatus(0).availability ===
-          OCPP16AvailabilityType.INOPERATIVE &&
+      (chargingStation.isChargingStationAvailable() === true ||
+        (chargingStation.isChargingStationAvailable() === false &&
           commandPayload.type === OCPP16AvailabilityType.INOPERATIVE))
     ) {
-      if (chargingStation.getConnectorStatus(connectorId)?.transactionStarted) {
+      if (chargingStation.getConnectorStatus(connectorId)?.transactionStarted === true) {
         chargingStation.getConnectorStatus(connectorId).availability = commandPayload.type;
         return Constants.OCPP_AVAILABILITY_RESPONSE_SCHEDULED;
       }
@@ -759,15 +771,17 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
     chargingStation: ChargingStation,
     commandPayload: RemoteStartTransactionRequest
   ): Promise<DefaultResponse> {
-    this.validateIncomingRequestPayload(
-      chargingStation,
-      OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION,
-      this.remoteStartTransactionJsonSchema,
-      commandPayload
-    );
     const transactionConnectorId = commandPayload.connectorId;
-    const connectorStatus = chargingStation.getConnectorStatus(transactionConnectorId);
-    if (transactionConnectorId) {
+    if (chargingStation.connectors.has(transactionConnectorId) === true) {
+      const remoteStartTransactionLogMsg =
+        chargingStation.logPrefix() +
+        ' Transaction remotely STARTED on ' +
+        chargingStation.stationInfo.chargingStationId +
+        '#' +
+        transactionConnectorId.toString() +
+        " for idTag '" +
+        commandPayload.idTag +
+        "'";
       await chargingStation.ocppRequestService.requestHandler<
         OCPP16StatusNotificationRequest,
         OCPP16StatusNotificationResponse
@@ -776,24 +790,25 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
         status: OCPP16ChargePointStatus.PREPARING,
         errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
       });
+      const connectorStatus = chargingStation.getConnectorStatus(transactionConnectorId);
       connectorStatus.status = OCPP16ChargePointStatus.PREPARING;
-      if (chargingStation.isChargingStationAvailable() && connectorStatus) {
+      if (chargingStation.isChargingStationAvailable() === true) {
         // Check if authorized
-        if (chargingStation.getAuthorizeRemoteTxRequests()) {
+        if (chargingStation.getAuthorizeRemoteTxRequests() === true) {
           let authorized = false;
           if (
-            chargingStation.getLocalAuthListEnabled() &&
-            chargingStation.hasAuthorizedTags() &&
+            chargingStation.getLocalAuthListEnabled() === true &&
+            chargingStation.hasAuthorizedTags() === true &&
             chargingStation.authorizedTagsCache
               .getAuthorizedTags(
                 ChargingStationUtils.getAuthorizationFile(chargingStation.stationInfo)
               )
-              .find((value) => value === commandPayload.idTag)
+              .find((idTag) => idTag === commandPayload.idTag)
           ) {
             connectorStatus.localAuthorizeIdTag = commandPayload.idTag;
             connectorStatus.idTagLocalAuthorized = true;
             authorized = true;
-          } else if (chargingStation.getMayAuthorizeAtRemoteStart()) {
+          } else if (chargingStation.getMustAuthorizeAtRemoteStart() === true) {
             connectorStatus.authorizeIdTag = commandPayload.idTag;
             const authorizeResponse: OCPP16AuthorizeResponse =
               await chargingStation.ocppRequestService.requestHandler<
@@ -810,14 +825,14 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
               `${chargingStation.logPrefix()} The charging station configuration expects authorize at remote start transaction but local authorization or authorize isn't enabled`
             );
           }
-          if (authorized) {
+          if (authorized === true) {
             // Authorization successful, start transaction
             if (
               this.setRemoteStartTransactionChargingProfile(
                 chargingStation,
                 transactionConnectorId,
                 commandPayload.chargingProfile
-              )
+              ) === true
             ) {
               connectorStatus.transactionRemoteStarted = true;
               if (
@@ -831,15 +846,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
                   })
                 ).idTagInfo.status === OCPP16AuthorizationStatus.ACCEPTED
               ) {
-                logger.debug(
-                  chargingStation.logPrefix() +
-                    ' Transaction remotely STARTED on ' +
-                    chargingStation.stationInfo.chargingStationId +
-                    '#' +
-                    transactionConnectorId.toString() +
-                    ' for idTag ' +
-                    commandPayload.idTag
-                );
+                logger.debug(remoteStartTransactionLogMsg);
                 return Constants.OCPP_RESPONSE_ACCEPTED;
               }
               return this.notifyRemoteStartTransactionRejected(
@@ -866,7 +873,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
             chargingStation,
             transactionConnectorId,
             commandPayload.chargingProfile
-          )
+          ) === true
         ) {
           connectorStatus.transactionRemoteStarted = true;
           if (
@@ -880,15 +887,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
               })
             ).idTagInfo.status === OCPP16AuthorizationStatus.ACCEPTED
           ) {
-            logger.debug(
-              chargingStation.logPrefix() +
-                ' Transaction remotely STARTED on ' +
-                chargingStation.stationInfo.chargingStationId +
-                '#' +
-                transactionConnectorId.toString() +
-                ' for idTag ' +
-                commandPayload.idTag
-            );
+            logger.debug(remoteStartTransactionLogMsg);
             return Constants.OCPP_RESPONSE_ACCEPTED;
           }
           return this.notifyRemoteStartTransactionRejected(
@@ -938,12 +937,13 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
       chargingStation.logPrefix() +
         ' Remote starting transaction REJECTED on connector Id ' +
         connectorId.toString() +
-        ', idTag ' +
+        ", idTag '" +
         idTag +
-        ', availability ' +
+        "', availability '" +
         chargingStation.getConnectorStatus(connectorId).availability +
-        ', status ' +
-        chargingStation.getConnectorStatus(connectorId).status
+        "', status '" +
+        chargingStation.getConnectorStatus(connectorId).status +
+        "'"
     );
     return Constants.OCPP_RESPONSE_REJECTED;
   }
@@ -954,7 +954,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
     cp: OCPP16ChargingProfile
   ): boolean {
     if (cp && cp.chargingProfilePurpose === ChargingProfilePurposeType.TX_PROFILE) {
-      chargingStation.setChargingProfile(connectorId, cp);
+      OCPP16ServiceUtils.setChargingProfile(chargingStation, connectorId, cp);
       logger.debug(
         `${chargingStation.logPrefix()} Charging profile(s) set at remote start transaction on connector id ${connectorId}, dump their stack: %j`,
         chargingStation.getConnectorStatus(connectorId).chargingProfiles
@@ -976,12 +976,6 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
     chargingStation: ChargingStation,
     commandPayload: RemoteStopTransactionRequest
   ): Promise<DefaultResponse> {
-    this.validateIncomingRequestPayload(
-      chargingStation,
-      OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION,
-      this.remoteStopTransactionJsonSchema,
-      commandPayload
-    );
     const transactionId = commandPayload.transactionId;
     for (const connectorId of chargingStation.connectors.keys()) {
       if (
@@ -997,35 +991,14 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
           errorCode: OCPP16ChargePointErrorCode.NO_ERROR,
         });
         chargingStation.getConnectorStatus(connectorId).status = OCPP16ChargePointStatus.FINISHING;
-        if (
-          chargingStation.getBeginEndMeterValues() &&
-          chargingStation.getOcppStrictCompliance() &&
-          !chargingStation.getOutOfOrderEndMeterValues()
-        ) {
-          // FIXME: Implement OCPP version agnostic helpers
-          const transactionEndMeterValue = OCPP16ServiceUtils.buildTransactionEndMeterValue(
-            chargingStation,
-            connectorId,
-            chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId)
-          );
-          await chargingStation.ocppRequestService.requestHandler<
-            OCPP16MeterValuesRequest,
-            OCPP16MeterValuesResponse
-          >(chargingStation, OCPP16RequestCommand.METER_VALUES, {
-            connectorId,
-            transactionId,
-            meterValue: [transactionEndMeterValue],
-          });
+        const stopResponse = await chargingStation.stopTransactionOnConnector(
+          connectorId,
+          OCPP16StopTransactionReason.REMOTE
+        );
+        if (stopResponse.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED) {
+          return Constants.OCPP_RESPONSE_ACCEPTED;
         }
-        await chargingStation.ocppRequestService.requestHandler<
-          OCPP16StopTransactionRequest,
-          OCPP16StopTransactionResponse
-        >(chargingStation, OCPP16RequestCommand.STOP_TRANSACTION, {
-          transactionId,
-          meterStop: chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId),
-          idTag: chargingStation.getTransactionIdTag(transactionId),
-        });
-        return Constants.OCPP_RESPONSE_ACCEPTED;
+        return Constants.OCPP_RESPONSE_REJECTED;
       }
     }
     logger.warn(
@@ -1036,22 +1009,38 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
     return Constants.OCPP_RESPONSE_REJECTED;
   }
 
+  private handleRequestUpdateFirmware(
+    chargingStation: ChargingStation,
+    commandPayload: OCPP16UpdateFirmwareRequest
+  ): OCPP16UpdateFirmwareResponse {
+    if (
+      OCPP16ServiceUtils.checkFeatureProfile(
+        chargingStation,
+        OCPP16SupportedFeatureProfiles.FirmwareManagement,
+        OCPP16IncomingRequestCommand.UPDATE_FIRMWARE
+      ) === false
+    ) {
+      return Constants.OCPP_RESPONSE_EMPTY;
+    }
+    logger.debug(
+      chargingStation.logPrefix() +
+        ' ' +
+        OCPP16IncomingRequestCommand.UPDATE_FIRMWARE +
+        ' request received: %j',
+      commandPayload
+    );
+  }
+
   private async handleRequestGetDiagnostics(
     chargingStation: ChargingStation,
     commandPayload: GetDiagnosticsRequest
   ): Promise<GetDiagnosticsResponse> {
-    this.validateIncomingRequestPayload(
-      chargingStation,
-      OCPP16IncomingRequestCommand.GET_DIAGNOSTICS,
-      this.getDiagnosticsJsonSchema,
-      commandPayload
-    );
     if (
-      !OCPP16ServiceUtils.checkFeatureProfile(
+      OCPP16ServiceUtils.checkFeatureProfile(
         chargingStation,
         OCPP16SupportedFeatureProfiles.FirmwareManagement,
         OCPP16IncomingRequestCommand.GET_DIAGNOSTICS
-      )
+      ) === false
     ) {
       return Constants.OCPP_RESPONSE_EMPTY;
     }
@@ -1166,62 +1155,48 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
     chargingStation: ChargingStation,
     commandPayload: OCPP16TriggerMessageRequest
   ): OCPP16TriggerMessageResponse {
-    this.validateIncomingRequestPayload(
-      chargingStation,
-      OCPP16IncomingRequestCommand.TRIGGER_MESSAGE,
-      this.triggerMessageJsonSchema,
-      commandPayload
-    );
     if (
       !OCPP16ServiceUtils.checkFeatureProfile(
         chargingStation,
         OCPP16SupportedFeatureProfiles.RemoteTrigger,
         OCPP16IncomingRequestCommand.TRIGGER_MESSAGE
+      ) ||
+      !OCPP16ServiceUtils.isMessageTriggerSupported(
+        chargingStation,
+        commandPayload.requestedMessage
       )
     ) {
       return Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED;
     }
-    // TODO: factor out the check on connector id
-    if (commandPayload?.connectorId < 0) {
-      logger.warn(
-        `${chargingStation.logPrefix()} ${
-          OCPP16IncomingRequestCommand.TRIGGER_MESSAGE
-        } incoming request received with invalid connectorId ${commandPayload.connectorId}`
-      );
+    if (
+      !OCPP16ServiceUtils.isConnectorIdValid(
+        chargingStation,
+        OCPP16IncomingRequestCommand.TRIGGER_MESSAGE,
+        commandPayload.connectorId
+      )
+    ) {
       return Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED;
     }
     try {
       switch (commandPayload.requestedMessage) {
-        case MessageTrigger.BootNotification:
+        case OCPP16MessageTrigger.BootNotification:
           setTimeout(() => {
             chargingStation.ocppRequestService
               .requestHandler<OCPP16BootNotificationRequest, OCPP16BootNotificationResponse>(
                 chargingStation,
                 OCPP16RequestCommand.BOOT_NOTIFICATION,
-                {
-                  chargePointModel: chargingStation.getBootNotificationRequest().chargePointModel,
-                  chargePointVendor: chargingStation.getBootNotificationRequest().chargePointVendor,
-                  chargeBoxSerialNumber:
-                    chargingStation.getBootNotificationRequest().chargeBoxSerialNumber,
-                  firmwareVersion: chargingStation.getBootNotificationRequest().firmwareVersion,
-                  chargePointSerialNumber:
-                    chargingStation.getBootNotificationRequest().chargePointSerialNumber,
-                  iccid: chargingStation.getBootNotificationRequest().iccid,
-                  imsi: chargingStation.getBootNotificationRequest().imsi,
-                  meterSerialNumber: chargingStation.getBootNotificationRequest().meterSerialNumber,
-                  meterType: chargingStation.getBootNotificationRequest().meterType,
-                },
+                chargingStation.bootNotificationRequest,
                 { skipBufferingOnError: true, triggerMessage: true }
               )
-              .then((value) => {
-                chargingStation.bootNotificationResponse = value;
+              .then((response) => {
+                chargingStation.bootNotificationResponse = response;
               })
               .catch(() => {
                 /* This is intentional */
               });
           }, Constants.OCPP_TRIGGER_MESSAGE_DELAY);
           return Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED;
-        case MessageTrigger.Heartbeat:
+        case OCPP16MessageTrigger.Heartbeat:
           setTimeout(() => {
             chargingStation.ocppRequestService
               .requestHandler<OCPP16HeartbeatRequest, OCPP16HeartbeatResponse>(
@@ -1237,7 +1212,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
               });
           }, Constants.OCPP_TRIGGER_MESSAGE_DELAY);
           return Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED;
-        case MessageTrigger.StatusNotification:
+        case OCPP16MessageTrigger.StatusNotification:
           setTimeout(() => {
             if (commandPayload?.connectorId) {
               chargingStation.ocppRequestService
@@ -1293,4 +1268,27 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
       );
     }
   }
+
+  private handleRequestDataTransfer(
+    chargingStation: ChargingStation,
+    commandPayload: OCPP16DataTransferRequest
+  ): OCPP16DataTransferResponse {
+    try {
+      if (Object.values(OCPP16DataTransferVendorId).includes(commandPayload.vendorId)) {
+        return {
+          status: OCPP16DataTransferStatus.ACCEPTED,
+        };
+      }
+      return {
+        status: OCPP16DataTransferStatus.UNKNOWN_VENDOR_ID,
+      };
+    } catch (error) {
+      return this.handleIncomingRequestError(
+        chargingStation,
+        OCPP16IncomingRequestCommand.DATA_TRANSFER,
+        error as Error,
+        { errorResponse: Constants.OCPP_DATA_TRANSFER_RESPONSE_REJECTED }
+      );
+    }
+  }
 }