validation ocpp : heartbeat && diagnosticsStatusNotif
ADD
src/assets/server/ocpp/schemas/diagnostics-status-notification-request.json
+{
+ "$id": "diagnostics-status-notification-request",
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "title": "DiagnosticsStatusNotificationRequest",
+ "type": "object",
+ "properties": {
+ "status": {
+ "type": "string",
+ "enum": [
+ "Idle",
+ "Uploaded",
+ "UploadFailed",
+ "Uploading"
+ ]
+ }
+ },
+ "additionalProperties": false,
+ "performanceID": {
+ "type": "string",
+ "description": "performance correlation ID"
+ },
+ "required": [
+ "status"
+ ]
+}

ADD
src/assets/server/ocpp/schemas/heartbeat-request.json
+{
+ "$id": "heartbeat-request",
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "title": "HeartbeatResponse",
+ "type": "object",
+ "properties": {},
+ "additionalProperties": false
+}

MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -305,7 +305,7 @@ export default class OCPPService {
const { chargingStation, tenant } = headers;
try {
// Check props
- OCPPValidation.getInstance().validateDiagnosticsStatusNotification(chargingStation, diagnosticsStatusNotification);
+ OCPPValidation.getInstance().validateDiagnosticsStatusNotification(diagnosticsStatusNotification);
// Enrich
this.enrichOCPPRequest(chargingStation, diagnosticsStatusNotification);
// Save it

MODIFY
src/server/ocpp/validation/OCPPValidation.ts
src/server/ocpp/validation/OCPPValidation.ts
@@ -23,7 +23,8 @@ export default class OCPPValidation extends SchemaValidator {
private startTransactionRequest: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/ocpp/schemas/start-transaction-request.json`, 'utf8'));
private stopTransactionRequest16: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/ocpp/schemas/stop-transaction-request-16.json`, 'utf8'));
private stopTransactionRequest15: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/ocpp/schemas/stop-transaction-request-15.json`, 'utf8'));
-
+ private diagnosticsStatusNotificationRequest: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/ocpp/schemas/diagnostics-status-notification-request.json`, 'utf8'));
+ private heartbeatRequest: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/ocpp/schemas/heartbeat-request.json`, 'utf8'));
private constructor() {
super('OCPPValidation');
}
@@ -36,6 +37,7 @@ export default class OCPPValidation extends SchemaValidator {
}
public validateHeartbeat(heartbeat: OCPPHeartbeatRequestExtended): void {
+ this.validate(this.heartbeatRequest, heartbeat);
}
public validateStatusNotification(statusNotification: OCPPStatusNotificationRequestExtended): void {
@@ -64,8 +66,8 @@ export default class OCPPValidation extends SchemaValidator {
this.validate(this.bootNotificationRequest, bootNotification);
}
- public validateDiagnosticsStatusNotification(chargingStation: ChargingStation,
- diagnosticsStatusNotification: OCPPDiagnosticsStatusNotificationRequestExtended): void {
+ public validateDiagnosticsStatusNotification(diagnosticsStatusNotification: OCPPDiagnosticsStatusNotificationRequestExtended): void {
+ this.validate(this.diagnosticsStatusNotificationRequest, diagnosticsStatusNotification);
}
public validateFirmwareStatusNotification(chargingStation: ChargingStation,

validation ocpp : heartbeat && diagnosticsStatusNotif