X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2F1.6%2FOCPP16IncomingRequestService.ts;h=937edd41cc22000530c000dbba844a2282d4fe8a;hb=6f35d2daed5ff5d26de15c1547ffa3dbd013c5b3;hp=7e04e6bf4b6423e745682c2f7f6ff035a2590b01;hpb=ef6fa3fb6f4872fc57bae634ac3edb8164a0bc79;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 7e04e6bf..937edd41 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -54,6 +54,10 @@ import { OCPP16MeterValuesRequest, OCPP16MeterValuesResponse, } from '../../../types/ocpp/1.6/MeterValues'; +import { + OCPP16StandardParametersKey, + OCPP16SupportedFeatureProfiles, +} from '../../../types/ocpp/1.6/Configuration'; import type ChargingStation from '../../ChargingStation'; import Constants from '../../../utils/Constants'; @@ -65,7 +69,6 @@ import { OCPP16ChargePointErrorCode } from '../../../types/ocpp/1.6/ChargePointE import { OCPP16ChargePointStatus } from '../../../types/ocpp/1.6/ChargePointStatus'; import { OCPP16DiagnosticsStatus } from '../../../types/ocpp/1.6/DiagnosticsStatus'; import { OCPP16ServiceUtils } from './OCPP16ServiceUtils'; -import { OCPP16StandardParametersKey } from '../../../types/ocpp/1.6/Configuration'; import { OCPPConfigurationKey } from '../../../types/ocpp/Configuration'; import OCPPError from '../../../exception/OCPPError'; import OCPPIncomingRequestService from '../OCPPIncomingRequestService'; @@ -378,6 +381,16 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer private handleRequestSetChargingProfile( commandPayload: SetChargingProfileRequest ): SetChargingProfileResponse { + if (!this.chargingStation.hasFeatureProfile(OCPP16SupportedFeatureProfiles.SmartCharging)) { + logger.error( + `${this.chargingStation.logPrefix()} Trying to set charging profile(s) without '${ + OCPP16SupportedFeatureProfiles.SmartCharging + }' feature enabled in ${ + OCPP16StandardParametersKey.SupportedFeatureProfiles + } in configuration` + ); + return Constants.OCPP_SET_CHARGING_PROFILE_RESPONSE_NOT_SUPPORTED; + } if (!this.chargingStation.getConnectorStatus(commandPayload.connectorId)) { logger.error( `${this.chargingStation.logPrefix()} Trying to set charging profile(s) to a non existing connector Id ${ @@ -417,6 +430,16 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer private handleRequestClearChargingProfile( commandPayload: ClearChargingProfileRequest ): ClearChargingProfileResponse { + if (!this.chargingStation.hasFeatureProfile(OCPP16SupportedFeatureProfiles.SmartCharging)) { + logger.error( + `${this.chargingStation.logPrefix()} Trying to clear charging profile(s) without '${ + OCPP16SupportedFeatureProfiles.SmartCharging + }' feature enabled in ${ + OCPP16StandardParametersKey.SupportedFeatureProfiles + } in configuration` + ); + return Constants.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN; + } const connectorStatus = this.chargingStation.getConnectorStatus(commandPayload.connectorId); if (!connectorStatus) { logger.error( @@ -804,6 +827,18 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer private async handleRequestGetDiagnostics( commandPayload: GetDiagnosticsRequest ): Promise { + if ( + !this.chargingStation.hasFeatureProfile(OCPP16SupportedFeatureProfiles.FirmwareManagement) + ) { + logger.error( + `${this.chargingStation.logPrefix()} Trying to get diagnostics without '${ + OCPP16SupportedFeatureProfiles.FirmwareManagement + }' feature enabled in ${ + OCPP16StandardParametersKey.SupportedFeatureProfiles + } in configuration` + ); + return Constants.OCPP_RESPONSE_EMPTY; + } logger.debug( this.chargingStation.logPrefix() + ' ' + @@ -911,6 +946,16 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer private handleRequestTriggerMessage( commandPayload: OCPP16TriggerMessageRequest ): OCPP16TriggerMessageResponse { + if (!this.chargingStation.hasFeatureProfile(OCPP16SupportedFeatureProfiles.RemoteTrigger)) { + logger.error( + `${this.chargingStation.logPrefix()} Trying to remote trigger message without '${ + OCPP16SupportedFeatureProfiles.RemoteTrigger + }' feature enabled in ${ + OCPP16StandardParametersKey.SupportedFeatureProfiles + } in configuration` + ); + return Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED; + } try { switch (commandPayload.requestedMessage) { case MessageTrigger.BootNotification: