Make OCPP command clear cache code clear the authorization tags
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 2 Oct 2022 21:14:24 +0000 (23:14 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 2 Oct 2022 21:14:24 +0000 (23:14 +0200)
cache

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/AuthorizedTagsCache.ts
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts

index 747b7593e422d5ef123444170a6cbc470a8333b0..0f702047702ce5cc92890f28679a9cafddacf1fc 100644 (file)
@@ -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);
   }
index ceaea14e607aebb0d0c9be9c8354a0ccb429188f..f5779ab2952bbf3eb3c660d79a7882539aa5a687 100644 (file)
@@ -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;
     }