"Configuration": {
"configurationKey": [
{
- "key": "TxUpdatedMeasurands",
+ "key": "SampledDataCtrlr.TxUpdatedMeasurands",
"readonly": false,
"value": "Energy.Active.Import.Register,Power.Active.Import,Current.Import,Voltage"
},
{
- "key": "TxUpdatedInterval",
+ "key": "SampledDataCtrlr.TxUpdatedInterval",
"readonly": false,
"value": "30"
},
{
- "key": "AuthorizeRemoteStart",
+ "key": "AuthCtrlr.AuthorizeRemoteStart",
"readonly": false,
"value": "false"
},
{
- "key": "LocalPreAuthorization",
+ "key": "AuthCtrlr.LocalPreAuthorization",
"readonly": false,
"value": "false"
},
{
- "key": "OfflineTxForUnknownIdEnabled",
+ "key": "AuthCtrlr.OfflineTxForUnknownIdEnabled",
"readonly": false,
"value": "false"
},
{
- "key": "MessageAttempts.TransactionEvent",
+ "key": "OCPPCommCtrlr.MessageAttempts.TransactionEvent",
"readonly": false,
"value": "3"
},
{
- "key": "MessageAttemptInterval.TransactionEvent",
+ "key": "OCPPCommCtrlr.MessageAttemptInterval.TransactionEvent",
"readonly": false,
"value": "20"
},
{
- "key": "WebSocketPingInterval",
+ "key": "ChargingStation.WebSocketPingInterval",
"readonly": false,
"value": "60"
}
import {
type ConfigurationKey,
type ConfigurationKeyType,
+ OCPP20ComponentName,
OCPPVersion,
StandardParametersKey,
} from '../types/index.js'
import { logger, once } from '../utils/index.js'
+export const buildConfigKey = (component: string, variable: string, instance?: string): string => {
+ const base = `${component}.${variable}`
+ return instance != null ? `${base}.${instance}` : base
+}
+
const OCPP2_PARAMETER_KEY_MAP = new Map<
ConfigurationKeyType,
{
>(
(
[
- [StandardParametersKey.AuthorizeRemoteTxRequests, StandardParametersKey.AuthorizeRemoteStart],
- [StandardParametersKey.ConnectionTimeOut, StandardParametersKey.EVConnectionTimeOut],
+ [
+ StandardParametersKey.AuthorizeRemoteTxRequests,
+ buildConfigKey(OCPP20ComponentName.AuthCtrlr, StandardParametersKey.AuthorizeRemoteStart),
+ ],
+ [
+ StandardParametersKey.ConnectionTimeOut,
+ buildConfigKey(OCPP20ComponentName.TxCtrlr, StandardParametersKey.EVConnectionTimeOut),
+ ],
[
StandardParametersKey.LocalAuthorizeOffline,
- StandardParametersKey.LocalAuthorizationOffline,
+ buildConfigKey(
+ OCPP20ComponentName.AuthCtrlr,
+ StandardParametersKey.LocalAuthorizationOffline
+ ),
+ ],
+ [
+ StandardParametersKey.LocalPreAuthorize,
+ buildConfigKey(OCPP20ComponentName.AuthCtrlr, StandardParametersKey.LocalPreAuthorization),
+ ],
+ [
+ StandardParametersKey.MeterValueSampleInterval,
+ buildConfigKey(
+ OCPP20ComponentName.SampledDataCtrlr,
+ StandardParametersKey.TxUpdatedInterval
+ ),
+ ],
+ [
+ StandardParametersKey.MeterValuesSampledData,
+ buildConfigKey(
+ OCPP20ComponentName.SampledDataCtrlr,
+ StandardParametersKey.TxUpdatedMeasurands
+ ),
],
- [StandardParametersKey.LocalPreAuthorize, StandardParametersKey.LocalPreAuthorization],
- [StandardParametersKey.MeterValueSampleInterval, StandardParametersKey.TxUpdatedInterval],
- [StandardParametersKey.MeterValuesSampledData, StandardParametersKey.TxUpdatedMeasurands],
] as [ConfigurationKeyType, ConfigurationKeyType][]
).map(([from, to]) => [
from,
export type { ChargingStation } from './ChargingStation.js'
export {
addConfigurationKey,
+ buildConfigKey,
getConfigurationKey,
setConfigurationKeyValue,
} from './ConfigurationKeyUtils.js'
type OCPP20NotifyReportRequest,
type OCPP20NotifyReportResponse,
OCPP20OperationalStatusEnumType,
+ OCPP20OptionalVariableName,
OCPP20ReasonEnumType,
OCPP20RequestCommand,
type OCPP20RequestStartTransactionRequest,
truncateId,
validateUUID,
} from '../../../utils/index.js'
-import { getConfigurationKey } from '../../ConfigurationKeyUtils.js'
+import { buildConfigKey, getConfigurationKey } from '../../ConfigurationKeyUtils.js'
import {
getIdTagsFile,
hasPendingReservation,
}
// A02.FR.16: Enforce MaxCertificateChainSize — reject if chain exceeds configured limit
- const maxChainSizeKey = getConfigurationKey(chargingStation, 'MaxCertificateChainSize')
+ const maxChainSizeKey = getConfigurationKey(
+ chargingStation,
+ buildConfigKey(
+ OCPP20ComponentName.SecurityCtrlr,
+ OCPP20OptionalVariableName.MaxCertificateChainSize
+ )
+ )
if (maxChainSizeKey?.value != null) {
const maxChainSize = parseInt(maxChainSizeKey.value, 10)
if (!isNaN(maxChainSize) && maxChainSize > 0) {
const chainByteSize = Buffer.byteLength(certificateChain, 'utf8')
if (chainByteSize > maxChainSize) {
logger.warn(
- `${chargingStation.logPrefix()} ${moduleName}.handleRequestCertificateSigned: Certificate chain size ${chainByteSize.toString()} bytes exceeds MaxCertificateChainSize ${maxChainSize.toString()} bytes`
+ `${chargingStation.logPrefix()} ${moduleName}.handleRequestCertificateSigned: Certificate chain size ${chainByteSize.toString()} bytes exceeds ${OCPP20OptionalVariableName.MaxCertificateChainSize as string} ${maxChainSize.toString()} bytes`
)
return {
status: GenericStatus.Rejected,
statusInfo: {
- additionalInfo: `Certificate chain size (${chainByteSize.toString()} bytes) exceeds MaxCertificateChainSize (${maxChainSize.toString()} bytes)`,
+ additionalInfo: `Certificate chain size (${chainByteSize.toString()} bytes) exceeds ${OCPP20OptionalVariableName.MaxCertificateChainSize as string} (${maxChainSize.toString()} bytes)`,
reasonCode: ReasonCodeEnumType.InvalidCertificate,
},
}
import type { ValidateFunction } from 'ajv'
-import { addConfigurationKey, type ChargingStation } from '../../../charging-station/index.js'
+import {
+ addConfigurationKey,
+ buildConfigKey,
+ type ChargingStation,
+} from '../../../charging-station/index.js'
import {
ChargingStationEvents,
ConnectorStatusEnum,
OCPP20AuthorizationStatusEnumType,
type OCPP20AuthorizeResponse,
type OCPP20BootNotificationResponse,
+ OCPP20ComponentName,
type OCPP20DataTransferResponse,
type OCPP20FirmwareStatusNotificationResponse,
type OCPP20Get15118EVCertificateResponse,
import { OCPPResponseService } from '../OCPPResponseService.js'
import { sendAndSetConnectorStatus } from '../OCPPServiceUtils.js'
import { OCPP20ServiceUtils } from './OCPP20ServiceUtils.js'
-
const moduleName = 'OCPP20ResponseService'
/**
)
addConfigurationKey(
chargingStation,
- OCPP20OptionalVariableName.HeartbeatInterval,
+ buildConfigKey(
+ OCPP20ComponentName.OCPPCommCtrlr,
+ OCPP20OptionalVariableName.HeartbeatInterval
+ ),
payload.interval.toString(),
{},
{ overwrite: true, save: true }
logger,
validateIdentifierString,
} from '../../../utils/index.js'
-import { getConfigurationKey } from '../../ConfigurationKeyUtils.js'
+import { buildConfigKey, getConfigurationKey } from '../../ConfigurationKeyUtils.js'
import {
buildMeterValue,
OCPPServiceUtils,
try {
const itemsCfg = getConfigurationKey(
chargingStation,
- OCPP20RequiredVariableName.ItemsPerMessage
+ buildConfigKey(
+ OCPP20ComponentName.DeviceDataCtrlr,
+ OCPP20RequiredVariableName.ItemsPerMessage
+ )
)?.value
const bytesCfg = getConfigurationKey(
chargingStation,
- OCPP20RequiredVariableName.BytesPerMessage
+ buildConfigKey(
+ OCPP20ComponentName.DeviceDataCtrlr,
+ OCPP20RequiredVariableName.BytesPerMessage
+ )
)?.value
if (itemsCfg && /^\d+$/.test(itemsCfg)) {
itemsLimit = convertToIntOrNaN(itemsCfg)
import { type ChargingStation } from '../../ChargingStation.js'
import {
addConfigurationKey,
+ buildConfigKey,
getConfigurationKey,
setConfigurationKeyValue,
} from '../../ConfigurationKeyUtils.js'
return Object.values(OCPP20RequiredVariableName).includes(name as OCPP20RequiredVariableName)
}
-const shouldFlattenInstance = (variableMetadata: VariableMetadata): boolean => {
- // TODO: Generalize instance flattening via registry metadata
- return variableMetadata.variable === (OCPP20RequiredVariableName.MessageAttemptInterval as string)
-}
-const computeConfigurationKeyName = (variableMetadata: VariableMetadata): string => {
- return variableMetadata.instance != null && !shouldFlattenInstance(variableMetadata)
- ? `${variableMetadata.variable}.${variableMetadata.instance}`
- : variableMetadata.variable
-}
+const computeConfigurationKeyName = (variableMetadata: VariableMetadata): string =>
+ buildConfigKey(variableMetadata.component, variableMetadata.variable, variableMetadata.instance)
+
export class OCPP20VariableManager {
private static instance: null | OCPP20VariableManager = null
let valueSize: string | undefined
let reportingValueSize: string | undefined
if (!invalidVariables.has(valueSizeKey)) {
- valueSize = getConfigurationKey(chargingStation, OCPP20RequiredVariableName.ValueSize)?.value
+ valueSize = getConfigurationKey(
+ chargingStation,
+ buildConfigKey(OCPP20ComponentName.DeviceDataCtrlr, OCPP20RequiredVariableName.ValueSize)
+ )?.value
}
if (!invalidVariables.has(reportingValueSizeKey)) {
reportingValueSize = getConfigurationKey(
chargingStation,
- OCPP20RequiredVariableName.ReportingValueSize
+ buildConfigKey(
+ OCPP20ComponentName.DeviceDataCtrlr,
+ OCPP20RequiredVariableName.ReportingValueSize
+ )
)?.value
}
// Apply ValueSize first then ReportingValueSize
if (!invalidVariables.has(configurationValueSizeKey)) {
configurationValueSizeRaw = getConfigurationKey(
chargingStation,
- OCPP20RequiredVariableName.ConfigurationValueSize
+ buildConfigKey(
+ OCPP20ComponentName.DeviceDataCtrlr,
+ OCPP20RequiredVariableName.ConfigurationValueSize
+ )
)?.value
}
if (!invalidVariables.has(valueSizeKey)) {
valueSizeRaw = getConfigurationKey(
chargingStation,
- OCPP20RequiredVariableName.ValueSize
+ buildConfigKey(OCPP20ComponentName.DeviceDataCtrlr, OCPP20RequiredVariableName.ValueSize)
)?.value
}
const cfgLimit = convertToIntOrNaN(configurationValueSizeRaw ?? '')
supportedAttributes: [AttributeEnumType.Actual],
variable: 'Identity',
},
- [buildRegistryKey(OCPP20ComponentName.SecurityCtrlr as string, 'MaxCertificateChainSize')]: {
+ [buildRegistryKey(
+ OCPP20ComponentName.SecurityCtrlr as string,
+ OCPP20OptionalVariableName.MaxCertificateChainSize
+ )]: {
component: OCPP20ComponentName.SecurityCtrlr as string,
dataType: DataEnumType.integer,
description:
mutability: MutabilityEnumType.ReadWrite,
persistence: PersistenceEnumType.Persistent,
supportedAttributes: [AttributeEnumType.Actual],
- variable: 'MaxCertificateChainSize',
+ variable: OCPP20OptionalVariableName.MaxCertificateChainSize as string,
},
[buildRegistryKey(
OCPP20ComponentName.SecurityCtrlr as string,
export enum OCPP20OptionalVariableName {
HeartbeatInterval = 'HeartbeatInterval',
+ MaxCertificateChainSize = 'MaxCertificateChainSize',
WebSocketPingInterval = 'WebSocketPingInterval',
}
import {
addConfigurationKey,
+ buildConfigKey,
deleteConfigurationKey,
getConfigurationKey,
setConfigurationKeyValue,
} from '../../src/charging-station/ConfigurationKeyUtils.js'
-import { OCPPVersion, StandardParametersKey } from '../../src/types/index.js'
+import { OCPP20ComponentName, OCPPVersion, StandardParametersKey } from '../../src/types/index.js'
import { logger } from '../../src/utils/index.js'
import { standardCleanup } from '../helpers/TestLifecycleHelpers.js'
import { createMockChargingStation } from './ChargingStationTestUtils.js'
if (k == null) {
assert.fail('Expected configuration key to be found')
}
- assert.strictEqual(k.key, StandardParametersKey.TxUpdatedMeasurands)
+ assert.strictEqual(
+ k.key,
+ buildConfigKey(
+ OCPP20ComponentName.SampledDataCtrlr,
+ StandardParametersKey.TxUpdatedMeasurands
+ )
+ )
assert.strictEqual(k.value, VALUE_A)
})
if (k == null) {
assert.fail('Expected configuration key to be found')
}
- assert.strictEqual(k.key, StandardParametersKey.EVConnectionTimeOut)
+ assert.strictEqual(
+ k.key,
+ buildConfigKey(OCPP20ComponentName.TxCtrlr, StandardParametersKey.EVConnectionTimeOut)
+ )
assert.strictEqual(k.value, '30')
})
if (k == null) {
assert.fail('Expected configuration key to be found')
}
- assert.strictEqual(k.key, StandardParametersKey.AuthorizeRemoteStart)
+ assert.strictEqual(
+ k.key,
+ buildConfigKey(OCPP20ComponentName.AuthCtrlr, StandardParametersKey.AuthorizeRemoteStart)
+ )
assert.strictEqual(k.value, 'false')
})
if (k == null) {
assert.fail('Expected configuration key to be found')
}
- assert.strictEqual(k.key, StandardParametersKey.TxUpdatedInterval)
+ assert.strictEqual(
+ k.key,
+ buildConfigKey(
+ OCPP20ComponentName.SampledDataCtrlr,
+ StandardParametersKey.TxUpdatedInterval
+ )
+ )
assert.strictEqual(k.value, '60')
})
})
import type { ChargingStation } from '../../../../src/charging-station/index.js'
import type { ChargingStationWithCertificateManager } from '../../../../src/charging-station/ocpp/2.0/OCPP20CertificateManager.js'
-import { addConfigurationKey } from '../../../../src/charging-station/ConfigurationKeyUtils.js'
+import { addConfigurationKey, buildConfigKey } from '../../../../src/charging-station/index.js'
import { createTestableIncomingRequestService } from '../../../../src/charging-station/ocpp/2.0/__testable__/index.js'
import { OCPP20IncomingRequestService } from '../../../../src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.js'
import {
GenericStatus,
type OCPP20CertificateSignedRequest,
type OCPP20CertificateSignedResponse,
+ OCPP20ComponentName,
+ OCPP20OptionalVariableName,
OCPP20RequestCommand,
OCPPVersion,
ReasonCodeEnumType,
storeCertificateResult: true,
})
- addConfigurationKey(station, 'MaxCertificateChainSize', '10')
+ addConfigurationKey(
+ station,
+ buildConfigKey(
+ OCPP20ComponentName.SecurityCtrlr,
+ OCPP20OptionalVariableName.MaxCertificateChainSize
+ ),
+ '10'
+ )
const request: OCPP20CertificateSignedRequest = {
certificateChain: VALID_PEM_CERTIFICATE,
assert.strictEqual(response.status, GenericStatus.Rejected)
assert.notStrictEqual(response.statusInfo, undefined)
assert.strictEqual(response.statusInfo?.reasonCode, 'InvalidCertificate')
- assert.ok(response.statusInfo.additionalInfo?.includes('MaxCertificateChainSize'))
+ assert.ok(
+ response.statusInfo.additionalInfo?.includes(
+ OCPP20OptionalVariableName.MaxCertificateChainSize as string
+ )
+ )
})
await it('should accept certificate chain within MaxCertificateChainSize', async () => {
storeCertificateResult: true,
})
- addConfigurationKey(station, 'MaxCertificateChainSize', '100000')
+ addConfigurationKey(
+ station,
+ buildConfigKey(
+ OCPP20ComponentName.SecurityCtrlr,
+ OCPP20OptionalVariableName.MaxCertificateChainSize
+ ),
+ '100000'
+ )
const request: OCPP20CertificateSignedRequest = {
certificateChain: VALID_PEM_CERTIFICATE,
import {
addConfigurationKey,
+ buildConfigKey,
setConfigurationKeyValue,
} from '../../../../src/charging-station/ConfigurationKeyUtils.js'
import { createTestableIncomingRequestService } from '../../../../src/charging-station/ocpp/2.0/__testable__/index.js'
import { OCPP20IncomingRequestService } from '../../../../src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.js'
-import { OCPP20VariableManager } from '../../../../src/charging-station/ocpp/2.0/OCPP20VariableManager.js'
+import {
+ OCPP20VariableManager,
+} from '../../../../src/charging-station/ocpp/2.0/OCPP20VariableManager.js'
import {
AttributeEnumType,
GenericDeviceModelStatusEnumType,
// ReportingValueSize truncation test
await it('should truncate long SequenceList/MemberList values per ReportingValueSize', () => {
// Ensure ReportingValueSize is at a small value (default is Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH). We will override configuration key if absent.
- const reportingSizeKey = StandardParametersKey.ReportingValueSize
+ const reportingSizeKey = buildConfigKey(
+ OCPP20ComponentName.DeviceDataCtrlr,
+ StandardParametersKey.ReportingValueSize
+ )
// Add or lower configuration key to 10 to force truncation
addConfigurationKey(station, reportingSizeKey, '10', undefined, {
overwrite: true,
import assert from 'node:assert/strict'
import { afterEach, beforeEach, describe, it } from 'node:test'
-import type { ChargingStation } from '../../../../src/charging-station/index.js'
-
+import { buildConfigKey, type ChargingStation } from '../../../../src/charging-station/index.js'
import { createTestableIncomingRequestService } from '../../../../src/charging-station/ocpp/2.0/__testable__/index.js'
import { OCPP20IncomingRequestService } from '../../../../src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.js'
import { OCPP20VariableManager } from '../../../../src/charging-station/ocpp/2.0/OCPP20VariableManager.js'
const postCalcLimit = preEstimate + 10
upsertConfigurationKey(
mockStation,
- OCPP20RequiredVariableName.BytesPerMessage,
+ buildConfigKey(
+ OCPP20ComponentName.DeviceDataCtrlr,
+ OCPP20RequiredVariableName.BytesPerMessage
+ ),
postCalcLimit.toString(),
false
)
await it('should enforce ConfigurationValueSize when ValueSize unset (service propagation)', () => {
resetValueSizeLimits(mockStation)
setConfigurationValueSize(mockStation, 100)
- upsertConfigurationKey(mockStation, OCPP20RequiredVariableName.ValueSize, '')
+ upsertConfigurationKey(
+ mockStation,
+ buildConfigKey(OCPP20ComponentName.DeviceDataCtrlr, OCPP20RequiredVariableName.ValueSize),
+ ''
+ )
const prefix = 'wss://example.com/'
const withinLimit = prefix + 'a'.repeat(100 - prefix.length)
const overLimit = prefix + 'a'.repeat(100 - prefix.length + 1)
await it('should enforce ValueSize when ConfigurationValueSize unset (service propagation)', () => {
resetValueSizeLimits(mockStation)
- upsertConfigurationKey(mockStation, OCPP20RequiredVariableName.ConfigurationValueSize, '')
+ upsertConfigurationKey(
+ mockStation,
+ buildConfigKey(
+ OCPP20ComponentName.DeviceDataCtrlr,
+ OCPP20RequiredVariableName.ConfigurationValueSize
+ ),
+ ''
+ )
setValueSize(mockStation, 120)
const prefix = 'wss://example.com/'
const withinLimit = prefix + 'b'.repeat(120 - prefix.length)
import type { MockChargingStation } from '../../ChargingStationTestUtils.js'
+import { buildConfigKey } from '../../../../src/charging-station/index.js'
import { OCPP20ResponseService } from '../../../../src/charging-station/ocpp/2.0/OCPP20ResponseService.js'
import {
ChargingStationEvents,
type OCPP20BootNotificationResponse,
+ OCPP20ComponentName,
OCPP20OptionalVariableName,
OCPP20RequestCommand,
OCPPVersion,
assert.fail('Expected configKey to be defined')
}
assert.strictEqual(configKey.length, 1)
- assert.strictEqual(configKey[0].key, OCPP20OptionalVariableName.HeartbeatInterval)
+ assert.strictEqual(
+ configKey[0].key,
+ buildConfigKey(
+ OCPP20ComponentName.OCPPCommCtrlr,
+ OCPP20OptionalVariableName.HeartbeatInterval
+ )
+ )
assert.strictEqual(configKey[0].value, '300')
})
} from '../../../../src/types/index.js'
import type { OCPP20RequestCommand } from '../../../../src/types/index.js'
+import { buildConfigKey } from '../../../../src/charging-station/index.js'
import { OCPP20RequestService } from '../../../../src/charging-station/ocpp/2.0/OCPP20RequestService.js'
import { OCPP20ResponseService } from '../../../../src/charging-station/ocpp/2.0/OCPP20ResponseService.js'
import {
ConnectorStatusEnum,
DeleteCertificateStatusEnumType,
HashAlgorithmEnumType,
+ OCPP20ComponentName,
OCPP20IdTokenEnumType,
OCPP20RequiredVariableName,
OCPPVersion,
* @param chargingStation Charging station test instance whose configuration limits are reset.
*/
export function resetLimits (chargingStation: ChargingStation) {
- upsertConfigurationKey(chargingStation, OCPP20RequiredVariableName.ItemsPerMessage, '100')
- upsertConfigurationKey(chargingStation, OCPP20RequiredVariableName.BytesPerMessage, '10000')
+ upsertConfigurationKey(
+ chargingStation,
+ buildConfigKey(OCPP20ComponentName.DeviceDataCtrlr, OCPP20RequiredVariableName.ItemsPerMessage),
+ '100'
+ )
+ upsertConfigurationKey(
+ chargingStation,
+ buildConfigKey(OCPP20ComponentName.DeviceDataCtrlr, OCPP20RequiredVariableName.BytesPerMessage),
+ '10000'
+ )
}
/**
export function resetReportingValueSize (chargingStation: ChargingStation) {
upsertConfigurationKey(
chargingStation,
- OCPP20RequiredVariableName.ReportingValueSize,
+ buildConfigKey(
+ OCPP20ComponentName.DeviceDataCtrlr,
+ OCPP20RequiredVariableName.ReportingValueSize
+ ),
Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH.toString()
)
}
export function resetValueSizeLimits (chargingStation: ChargingStation) {
upsertConfigurationKey(
chargingStation,
- OCPP20RequiredVariableName.ConfigurationValueSize,
+ buildConfigKey(
+ OCPP20ComponentName.DeviceDataCtrlr,
+ OCPP20RequiredVariableName.ConfigurationValueSize
+ ),
Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH.toString()
)
upsertConfigurationKey(
chargingStation,
- OCPP20RequiredVariableName.ValueSize,
+ buildConfigKey(OCPP20ComponentName.DeviceDataCtrlr, OCPP20RequiredVariableName.ValueSize),
Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH.toString()
)
}
export function setConfigurationValueSize (chargingStation: ChargingStation, size: number) {
upsertConfigurationKey(
chargingStation,
- OCPP20RequiredVariableName.ConfigurationValueSize,
+ buildConfigKey(
+ OCPP20ComponentName.DeviceDataCtrlr,
+ OCPP20RequiredVariableName.ConfigurationValueSize
+ ),
size.toString()
)
}
export function setReportingValueSize (chargingStation: ChargingStation, size: number) {
upsertConfigurationKey(
chargingStation,
- OCPP20RequiredVariableName.ReportingValueSize,
+ buildConfigKey(
+ OCPP20ComponentName.DeviceDataCtrlr,
+ OCPP20RequiredVariableName.ReportingValueSize
+ ),
size.toString()
)
}
) {
upsertConfigurationKey(
chargingStation,
- OCPP20RequiredVariableName.ItemsPerMessage,
+ buildConfigKey(OCPP20ComponentName.DeviceDataCtrlr, OCPP20RequiredVariableName.ItemsPerMessage),
itemsLimit.toString()
)
upsertConfigurationKey(
chargingStation,
- OCPP20RequiredVariableName.BytesPerMessage,
+ buildConfigKey(OCPP20ComponentName.DeviceDataCtrlr, OCPP20RequiredVariableName.BytesPerMessage),
bytesLimit.toString()
)
}
* @param size Desired stored value size limit.
*/
export function setValueSize (chargingStation: ChargingStation, size: number) {
- upsertConfigurationKey(chargingStation, OCPP20RequiredVariableName.ValueSize, size.toString())
+ upsertConfigurationKey(
+ chargingStation,
+ buildConfigKey(OCPP20ComponentName.DeviceDataCtrlr, OCPP20RequiredVariableName.ValueSize),
+ size.toString()
+ )
}
/**
import type { ChargingStation } from '../../../../src/charging-station/index.js'
import {
+ buildConfigKey,
deleteConfigurationKey,
getConfigurationKey,
} from '../../../../src/charging-station/ConfigurationKeyUtils.js'
ocppConfiguration: {
configurationKey: [
{
- key: StandardParametersKey.HeartbeatInterval,
+ key: buildConfigKey(
+ OCPP20ComponentName.OCPPCommCtrlr,
+ StandardParametersKey.HeartbeatInterval
+ ),
readonly: false,
value: millisecondsToSeconds(Constants.DEFAULT_HEARTBEAT_INTERVAL).toString(),
},
{
- key: StandardParametersKey.WebSocketPingInterval,
+ key: buildConfigKey(
+ OCPP20ComponentName.ChargingStation,
+ StandardParametersKey.WebSocketPingInterval
+ ),
readonly: false,
value: Constants.DEFAULT_WEBSOCKET_PING_INTERVAL.toString(),
},
await it('should avoid duplicate persistence operations when value unchanged', () => {
const keyBefore = getConfigurationKey(
station,
- OCPP20OptionalVariableName.HeartbeatInterval as unknown as VariableType['name']
+ buildConfigKey(
+ OCPP20ComponentName.OCPPCommCtrlr,
+ OCPP20OptionalVariableName.HeartbeatInterval
+ )
)
assert.notStrictEqual(keyBefore, undefined)
const originalValue = keyBefore?.value
assert.strictEqual(changed.attributeStatus, SetVariableStatusEnumType.Accepted)
const keyAfterChange = getConfigurationKey(
station,
- OCPP20OptionalVariableName.HeartbeatInterval as unknown as VariableType['name']
+ buildConfigKey(
+ OCPP20ComponentName.OCPPCommCtrlr,
+ OCPP20OptionalVariableName.HeartbeatInterval
+ )
)
assert.notStrictEqual(keyAfterChange?.value, originalValue)
const reverted = manager.setVariables(station, [
assert.strictEqual(reverted.attributeStatus, SetVariableStatusEnumType.Accepted)
const keyAfterRevert = getConfigurationKey(
station,
- OCPP20OptionalVariableName.HeartbeatInterval as unknown as VariableType['name']
+ buildConfigKey(
+ OCPP20ComponentName.OCPPCommCtrlr,
+ OCPP20OptionalVariableName.HeartbeatInterval
+ )
)
assert.strictEqual(keyAfterRevert?.value, originalValue)
})
await it('should add missing configuration key with default during self-check', () => {
deleteConfigurationKey(
station,
- OCPP20RequiredVariableName.EVConnectionTimeOut as unknown as VariableType['name'],
+ buildConfigKey(OCPP20ComponentName.TxCtrlr, OCPP20RequiredVariableName.EVConnectionTimeOut),
{ save: false }
)
const before = getConfigurationKey(
station,
- OCPP20RequiredVariableName.EVConnectionTimeOut as unknown as VariableType['name']
+ buildConfigKey(OCPP20ComponentName.TxCtrlr, OCPP20RequiredVariableName.EVConnectionTimeOut)
)
assert.strictEqual(before, undefined)
const res = manager.getVariables(station, [
assert.strictEqual(res.attributeValue, Constants.DEFAULT_EV_CONNECTION_TIMEOUT.toString())
const after = getConfigurationKey(
station,
- OCPP20RequiredVariableName.EVConnectionTimeOut as unknown as VariableType['name']
+ buildConfigKey(OCPP20ComponentName.TxCtrlr, OCPP20RequiredVariableName.EVConnectionTimeOut)
)
assert.notStrictEqual(after, undefined)
})
// remove ValueSize to simulate unset
deleteConfigurationKey(
station,
- OCPP20RequiredVariableName.ValueSize as unknown as VariableType['name'],
+ buildConfigKey(OCPP20ComponentName.DeviceDataCtrlr, OCPP20RequiredVariableName.ValueSize),
{ save: false }
)
const okRes = manager.setVariables(station, [
setValueSize(station, 40)
deleteConfigurationKey(
station,
- OCPP20RequiredVariableName.ConfigurationValueSize as unknown as VariableType['name'],
+ buildConfigKey(
+ OCPP20ComponentName.DeviceDataCtrlr,
+ OCPP20RequiredVariableName.ConfigurationValueSize
+ ),
{ save: false }
)
const okRes = manager.setVariables(station, [
const beforeCfg = getConfigurationKey(
station,
- OCPP20RequiredVariableName.FileTransferProtocols as unknown as VariableType['name']
+ buildConfigKey(
+ OCPP20ComponentName.OCPPCommCtrlr,
+ OCPP20RequiredVariableName.FileTransferProtocols
+ )
)
assert.strictEqual(beforeCfg?.value, 'HTTPS,FTPS,SFTP')
const rejected = manager.setVariables(station, [
assert.strictEqual(afterGet.attributeValue, 'HTTPS,FTPS,SFTP')
const afterCfg = getConfigurationKey(
station,
- OCPP20RequiredVariableName.FileTransferProtocols as unknown as VariableType['name']
+ buildConfigKey(
+ OCPP20ComponentName.OCPPCommCtrlr,
+ OCPP20RequiredVariableName.FileTransferProtocols
+ )
)
assert.strictEqual(afterCfg?.value, beforeCfg.value)
})
// Ensure ReportingValueSize unset
deleteConfigurationKey(
station,
- OCPP20RequiredVariableName.ReportingValueSize as unknown as VariableType['name'],
+ buildConfigKey(
+ OCPP20ComponentName.DeviceDataCtrlr,
+ OCPP20RequiredVariableName.ReportingValueSize
+ ),
{ save: false }
)
// Temporarily set large ValueSize to allow storing long value
const overLongValue = buildWsExampleUrl(3000, 'c')
upsertConfigurationKey(
station,
- OCPP20VendorVariableName.ConnectionUrl as unknown as VariableType['name'],
+ buildConfigKey(OCPP20ComponentName.ChargingStation, OCPP20VendorVariableName.ConnectionUrl),
overLongValue
)
// Set generous ValueSize (1500) and ReportingValueSize (1400) so only absolute cap applies (since both < Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH)
await it('should auto-create persistent OrganizationName configuration key during self-check', () => {
deleteConfigurationKey(
station,
- OCPP20RequiredVariableName.OrganizationName as unknown as VariableType['name'],
+ buildConfigKey(
+ OCPP20ComponentName.SecurityCtrlr,
+ OCPP20RequiredVariableName.OrganizationName
+ ),
{ save: false }
)
const before = getConfigurationKey(
station,
- OCPP20RequiredVariableName.OrganizationName as unknown as VariableType['name']
+ buildConfigKey(
+ OCPP20ComponentName.SecurityCtrlr,
+ OCPP20RequiredVariableName.OrganizationName
+ )
)
assert.strictEqual(before, undefined)
const res = manager.getVariables(station, [
assert.strictEqual(res.attributeValue, 'ChangeMeOrg')
const after = getConfigurationKey(
station,
- OCPP20RequiredVariableName.OrganizationName as unknown as VariableType['name']
+ buildConfigKey(
+ OCPP20ComponentName.SecurityCtrlr,
+ OCPP20RequiredVariableName.OrganizationName
+ )
)
assert.notStrictEqual(after, undefined)
assert.strictEqual(after?.value, 'ChangeMeOrg')
// Ensure no configuration key exists before operations
const cfgBefore = getConfigurationKey(
station,
- OCPP20RequiredVariableName.MessageAttemptInterval as unknown as VariableType['name']
+ buildConfigKey(
+ OCPP20ComponentName.OCPPCommCtrlr,
+ OCPP20RequiredVariableName.MessageAttemptInterval,
+ 'TransactionEvent'
+ )
)
assert.strictEqual(cfgBefore, undefined)
const initialGet = manager.getVariables(station, [
const cfgAfter = getConfigurationKey(
station,
- OCPP20RequiredVariableName.MessageAttemptInterval as unknown as VariableType['name']
+ buildConfigKey(
+ OCPP20ComponentName.OCPPCommCtrlr,
+ OCPP20RequiredVariableName.MessageAttemptInterval,
+ 'TransactionEvent'
+ )
)
assert.notStrictEqual(cfgAfter, undefined)
assert.strictEqual(cfgAfter?.value, '7')
try {
deleteConfigurationKey(
stationA,
- OCPP20RequiredVariableName.EVConnectionTimeOut as unknown as VariableType['name'],
+ buildConfigKey(OCPP20ComponentName.TxCtrlr, OCPP20RequiredVariableName.EVConnectionTimeOut),
{ save: false }
)
VARIABLE_REGISTRY[registryKey].defaultValue = undefined