this._isSocketRestart = false;
- this._authorizedTags = this._getAuthorizedTags();
+ this._authorizedTags = this._loadAndGetAuthorizedTags();
}
_initialize() {
this._bootNotificationMessage = {
chargePointModel: this._stationInfo.chargePointModel,
chargePointVendor: this._stationInfo.chargePointVendor,
- // chargePointSerialNumber: this._stationInfo.chargePointSerialNumber,
+ chargePointSerialNumber: this._stationInfo.chargePointSerialNumberPrefix ? this._stationInfo.chargePointSerialNumberPrefix : '',
firmwareVersion: this._stationInfo.firmwareVersion ? this._stationInfo.firmwareVersion : '',
};
this._configuration = this._getConfiguration();
return this._stationInfo.authorizationFile ? this._stationInfo.authorizationFile : '';
}
- _getAuthorizedTags() {
+ _loadAndGetAuthorizedTags() {
let authorizedTags = [];
const authorizationFile = this._getAuthorizationFile();
if (authorizationFile) {
try {
logger.debug(this._basicFormatLog() + ' Authorization file ' + this._getAuthorizationFile() + ' have changed, reload');
// Initialize _authorizedTags
- this._authorizedTags = this._getAuthorizedTags();
+ this._authorizedTags = this._loadAndGetAuthorizedTags();
} catch (error) {
logger.error(this._basicFormatLog() + ' Authorization file monitoring error: ' + error);
}
onOpen() {
logger.info(`${this._basicFormatLog()} Is connected to server through ${this._url}`);
+ if (!this._heartbeatInterval) {
+ // Send BootNotification
+ try {
+ this.sendMessage(Utils.generateUUID(), this._bootNotificationMessage, Constants.OCPP_JSON_CALL_MESSAGE, 'BootNotification');
+ } catch (error) {
+ logger.error(this._basicFormatLog() + ' Send boot notification error: ' + error);
+ }
+ }
if (this._isSocketRestart) {
this._basicStartMessageSequence();
if (this._messageQueue.length > 0) {
}
});
}
- } else {
- // At first start, send BootNotification
- try {
- this.sendMessage(Utils.generateUUID(), this._bootNotificationMessage, Constants.OCPP_JSON_CALL_MESSAGE, 'BootNotification');
- } catch (error) {
- logger.error(this._basicFormatLog() + ' Send boot notification error: ' + error);
- }
}
this._autoReconnectRetryCount = 0;
this._isSocketRestart = false;
// eslint-disable-next-line class-methods-use-this
async _startHeartbeat(self) {
if (self._heartbeatInterval && !self._heartbeatSetInterval) {
- logger.info(self._basicFormatLog() + ' Heartbeat started every ' + self._heartbeatInterval + 'ms');
self._heartbeatSetInterval = setInterval(() => {
try {
const payload = {
logger.error(self._basicFormatLog() + ' Send heartbeat error: ' + error);
}
}, self._heartbeatInterval);
+ logger.info(self._basicFormatLog() + ' Heartbeat started every ' + self._heartbeatInterval + 'ms');
} else {
logger.error(self._basicFormatLog() + ' Heartbeat interval undefined, not starting the heartbeat');
}