repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixes to OCPP 1.6 payload type definitions
[e-mobility-charging-stations-simulator.git]
/
src
/
charging-station
/
ocpp
/
1.6
/
OCPP16RequestService.ts
diff --git
a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts
b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts
index d840e5e97a23ca788d7a922697e471215ae60755..cf5ff237cb2e24b93dcbe5e1258ef2cd71862ae1 100644
(file)
--- a/
src/charging-station/ocpp/1.6/OCPP16RequestService.ts
+++ b/
src/charging-station/ocpp/1.6/OCPP16RequestService.ts
@@
-1,4
+1,4
@@
-// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
+// Partial Copyright Jerome Benoit. 2021
-2023
. All Rights Reserved.
import fs from 'fs';
import path from 'path';
import fs from 'fs';
import path from 'path';
@@
-10,11
+10,12
@@
import OCPPError from '../../../exception/OCPPError';
import type { JsonObject, JsonType } from '../../../types/JsonType';
import type { OCPP16MeterValuesRequest } from '../../../types/ocpp/1.6/MeterValues';
import {
import type { JsonObject, JsonType } from '../../../types/JsonType';
import type { OCPP16MeterValuesRequest } from '../../../types/ocpp/1.6/MeterValues';
import {
- DiagnosticsStatusNotificationRequest,
- OCPP16BootNotificationRequest,
- OCPP16HeartbeatRequest,
+ type DiagnosticsStatusNotificationRequest,
+ type OCPP16BootNotificationRequest,
+ type OCPP16DataTransferRequest,
+ type OCPP16HeartbeatRequest,
OCPP16RequestCommand,
OCPP16RequestCommand,
- OCPP16StatusNotificationRequest,
+
type
OCPP16StatusNotificationRequest,
} from '../../../types/ocpp/1.6/Requests';
import type {
OCPP16AuthorizeRequest,
} from '../../../types/ocpp/1.6/Requests';
import type {
OCPP16AuthorizeRequest,
@@
-22,12
+23,12
@@
import type {
OCPP16StopTransactionRequest,
} from '../../../types/ocpp/1.6/Transaction';
import { ErrorType } from '../../../types/ocpp/ErrorType';
OCPP16StopTransactionRequest,
} from '../../../types/ocpp/1.6/Transaction';
import { ErrorType } from '../../../types/ocpp/ErrorType';
+import { OCPPVersion } from '../../../types/ocpp/OCPPVersion';
import type { RequestParams } from '../../../types/ocpp/Requests';
import Constants from '../../../utils/Constants';
import logger from '../../../utils/Logger';
import Utils from '../../../utils/Utils';
import type ChargingStation from '../../ChargingStation';
import type { RequestParams } from '../../../types/ocpp/Requests';
import Constants from '../../../utils/Constants';
import logger from '../../../utils/Logger';
import Utils from '../../../utils/Utils';
import type ChargingStation from '../../ChargingStation';
-import { ChargingStationUtils } from '../../ChargingStationUtils';
import OCPPRequestService from '../OCPPRequestService';
import type OCPPResponseService from '../OCPPResponseService';
import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';
import OCPPRequestService from '../OCPPRequestService';
import type OCPPResponseService from '../OCPPResponseService';
import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';
@@
-41,7
+42,7
@@
export default class OCPP16RequestService extends OCPPRequestService {
if (new.target?.name === moduleName) {
throw new TypeError(`Cannot construct ${new.target?.name} instances directly`);
}
if (new.target?.name === moduleName) {
throw new TypeError(`Cannot construct ${new.target?.name} instances directly`);
}
- super(ocppResponseService);
+ super(
OCPPVersion.VERSION_16,
ocppResponseService);
this.jsonSchemas = new Map<OCPP16RequestCommand, JSONSchemaType<JsonObject>>([
[
OCPP16RequestCommand.AUTHORIZE,
this.jsonSchemas = new Map<OCPP16RequestCommand, JSONSchemaType<JsonObject>>([
[
OCPP16RequestCommand.AUTHORIZE,
@@
-139,6
+140,18
@@
export default class OCPP16RequestService extends OCPPRequestService {
)
) as JSONSchemaType<OCPP16StopTransactionRequest>,
],
)
) as JSONSchemaType<OCPP16StopTransactionRequest>,
],
+ [
+ OCPP16RequestCommand.DATA_TRANSFER,
+ JSON.parse(
+ fs.readFileSync(
+ path.resolve(
+ path.dirname(fileURLToPath(import.meta.url)),
+ '../../../assets/json-schemas/ocpp/1.6/DataTransfer.json'
+ ),
+ 'utf8'
+ )
+ ) as JSONSchemaType<OCPP16DataTransferRequest>,
+ ],
]);
this.buildRequestPayload.bind(this);
this.validatePayload.bind(this);
]);
this.buildRequestPayload.bind(this);
this.validatePayload.bind(this);
@@
-150,7
+163,7
@@
export default class OCPP16RequestService extends OCPPRequestService {
commandParams?: JsonType,
params?: RequestParams
): Promise<ResponseType> {
commandParams?: JsonType,
params?: RequestParams
): Promise<ResponseType> {
- if (OCPP16ServiceUtils.isRequestCommandSupported(c
ommandName, chargingStation)
) {
+ if (OCPP16ServiceUtils.isRequestCommandSupported(c
hargingStation, commandName) === true
) {
const requestPayload = this.buildRequestPayload<RequestType>(
chargingStation,
commandName,
const requestPayload = this.buildRequestPayload<RequestType>(
chargingStation,
commandName,
@@
-269,6
+282,8
@@
export default class OCPP16RequestService extends OCPPRequestService {
),
}),
} as unknown as Request;
),
}),
} as unknown as Request;
+ case OCPP16RequestCommand.DATA_TRANSFER:
+ return commandParams as unknown as Request;
default:
// OCPPError usage here is debatable: it's an error in the OCPP stack but not targeted to sendError().
throw new OCPPError(
default:
// OCPPError usage here is debatable: it's an error in the OCPP stack but not targeted to sendError().
throw new OCPPError(