import OCPPError from '../../../exception/OCPPError';
import type { JsonObject, JsonType } from '../../../types/JsonType';
import {
- OCPP20ClearCacheRequest,
+ type OCPP20ClearCacheRequest,
OCPP20IncomingRequestCommand,
} from '../../../types/ocpp/2.0/Requests';
import { ErrorType } from '../../../types/ocpp/ErrorType';
let response: JsonType;
if (
chargingStation.getOcppStrictCompliance() === true &&
- chargingStation.isInPendingState() === true /* &&
- (commandName === OCPP20IncomingRequestCommand.REMOTE_START_TRANSACTION ||
- commandName === OCPP20IncomingRequestCommand.REMOTE_STOP_TRANSACTION ) */
+ chargingStation.isInPendingState() === true &&
+ (commandName === OCPP20IncomingRequestCommand.REQUEST_START_TRANSACTION ||
+ commandName === OCPP20IncomingRequestCommand.REQUEST_STOP_TRANSACTION)
) {
throw new OCPPError(
ErrorType.SECURITY_ERROR,
import type { JsonObject, JsonType } from '../../../types/JsonType';
import {
type OCPP20BootNotificationRequest,
+ type OCPP20HeartbeatRequest,
OCPP20RequestCommand,
} from '../../../types/ocpp/2.0/Requests';
import { ErrorType } from '../../../types/ocpp/ErrorType';
)
) as JSONSchemaType<OCPP20BootNotificationRequest>,
],
+ [
+ OCPP20RequestCommand.HEARTBEAT,
+ JSON.parse(
+ fs.readFileSync(
+ path.resolve(
+ path.dirname(fileURLToPath(import.meta.url)),
+ '../../../assets/json-schemas/ocpp/2.0/HeartbeatRequest.json'
+ ),
+ 'utf8'
+ )
+ ) as JSONSchemaType<OCPP20HeartbeatRequest>,
+ ],
]);
this.buildRequestPayload.bind(this);
}
}),
},
} as unknown as Request;
+ case OCPP20RequestCommand.HEARTBEAT:
+ return {} 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(
import type {
OCPP20BootNotificationResponse,
OCPP20ClearCacheResponse,
+ OCPP20HeartbeatResponse,
} from '../../../types/ocpp/2.0/Responses';
import { ErrorType } from '../../../types/ocpp/ErrorType';
import { OCPPVersion } from '../../../types/ocpp/OCPPVersion';
super(OCPPVersion.VERSION_20);
this.responseHandlers = new Map<OCPP20RequestCommand, ResponseHandler>([
[OCPP20RequestCommand.BOOT_NOTIFICATION, this.handleResponseBootNotification.bind(this)],
+ [OCPP20RequestCommand.HEARTBEAT, this.emptyResponseHandler.bind(this)],
]);
this.jsonSchemas = new Map<OCPP20RequestCommand, JSONSchemaType<JsonObject>>([
[
)
) as JSONSchemaType<OCPP20BootNotificationResponse>,
],
+ [
+ OCPP20RequestCommand.HEARTBEAT,
+ JSON.parse(
+ fs.readFileSync(
+ path.resolve(
+ path.dirname(fileURLToPath(import.meta.url)),
+ '../../../assets/json-schemas/ocpp/2.0/HeartbeatResponse.json'
+ ),
+ 'utf8'
+ )
+ ) as JSONSchemaType<OCPP20HeartbeatResponse>,
+ ],
]);
this.jsonIncomingRequestResponseSchemas = new Map([
[
export enum OCPP20IncomingRequestCommand {
CLEAR_CACHE = 'ClearCache',
+ REQUEST_START_TRANSACTION = 'RequestStartTransaction',
+ REQUEST_STOP_TRANSACTION = 'RequestStopTransaction',
}
export enum BootReasonEnumType {
chargingStation: ChargingStationType;
} & JsonObject;
+export type OCPP20HeartbeatRequest = EmptyObject;
+
export type OCPP20ClearCacheRequest = EmptyObject;
statusInfo?: StatusInfoType;
} & JsonObject;
+export type OCPP20HeartbeatResponse = {
+ currentTime: Date;
+} & JsonObject;
+
export type OCPP20ClearCacheResponse = {
status: DefaultStatus;
statusInfo?: StatusInfoType;