From 30198d1b1abb8ab7b4a216fce3389f6f48e4391b Mon Sep 17 00:00:00 2001 From: sergiu Date: Sun, 30 Apr 2023 14:26:44 +0300 Subject: [PATCH 1/4] LINXD-2396: Get Hub address from asset configuration; Take default main group if not specified in config; Update config to not declare hub address and voice server --- config/dev/default.toml | 7 -- index.js | 4 +- src/asset.js | 146 +++++++++++++++++++++++++++------------- src/mumble.js | 15 +++-- 4 files changed, 112 insertions(+), 60 deletions(-) diff --git a/config/dev/default.toml b/config/dev/default.toml index 5b87f1d..c8bf391 100644 --- a/config/dev/default.toml +++ b/config/dev/default.toml @@ -1,10 +1,3 @@ -[mumble] -port = '5668' -host = 'dev.linx.safemobile.com' - -[hub] -address = 'https://hub.dev.linx.safemobile.com/' - [elogs] name = 'dev' diff --git a/index.js b/index.js index 9c6406b..4a26c8f 100644 --- a/index.js +++ b/index.js @@ -6,8 +6,8 @@ const Simulator = require('./src/simulator'); // Read configs. let configs = { - mumble: config.get('mumble'), - hub: config.get('hub'), + // mumble: config.get('mumble'), + // hub: config.get('hub'), api: config.get('api'), assets: config.get('assets'), sounds: config.get('sounds'), diff --git a/src/asset.js b/src/asset.js index a889470..614f11e 100644 --- a/src/asset.js +++ b/src/asset.js @@ -21,9 +21,14 @@ class Asset { constructor(asset, configs, token) { this.id = asset.asset_id; + this.mumbleHost = null; + this.mumblePort = null; + this.murmurUser = null; + this.murmurPassword = null; + this.hubAddress = null; this.group_id = asset.group_id; - this.generate_voice = asset.generate_voice; - this.generate_gps = asset.generate_gps; + this.generate_voice = asset.generate_voice || false; + this.generate_gps = asset.generate_gps || false; this.token = token; this.configs = configs this._processConfigs(); @@ -36,7 +41,9 @@ class Asset { // Do async work: Init asset. async.waterfall([ + this._getConfiguration.bind(this), this._getDataFromApi.bind(this), + this._checkGroupToJoin.bind(this), this._connectToHub.bind(this), this._connectToMurmur.bind(this), this._register.bind(this), @@ -56,12 +63,70 @@ class Asset { }); } - _processConfigs() { + _processConfigs(callback) { let apiConfig = this.configs.api; this.apiEndpoint = apiConfig.use_secure ? 'https' : 'http'; this.apiEndpoint += '://' + apiConfig.host + (apiConfig.port ? (':' + apiConfig.port) : ''); } + _getConfiguration(callback) { + console.log('_getConfiguration', this.id); + Request.get( + this.apiEndpoint + '/asset/' + this.id + '/account', + { + headers: { + Authorization: `Bearer ${this.token}` + } + }, + (error, response, body) => { + if (!error && (response.statusCode === 200 || response.statusCode === 201)) { + const bodyObj = JSON.parse(body); + const data = bodyObj.data; + // console.log('_getConfiguration', data); + this.mumbleHost = data.configuration.mumble_address; + this.mumblePort = data.configuration.voice_rtp_port; + this.murmurUser = bodyObj.data.configuration.mumble_username; + this.murmurPassword = bodyObj.data.configuration.mumble_password; + this.hubAddress = data.configuration.hub_address; + return callback(); + } else { + utils.writeLog(`ERROR getting informations about asset ${this.id}`, error); + utils.writeErrorLog(`ERROR_API`); + return callback(error); + } + } + ); + } + + _checkGroupToJoin(callback) { + console.log('_getConfiguration', this.id); + Request.get( + this.apiEndpoint + '/assets/' + this.id + '/groups', + { + headers: { + Authorization: `Bearer ${this.token}` + } + }, + (error, response, body) => { + if (!error && (response.statusCode === 200 || response.statusCode === 201)) { + const bodyObj = JSON.parse(body); + const data = bodyObj.data.map(group => group.group_id); + if (data.includes(this.group_id)) { + utils.writeLog(`Asset ${this.id} have group ${this.group_id}`); + return callback(); + } else { + utils.writeLog(`ERROR Asset ${this.id} is not in group ${this.group_id}`); + return; + } + } else { + utils.writeLog(`ERROR getting informations about asset ${this.id}`, error); + utils.writeErrorLog(`ERROR_API`); + return callback(error); + } + } + ); + } + _getDataFromApi(callback) { utils.writeLog(`Get informations about asset ${this.id}`); Request.get( @@ -74,35 +139,7 @@ class Asset { (error, response, body) => { if (!error && (response.statusCode === 200 || response.statusCode === 201)) { let bodyObj = JSON.parse(body); - // Here are the asset fields. this.assetProps = bodyObj.data; - // console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!', this.assetProps) - return this._getMumblePassword(callback); - } else { - utils.writeLog(`ERROR getting informations about asset ${this.id}`, error); - utils.writeErrorLog(`ERROR_API`); - return callback(error); - } - } - ); - } - - _getMumblePassword(callback) { - utils.writeLog(`Get Mumble password for asset ${this.id}`); - Request.get( - this.apiEndpoint + '/asset/' + this.id + '/account', - { - headers: { - Authorization: `Bearer ${this.token}` - } - }, - (error, response, body) => { - if (!error && (response.statusCode === 200 || response.statusCode === 201)) { - let bodyObj = JSON.parse(body); - - // Here are the asset fields. - this.murmurPassword = bodyObj.data.configuration.mumble_password; - // console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!', this.assetProps) return this._getGroupsFromApi(callback); } else { utils.writeLog(`ERROR getting informations about asset ${this.id}`, error); @@ -129,17 +166,28 @@ class Asset { this.groups = bodyObj.data; - // Find what group this asset is monitoring. - this.groups.forEach((g) => { - if (g.id === this.group_id) { - this.groupSipId = g.sip_id; - this.groupName = g.name; - } - }); + if (this.group_id) { + this.groups.forEach((g) => { + if (g.id === this.group_id) { + this.groupSipId = g.sip_id; + this.groupName = g.name; + } + }); + } else { + this.groups.forEach((g) => { + if (g.is_talk_group && g.monitoring.indexOf(this.id) != -1) { + this.groupSipId = g.sip_id; + this.groupName = g.name; + this.group_id = g.id; + } + }) + } - // if (!this.groupId) { - // return callback('No talk group assigned to ' + this.id); - // } + if (!this.group_id) { + utils.writeErrorLog(`Group/Default voice group not found for asset: ${this.group_id}`); + } + + utils.writeLog(`Group: ${this.group_id} found for asset: ${this.id}`); utils.writeLog(`Informations about asset ${this.id} received | groupId: ${this.group_id} | groupName: ${this.groupName}`); return callback(); } else { @@ -152,10 +200,8 @@ class Asset { } _connectToHub(callback) { - - let hubAddress = this.configs.hub.address; let options = {rejectUnauthorized: false, secure: true}; - let hub = io(hubAddress, options); + let hub = io(this.hubAddress, options); this.hub = hub; // Disconnect event @@ -210,10 +256,16 @@ class Asset { } _connectToMurmur(callback) { + !this.group_id && return callback(); + console.log(`Asset ${this.id} connecting to Murmur`); - this.configs.murmurPassword = this.murmurPassword; - - this.mumble = new Mumble(this.id, this.configs, (err) => { + const murmurConnectionDetails = { + mumbleHost: this.mumbleHost, + mumblePort: this.mumblePort, + murmurUser: this.murmurUser, + murmurPassword: this.murmurPassword + }; + this.mumble = new Mumble(this.id, murmurConnectionDetails, (err) => { if (err) { utils.writeLog(`Asset ${this.id} Murmur connection error`, err); utils.writeErrorLog(`ERROR_MURMUR`); diff --git a/src/mumble.js b/src/mumble.js index 1f5cf69..ebd8f8a 100644 --- a/src/mumble.js +++ b/src/mumble.js @@ -11,12 +11,19 @@ const OpusEncoder = require('node-opus').OpusEncoder; class Mumble { - constructor(id, configs, connectedCallback) { + constructor(id, murmurConnectionDetails, connectedCallback) { this.id = id; - this.configs = configs; - let mumble = configs.mumble; + this.mumbleHost = murmurConnectionDetails.mumbleHost; + this.mumblePort = murmurConnectionDetails.mumblePort; + this.murmurUser = murmurConnectionDetails.murmurUser; + this.murmurPassword = murmurConnectionDetails.murmurPassword; + console.log('mumbleHost', this.mumbleHost) + console.log('mumblePort', this.mumblePort) + console.log('murmurUser', this.murmurUser) + console.log('murmurPassword', this.murmurPassword) + this._createCertificatesForUser(id, () => { - this._makeMumbleConnection(id, mumble.port, mumble.host, id, this.configs.murmurPassword, connectedCallback); + this._makeMumbleConnection(id, this.mumblePort, this.mumbleHost, id, this.murmurPassword, connectedCallback); }) } -- 2.37.1 From faa8e8099e7a560624e8ac1c5a0e595b7e8ea200 Mon Sep 17 00:00:00 2001 From: sergiu Date: Wed, 3 May 2023 17:17:11 +0300 Subject: [PATCH 2/4] LINXD-2396: Added error informations; Update to send gps from interval(min-max) --- config/dev/default.toml | 465 +++++++++++++++++++++++++++++++++++++++- src/asset.js | 54 ++--- src/mumble.js | 8 +- src/simulator.js | 12 +- 4 files changed, 489 insertions(+), 50 deletions(-) diff --git a/config/dev/default.toml b/config/dev/default.toml index c8bf391..60d519b 100644 --- a/config/dev/default.toml +++ b/config/dev/default.toml @@ -3,31 +3,476 @@ name = 'dev' [api] port = '' -host = 'dev.linx.safemobile.com/api' +host = 'node.dev.linx.safemobile.com/api' use_secure = true accept_untrusted_certs = true [settings] max_fails = 3 -send_group_monitoring_before_each_call = 'true' -gps_report_interval = 1000 # The interval in which the GPS is sent +send_group_monitoring_before_each_call = 'false' +gps_report_interval = '' +gps_min_interval = 1000 +gps_max_interval = 10000 gps_lat_start_point = 46.217802 gps_lng_start_point = 24.776126 -delay_between_clients = 300 -testing_duration = 40 # seconds +delay_between_clients = 500 +testing_duration = 240 # seconds +# group 1 / 1 send / 10 listen [[assets]] -asset_id = 63 -group_id = 1 +asset_id = 7516 +group_id = 2561 generate_voice = true generate_gps = true - + [[assets]] -asset_id = 64 -group_id = 1 +asset_id = 7517 +group_id = 2561 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7518 +group_id = 2561 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7519 +group_id = 2561 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7520 +group_id = 2561 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7521 +group_id = 2561 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7522 +group_id = 2561 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7523 +group_id = 2561 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7524 +group_id = 2561 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7525 +group_id = 2561 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7526 +group_id = 2561 +generate_voice = false +generate_gps = true + +# group 2 / 1 send / 10 listen + +[[assets]] +asset_id = 7536 +group_id = 2560 +generate_voice = true +generate_gps = true + +[[assets]] +asset_id = 7537 +group_id = 2560 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7538 +group_id = 2560 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7539 +group_id = 2560 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7540 +group_id = 2560 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7541 +group_id = 2560 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7542 +group_id = 2560 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7543 +group_id = 2560 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7544 +group_id = 2560 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7545 +group_id = 2560 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7546 +group_id = 2560 +generate_voice = false +generate_gps = true + +# group 3 / 1 send / 10 listen + +[[assets]] +asset_id = 7556 +group_id = 2559 +generate_voice = true +generate_gps = true + +[[assets]] +asset_id = 7557 +group_id = 2559 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7558 +group_id = 2559 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7559 +group_id = 2559 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7560 +group_id = 2559 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7561 +group_id = 2559 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7562 +group_id = 2559 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7563 +group_id = 2559 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7564 +group_id = 2559 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7565 +group_id = 2559 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7566 +group_id = 2559 +generate_voice = false +generate_gps = true + +# group 4 / 1 send / 10 listen + +[[assets]] +asset_id = 7576 +group_id = 2558 +generate_voice = true +generate_gps = true + +[[assets]] +asset_id = 7577 +group_id = 2558 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7578 +group_id = 2558 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7579 +group_id = 2558 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7580 +group_id = 2558 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7581 +group_id = 2558 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7582 +group_id = 2558 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7583 +group_id = 2558 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7584 +group_id = 2558 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7585 +group_id = 2558 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7586 +group_id = 2558 +generate_voice = false +generate_gps = true + +# group 5 / 1 send / 10 listen + +# group 6 / 1 send / 10 listen + +# group 7 / 1 send / 10 listen + +# group 8 / 1 send / 10 listen + +# group 9 / 1 send / 10 listen + +# group 10 / 1 send / 10 listen + +[[assets]] +asset_id = 7715 +group_id = 2552 +generate_voice = true +generate_gps = true + +[[assets]] +asset_id = 7714 +group_id = 2552 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7713 +group_id = 2552 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7712 +group_id = 2552 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7711 +group_id = 2552 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7710 +group_id = 2552 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7709 +group_id = 2552 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7708 +group_id = 2552 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7707 +group_id = 2552 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7706 +group_id = 2552 +generate_voice = false +generate_gps = true + +[[assets]] +asset_id = 7705 +group_id = 2552 generate_voice = false generate_gps = true +[[assets]] +asset_id = 7796 +group_id = 2557 + +[[assets]] +asset_id = 7797 +group_id = 2557 + +[[assets]] +asset_id = 7798 +group_id = 2557 + +[[assets]] +asset_id = 7799 +group_id = 2557 + +[[assets]] +asset_id = 7800 +group_id = 2557 + +[[assets]] +asset_id = 7801 +group_id = 2557 + +[[assets]] +asset_id = 7802 +group_id = 2557 + +[[assets]] +asset_id = 7803 +group_id = 2557 + +[[assets]] +asset_id = 7804 +group_id = 2557 + +[[assets]] +asset_id = 7805 +group_id = 2557 + +[[assets]] +asset_id = 7806 +group_id = 2557 + +[[assets]] +asset_id = 7817 +group_id = 2556 + +[[assets]] +asset_id = 7818 +group_id = 2556 + +[[assets]] +asset_id = 7819 +group_id = 2556 + +[[assets]] +asset_id = 7820 +group_id = 2556 + +[[assets]] +asset_id = 7821 +group_id = 2556 + +[[assets]] +asset_id = 7822 +group_id = 2556 + +[[assets]] +asset_id = 7823 +group_id = 2556 + +[[assets]] +asset_id = 7824 +group_id = 2556 + +[[assets]] +asset_id = 7825 +group_id = 2556 + +[[assets]] +asset_id = 7826 +group_id = 2556 + +[[assets]] +asset_id = 7827 +group_id = 2556 + + + + + + + + + + + + + + + + + + + [sounds] tracks = ['1.mp3','2.mp3','3.mp3','4.mp3','5.mp3','6.mp3','7.mp3','8.mp3','9.mp3','10.mp3','11.mp3','12.mp3','13.mp3','14.mp3','15.mp3','16.mp3','17.mp3','18.mp3','19.mp3'] diff --git a/src/asset.js b/src/asset.js index 614f11e..2b50106 100644 --- a/src/asset.js +++ b/src/asset.js @@ -119,8 +119,9 @@ class Asset { return; } } else { + utils.writeLog(`_getConfiguration | response ${JSON.stringify(response)} | body: ${JSON.stringify(body)}`) utils.writeLog(`ERROR getting informations about asset ${this.id}`, error); - utils.writeErrorLog(`ERROR_API`); + utils.writeErrorLog(`ERROR_API | _checkGroupToJoin`); return callback(error); } } @@ -143,7 +144,7 @@ class Asset { return this._getGroupsFromApi(callback); } else { utils.writeLog(`ERROR getting informations about asset ${this.id}`, error); - utils.writeErrorLog(`ERROR_API`); + utils.writeErrorLog(`ERROR_API | _getDataFromApi`); return callback(error); } } @@ -192,7 +193,7 @@ class Asset { return callback(); } else { utils.writeLog(`Error getting informations about asset ${this.id}`, error); - utils.writeErrorLog(`ERROR_API`); + utils.writeErrorLog(`ERROR_API | _getGroupsFromApi`); return callback(error); } } @@ -211,12 +212,12 @@ class Asset { hub.on('connect_timeout', () => { utils.writeLog(`Asset ${this.id} connect_timeout from HUB`); - utils.writeErrorLog(`ERROR_HUB`); + utils.writeErrorLog(`ERROR_HUB | _connectToHub`); }); hub.on('connect_error', () => { utils.writeLog(`Asset ${this.id} connect_error from HUB`); - utils.writeErrorLog(`ERROR_HUB`); + utils.writeErrorLog(`ERROR_HUB | _connectToHub`); }); hub.once('connect', () => { @@ -256,8 +257,8 @@ class Asset { } _connectToMurmur(callback) { - !this.group_id && return callback(); - + if (!this.group_id) { return callback(); } + console.log(`Asset ${this.id} connecting to Murmur`); const murmurConnectionDetails = { mumbleHost: this.mumbleHost, @@ -268,13 +269,12 @@ class Asset { this.mumble = new Mumble(this.id, murmurConnectionDetails, (err) => { if (err) { utils.writeLog(`Asset ${this.id} Murmur connection error`, err); - utils.writeErrorLog(`ERROR_MURMUR`); + utils.writeErrorLog(`ERROR_MURMUR | _connectToMurmur`); return callback(err); } else { - // return callback(); setTimeout(()=> { return callback(); - }, 400); + }, 500); } }); } @@ -293,13 +293,10 @@ class Asset { utils.writeLog(`Asset ${this.id} audio registered`); return callback(); } else { - console.log('_register--------------------') - console.log('error---', error) - // console.log('response---', response) - console.log('body---', body) - // utils.writeLog(`Asset ${this.id} audio registered error`, error); - // utils.writeErrorLog(`ERROR_API`); - // return callback(error); + console.log('body', body) + utils.writeLog(`Asset ${this.id} audio registered error`, error); + utils.writeErrorLog(`ERROR_AUDIO | _register`); + return callback(error); } } ); @@ -338,13 +335,9 @@ class Asset { if (callback) return callback('Cannot send group-monitoring: Hub not connected'); } } else { - console.log('_moveToChannel--------------------') - console.log('error---', error) - // console.log('response---', response) - console.log('body---', body) - // utils.writeLog(`Asset ${this.id} audio enter group error`, error); - // utils.writeErrorLog(`ERROR_API`); - // return callback(error); + utils.writeLog(`Asset ${this.id} audio enter group error`, error); + utils.writeErrorLog(`ERROR_AUDIO | _moveToChannel`); + return callback(error); } } ); @@ -396,7 +389,7 @@ class Asset { } } else { utils.writeLog(`Error getting record for asset ${this.id} | ${error}`); - utils.writeErrorLog(`ERROR_RECORDER`); + utils.writeErrorLog(`ERROR_RECORDER | _getRecord`); } let assetIds = configs.assets.ids; @@ -544,6 +537,15 @@ class Asset { if (hub && hub.connected) { let lat = this.configs.settings.gps_lat_start_point; let lng = this.configs.settings.gps_lng_start_point; + const max = this.configs.settings.gps_max_interval; + const min = this.configs.settings.gps_min_interval; + + let interval = null; + if (!this.configs.settings.gps_report_interval) { + interval = Math.floor(Math.random() * (max - min + 1) + min); + } else { + interval = this.configs.settings.gps_report_interval; + } setInterval(() => { const now = +new Date(); @@ -574,7 +576,7 @@ class Asset { }); }, 11000); } - }, this.configs.settings.gps_report_interval); + }, interval); } } diff --git a/src/mumble.js b/src/mumble.js index ebd8f8a..5daacda 100644 --- a/src/mumble.js +++ b/src/mumble.js @@ -17,10 +17,10 @@ class Mumble { this.mumblePort = murmurConnectionDetails.mumblePort; this.murmurUser = murmurConnectionDetails.murmurUser; this.murmurPassword = murmurConnectionDetails.murmurPassword; - console.log('mumbleHost', this.mumbleHost) - console.log('mumblePort', this.mumblePort) - console.log('murmurUser', this.murmurUser) - console.log('murmurPassword', this.murmurPassword) + // console.log('mumbleHost', this.mumbleHost) + // console.log('mumblePort', this.mumblePort) + // console.log('murmurUser', this.murmurUser) + // console.log('murmurPassword', this.murmurPassword) this._createCertificatesForUser(id, () => { this._makeMumbleConnection(id, this.mumblePort, this.mumbleHost, id, this.murmurPassword, connectedCallback); diff --git a/src/simulator.js b/src/simulator.js index b6975cd..9c307b3 100644 --- a/src/simulator.js +++ b/src/simulator.js @@ -36,19 +36,11 @@ class Simulator { _start() { const settings = this.configs.settings; - // this.assetIds.forEach((id, i) => { this.assets.forEach((asset, i) => { - let delay_between_clients = 500; - if(settings.hasOwnProperty('delay_between_clients')) { - delay_between_clients = parseInt(settings.delay_between_clients, 10); - } - console.log('asset_id', asset.asset_id, i * delay_between_clients+'ms') - - delay_between_clients = this._getRandomInt(delay_between_clients); + console.log('asset_id', asset.asset_id, i * settings.delay_between_clients + 'ms'); setTimeout(() => { new Asset(asset, this.configs, this.token); - // console.log('id, this.configs, this.token', id, this.configs, this.token) - }, i * delay_between_clients); + }, i * settings.delay_between_clients); }) } -- 2.37.1 From e2b3b35e338aeddeee58016efe893ff65577eabb Mon Sep 17 00:00:00 2001 From: sergiu Date: Wed, 3 May 2023 17:20:46 +0300 Subject: [PATCH 3/4] LINXD-2396: Added error informations; Update to send gps from interval(min-max) --- src/asset.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/asset.js b/src/asset.js index 2b50106..640dcb3 100644 --- a/src/asset.js +++ b/src/asset.js @@ -90,8 +90,9 @@ class Asset { this.hubAddress = data.configuration.hub_address; return callback(); } else { + utils.writeLog(`_getConfiguration | response ${JSON.stringify(response)} | body: ${JSON.stringify(body)}`) utils.writeLog(`ERROR getting informations about asset ${this.id}`, error); - utils.writeErrorLog(`ERROR_API`); + utils.writeErrorLog(`ERROR_API | _getConfiguration`); return callback(error); } } @@ -99,7 +100,7 @@ class Asset { } _checkGroupToJoin(callback) { - console.log('_getConfiguration', this.id); + console.log('_checkGroupToJoin', this.id); Request.get( this.apiEndpoint + '/assets/' + this.id + '/groups', { @@ -119,7 +120,7 @@ class Asset { return; } } else { - utils.writeLog(`_getConfiguration | response ${JSON.stringify(response)} | body: ${JSON.stringify(body)}`) + utils.writeLog(`_checkGroupToJoin | response ${JSON.stringify(response)} | body: ${JSON.stringify(body)}`) utils.writeLog(`ERROR getting informations about asset ${this.id}`, error); utils.writeErrorLog(`ERROR_API | _checkGroupToJoin`); return callback(error); -- 2.37.1 From 8793db7c00b12b3c363f68be1fed354b5b3fcea6 Mon Sep 17 00:00:00 2001 From: sergiu Date: Wed, 3 May 2023 17:59:13 +0300 Subject: [PATCH 4/4] LAPI-633: Add config for no gps --- config/dev/default-no-gps.toml | 440 +++++++++++++++++++++++++++++++++ config/dev/default.toml | 110 +++------ src/asset.js | 23 +- 3 files changed, 487 insertions(+), 86 deletions(-) create mode 100644 config/dev/default-no-gps.toml diff --git a/config/dev/default-no-gps.toml b/config/dev/default-no-gps.toml new file mode 100644 index 0000000..634b5ad --- /dev/null +++ b/config/dev/default-no-gps.toml @@ -0,0 +1,440 @@ +[elogs] +name = 'dev' + +[api] +port = '' +host = 'node.dev.linx.safemobile.com/api' +use_secure = true +accept_untrusted_certs = true + +[settings] +max_fails = 3 +send_group_monitoring_before_each_call = 'false' +gps_report_interval = '' +gps_min_interval = 1000 +gps_max_interval = 10000 +gps_lat_start_point = 46.217802 +gps_lng_start_point = 24.776126 +delay_between_clients = 500 +testing_duration = 240 # seconds + + +# group 1 / 1 send / 10 listen +[[assets]] +asset_id = 7516 +group_id = 2561 +generate_voice = true +generate_gps = true + +[[assets]] +asset_id = 7517 +group_id = 2561 +generate_voice = false + + +[[assets]] +asset_id = 7518 +group_id = 2561 +generate_voice = false + + +[[assets]] +asset_id = 7519 +group_id = 2561 +generate_voice = false + + +[[assets]] +asset_id = 7520 +group_id = 2561 +generate_voice = false + + +[[assets]] +asset_id = 7521 +group_id = 2561 +generate_voice = false + + +[[assets]] +asset_id = 7522 +group_id = 2561 +generate_voice = false + + +[[assets]] +asset_id = 7523 +group_id = 2561 +generate_voice = false + + +[[assets]] +asset_id = 7524 +group_id = 2561 +generate_voice = false + + +[[assets]] +asset_id = 7525 +group_id = 2561 +generate_voice = false + + +[[assets]] +asset_id = 7526 +group_id = 2561 +generate_voice = false + + +# group 2 / 1 send / 10 listen + +[[assets]] +asset_id = 7536 +group_id = 2560 +generate_voice = true + + +[[assets]] +asset_id = 7537 +group_id = 2560 +generate_voice = false + + +[[assets]] +asset_id = 7538 +group_id = 2560 +generate_voice = false + + +[[assets]] +asset_id = 7539 +group_id = 2560 +generate_voice = false + + +[[assets]] +asset_id = 7540 +group_id = 2560 +generate_voice = false + + +[[assets]] +asset_id = 7541 +group_id = 2560 +generate_voice = false + + +[[assets]] +asset_id = 7542 +group_id = 2560 +generate_voice = false + + +[[assets]] +asset_id = 7543 +group_id = 2560 +generate_voice = false + + +[[assets]] +asset_id = 7544 +group_id = 2560 +generate_voice = false + + +[[assets]] +asset_id = 7545 +group_id = 2560 +generate_voice = false + + +[[assets]] +asset_id = 7546 +group_id = 2560 +generate_voice = false + + +# group 3 / 1 send / 10 listen + +[[assets]] +asset_id = 7556 +group_id = 2559 +generate_voice = true + + +[[assets]] +asset_id = 7557 +group_id = 2559 +generate_voice = false + + +[[assets]] +asset_id = 7558 +group_id = 2559 +generate_voice = false + + +[[assets]] +asset_id = 7559 +group_id = 2559 +generate_voice = false + + +[[assets]] +asset_id = 7560 +group_id = 2559 +generate_voice = false + + +[[assets]] +asset_id = 7561 +group_id = 2559 +generate_voice = false + + +[[assets]] +asset_id = 7562 +group_id = 2559 +generate_voice = false + + +[[assets]] +asset_id = 7563 +group_id = 2559 +generate_voice = false + + +[[assets]] +asset_id = 7564 +group_id = 2559 +generate_voice = false + + +[[assets]] +asset_id = 7565 +group_id = 2559 +generate_voice = false + + +[[assets]] +asset_id = 7566 +group_id = 2559 +generate_voice = false + + +# group 4 / 1 send / 10 listen + +[[assets]] +asset_id = 7576 +group_id = 2558 +generate_voice = true + + +[[assets]] +asset_id = 7577 +group_id = 2558 +generate_voice = false + + +[[assets]] +asset_id = 7578 +group_id = 2558 +generate_voice = false + + +[[assets]] +asset_id = 7579 +group_id = 2558 +generate_voice = false + + +[[assets]] +asset_id = 7580 +group_id = 2558 +generate_voice = false + + +[[assets]] +asset_id = 7581 +group_id = 2558 +generate_voice = false + + +[[assets]] +asset_id = 7582 +group_id = 2558 +generate_voice = false + + +[[assets]] +asset_id = 7583 +group_id = 2558 +generate_voice = false + + +[[assets]] +asset_id = 7584 +group_id = 2558 +generate_voice = false + + +[[assets]] +asset_id = 7585 +group_id = 2558 +generate_voice = false + + +[[assets]] +asset_id = 7586 +group_id = 2558 +generate_voice = false + + +# group 5 / 1 send / 10 listen + +# group 6 / 1 send / 10 listen + +# group 7 / 1 send / 10 listen + +# group 8 / 1 send / 10 listen + +# group 9 / 1 send / 10 listen + +# group 10 / 1 send / 10 listen + +[[assets]] +asset_id = 7715 +group_id = 2552 +generate_voice = true + + +[[assets]] +asset_id = 7714 +group_id = 2552 +generate_voice = false + + +[[assets]] +asset_id = 7713 +group_id = 2552 +generate_voice = false + + +[[assets]] +asset_id = 7712 +group_id = 2552 +generate_voice = false + + +[[assets]] +asset_id = 7711 +group_id = 2552 +generate_voice = false + + +[[assets]] +asset_id = 7710 +group_id = 2552 +generate_voice = false + + +[[assets]] +asset_id = 7709 +group_id = 2552 +generate_voice = false + + +[[assets]] +asset_id = 7708 +group_id = 2552 +generate_voice = false + + +[[assets]] +asset_id = 7707 +group_id = 2552 +generate_voice = false + + +[[assets]] +asset_id = 7706 +group_id = 2552 +generate_voice = false + + +[[assets]] +asset_id = 7705 +group_id = 2552 +generate_voice = false + + +[[assets]] +asset_id = 7704 +group_id = 2552 +generate_voice = false + + +[[assets]] +asset_id = 7703 +group_id = 2552 +generate_voice = false + + +[[assets]] +asset_id = 7702 +group_id = 2552 +generate_voice = false + + +[[assets]] +asset_id = 7701 +group_id = 2552 +generate_voice = false + + +[[assets]] +asset_id = 7700 +group_id = 2552 +generate_voice = false + + +[[assets]] +asset_id = 7699 +group_id = 2552 +generate_voice = false + + +[[assets]] +asset_id = 7698 +group_id = 2552 +generate_voice = false + + +[[assets]] +asset_id = 7697 +group_id = 2552 +generate_voice = false + + +[[assets]] +asset_id = 7696 +group_id = 2552 +generate_voice = false + + + + + + + + + + + + + + + + +[sounds] +tracks = ['1.mp3','2.mp3','3.mp3','4.mp3','5.mp3','6.mp3','7.mp3','8.mp3','9.mp3','10.mp3','11.mp3','12.mp3','13.mp3','14.mp3','15.mp3','16.mp3','17.mp3','18.mp3','19.mp3'] diff --git a/config/dev/default.toml b/config/dev/default.toml index 60d519b..2a6d72d 100644 --- a/config/dev/default.toml +++ b/config/dev/default.toml @@ -369,96 +369,58 @@ generate_voice = false generate_gps = true [[assets]] -asset_id = 7796 -group_id = 2557 +asset_id = 7704 +group_id = 2552 +generate_voice = false +generate_gps = true [[assets]] -asset_id = 7797 -group_id = 2557 +asset_id = 7703 +group_id = 2552 +generate_voice = false +generate_gps = true [[assets]] -asset_id = 7798 -group_id = 2557 +asset_id = 7702 +group_id = 2552 +generate_voice = false +generate_gps = true [[assets]] -asset_id = 7799 -group_id = 2557 +asset_id = 7701 +group_id = 2552 +generate_voice = false +generate_gps = true [[assets]] -asset_id = 7800 -group_id = 2557 +asset_id = 7700 +group_id = 2552 +generate_voice = false +generate_gps = true [[assets]] -asset_id = 7801 -group_id = 2557 +asset_id = 7699 +group_id = 2552 +generate_voice = false +generate_gps = true [[assets]] -asset_id = 7802 -group_id = 2557 +asset_id = 7698 +group_id = 2552 +generate_voice = false +generate_gps = true [[assets]] -asset_id = 7803 -group_id = 2557 +asset_id = 7697 +group_id = 2552 +generate_voice = false +generate_gps = true [[assets]] -asset_id = 7804 -group_id = 2557 - -[[assets]] -asset_id = 7805 -group_id = 2557 - -[[assets]] -asset_id = 7806 -group_id = 2557 - -[[assets]] -asset_id = 7817 -group_id = 2556 - -[[assets]] -asset_id = 7818 -group_id = 2556 - -[[assets]] -asset_id = 7819 -group_id = 2556 - -[[assets]] -asset_id = 7820 -group_id = 2556 - -[[assets]] -asset_id = 7821 -group_id = 2556 - -[[assets]] -asset_id = 7822 -group_id = 2556 - -[[assets]] -asset_id = 7823 -group_id = 2556 - -[[assets]] -asset_id = 7824 -group_id = 2556 - -[[assets]] -asset_id = 7825 -group_id = 2556 - -[[assets]] -asset_id = 7826 -group_id = 2556 - -[[assets]] -asset_id = 7827 -group_id = 2556 - - - - +asset_id = 7696 +group_id = 2552 +generate_voice = false +generate_gps = true diff --git a/src/asset.js b/src/asset.js index 640dcb3..c9d6bd1 100644 --- a/src/asset.js +++ b/src/asset.js @@ -90,8 +90,8 @@ class Asset { this.hubAddress = data.configuration.hub_address; return callback(); } else { - utils.writeLog(`_getConfiguration | response ${JSON.stringify(response)} | body: ${JSON.stringify(body)}`) - utils.writeLog(`ERROR getting informations about asset ${this.id}`, error); + utils.writeLog(`ERROR | _getConfiguration | response ${JSON.stringify(response)} | body: ${JSON.stringify(body)}`) + utils.writeLog(`ERROR | _getConfiguration | Getting informations about asset ${this.id}`, error); utils.writeErrorLog(`ERROR_API | _getConfiguration`); return callback(error); } @@ -121,7 +121,7 @@ class Asset { } } else { utils.writeLog(`_checkGroupToJoin | response ${JSON.stringify(response)} | body: ${JSON.stringify(body)}`) - utils.writeLog(`ERROR getting informations about asset ${this.id}`, error); + utils.writeLog(`ERROR | _checkGroupToJoin | Getting informations about asset ${this.id}`, error); utils.writeErrorLog(`ERROR_API | _checkGroupToJoin`); return callback(error); } @@ -144,7 +144,7 @@ class Asset { this.assetProps = bodyObj.data; return this._getGroupsFromApi(callback); } else { - utils.writeLog(`ERROR getting informations about asset ${this.id}`, error); + utils.writeLog(`ERROR | _getDataFromApi | Getting informations about asset ${this.id}`, error); utils.writeErrorLog(`ERROR_API | _getDataFromApi`); return callback(error); } @@ -186,14 +186,14 @@ class Asset { } if (!this.group_id) { - utils.writeErrorLog(`Group/Default voice group not found for asset: ${this.group_id}`); + utils.writeLog(`Group/Default voice group not found for asset: ${this.group_id}`); } utils.writeLog(`Group: ${this.group_id} found for asset: ${this.id}`); utils.writeLog(`Informations about asset ${this.id} received | groupId: ${this.group_id} | groupName: ${this.groupName}`); return callback(); } else { - utils.writeLog(`Error getting informations about asset ${this.id}`, error); + utils.writeLog(`ERROR | _getGroupsFromApi | Getting informations about asset ${this.id}`, error); utils.writeErrorLog(`ERROR_API | _getGroupsFromApi`); return callback(error); } @@ -269,7 +269,7 @@ class Asset { }; this.mumble = new Mumble(this.id, murmurConnectionDetails, (err) => { if (err) { - utils.writeLog(`Asset ${this.id} Murmur connection error`, err); + utils.writeLog(`ERROR | _connectToMurmur | Asset ${this.id} Murmur connection error`, err); utils.writeErrorLog(`ERROR_MURMUR | _connectToMurmur`); return callback(err); } else { @@ -294,8 +294,7 @@ class Asset { utils.writeLog(`Asset ${this.id} audio registered`); return callback(); } else { - console.log('body', body) - utils.writeLog(`Asset ${this.id} audio registered error`, error); + utils.writeLog(`ERROR | _register | Asset ${this.id} audio registered error`, error); utils.writeErrorLog(`ERROR_AUDIO | _register`); return callback(error); } @@ -336,7 +335,7 @@ class Asset { if (callback) return callback('Cannot send group-monitoring: Hub not connected'); } } else { - utils.writeLog(`Asset ${this.id} audio enter group error`, error); + utils.writeLog(`ERROR | _moveToChannel | Asset ${this.id} audio enter group error`, error); utils.writeErrorLog(`ERROR_AUDIO | _moveToChannel`); return callback(error); } @@ -389,7 +388,7 @@ class Asset { console.log(chalk.yellow(`[RECORDER] for asset ${this.id} not found`)); } } else { - utils.writeLog(`Error getting record for asset ${this.id} | ${error}`); + utils.writeLog(`ERROR | _getRecord | Error getting record for asset ${this.id} | ${error}`); utils.writeErrorLog(`ERROR_RECORDER | _getRecord`); } let assetIds = configs.assets.ids; @@ -461,7 +460,7 @@ class Asset { this._sendPttRelease(); const now = +new Date(); if(this.endTime > now) { - this._makePtt(); + this._makePtt(callback); } else { setTimeout(() => { -- 2.37.1