feat: add template example with evses configuration
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / 1.6 / OCPP16RequestService.ts
index eee9e9a9d1687939a5e1d523496a6386abd97395..3bc73aaabb38d983f8fce8fd21ac4e743741c0be 100644 (file)
@@ -24,8 +24,8 @@ import {
 } from '../../../types';
 import { Constants, Utils } from '../../../utils';
 import {
+  OCPP16Constants,
   OCPP16ServiceUtils,
-  OCPPConstants,
   OCPPRequestService,
   type OCPPResponseService,
 } from '../internal';
@@ -122,7 +122,11 @@ export class OCPP16RequestService extends OCPPRequestService {
         ),
       ],
     ]);
-    this.buildRequestPayload.bind(this);
+    this.buildRequestPayload = this.buildRequestPayload.bind(this) as <Request extends JsonType>(
+      chargingStation: ChargingStation,
+      commandName: OCPP16RequestCommand,
+      commandParams?: JsonType
+    ) => Request;
   }
 
   public async requestHandler<RequestType extends JsonType, ResponseType extends JsonType>(
@@ -131,6 +135,7 @@ export class OCPP16RequestService extends OCPPRequestService {
     commandParams?: JsonType,
     params?: RequestParams
   ): Promise<ResponseType> {
+    // FIXME?: add sanity checks on charging station availability, connector availability, connector status, etc.
     if (OCPP16ServiceUtils.isRequestCommandSupported(chargingStation, commandName) === true) {
       return (await this.sendMessage(
         chargingStation,
@@ -171,7 +176,7 @@ export class OCPP16RequestService extends OCPPRequestService {
           ...commandParams,
         } as unknown as Request;
       case OCPP16RequestCommand.HEARTBEAT:
-        return OCPPConstants.OCPP_REQUEST_EMPTY as unknown as Request;
+        return OCPP16Constants.OCPP_REQUEST_EMPTY as unknown as Request;
       case OCPP16RequestCommand.START_TRANSACTION:
         return {
           idTag: Constants.DEFAULT_IDTAG,