Move the UI WS protocol version handling is protocol header
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / 1.6 / OCPP16ResponseService.ts
index 2c2b80488954520555decfa8fa7eaedd156f0387..d429e04569a5100bcf92095ff018c8f596ee434a 100644 (file)
@@ -6,9 +6,11 @@ import { HeartbeatResponse, OCPP16BootNotificationResponse, OCPP16RegistrationSt
 import { MeterValuesRequest, MeterValuesResponse } from '../../../types/ocpp/1.6/MeterValues';
 
 import ChargingStation from '../../ChargingStation';
+import { ErrorType } from '../../../types/ocpp/ErrorType';
 import { OCPP16ChargePointStatus } from '../../../types/ocpp/1.6/ChargePointStatus';
 import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';
 import { OCPP16StandardParametersKey } from '../../../types/ocpp/1.6/Configuration';
+import OCPPError from '../OCPPError';
 import OCPPResponseService from '../OCPPResponseService';
 import { ResponseHandler } from '../../../types/ocpp/Responses';
 import Utils from '../../../utils/Utils';
@@ -36,16 +38,18 @@ export default class OCPP16ResponseService extends OCPPResponseService {
         await this.responseHandlers.get(commandName)(payload, requestPayload);
       } catch (error) {
         logger.error(this.chargingStation.logPrefix() + ' Handle request response error: %j', error);
+        throw error;
       }
     } else {
-      logger.error(`${this.chargingStation.logPrefix()} %s is not implemented to handle request response payload %j`, commandName, payload);
+      // Throw exception
+      throw new OCPPError(ErrorType.NOT_IMPLEMENTED, `${commandName} is not implemented to handle request response payload ${JSON.stringify(payload, null, 2)}`, commandName);
     }
   }
 
   private handleResponseBootNotification(payload: OCPP16BootNotificationResponse): void {
     if (payload.status === OCPP16RegistrationStatus.ACCEPTED) {
       this.chargingStation.addConfigurationKey(OCPP16StandardParametersKey.HeartBeatInterval, payload.interval.toString());
-      this.chargingStation.addConfigurationKey(OCPP16StandardParametersKey.HeartbeatInterval, payload.interval.toString(), false, false);
+      this.chargingStation.addConfigurationKey(OCPP16StandardParametersKey.HeartbeatInterval, payload.interval.toString(), { visible: false });
       this.chargingStation.heartbeatSetInterval ? this.chargingStation.restartHeartbeat() : this.chargingStation.startHeartbeat();
     } else if (payload.status === OCPP16RegistrationStatus.PENDING) {
       logger.info(this.chargingStation.logPrefix() + ' Charging station in pending state on the central server');