const keyToChange = this._configuration.configurationKey.find((element) => element.key === commandPayload.key);
if (keyToChange) {
keyToChange.value = commandPayload.value;
- return {
- status: 'Accepted',
- };
+ return Constants.OCPP_RESPONSE_ACCEPTED;
}
- return {
- status: 'Rejected',
- };
+ return Constants.OCPP_RESPONSE_REJECTED;
}
async handleRemoteStartTransaction(commandPayload) {
const transactionConnectorID = (commandPayload.connectorId ? commandPayload.connectorId : '1');
if (this.isAuthorizationRequested() && this._authorizeRemoteTxRequests) {
- // check if authorized
+ // Check if authorized
if (this._authorizedKeys.find((value) => value === commandPayload.idTag)) {
// Authorization successful start transaction
setTimeout(() => this.sendStartTransaction(transactionConnectorID, commandPayload.idTag), 500);
- return {
- status: 'Accepted',
- };
+ return Constants.OCPP_RESPONSE_ACCEPTED;
}
// Start authorization checks
- return {
- status: 'Rejected',
- };
+ return Constants.OCPP_RESPONSE_REJECTED;
}
- // no local authorization check required => start transaction
+ // No local authorization check required => start transaction
setTimeout(() => this.sendStartTransaction(transactionConnectorID, commandPayload.idTag), 500);
- return {
- status: 'Accepted',
- };
+ return Constants.OCPP_RESPONSE_ACCEPTED;
}
async sendStartTransaction(connectorID, idTag) {
this.sendStopTransaction(commandPayload.transactionId, connector);
}
}
- return {
- status: 'Accepted',
- };
+ return Constants.OCPP_RESPONSE_ACCEPTED;
}
isAuthorizationRequested() {
let numStationsTotal = 0;
Configuration.getChargingStationTemplateURLs().forEach((stationURL) => {
try {
- // load file
+ // Load file
const fileDescriptor = fs.openSync(stationURL.file, 'r');
const stationTemplate = JSON.parse(fs.readFileSync(fileDescriptor, 'utf8'));
fs.closeSync(fileDescriptor);
static WS_UNSUPPORTED_DATA = 1007;
+ static OCPP_RESPONSE_ACCEPTED = {status: 'Accepted'};
+ static OCPP_RESPONSE_REJECTED = {status: 'Rejected'};
static OCPP_SOCKET_TIMEOUT = 60000; // 60 sec
static OCPP_JSON_CALL_MESSAGE = 2; // Client-to-Server
static OCPP_JSON_CALL_RESULT_MESSAGE = 3; // Server-to-Client