// Partial Copyright Jerome Benoit. 2021. All Rights Reserved.
+import fs from 'fs';
+import path from 'path';
+import { URL, fileURLToPath } from 'url';
+
+import { Client, FTPResponse } from 'basic-ftp';
+import tar from 'tar';
+
+import OCPPError from '../../../exception/OCPPError';
+import { JsonType } from '../../../types/JsonType';
+import { OCPP16ChargePointErrorCode } from '../../../types/ocpp/1.6/ChargePointErrorCode';
+import { OCPP16ChargePointStatus } from '../../../types/ocpp/1.6/ChargePointStatus';
+import {
+ ChargingProfilePurposeType,
+ OCPP16ChargingProfile,
+} from '../../../types/ocpp/1.6/ChargingProfile';
+import {
+ OCPP16StandardParametersKey,
+ OCPP16SupportedFeatureProfiles,
+} from '../../../types/ocpp/1.6/Configuration';
+import { OCPP16DiagnosticsStatus } from '../../../types/ocpp/1.6/DiagnosticsStatus';
+import {
+ OCPP16MeterValuesRequest,
+ OCPP16MeterValuesResponse,
+} from '../../../types/ocpp/1.6/MeterValues';
import {
ChangeAvailabilityRequest,
ChangeConfigurationRequest,
SetChargingProfileResponse,
UnlockConnectorResponse,
} from '../../../types/ocpp/1.6/Responses';
-import {
- ChargingProfilePurposeType,
- OCPP16ChargingProfile,
-} from '../../../types/ocpp/1.6/ChargingProfile';
-import { Client, FTPResponse } from 'basic-ftp';
import {
OCPP16AuthorizationStatus,
OCPP16AuthorizeRequest,
OCPP16StopTransactionRequest,
OCPP16StopTransactionResponse,
} from '../../../types/ocpp/1.6/Transaction';
-import {
- OCPP16MeterValuesRequest,
- OCPP16MeterValuesResponse,
-} from '../../../types/ocpp/1.6/MeterValues';
-import {
- OCPP16StandardParametersKey,
- OCPP16SupportedFeatureProfiles,
-} from '../../../types/ocpp/1.6/Configuration';
-import { URL, fileURLToPath } from 'url';
-
-import type ChargingStation from '../../ChargingStation';
-import { ChargingStationConfigurationUtils } from '../../ChargingStationConfigurationUtils';
-import Constants from '../../../utils/Constants';
-import { DefaultResponse } from '../../../types/ocpp/Responses';
+import { OCPPConfigurationKey } from '../../../types/ocpp/Configuration';
import { ErrorType } from '../../../types/ocpp/ErrorType';
import { IncomingRequestHandler } from '../../../types/ocpp/Requests';
-import { JsonType } from '../../../types/JsonType';
-import { OCPP16ChargePointErrorCode } from '../../../types/ocpp/1.6/ChargePointErrorCode';
-import { OCPP16ChargePointStatus } from '../../../types/ocpp/1.6/ChargePointStatus';
-import { OCPP16DiagnosticsStatus } from '../../../types/ocpp/1.6/DiagnosticsStatus';
-import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';
-import { OCPPConfigurationKey } from '../../../types/ocpp/Configuration';
-import OCPPError from '../../../exception/OCPPError';
-import OCPPIncomingRequestService from '../OCPPIncomingRequestService';
-import Utils from '../../../utils/Utils';
-import fs from 'fs';
+import { DefaultResponse } from '../../../types/ocpp/Responses';
+import Constants from '../../../utils/Constants';
import logger from '../../../utils/Logger';
-import path from 'path';
-import tar from 'tar';
+import Utils from '../../../utils/Utils';
+import type ChargingStation from '../../ChargingStation';
+import { ChargingStationConfigurationUtils } from '../../ChargingStationConfigurationUtils';
+import { ChargingStationUtils } from '../../ChargingStationUtils';
+import OCPPIncomingRequestService from '../OCPPIncomingRequestService';
+import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';
const moduleName = 'OCPP16IncomingRequestService';
null,
2
)} while the charging station is in pending state on the central server`,
- commandName
+ commandName,
+ commandPayload
);
}
if (
chargingStation.isRegistered() ||
(!chargingStation.getOcppStrictCompliance() && chargingStation.isInUnknownState())
) {
- if (this.incomingRequestHandlers.has(commandName)) {
+ if (
+ this.incomingRequestHandlers.has(commandName) &&
+ ChargingStationUtils.isCommandSupported(commandName, chargingStation.stationInfo)
+ ) {
try {
// Call the method to build the response
response = await this.incomingRequestHandlers.get(commandName)(
null,
2
)}`,
- commandName
+ commandName,
+ commandPayload
);
}
} else {
null,
2
)} while the charging station is not registered on the central server.`,
- commandName
+ commandName,
+ commandPayload
);
}
// Send the built response
>(chargingStation, OCPP16RequestCommand.METER_VALUES, {
connectorId,
transactionId,
- meterValue: transactionEndMeterValue,
+ meterValue: [transactionEndMeterValue],
});
}
const stopResponse = await chargingStation.ocppRequestService.requestHandler<
if (
chargingStation.getLocalAuthListEnabled() &&
chargingStation.hasAuthorizedTags() &&
- chargingStation.authorizedTags.find((value) => value === commandPayload.idTag)
+ chargingStation.authorizedTagsCache
+ .getAuthorizedTags(
+ ChargingStationUtils.getAuthorizationFile(chargingStation.stationInfo)
+ )
+ .find((value) => value === commandPayload.idTag)
) {
connectorStatus.localAuthorizeIdTag = commandPayload.idTag;
connectorStatus.idTagLocalAuthorized = true;
>(chargingStation, OCPP16RequestCommand.METER_VALUES, {
connectorId,
transactionId,
- meterValue: transactionEndMeterValue,
+ meterValue: [transactionEndMeterValue],
});
}
await chargingStation.ocppRequestService.requestHandler<
return Constants.OCPP_RESPONSE_ACCEPTED;
}
}
- logger.info(
+ logger.warn(
chargingStation.logPrefix() +
' Trying to remote stop a non existing transaction ' +
transactionId.toString()