Set the standard Heartbeat OCPP param first and try workarounds next if it failed
MODIFY
src/scheduler/tasks/CheckOfflineChargingStationsTask.ts
src/scheduler/tasks/CheckOfflineChargingStationsTask.ts
@@ -33,8 +33,8 @@ export default class CheckOfflineChargingStationsTask extends SchedulerTask {
let ocppHeartbeatConfiguration: OCPPGetConfigurationCommandResult;
// Check if charging station is still connected
try {
- const ocppParamHeartbeatKeys = ['HeartBeatInterval', 'HeartbeatInterval'];
- ocppHeartbeatConfiguration = await OCPPUtils.requestChargingStationOcppParameters(tenant, chargingStation, { key: ocppParamHeartbeatKeys });
+ ocppHeartbeatConfiguration = await OCPPUtils.requestChargingStationOcppParameters(
+ tenant, chargingStation, { key: Constants.OCPP_HEARTBEAT_KEYS as string[] });
} catch (error) {
// Charging Station is offline!
continue;
@@ -47,6 +47,7 @@ export default class CheckOfflineChargingStationsTask extends SchedulerTask {
action: ServerAction.OFFLINE_CHARGING_STATION,
module: MODULE_NAME, method: 'processTenant',
message: 'Offline charging station responded successfully to an OCPP command and will be ignored',
+ detailedMessages: { ocppHeartbeatConfiguration }
});
// Update lastSeen
await ChargingStationStorage.saveChargingStationLastSeen(tenant.id, chargingStation.id,

MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -1910,26 +1910,20 @@ export default class OCPPService {
setTimeout(async () => {
let result: OCPPChangeConfigurationCommandResult;
// Synchronize heartbeat interval OCPP parameter for charging stations that do not take into account its value in the boot notification response
- // Set OCPP 'HeartBeatInterval'
- let heartBeatIntervalSettingFailure = false;
+ let heartbeatIntervalOcppParamSet = false;
+ // Change one of the key
+ for (const heartbeatOcppKey of Constants.OCPP_HEARTBEAT_KEYS) {
result = await OCPPUtils.requestChangeChargingStationOcppParameter(tenant, chargingStation, {
- key: 'HeartBeatInterval',
+ key: heartbeatOcppKey,
value: heartbeatIntervalSecs.toString()
}, false);
- if (result.status !== OCPPConfigurationStatus.ACCEPTED) {
- heartBeatIntervalSettingFailure = true;
+ if (result.status === OCPPConfigurationStatus.ACCEPTED ||
+ result.status === OCPPConfigurationStatus.REBOOT_REQUIRED) {
+ heartbeatIntervalOcppParamSet = true;
+ break;
}
- // Set OCPP 'HeartbeatInterval'
- result = await OCPPUtils.requestChangeChargingStationOcppParameter(tenant, chargingStation, {
- key: 'HeartbeatInterval',
- value: heartbeatIntervalSecs.toString()
- }, false);
- let heartbeatIntervalSettingFailure = false;
- if (result.status !== OCPPConfigurationStatus.ACCEPTED) {
- heartbeatIntervalSettingFailure = true;
}
- // Check
- if (heartBeatIntervalSettingFailure && heartbeatIntervalSettingFailure) {
+ if (!heartbeatIntervalOcppParamSet) {
await Logging.logError({
tenantID: tenant.id,
action: ServerAction.BOOT_NOTIFICATION,

MODIFY
src/server/ocpp/utils/OCPPUtils.ts
src/server/ocpp/utils/OCPPUtils.ts
@@ -1971,7 +1971,7 @@ export default class OCPPUtils {
});
continue;
}
- if (parameter === 'HeartBeatInterval' || parameter === 'HeartbeatInterval') {
+ if (Constants.OCPP_HEARTBEAT_KEYS.includes(parameter)) {
await Logging.logWarning({
tenantID: tenant.id,
source: chargingStation.id,
@@ -2032,7 +2032,7 @@ export default class OCPPUtils {
});
continue;
}
- if (parameter === 'HeartBeatInterval' || parameter === 'HeartbeatInterval') {
+ if (Constants.OCPP_HEARTBEAT_KEYS.includes(parameter)) {
await Logging.logWarning({
tenantID: tenant.id,
source: chargingStation.id,

MODIFY
src/utils/Constants.ts
src/utils/Constants.ts
@@ -289,6 +289,7 @@ export default class Constants {
public static readonly WS_DEFAULT_RECONNECT_TIMEOUT = 30; // Seconds
public static readonly OCPP_SOCKET_TIMEOUT = 30000; // 30 sec
+ public static readonly OCPP_HEARTBEAT_KEYS = Object.freeze(['HeartBeatInterval', 'HeartbeatInterval']);
public static readonly MAX_DATE = new Date('9999-12-31Z23:59:59:999');
public static readonly MIN_DATE = new Date('1970-01-01Z00:00:00:000');
@@ -350,7 +351,6 @@ export default class Constants {
{ 'key': 'ClockAlignedDataInterval', 'readonly': false, 'value': null },
{ 'key': 'ConnectionTimeOut', 'readonly': false, 'value': null },
{ 'key': 'GetConfigurationMaxKeys', 'readonly': false, 'value': null },
- { 'key': 'HeartBeatInterval', 'readonly': false, 'value': null },
{ 'key': 'HeartbeatInterval', 'readonly': false, 'value': null },
{ 'key': 'LightIntensity', 'readonly': false, 'value': null },
{ 'key': 'LocalAuthorizeOffline', 'readonly': false, 'value': null },

Set the standard Heartbeat OCPP param first and try workarounds next if it failed