From a36bad10340be6ff3ac66b8cedf136d36778c857 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 2 Oct 2022 23:14:24 +0200 Subject: [PATCH] Make OCPP command clear cache code clear the authorization tags cache MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/AuthorizedTagsCache.ts | 4 ++++ .../ocpp/1.6/OCPP16IncomingRequestService.ts | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/charging-station/AuthorizedTagsCache.ts b/src/charging-station/AuthorizedTagsCache.ts index 747b7593..0f702047 100644 --- a/src/charging-station/AuthorizedTagsCache.ts +++ b/src/charging-station/AuthorizedTagsCache.ts @@ -64,6 +64,10 @@ export default class AuthorizedTagsCache { return this.getTags(file); } + public deleteAuthorizedTags(file: string): boolean { + return this.deleteTags(file); + } + private hasTags(file: string): boolean { return this.tagsCaches.has(file); } diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index ceaea14e..f5779ab2 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -392,7 +392,10 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer return Constants.OCPP_RESPONSE_ACCEPTED; } - private handleRequestClearCache(): DefaultResponse { + private handleRequestClearCache(chargingStation: ChargingStation): DefaultResponse { + chargingStation.authorizedTagsCache.deleteAuthorizedTags( + ChargingStationUtils.getAuthorizationFile(chargingStation.stationInfo) + ); return Constants.OCPP_RESPONSE_ACCEPTED; } @@ -588,11 +591,11 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer commandPayload: ClearChargingProfileRequest ): ClearChargingProfileResponse { if ( - !OCPP16ServiceUtils.checkFeatureProfile( + OCPP16ServiceUtils.checkFeatureProfile( chargingStation, OCPP16SupportedFeatureProfiles.SmartCharging, OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE - ) + ) === false ) { return Constants.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN; } -- 2.34.1