Skip to content

Commit

Permalink
Undo changes in IFF-Agent
Browse files Browse the repository at this point in the history
  • Loading branch information
wagmarcel committed Dec 17, 2024
1 parent 99a4eed commit 95571a0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
9 changes: 3 additions & 6 deletions NgsildAgent/lib/CloudProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ function updateToken (token) {
const parsedToken = JSON.parse(token);
common.saveToDeviceConfig('device_token', parsedToken.access_token);
common.saveToDeviceConfig('refresh_token', parsedToken.refresh_token);
// Update device_token_expire
const expireTime = parsedToken.exp ? parsedToken.exp * 1000 : new Date().getTime() + 3600 * 1000;
common.saveToDeviceConfig('device_token_expire', expireTime);
}

function updateSecrets (me) {
Expand Down Expand Up @@ -145,15 +142,15 @@ class CloudProxy {
}
}

async init() {
async init () {
try {
await this.spBProxy.init();
} catch (err) {
if (err.name === 'ConnectionError' && err.errno === 1) {
if (err instanceof ConnectionError && err.errno === 1) {
this.logger.error('SparkplugB MQTT NBIRTH Metric not sent. Trying to refresh token.');
await this.checkDeviceToken();
return 1;
} else {
} else { // unrecoverable
this.logger.error('Unexpected Error: ' + err.stack);
return 2;
}
Expand Down
4 changes: 2 additions & 2 deletions NgsildAgent/lib/ConnectionError.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* 2: other
*/
class ConnectionError extends Error {
constructor(errno, message) {
constructor (message, errno) {
super(message);
this.name = 'ConnectionError';
this.name = 'ConnectorError';
this.errno = errno;
}
}
Expand Down
2 changes: 1 addition & 1 deletion NgsildAgent/lib/SparkplugbConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class SparkplugbConnector {
this.client.disconnect();
};

updateDeviceInfo(deviceInfo) {
updateDeviceInfo = function (deviceInfo) {
const me = this;
me.client.updateDeviceInfo(deviceInfo);
};
Expand Down
1 change: 0 additions & 1 deletion NgsildAgent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"json-schema": "^0.4.0",
"jwt-decode": "^2.2.0",
"mqtt": "^5.3.4",
"request": "^2.88.0",
"sqlite3": "^5.1.6",
"validate-iri": "^1.0.1",
"winston": "^3.7.2"
Expand Down

0 comments on commit 95571a0

Please sign in to comment.