OCPP: Cleanup helpers
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 2 Oct 2022 10:16:43 +0000 (12:16 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 2 Oct 2022 10:16:43 +0000 (12:16 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
src/charging-station/ocpp/1.6/OCPP16RequestService.ts
src/charging-station/ocpp/1.6/OCPP16ResponseService.ts
src/charging-station/ocpp/OCPPServiceUtils.ts
src/charging-station/ui-server/UIWebSocketServer.ts

index 0597e5cef6c95af84b0300fbaac0b4bd8e70ec43..c4b8d156ce2b00d9d32570b7cdb4ff09275e44fa 100644 (file)
@@ -303,7 +303,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
     ) {
       if (
         this.incomingRequestHandlers.has(commandName) &&
-        OCPP16ServiceUtils.isIncomingRequestCommandSupported(commandName, chargingStation)
+        OCPP16ServiceUtils.isIncomingRequestCommandSupported(chargingStation, commandName)
       ) {
         try {
           this.validatePayload(chargingStation, commandName, commandPayload);
index d840e5e97a23ca788d7a922697e471215ae60755..3bb9f6ce4426965e97a20c690cbf67a996b0ca6b 100644 (file)
@@ -27,7 +27,6 @@ import Constants from '../../../utils/Constants';
 import logger from '../../../utils/Logger';
 import Utils from '../../../utils/Utils';
 import type ChargingStation from '../../ChargingStation';
-import { ChargingStationUtils } from '../../ChargingStationUtils';
 import OCPPRequestService from '../OCPPRequestService';
 import type OCPPResponseService from '../OCPPResponseService';
 import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';
@@ -150,7 +149,7 @@ export default class OCPP16RequestService extends OCPPRequestService {
     commandParams?: JsonType,
     params?: RequestParams
   ): Promise<ResponseType> {
-    if (OCPP16ServiceUtils.isRequestCommandSupported(commandName, chargingStation)) {
+    if (OCPP16ServiceUtils.isRequestCommandSupported(chargingStation, commandName)) {
       const requestPayload = this.buildRequestPayload<RequestType>(
         chargingStation,
         commandName,
index 041122c5fffd2880045860597092e03a0b82814b..f72f2c3ccc73b48cd3092920d6e027796a4f5284 100644 (file)
@@ -43,7 +43,6 @@ import logger from '../../../utils/Logger';
 import Utils from '../../../utils/Utils';
 import type ChargingStation from '../../ChargingStation';
 import { ChargingStationConfigurationUtils } from '../../ChargingStationConfigurationUtils';
-import { ChargingStationUtils } from '../../ChargingStationUtils';
 import OCPPResponseService from '../OCPPResponseService';
 import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';
 
@@ -178,7 +177,7 @@ export default class OCPP16ResponseService extends OCPPResponseService {
     if (chargingStation.isRegistered() || commandName === OCPP16RequestCommand.BOOT_NOTIFICATION) {
       if (
         this.responseHandlers.has(commandName) &&
-        OCPP16ServiceUtils.isRequestCommandSupported(commandName, chargingStation)
+        OCPP16ServiceUtils.isRequestCommandSupported(chargingStation, commandName)
       ) {
         try {
           this.validatePayload(chargingStation, commandName, payload);
index c524d45485692e8e079ba61caedfdd0dfc5e6d0a..163828d5fdffdce59810c6a2c67d8e78fc106ba8 100644 (file)
@@ -34,8 +34,8 @@ export class OCPPServiceUtils {
   }
 
   public static isRequestCommandSupported(
-    command: RequestCommand,
-    chargingStation: ChargingStation
+    chargingStation: ChargingStation,
+    command: RequestCommand
   ): boolean {
     const isRequestCommand = Object.values(RequestCommand).includes(command);
     if (
@@ -54,8 +54,8 @@ export class OCPPServiceUtils {
   }
 
   public static isIncomingRequestCommandSupported(
-    command: IncomingRequestCommand,
-    chargingStation: ChargingStation
+    chargingStation: ChargingStation,
+    command: IncomingRequestCommand
   ): boolean {
     const isIncomingRequestCommand = Object.values(IncomingRequestCommand).includes(command);
     if (
index cf1bfa65bddfc4f415f46feb0acdc73646ddcf96..1b060783021450c367243f80df06050f74b15717 100644 (file)
@@ -27,6 +27,7 @@ export default class UIWebSocketServer extends AbstractUIServer {
   }
 
   public start(): void {
+    // eslint-disable-next-line @typescript-eslint/no-unused-vars
     this.webSocketServer.on('connection', (ws: WebSocket, req: IncomingMessage): void => {
       if (UIServerUtils.isProtocolAndVersionSupported(ws.protocol) === false) {
         logger.error(