#### Remote Trigger Profile
-- :x: TriggerMessage
+- :white_check_mark: TriggerMessage
## OCPP-J standard parameters supported
return Utils.logPrefix(` ${this.stationInfo.chargingStationId} |`);
}
+ public getBootNotificationRequest(): BootNotificationRequest {
+ return this.bootNotificationRequest;
+ }
+
public getRandomTagId(): string {
const index = Math.floor(Math.random() * this.authorizedTags.length);
return this.authorizedTags[index];
import * as url from 'url';
-import { ChangeAvailabilityRequest, ChangeConfigurationRequest, ClearChargingProfileRequest, GetConfigurationRequest, GetDiagnosticsRequest, OCPP16AvailabilityType, OCPP16IncomingRequestCommand, RemoteStartTransactionRequest, RemoteStopTransactionRequest, ResetRequest, SetChargingProfileRequest, UnlockConnectorRequest } from '../../../types/ocpp/1.6/Requests';
-import { ChangeAvailabilityResponse, ChangeConfigurationResponse, ClearChargingProfileResponse, GetConfigurationResponse, GetDiagnosticsResponse, SetChargingProfileResponse, UnlockConnectorResponse } from '../../../types/ocpp/1.6/Responses';
+import { ChangeAvailabilityRequest, ChangeConfigurationRequest, ClearChargingProfileRequest, GetConfigurationRequest, GetDiagnosticsRequest, MessageTrigger, OCPP16AvailabilityType, OCPP16IncomingRequestCommand, OCPP16TriggerMessageRequest, RemoteStartTransactionRequest, RemoteStopTransactionRequest, ResetRequest, SetChargingProfileRequest, UnlockConnectorRequest } from '../../../types/ocpp/1.6/Requests';
+import { ChangeAvailabilityResponse, ChangeConfigurationResponse, ClearChargingProfileResponse, GetConfigurationResponse, GetDiagnosticsResponse, OCPP16TriggerMessageResponse, SetChargingProfileResponse, UnlockConnectorResponse } from '../../../types/ocpp/1.6/Responses';
import { ChargingProfilePurposeType, OCPP16ChargingProfile } from '../../../types/ocpp/1.6/ChargingProfile';
import { Client, FTPResponse } from 'basic-ftp';
import { IncomingRequestCommand, RequestCommand } from '../../../types/ocpp/Requests';
return Constants.OCPP_RESPONSE_EMPTY;
}
}
+
+ private handleRequestTriggerMessage(commandPayload: OCPP16TriggerMessageRequest): OCPP16TriggerMessageResponse {
+ try {
+ switch (commandPayload.requestedMessage) {
+ case MessageTrigger.BootNotification:
+ setTimeout(() => {
+ this.chargingStation.ocppRequestService.sendBootNotification(this.chargingStation.getBootNotificationRequest().chargePointModel,
+ this.chargingStation.getBootNotificationRequest().chargePointVendor, this.chargingStation.getBootNotificationRequest().chargeBoxSerialNumber,
+ this.chargingStation.getBootNotificationRequest().firmwareVersion).catch(() => {});
+ }, Constants.OCPP_TRIGGER_MESSAGE_DELAY);
+ return Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED;
+ case MessageTrigger.Heartbeat:
+ setTimeout(() => {
+ this.chargingStation.ocppRequestService.sendHeartbeat().catch(() => {});
+ }, Constants.OCPP_TRIGGER_MESSAGE_DELAY);
+ return Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED;
+ default:
+ return Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED;
+ }
+ } catch (error) {
+ return this.handleIncomingRequestError(IncomingRequestCommand.TRIGGER_MESSAGE, error, Constants.OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED) as OCPP16TriggerMessageResponse;
+ }
+ }
}
START_TRANSACTION = 'StartTransaction',
STOP_TRANSACTION = 'StopTransaction',
METER_VALUES = 'MeterValues',
- DIAGNOSTICS_STATUS_NOTIFICATION= 'DiagnosticsStatusNotification'
+ DIAGNOSTICS_STATUS_NOTIFICATION = 'DiagnosticsStatusNotification'
}
export enum OCPP16IncomingRequestCommand {
CLEAR_CHARGING_PROFILE = 'ClearChargingProfile',
REMOTE_START_TRANSACTION = 'RemoteStartTransaction',
REMOTE_STOP_TRANSACTION = 'RemoteStopTransaction',
- GET_DIAGNOSTICS = 'GetDiagnostics'
+ GET_DIAGNOSTICS = 'GetDiagnostics',
+ TRIGGER_MESSAGE = 'TriggerMessage'
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface DiagnosticsStatusNotificationRequest {
status: OCPP16DiagnosticsStatus
}
+
+export enum MessageTrigger {
+ BootNotification = 'BootNotification',
+ DiagnosticsStatusNotification = 'DiagnosticsStatusNotification',
+ FirmwareStatusNotification = 'FirmwareStatusNotification',
+ Heartbeat = 'Heartbeat',
+ MeterValues = 'MeterValues',
+ StatusNotification = 'StatusNotification'
+}
+
+export interface OCPP16TriggerMessageRequest {
+ requestedMessage: MessageTrigger;
+ connectorId?: number
+}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface DiagnosticsStatusNotificationResponse {}
+
+export enum OCPP16TriggerMessageStatus {
+ ACCEPTED = 'Accepted',
+ REJECTED = 'Rejected',
+ NOT_IMPLEMENTED = 'NotImplemented'
+}
+
+export interface OCPP16TriggerMessageResponse {
+ status: OCPP16TriggerMessageStatus
+}
-import { OCPP16AvailabilityStatus, OCPP16BootNotificationResponse, OCPP16ChargingProfileStatus, OCPP16ClearChargingProfileStatus, OCPP16ConfigurationStatus, OCPP16RegistrationStatus, OCPP16UnlockStatus } from './1.6/Responses';
+import { OCPP16AvailabilityStatus, OCPP16BootNotificationResponse, OCPP16ChargingProfileStatus, OCPP16ClearChargingProfileStatus, OCPP16ConfigurationStatus, OCPP16RegistrationStatus, OCPP16TriggerMessageStatus, OCPP16UnlockStatus } from './1.6/Responses';
export type BootNotificationResponse = OCPP16BootNotificationResponse;
export const UnlockStatus = {
...OCPP16UnlockStatus
};
+
+export type TriggerMessageStatus = OCPP16TriggerMessageStatus;
+
+export const TriggerMessageStatus = {
+ ...OCPP16TriggerMessageStatus
+};
-import { AvailabilityStatus, ChargingProfileStatus, ClearChargingProfileStatus, ConfigurationStatus, DefaultStatus, UnlockStatus } from '../types/ocpp/Responses';
+import { AvailabilityStatus, ChargingProfileStatus, ClearChargingProfileStatus, ConfigurationStatus, DefaultStatus, TriggerMessageStatus, UnlockStatus } from '../types/ocpp/Responses';
import { MeterValueMeasurand } from '../types/ocpp/MeterValues';
static readonly OCPP_AVAILABILITY_RESPONSE_ACCEPTED = Object.freeze({ status: AvailabilityStatus.ACCEPTED });
static readonly OCPP_AVAILABILITY_RESPONSE_REJECTED = Object.freeze({ status: AvailabilityStatus.REJECTED });
static readonly OCPP_AVAILABILITY_RESPONSE_SCHEDULED = Object.freeze({ status: AvailabilityStatus.SCHEDULED });
+ static readonly OCPP_TRIGGER_MESSAGE_RESPONSE_ACCEPTED = Object.freeze({ status: TriggerMessageStatus.ACCEPTED });
+ static readonly OCPP_TRIGGER_MESSAGE_RESPONSE_REJECTED = Object.freeze({ status: TriggerMessageStatus.REJECTED });
+ static readonly OCPP_TRIGGER_MESSAGE_RESPONSE_NOT_IMPLEMENTED = Object.freeze({ status: TriggerMessageStatus.NOT_IMPLEMENTED });
static readonly OCPP_DEFAULT_BOOT_NOTIFICATION_INTERVAL = 60000; // Ms
static readonly OCPP_ERROR_TIMEOUT = 60000; // Ms
+ static readonly OCPP_TRIGGER_MESSAGE_DELAY = 2000; // Ms
static readonly CHARGING_STATION_DEFAULT_RESET_TIME = 60000; // Ms
static readonly CHARGING_STATION_ATG_WAIT_TIME = 2000; // Ms