4 Commits

4 changed files with 72 additions and 17 deletions

20
Dockerfile Normal file
View File

@ -0,0 +1,20 @@
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get -qq update
RUN apt-get install -y build-essential
RUN apt-get install -y curl
RUN apt-get install -y python-minimal
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash
RUN apt-get install -y nodejs
WORKDIR /simulator
ADD . /simulator
RUN apt-get install -y libasound2-dev
RUN npm i -g node-gyp
RUN apt install -y alsa-base pulseaudio
RUN npm install --unsafe-perm
# docker run -it -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY --device /dev/snd

View File

@ -24,6 +24,9 @@ gps_lng_start_point = 24.776126
testing_period = 1500
[assets]
# linx-simulator-1
ids = [15]
# linx-simulator-1 - linx-simulator-10
# ids = [15,16,17,18,19,20,21,22,23,24]
@ -35,13 +38,13 @@ testing_period = 1500
# ]
# linx-simulator-1 - linx-simulator-50
ids = [
15,16,17,18,19,20,21,22,23,24,
25,26,27,28,29,30,31,32,33,34,
35,36,37,38,39,40,41,42,43,44,
45,46,47,48,49,50,51,52,53,54,
55,56,57,58,59,60,61,62,63,64
]
# ids = [
# 15,16,17,18,19,20,21,22,23,24,
# 25,26,27,28,29,30,31,32,33,34,
# 35,36,37,38,39,40,41,42,43,44,
# 45,46,47,48,49,50,51,52,53,54,
# 55,56,57,58,59,60,61,62,63,64
# ]
[sounds]
sound = 'sound.mp3'

View File

@ -27,6 +27,7 @@ class Asset {
this.startTime = +new Date();
this.pttEndSuccessfully = false;
this.assetProps = {};
this.murmurPassword = '';
utils.writeLog(`Creating asset ${id}`)
@ -87,6 +88,32 @@ class Asset {
// 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);
@ -195,6 +222,7 @@ class Asset {
}
_connectToMurmur(callback) {
this.configs.murmurPassword = this.murmurPassword;
this.mumble = new Mumble(this.id, this.configs, (err) => {
if (err) {
@ -223,9 +251,13 @@ class Asset {
utils.writeLog(`Asset ${this.id} audio registered`);
return callback();
} else {
utils.writeLog(`Asset ${this.id} audio registered error`, error);
utils.writeErrorLog(`ERROR_API`);
return callback(error);
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);
}
}
);
@ -262,13 +294,13 @@ class Asset {
return callback('Cannot send group-monitoring: Hub not connected');
}
} else {
console.log('ssssss1--------------------')
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_API`);
// return callback(error);
}
}
);

View File

@ -12,12 +12,12 @@ const OpusEncoder = require('node-opus').OpusEncoder;
class Mumble {
constructor(id, configs, connectedCallback) {
console.log('------', configs)
this.id = id;
this.configs = configs;
let mumble = configs.mumble;
this._createCertificatesForUser(id, () => {
this._makeMumbleConnection(id, mumble.port, mumble.host, id, id, connectedCallback);
this._makeMumbleConnection(id, mumble.port, mumble.host, id, this.configs.murmurPassword, connectedCallback);
})
}
@ -87,7 +87,7 @@ class Mumble {
// Connect to mumble server.
this.client = new MumbleClient({
username: '' + username,
password: '' + password,
password,
codecs: NodeCodecs
});
this.client.connectDataStream(this.socket);