OCPP16AvailabilityType,
OCPP16BootNotificationRequest,
OCPP16ClearCacheRequest,
+ OCPP16DataTransferRequest,
+ OCPP16DataTransferVendorId,
OCPP16HeartbeatRequest,
OCPP16IncomingRequestCommand,
OCPP16MessageTrigger,
SetChargingProfileRequest,
UnlockConnectorRequest,
} from '../../../types/ocpp/1.6/Requests';
-import type {
+import {
ChangeAvailabilityResponse,
ChangeConfigurationResponse,
ClearChargingProfileResponse,
GetConfigurationResponse,
GetDiagnosticsResponse,
OCPP16BootNotificationResponse,
+ OCPP16DataTransferResponse,
+ OCPP16DataTransferStatus,
OCPP16HeartbeatResponse,
OCPP16StatusNotificationResponse,
OCPP16TriggerMessageResponse,
],
[OCPP16IncomingRequestCommand.GET_DIAGNOSTICS, this.handleRequestGetDiagnostics.bind(this)],
[OCPP16IncomingRequestCommand.TRIGGER_MESSAGE, this.handleRequestTriggerMessage.bind(this)],
+ [OCPP16IncomingRequestCommand.DATA_TRANSFER, this.handleRequestDataTransfer.bind(this)],
]);
this.jsonSchemas = new Map<OCPP16IncomingRequestCommand, JSONSchemaType<JsonObject>>([
[
)
) as JSONSchemaType<OCPP16TriggerMessageRequest>,
],
+ [
+ OCPP16IncomingRequestCommand.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.validatePayload.bind(this);
}
);
}
}
+
+ private handleRequestDataTransfer(
+ chargingStation: ChargingStation,
+ commandPayload: OCPP16DataTransferRequest
+ ): OCPP16DataTransferResponse {
+ try {
+ if (Object.values(OCPP16DataTransferVendorId).includes(commandPayload.vendorId)) {
+ return {
+ status: OCPP16DataTransferStatus.ACCEPTED,
+ };
+ }
+ return {
+ status: OCPP16DataTransferStatus.UNKNOWN_VENDOR_ID,
+ };
+ } catch (error) {
+ return this.handleIncomingRequestError(
+ chargingStation,
+ OCPP16IncomingRequestCommand.DATA_TRANSFER,
+ error as Error,
+ { errorResponse: Constants.OCPP_DATA_TRANSFER_RESPONSE_REJECTED }
+ );
+ }
+ }
}
REMOTE_STOP_TRANSACTION = 'RemoteStopTransaction',
GET_DIAGNOSTICS = 'GetDiagnostics',
TRIGGER_MESSAGE = 'TriggerMessage',
+ DATA_TRANSFER = 'DataTransfer',
}
export type OCPP16ClearCacheRequest = EmptyObject;
connectorId?: number;
}
+export enum OCPP16DataTransferVendorId {}
+
export interface OCPP16DataTransferRequest extends JsonObject {
vendorId: string;
messageId?: string;
ChargingProfileStatus,
ClearChargingProfileStatus,
ConfigurationStatus,
+ DataTransferStatus,
DefaultStatus,
TriggerMessageStatus,
UnlockStatus,
status: TriggerMessageStatus.NOT_IMPLEMENTED,
});
+ static readonly OCPP_DATA_TRANSFER_RESPONSE_REJECTED = Object.freeze({
+ status: DataTransferStatus.REJECTED,
+ });
+
static readonly OCPP_DEFAULT_BOOT_NOTIFICATION_INTERVAL = 60000; // Ms
static readonly OCPP_WEBSOCKET_TIMEOUT = 60000; // Ms
static readonly OCPP_TRIGGER_MESSAGE_DELAY = 500; // Ms