- super(chargingStation, ocppResponseService);
- }
-
- public async sendHeartbeat(params?: SendParams): Promise<void> {
- const payload: HeartbeatRequest = {};
- await this.sendMessage(Utils.generateUUID(), payload, OCPP16RequestCommand.HEARTBEAT, params);
- }
-
- public async sendBootNotification(
- chargePointModel: string,
- chargePointVendor: string,
- chargeBoxSerialNumber?: string,
- firmwareVersion?: string,
- chargePointSerialNumber?: string,
- iccid?: string,
- imsi?: string,
- meterSerialNumber?: string,
- meterType?: string,
- params?: SendParams
- ): Promise<OCPP16BootNotificationResponse> {
- const payload: OCPP16BootNotificationRequest = {
- chargePointModel,
- chargePointVendor,
- ...(!Utils.isUndefined(chargeBoxSerialNumber) && { chargeBoxSerialNumber }),
- ...(!Utils.isUndefined(chargePointSerialNumber) && { chargePointSerialNumber }),
- ...(!Utils.isUndefined(firmwareVersion) && { firmwareVersion }),
- ...(!Utils.isUndefined(iccid) && { iccid }),
- ...(!Utils.isUndefined(imsi) && { imsi }),
- ...(!Utils.isUndefined(meterSerialNumber) && { meterSerialNumber }),
- ...(!Utils.isUndefined(meterType) && { meterType }),
- };
- return (await this.sendMessage(
- Utils.generateUUID(),
- payload,
- OCPP16RequestCommand.BOOT_NOTIFICATION,
- { ...params, skipBufferingOnError: true }
- )) as OCPP16BootNotificationResponse;
- }
-
- public async sendStatusNotification(
- connectorId: number,
- status: OCPP16ChargePointStatus,
- errorCode: OCPP16ChargePointErrorCode = OCPP16ChargePointErrorCode.NO_ERROR
- ): Promise<void> {
- const payload: StatusNotificationRequest = {
- connectorId,
- errorCode,
- status,
- };
- await this.sendMessage(Utils.generateUUID(), payload, OCPP16RequestCommand.STATUS_NOTIFICATION);
- }
-
- public async sendAuthorize(
- connectorId: number,
- idTag?: string
- ): Promise<OCPP16AuthorizeResponse> {
- const payload: AuthorizeRequest = {
- ...(!Utils.isUndefined(idTag) ? { idTag } : { idTag: Constants.DEFAULT_IDTAG }),
- };
- this.chargingStation.getConnectorStatus(connectorId).authorizeIdTag = idTag;
- return (await this.sendMessage(
- Utils.generateUUID(),
- payload,
- OCPP16RequestCommand.AUTHORIZE
- )) as OCPP16AuthorizeResponse;
- }
-
- public async sendStartTransaction(
- connectorId: number,
- idTag?: string
- ): Promise<OCPP16StartTransactionResponse> {
- const payload: StartTransactionRequest = {
- connectorId,
- ...(!Utils.isUndefined(idTag) ? { idTag } : { idTag: Constants.DEFAULT_IDTAG }),
- meterStart: this.chargingStation.getEnergyActiveImportRegisterByConnectorId(connectorId),
- timestamp: new Date().toISOString(),
- };
- return (await this.sendMessage(
- Utils.generateUUID(),
- payload,
- OCPP16RequestCommand.START_TRANSACTION
- )) as OCPP16StartTransactionResponse;
+ super(ocppResponseService);
+ this.jsonSchemas = new Map<OCPP16RequestCommand, JSONSchemaType<JsonObject>>([
+ [
+ OCPP16RequestCommand.AUTHORIZE,
+ JSON.parse(
+ fs.readFileSync(
+ path.resolve(
+ path.dirname(fileURLToPath(import.meta.url)),
+ '../../../assets/json-schemas/ocpp/1.6/Authorize.json'
+ ),
+ 'utf8'
+ )
+ ) as JSONSchemaType<OCPP16AuthorizeRequest>,
+ ],
+ [
+ OCPP16RequestCommand.BOOT_NOTIFICATION,
+ JSON.parse(
+ fs.readFileSync(
+ path.resolve(
+ path.dirname(fileURLToPath(import.meta.url)),
+ '../../../assets/json-schemas/ocpp/1.6/BootNotification.json'
+ ),
+ 'utf8'
+ )
+ ) as JSONSchemaType<OCPP16BootNotificationRequest>,
+ ],
+ [
+ OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION,
+ JSON.parse(
+ fs.readFileSync(
+ path.resolve(
+ path.dirname(fileURLToPath(import.meta.url)),
+ '../../../assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotification.json'
+ ),
+ 'utf8'
+ )
+ ) as JSONSchemaType<DiagnosticsStatusNotificationRequest>,
+ ],
+ [
+ OCPP16RequestCommand.HEARTBEAT,
+ JSON.parse(
+ fs.readFileSync(
+ path.resolve(
+ path.dirname(fileURLToPath(import.meta.url)),
+ '../../../assets/json-schemas/ocpp/1.6/Heartbeat.json'
+ ),
+ 'utf8'
+ )
+ ) as JSONSchemaType<OCPP16HeartbeatRequest>,
+ ],
+ [
+ OCPP16RequestCommand.METER_VALUES,
+ JSON.parse(
+ fs.readFileSync(
+ path.resolve(
+ path.dirname(fileURLToPath(import.meta.url)),
+ '../../../assets/json-schemas/ocpp/1.6/MeterValues.json'
+ ),
+ 'utf8'
+ )
+ ) as JSONSchemaType<OCPP16MeterValuesRequest>,
+ ],
+ [
+ OCPP16RequestCommand.STATUS_NOTIFICATION,
+ JSON.parse(
+ fs.readFileSync(
+ path.resolve(
+ path.dirname(fileURLToPath(import.meta.url)),
+ '../../../assets/json-schemas/ocpp/1.6/StatusNotification.json'
+ ),
+ 'utf8'
+ )
+ ) as JSONSchemaType<OCPP16StatusNotificationRequest>,
+ ],
+ [
+ OCPP16RequestCommand.START_TRANSACTION,
+ JSON.parse(
+ fs.readFileSync(
+ path.resolve(
+ path.dirname(fileURLToPath(import.meta.url)),
+ '../../../assets/json-schemas/ocpp/1.6/StartTransaction.json'
+ ),
+ 'utf8'
+ )
+ ) as JSONSchemaType<OCPP16StartTransactionRequest>,
+ ],
+ [
+ OCPP16RequestCommand.STOP_TRANSACTION,
+ JSON.parse(
+ fs.readFileSync(
+ path.resolve(
+ path.dirname(fileURLToPath(import.meta.url)),
+ '../../../assets/json-schemas/ocpp/1.6/StopTransaction.json'
+ ),
+ 'utf8'
+ )
+ ) as JSONSchemaType<OCPP16StopTransactionRequest>,
+ ],
+ ]);
+ this.buildRequestPayload.bind(this);
+ this.validatePayload.bind(this);