diff --git a/lib/db/api.js b/lib/db/api.js index f9ab28d6..610d4bb5 100644 --- a/lib/db/api.js +++ b/lib/db/api.js @@ -1,5 +1,5 @@ /** -* Copyright © 2019-2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0 +* Copyright © 2019-2025 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0 **/ var r = require('rethinkdb') @@ -14,7 +14,6 @@ const uuid = require('uuid') const apiutil = require('../util/apiutil') const Promise = require('bluebird') const _ = require('lodash') -const timeutil = require('../util/timeutil') dbapi.DuplicateSecondaryIndexError = function DuplicateSecondaryIndexError() { Error.call(this) @@ -1175,7 +1174,7 @@ dbapi.saveDeviceInitialState = function(serial, device) { , owner: null , status: device.status , statusChangedAt: r.now() - , statusTimeStamp: timeutil.now('nano') + , statusTimeStamp: device.statusTimeStamp , ready: false , reverseForwards: [] , remoteConnect: false diff --git a/lib/units/processor/index.js b/lib/units/processor/index.js index 1768b3fc..783fd99b 100644 --- a/lib/units/processor/index.js +++ b/lib/units/processor/index.js @@ -1,5 +1,5 @@ /** -* Copyright © 2019-2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0 +* Copyright © 2019-2025 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0 **/ var Promise = require('bluebird') @@ -99,6 +99,7 @@ module.exports = db.ensureConnectivity(function(options) { message.provider.channel , message.provider.name ) + , message.statusTimeStamp , new wire.DeviceGroupMessage( device.group.id , device.group.name diff --git a/lib/units/provider/index.js b/lib/units/provider/index.js index 66e24123..36c85650 100644 --- a/lib/units/provider/index.js +++ b/lib/units/provider/index.js @@ -1,5 +1,5 @@ /** -* Copyright © 2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0 +* Copyright © 2024-2025 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0 **/ var Promise = require('bluebird') @@ -171,6 +171,7 @@ module.exports = function(options) { solo , options.name ) + , timeutil.now('nano') )) ]) diff --git a/lib/units/websocket/index.js b/lib/units/websocket/index.js index 6eab8c86..88beecd5 100644 --- a/lib/units/websocket/index.js +++ b/lib/units/websocket/index.js @@ -1,5 +1,5 @@ /** -* Copyright © 2019-2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0 +* Copyright © 2019-2025 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0 **/ var http = require('http') @@ -223,6 +223,7 @@ module.exports = function(options) { , ready: false , reverseForwards: [] , group: message.group + , statusTimeStamp: message.statusTimeStamp } }) } diff --git a/lib/util/fakedevice.js b/lib/util/fakedevice.js index f6aa54ea..bd445ae2 100644 --- a/lib/util/fakedevice.js +++ b/lib/util/fakedevice.js @@ -1,5 +1,5 @@ /** -* Copyright © 2019 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0 +* Copyright © 2019-2025 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0 **/ var util = require('util') @@ -10,6 +10,8 @@ var _ = require('lodash') var dbapi = require('../db/api') var devices = require('@devicefarmer/stf-device-db/dist/devices-latest') +const timeutil = require('./timeutil') + module.exports.generate = function(wantedModel) { // no base64 because some characters as '=' or '/' are not compatible through API (delete devices) const serial = 'fake-' + util.format('%s', uuid.v4()).replace(/-/g, '') @@ -20,6 +22,7 @@ module.exports.generate = function(wantedModel) { , channel: '*fake' } , status: 'OFFLINE' + , statusTimeStamp: timeutil.now('nano') }) .then(function() { var model = wantedModel || _.sample(Object.keys(devices)) diff --git a/lib/wire/wire.proto b/lib/wire/wire.proto index 3c3f3a75..86373004 100644 --- a/lib/wire/wire.proto +++ b/lib/wire/wire.proto @@ -1,5 +1,5 @@ // -// Copyright © 2019-2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0 +// Copyright © 2019-2025 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0 // // Message wrapper @@ -339,7 +339,8 @@ message DeviceIntroductionMessage { required string serial = 1; required DeviceStatus status = 2; required ProviderMessage provider = 3; - optional DeviceGroupMessage group = 4; + required double statusTimeStamp = 4; + optional DeviceGroupMessage group = 5; } message DeviceRegisteredMessage {