Populating the additional fields using chargingStationStorage instead of URL.
MODIFY
src/server/ocpp/json/JsonWSConnection.ts
src/server/ocpp/json/JsonWSConnection.ts
@@ -88,6 +88,8 @@ export default class JsonWSConnection extends WSConnection {
const chargingStation = await ChargingStationStorage.getChargingStation(
this.getTenant(), this.getChargingStationID(), { issuer: true }, ['id']);
if (chargingStation) {
+ // Update charging station details
+ this.setChargingStationDetails(chargingStation);
// Update Last Seen
await ChargingStationStorage.saveChargingStationLastSeen(this.getTenant(),
chargingStation.id, { lastSeen: new Date() });

MODIFY
src/server/ocpp/json/WSConnection.ts
src/server/ocpp/json/WSConnection.ts
+import ChargingStation, { Command } from '../../../types/ChargingStation';
import { OCPPErrorType, OCPPIncomingRequest, OCPPMessageType, OCPPRequest } from '../../../types/ocpp/OCPPCommon';
import WebSocket, { CLOSED, CLOSING, CONNECTING, CloseEvent, ErrorEvent, MessageEvent, OPEN } from 'ws';
import BackendError from '../../../exception/BackendError';
-import { Command } from '../../../types/ChargingStation';
import Constants from '../../../utils/Constants';
import DatabaseUtils from '../../../storage/mongodb/DatabaseUtils';
import JsonCentralSystemServer from './JsonCentralSystemServer';
@@ -56,20 +56,10 @@ export default abstract class WSConnection {
// Remove '/'
this.url = this.url.substring(1, this.url.length);
}
- // Parse URL: should be like /OCPPxx/TENANTID/TOKEN/CHARGEBOXID/SITEID/SITEAREAID/COMPANYID
- // We support previous format like
- // for existing charging station without siteID, siteAreaID and companyID /OCPPxx/TENANTID/TOKEN/CHARGEBOXID
- // for existing charging station without token also /OCPPxx/TENANTID/CHARGEBOXID
+ // Parse URL: should be like /OCPPxx/TENANTID/TOKEN/CHARGEBOXID
+ // We support previous format like for existing charging station without token also /OCPPxx/TENANTID/CHARGEBOXID
const splittedURL = this.getURL().split('/');
- if (splittedURL.length === 7) {
- // URL /OCPPxx/TENANTID/TOKEN/CHARGEBOXID/SITEID/SITEAREAID/COMPANYID
- this.tenantID = splittedURL[1];
- this.token = splittedURL[2];
- this.chargingStationID = splittedURL[3];
- this.siteID = splittedURL[4];
- this.siteAreaID = splittedURL[5];
- this.companyID = splittedURL[6];
- } else if (splittedURL.length === 4) {
+ if (splittedURL.length === 4) {
// URL /OCPPxx/TENANTID/TOKEN/CHARGEBOXID
this.tenantID = splittedURL[1];
this.token = splittedURL[2];
@@ -337,6 +327,12 @@ export default abstract class WSConnection {
});
}
+ public setChargingStationDetails(chargingStation: ChargingStation): void {
+ this.siteID = chargingStation.siteID;
+ this.siteAreaID = chargingStation.siteAreaID;
+ this.companyID = chargingStation.companyID;
+ }
+
public getSiteID(): string {
return this.siteID;
}

Populating the additional fields using chargingStationStorage instead of URL.