Add sendResult helper to send response
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / 1.6 / OCPP16IncomingRequestService.ts
index 6510e68f38c57ca5053e3871cda6aaa01b38dfa6..33f0825515402eab4c51994a32a3063e36fa37f4 100644 (file)
@@ -47,11 +47,11 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
   }
 
   public async handleRequest(messageId: string, commandName: OCPP16IncomingRequestCommand, commandPayload: Record<string, unknown>): Promise<void> {
-    let response: Record<string, unknown>;
+    let result: Record<string, unknown>;
     if (this.incomingRequestHandlers.has(commandName)) {
       try {
-        // Call the method to build the response
-        response = await this.incomingRequestHandlers.get(commandName)(commandPayload);
+        // Call the method to build the result
+        result = await this.incomingRequestHandlers.get(commandName)(commandPayload);
       } catch (error) {
         // Log
         logger.error(this.chargingStation.logPrefix() + ' Handle request error: %j', error);
@@ -61,8 +61,8 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
       // Throw exception
       throw new OCPPError(ErrorType.NOT_IMPLEMENTED, `${commandName} is not implemented to handle request payload ${JSON.stringify(commandPayload, null, 2)}`, commandName);
     }
-    // Send the built response
-    await this.chargingStation.ocppRequestService.sendMessage(messageId, response, MessageType.CALL_RESULT_MESSAGE, commandName);
+    // Send the built result
+    await this.chargingStation.ocppRequestService.sendResult(messageId, result, commandName);
   }
 
   // Simulate charging station restart