mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
code cleanup
This commit is contained in:
parent
19cd2959c9
commit
da535d6636
|
@ -5,23 +5,19 @@ var config = require('./config.json');
|
||||||
var daemon = new net.Socket();
|
var daemon = new net.Socket();
|
||||||
var msg = ''; // Current message, per connection.
|
var msg = ''; // Current message, per connection.
|
||||||
|
|
||||||
const { ipcRenderer } = require('electron');
|
const {
|
||||||
|
ipcRenderer
|
||||||
|
} = require('electron');
|
||||||
|
|
||||||
|
|
||||||
setTimeout(connectDAEMON, 500)
|
setTimeout(connectDAEMON, 500)
|
||||||
|
|
||||||
function connectDAEMON(){
|
function connectDAEMON() {
|
||||||
|
|
||||||
console.log('connecting to DAEMON...')
|
console.log('connecting to DAEMON...')
|
||||||
|
|
||||||
//clear message buffer after reconnecting or inital connection
|
//clear message buffer after reconnecting or inital connection
|
||||||
msg = '';
|
msg = '';
|
||||||
|
|
||||||
//daemon_host = document.getElementById("daemon_adress").value
|
|
||||||
//daemon_port = document.getElementById("daemon_port").value
|
|
||||||
//daemon_host = '192.168.178.163'
|
|
||||||
//daemon_port = 3001
|
|
||||||
|
|
||||||
daemon.connect(config.daemon_port, config.daemon_host)
|
daemon.connect(config.daemon_port, config.daemon_host)
|
||||||
//client.setTimeout(5000);
|
//client.setTimeout(5000);
|
||||||
}
|
}
|
||||||
|
@ -49,22 +45,22 @@ daemon.on('end', function(data) {
|
||||||
|
|
||||||
|
|
||||||
//exports.writeCommand = function(command){
|
//exports.writeCommand = function(command){
|
||||||
writeDaemonCommand = function(command){
|
writeDaemonCommand = function(command) {
|
||||||
|
|
||||||
|
|
||||||
// we use the writingCommand function to update our TCPIP state because we are calling this function a lot
|
// we use the writingCommand function to update our TCPIP state because we are calling this function a lot
|
||||||
// if socket openend, we are able to run commands
|
// if socket openend, we are able to run commands
|
||||||
if(daemon.readyState == 'open'){
|
if (daemon.readyState == 'open') {
|
||||||
//uiMain.setDAEMONconnection('open')
|
//uiMain.setDAEMONconnection('open')
|
||||||
console.log(command)
|
console.log(command)
|
||||||
daemon.write(command + '\n');
|
daemon.write(command + '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(daemon.readyState == 'closed'){
|
if (daemon.readyState == 'closed') {
|
||||||
//uiMain.setDAEMONconnection('closed')
|
//uiMain.setDAEMONconnection('closed')
|
||||||
}
|
}
|
||||||
|
|
||||||
if(daemon.readyState == 'opening'){
|
if (daemon.readyState == 'opening') {
|
||||||
//uiMain.setDAEMONconnection('opening')
|
//uiMain.setDAEMONconnection('opening')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,9 +71,7 @@ writeDaemonCommand = function(command){
|
||||||
ipcRenderer.send('request-update-daemon-connection', Data);
|
ipcRenderer.send('request-update-daemon-connection', Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "https://stackoverflow.com/questions/9070700/nodejs-net-createserver-large-amount-of-data-coming-in"
|
||||||
|
|
||||||
// "https://stackoverflow.com/questions/9070700/nodejs-net-createserver-large-amount-of-data-coming-in"
|
|
||||||
|
|
||||||
|
|
||||||
daemon.on('data', function(data) {
|
daemon.on('data', function(data) {
|
||||||
|
@ -99,7 +93,7 @@ daemon.on('data', function(data) {
|
||||||
msg = '';
|
msg = '';
|
||||||
/*console.log("EOF detected!")*/
|
/*console.log("EOF detected!")*/
|
||||||
|
|
||||||
if(data['COMMAND'] == 'DAEMON_STATE'){
|
if (data['COMMAND'] == 'DAEMON_STATE') {
|
||||||
let Data = {
|
let Data = {
|
||||||
input_devices: data['INPUT_DEVICES'],
|
input_devices: data['INPUT_DEVICES'],
|
||||||
output_devices: data['OUTPUT_DEVICES'],
|
output_devices: data['OUTPUT_DEVICES'],
|
||||||
|
@ -108,22 +102,9 @@ daemon.on('data', function(data) {
|
||||||
};
|
};
|
||||||
ipcRenderer.send('request-update-daemon-state', Data);
|
ipcRenderer.send('request-update-daemon-state', Data);
|
||||||
|
|
||||||
|
|
||||||
//input_devices = data['INPUT_DEVICES']
|
|
||||||
//uiMain.updateAudioInput(input_devices)
|
|
||||||
|
|
||||||
//output_devices = data['OUTPUT_DEVICES']
|
|
||||||
//uiMain.updateAudioOutput(output_devices)
|
|
||||||
|
|
||||||
//daemon_state = data['DAEMON_STATE'][0]['STATUS']
|
|
||||||
//uiMain.updateTncRunningState(daemon_state)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////// check if EOF ...
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////// check if EOF ...
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,13 +117,8 @@ function hexToBytes(hex) {
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.getDaemonState = function() {
|
||||||
|
//function getDaemonState(){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
exports.getDaemonState = function(){
|
|
||||||
//function getDaemonState(){
|
|
||||||
command = '{"type" : "GET", "command": "DAEMON_STATE"}'
|
command = '{"type" : "GET", "command": "DAEMON_STATE"}'
|
||||||
writeDaemonCommand(command)
|
writeDaemonCommand(command)
|
||||||
}
|
}
|
||||||
|
@ -150,19 +126,11 @@ function hexToBytes(hex) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// START TNC
|
// START TNC
|
||||||
// ` `== multi line string
|
// ` `== multi line string
|
||||||
|
|
||||||
|
|
||||||
exports.startTNC = function(rx_audio, tx_audio, deviceid, deviceport, ptt){
|
exports.startTNC = function(rx_audio, tx_audio, deviceid, deviceport, ptt) {
|
||||||
var json_command = JSON.stringify({
|
var json_command = JSON.stringify({
|
||||||
type: 'SET',
|
type: 'SET',
|
||||||
command: 'STARTTNC',
|
command: 'STARTTNC',
|
||||||
|
@ -184,13 +152,7 @@ exports.startTNC = function(rx_audio, tx_audio, deviceid, deviceport, ptt){
|
||||||
}
|
}
|
||||||
|
|
||||||
// STOP TNC
|
// STOP TNC
|
||||||
exports.stopTNC = function(){
|
exports.stopTNC = function() {
|
||||||
command = '{"type" : "SET", "command": "STOPTNC" , "parameter": "---" }'
|
command = '{"type" : "SET", "command": "STOPTNC" , "parameter": "---" }'
|
||||||
writeDaemonCommand(command)
|
writeDaemonCommand(command)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
113
gui/main.js
113
gui/main.js
|
@ -1,24 +1,14 @@
|
||||||
const { app, BrowserWindow, ipcMain } = require('electron')
|
const {app,BrowserWindow,ipcMain} = require('electron')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
var config = require('./config.json');
|
var config = require('./config.json');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let win = null;
|
let win = null;
|
||||||
let data = null;
|
let data = null;
|
||||||
|
|
||||||
|
function createWindow() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function createWindow () {
|
|
||||||
|
|
||||||
|
|
||||||
win = new BrowserWindow({
|
win = new BrowserWindow({
|
||||||
width: 1220,
|
width: 1220,
|
||||||
height: 900,
|
height: 920,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
//preload: path.join(__dirname, 'preload-main.js'),
|
//preload: path.join(__dirname, 'preload-main.js'),
|
||||||
preload: require.resolve('./preload-main.js'),
|
preload: require.resolve('./preload-main.js'),
|
||||||
|
@ -29,13 +19,10 @@ function createWindow () {
|
||||||
})
|
})
|
||||||
//open dev tools
|
//open dev tools
|
||||||
win.webContents.openDevTools({
|
win.webContents.openDevTools({
|
||||||
mode : 'undocked',
|
mode: 'undocked',
|
||||||
activate: true,
|
activate: true,
|
||||||
})
|
})
|
||||||
win.loadFile('src/index.html')
|
win.loadFile('src/index.html')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
data = new BrowserWindow({
|
data = new BrowserWindow({
|
||||||
height: 900,
|
height: 900,
|
||||||
width: 600,
|
width: 600,
|
||||||
|
@ -48,20 +35,15 @@ function createWindow () {
|
||||||
})
|
})
|
||||||
//open dev tools
|
//open dev tools
|
||||||
data.webContents.openDevTools({
|
data.webContents.openDevTools({
|
||||||
mode : 'undocked',
|
mode: 'undocked',
|
||||||
activate: true,
|
activate: true,
|
||||||
})
|
})
|
||||||
data.loadFile('src/data-module.html')
|
data.loadFile('src/data-module.html')
|
||||||
data.hide()
|
data.hide()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Emitted when the window is closed.
|
// Emitted when the window is closed.
|
||||||
win.on('closed', function () {
|
win.on('closed', function() {
|
||||||
// Dereference the window object, usually you would store windows
|
// Dereference the window object, usually you would store windows
|
||||||
// in an array if your app supports multi windows, this is the time
|
// in an array if your app supports multi windows, this is the time
|
||||||
// when you should delete the corresponding element.
|
// when you should delete the corresponding element.
|
||||||
|
@ -69,37 +51,23 @@ function createWindow () {
|
||||||
data = null;
|
data = null;
|
||||||
})
|
})
|
||||||
|
|
||||||
/*
|
/*
|
||||||
data.on('closed', function () {
|
data.on('closed', function () {
|
||||||
// Dereference the window object, usually you would store windows
|
// Dereference the window object, usually you would store windows
|
||||||
// in an array if your app supports multi windows, this is the time
|
// in an array if your app supports multi windows, this is the time
|
||||||
// when you should delete the corresponding element.
|
// when you should delete the corresponding element.
|
||||||
})
|
})
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// https://stackoverflow.com/questions/44258831/only-hide-the-window-when-closing-it-electron
|
// https://stackoverflow.com/questions/44258831/only-hide-the-window-when-closing-it-electron
|
||||||
data.on('close', function (evt) {
|
data.on('close', function(evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
data.hide()
|
data.hide()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
createWindow()
|
createWindow()
|
||||||
|
|
||||||
|
@ -118,22 +86,11 @@ app.on('window-all-closed', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// IPC HANDLER
|
// IPC HANDLER
|
||||||
ipcMain.on('show-data-window', (event, arg) => {
|
ipcMain.on('show-data-window', (event, arg) => {
|
||||||
data.show()
|
data.show()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
ipcMain.on('request-update-tnc-state', (event, arg) => {
|
ipcMain.on('request-update-tnc-state', (event, arg) => {
|
||||||
win.webContents.send('action-update-tnc-state', arg);
|
win.webContents.send('action-update-tnc-state', arg);
|
||||||
data.webContents.send('action-update-tnc-state', arg);
|
data.webContents.send('action-update-tnc-state', arg);
|
||||||
|
@ -158,49 +115,5 @@ ipcMain.on('request-update-daemon-connection', (event, arg) => {
|
||||||
|
|
||||||
ipcMain.on('run-tnc-command', (event, arg) => {
|
ipcMain.on('run-tnc-command', (event, arg) => {
|
||||||
win.webContents.send('run-tnc-command', arg);
|
win.webContents.send('run-tnc-command', arg);
|
||||||
|
|
||||||
/*
|
|
||||||
if (arg.command == 'saveMyCall'){
|
|
||||||
sock.saveMyCall(arg.callsign)
|
|
||||||
}
|
|
||||||
if (arg.command == 'saveMyGrid'){
|
|
||||||
sock.saveMyGrid(arg.grid)
|
|
||||||
}
|
|
||||||
if (arg.command == 'ping'){
|
|
||||||
sock.sendPing(arg.dxcallsign)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
ipcMain.on('run-daemon-command', (event, arg) => {
|
|
||||||
win.webContents.send('run-daemon-command', arg);
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
if (arg.command == 'startTNC'){
|
|
||||||
daemon.startTNC(arg.rx_audio, arg.tx_audio, arg.deviceid, arg.deviceport, arg.ptt)
|
|
||||||
|
|
||||||
}
|
|
||||||
if (arg.command == 'stopTNC'){
|
|
||||||
daemon.stopTNC()
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
//setInterval(sock.getTncState, 500)
|
|
||||||
//setInterval(daemon.getDaemonState, 500)
|
|
||||||
/*
|
|
||||||
setInterval(function(){
|
|
||||||
sock.getTncState();
|
|
||||||
}, 1000);
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
setInterval(function(){
|
|
||||||
daemon.getDaemonState();
|
|
||||||
}, 1000);
|
|
||||||
*/
|
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
|
const {
|
||||||
const { ipcRenderer } = require('electron');
|
ipcRenderer
|
||||||
|
} = require('electron');
|
||||||
var config = require('./config.json');
|
var config = require('./config.json');
|
||||||
|
|
||||||
//const sock = require('./sock.js')
|
|
||||||
//const globals = require('./globals.js')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
window.addEventListener('DOMContentLoaded', () => {
|
window.addEventListener('DOMContentLoaded', () => {
|
||||||
const replaceText = (selector, text) => {
|
const replaceText = (selector, text) => {
|
||||||
const element = document.getElementById(selector)
|
const element = document.getElementById(selector)
|
||||||
|
@ -30,9 +26,6 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||||
alert("HALLO ")
|
alert("HALLO ")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,47 +33,47 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||||
|
|
||||||
ipcRenderer.on('action-update-tnc-state', (event, arg) => {
|
ipcRenderer.on('action-update-tnc-state', (event, arg) => {
|
||||||
|
|
||||||
// PTT STATE
|
// PTT STATE
|
||||||
if(arg.ptt_state == 'True'){
|
if (arg.ptt_state == 'True') {
|
||||||
document.getElementById("ptt_state").className = "btn btn-danger";
|
document.getElementById("ptt_state").className = "btn btn-danger";
|
||||||
} else if(arg.ptt_state == 'False'){
|
} else if (arg.ptt_state == 'False') {
|
||||||
document.getElementById("ptt_state").className = "btn btn-success";
|
document.getElementById("ptt_state").className = "btn btn-success";
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("ptt_state").className = "btn btn-secondary"
|
document.getElementById("ptt_state").className = "btn btn-secondary"
|
||||||
}
|
}
|
||||||
|
|
||||||
// BUSY STATE
|
// BUSY STATE
|
||||||
if(arg.busy_state == 'BUSY'){
|
if (arg.busy_state == 'BUSY') {
|
||||||
document.getElementById("busy_state").className = "btn btn-danger";
|
document.getElementById("busy_state").className = "btn btn-danger";
|
||||||
} else if(arg.busy_state == 'IDLE'){
|
} else if (arg.busy_state == 'IDLE') {
|
||||||
document.getElementById("busy_state").className = "btn btn-success";
|
document.getElementById("busy_state").className = "btn btn-success";
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("busy_state").className = "btn btn-secondary"
|
document.getElementById("busy_state").className = "btn btn-secondary"
|
||||||
}
|
}
|
||||||
|
|
||||||
// ARQ STATE
|
// ARQ STATE
|
||||||
if(arg.arq_state == 'DATA'){
|
if (arg.arq_state == 'DATA') {
|
||||||
document.getElementById("arq_state").className = "btn btn-warning";
|
document.getElementById("arq_state").className = "btn btn-warning";
|
||||||
} else if(arg.arq_state == 'IDLE'){
|
} else if (arg.arq_state == 'IDLE') {
|
||||||
document.getElementById("arq_state").className = "btn btn-secondary";
|
document.getElementById("arq_state").className = "btn btn-secondary";
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("arq_state").className = "btn btn-secondary"
|
document.getElementById("arq_state").className = "btn btn-secondary"
|
||||||
}
|
}
|
||||||
|
|
||||||
// CHANNEL STATE
|
// CHANNEL STATE
|
||||||
if(arg.channel_state == 'RECEIVING_SIGNALLING'){
|
if (arg.channel_state == 'RECEIVING_SIGNALLING') {
|
||||||
document.getElementById("signalling_state").className = "btn btn-success";
|
document.getElementById("signalling_state").className = "btn btn-success";
|
||||||
document.getElementById("data_state").className = "btn btn-secondary";
|
document.getElementById("data_state").className = "btn btn-secondary";
|
||||||
|
|
||||||
} else if(arg.channel_state == 'SENDING_SIGNALLING'){
|
} else if (arg.channel_state == 'SENDING_SIGNALLING') {
|
||||||
document.getElementById("signalling_state").className = "btn btn-danger";
|
document.getElementById("signalling_state").className = "btn btn-danger";
|
||||||
document.getElementById("data_state").className = "btn btn-secondary";
|
document.getElementById("data_state").className = "btn btn-secondary";
|
||||||
|
|
||||||
} else if(arg.channel_state == 'RECEIVING_DATA'){
|
} else if (arg.channel_state == 'RECEIVING_DATA') {
|
||||||
document.getElementById("signalling_state").className = "btn btn-secondary";
|
document.getElementById("signalling_state").className = "btn btn-secondary";
|
||||||
document.getElementById("data_state").className = "btn btn-success";
|
document.getElementById("data_state").className = "btn btn-success";
|
||||||
|
|
||||||
} else if(arg.channel_state == 'SENDING_DATA'){
|
} else if (arg.channel_state == 'SENDING_DATA') {
|
||||||
document.getElementById("signalling_state").className = "btn btn-secondary";
|
document.getElementById("signalling_state").className = "btn btn-secondary";
|
||||||
document.getElementById("data_state").className = "btn btn-danger";
|
document.getElementById("data_state").className = "btn btn-danger";
|
||||||
} else {
|
} else {
|
||||||
|
@ -89,9 +82,9 @@ ipcRenderer.on('action-update-tnc-state', (event, arg) => {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
ipcRenderer.on('action-update-data-state', (event, arg) => {
|
ipcRenderer.on('action-update-data-state', (event, arg) => {
|
||||||
|
|
||||||
});
|
});
|
|
@ -2,19 +2,12 @@ const sock = require('./sock.js')
|
||||||
const daemon = require('./daemon.js')
|
const daemon = require('./daemon.js')
|
||||||
const configPath = './config.json'
|
const configPath = './config.json'
|
||||||
const config = require(configPath);
|
const config = require(configPath);
|
||||||
const { ipcRenderer } = require('electron');
|
const {
|
||||||
|
ipcRenderer
|
||||||
|
} = require('electron');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// START INTERVALL COMMAND EXECUTION FOR STATES
|
// START INTERVALL COMMAND EXECUTION FOR STATES
|
||||||
setInterval(daemon.getDaemonState, 1000)
|
setInterval(daemon.getDaemonState, 1000)
|
||||||
setInterval(sock.getTncState, 250)
|
setInterval(sock.getTncState, 250)
|
||||||
|
@ -22,43 +15,32 @@ setInterval(sock.getDataState, 500)
|
||||||
setInterval(sock.getHeardStations, 500)
|
setInterval(sock.getHeardStations, 500)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// UPDATE FFT DEMO
|
// UPDATE FFT DEMO
|
||||||
|
|
||||||
updateFFT = function(fft){
|
updateFFT = function(fft) {
|
||||||
var fft = Array.from({length: 2048}, () => Math.floor(Math.random() * 10));
|
var fft = Array.from({
|
||||||
|
length: 2048
|
||||||
|
}, () => Math.floor(Math.random() * 10));
|
||||||
spectrum.addData(fft);
|
spectrum.addData(fft);
|
||||||
}
|
}
|
||||||
setInterval(updateFFT, 250)
|
setInterval(updateFFT, 250)
|
||||||
|
|
||||||
|
// WINDOW LISTENER
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
window.addEventListener('DOMContentLoaded', () => {
|
window.addEventListener('DOMContentLoaded', () => {
|
||||||
// LOAD SETTINGS
|
// LOAD SETTINGS
|
||||||
document.getElementById("tnc_adress").value = config.tnc_host
|
document.getElementById("tnc_adress").value = config.tnc_host
|
||||||
document.getElementById("tnc_port").value = config.tnc_port
|
document.getElementById("tnc_port").value = config.tnc_port
|
||||||
document.getElementById("myCall").value = config.mycall
|
document.getElementById("myCall").value = config.mycall
|
||||||
document.getElementById("myGrid").value = config.mygrid
|
document.getElementById("myGrid").value = config.mygrid
|
||||||
|
|
||||||
|
// Create spectrum object on canvas with ID "waterfall"
|
||||||
|
|
||||||
|
|
||||||
// Create spectrum object on canvas with ID "waterfall"
|
|
||||||
global.spectrum = new Spectrum(
|
global.spectrum = new Spectrum(
|
||||||
"waterfall", {
|
"waterfall", {
|
||||||
spectrumPercent: 20
|
spectrumPercent: 20
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// on change port and host
|
// on change port and host
|
||||||
|
|
||||||
document.getElementById("tnc_adress").addEventListener("change", () => {
|
document.getElementById("tnc_adress").addEventListener("change", () => {
|
||||||
console.log(document.getElementById("tnc_adress").value)
|
console.log(document.getElementById("tnc_adress").value)
|
||||||
|
@ -73,31 +55,14 @@ document.getElementById("myGrid").value = config.mygrid
|
||||||
config.daemon_port = document.getElementById("tnc_port").value + 1
|
config.daemon_port = document.getElementById("tnc_port").value + 1
|
||||||
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// tnc_host = document.getElementById("tnc_adress").value
|
|
||||||
//tnc_port = document.getElementById("tnc_port").value
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// saveMyCall button clicked
|
// saveMyCall button clicked
|
||||||
document.getElementById("saveMyCall").addEventListener("click", () => {
|
document.getElementById("saveMyCall").addEventListener("click", () => {
|
||||||
callsign = document.getElementById("myCall").value
|
callsign = document.getElementById("myCall").value
|
||||||
config.mycall = callsign
|
config.mycall = callsign
|
||||||
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
||||||
|
|
||||||
sock.saveMyCall(callsign)
|
sock.saveMyCall(callsign)
|
||||||
/*
|
|
||||||
let Data = {
|
|
||||||
command: "saveMyCall",
|
|
||||||
callsign: document.getElementById("myCall").value
|
|
||||||
};
|
|
||||||
ipcRenderer.send('run-tnc-command', Data);
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// saveMyGrid button clicked
|
// saveMyGrid button clicked
|
||||||
|
@ -105,46 +70,21 @@ document.getElementById("myGrid").value = config.mygrid
|
||||||
grid = document.getElementById("myGrid").value
|
grid = document.getElementById("myGrid").value
|
||||||
config.mygrid = grid
|
config.mygrid = grid
|
||||||
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
||||||
|
|
||||||
sock.saveMyGrid(grid)
|
sock.saveMyGrid(grid)
|
||||||
/*
|
|
||||||
let Data = {
|
|
||||||
command: "saveMyGrid",
|
|
||||||
grid: document.getElementById("myGrid").value
|
|
||||||
};
|
|
||||||
ipcRenderer.send('run-tnc-command', Data);
|
|
||||||
*/
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// startPing button clicked
|
// startPing button clicked
|
||||||
document.getElementById("sendPing").addEventListener("click", () => {
|
document.getElementById("sendPing").addEventListener("click", () => {
|
||||||
dxcallsign = document.getElementById("dxCall").value
|
dxcallsign = document.getElementById("dxCall").value
|
||||||
sock.sendPing(dxcallsign)
|
sock.sendPing(dxcallsign)
|
||||||
/*
|
|
||||||
let Data = {
|
|
||||||
command: "saveMyCall",
|
|
||||||
callsign: document.getElementById("myCall").value
|
|
||||||
};
|
|
||||||
ipcRenderer.send('run-tnc-command', Data);
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// sendCQ button clicked
|
// sendCQ button clicked
|
||||||
document.getElementById("sendCQ").addEventListener("click", () => {
|
document.getElementById("sendCQ").addEventListener("click", () => {
|
||||||
sock.sendCQ()
|
sock.sendCQ()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// startTNC button clicked
|
// startTNC button clicked
|
||||||
document.getElementById("startTNC").addEventListener("click", () => {
|
document.getElementById("startTNC").addEventListener("click", () => {
|
||||||
var rx_audio = document.getElementById("audio_input_selectbox").value
|
var rx_audio = document.getElementById("audio_input_selectbox").value
|
||||||
|
@ -154,32 +94,17 @@ document.getElementById("myGrid").value = config.mygrid
|
||||||
var ptt = document.getElementById("hamlib_ptt").value
|
var ptt = document.getElementById("hamlib_ptt").value
|
||||||
|
|
||||||
daemon.startTNC(rx_audio, tx_audio, deviceid, deviceport, ptt)
|
daemon.startTNC(rx_audio, tx_audio, deviceid, deviceport, ptt)
|
||||||
setTimeout( function() { sock.saveMyCall(config.mycall); }, 5000 );
|
setTimeout(function() {
|
||||||
setTimeout( function() { sock.saveMyGrid(config.mygrid); }, 5000 );
|
sock.saveMyCall(config.mycall);
|
||||||
|
}, 5000);
|
||||||
/*
|
setTimeout(function() {
|
||||||
let Data = {
|
sock.saveMyGrid(config.mygrid);
|
||||||
command: "startTNC",
|
}, 5000);
|
||||||
rx_audio : document.getElementById("audio_input_selectbox").value,
|
|
||||||
tx_audio : document.getElementById("audio_output_selectbox").value,
|
|
||||||
deviceid : document.getElementById("hamlib_deviceid").value,
|
|
||||||
deviceport : document.getElementById("hamlib_deviceport").value,
|
|
||||||
ptt : document.getElementById("hamlib_ptt").value,
|
|
||||||
};
|
|
||||||
ipcRenderer.send('run-daemon-command', Data);
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// stopTNC button clicked
|
// stopTNC button clicked
|
||||||
document.getElementById("stopTNC").addEventListener("click", () => {
|
document.getElementById("stopTNC").addEventListener("click", () => {
|
||||||
daemon.stopTNC()
|
daemon.stopTNC()
|
||||||
/* let Data = {
|
|
||||||
command: "stopTNC",
|
|
||||||
};
|
|
||||||
ipcRenderer.send('run-daemon-command', Data);
|
|
||||||
*/
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// openDataModule button clicked
|
// openDataModule button clicked
|
||||||
|
@ -190,69 +115,57 @@ document.getElementById("myGrid").value = config.mygrid
|
||||||
};
|
};
|
||||||
ipcRenderer.send('show-data-window', Data);
|
ipcRenderer.send('show-data-window', Data);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ipcRenderer.on('action-update-tnc-state', (event, arg) => {
|
ipcRenderer.on('action-update-tnc-state', (event, arg) => {
|
||||||
|
|
||||||
// PTT STATE
|
// PTT STATE
|
||||||
if(arg.ptt_state == 'True'){
|
if (arg.ptt_state == 'True') {
|
||||||
document.getElementById("ptt_state").className = "btn btn-danger";
|
document.getElementById("ptt_state").className = "btn btn-danger";
|
||||||
console.log("PTT TRUE!!!")
|
console.log("PTT TRUE!!!")
|
||||||
|
|
||||||
} else if(arg.ptt_state == 'False'){
|
} else if (arg.ptt_state == 'False') {
|
||||||
document.getElementById("ptt_state").className = "btn btn-success";
|
document.getElementById("ptt_state").className = "btn btn-success";
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("ptt_state").className = "btn btn-secondary"
|
document.getElementById("ptt_state").className = "btn btn-secondary"
|
||||||
}
|
}
|
||||||
|
|
||||||
// BUSY STATE
|
// BUSY STATE
|
||||||
if(arg.busy_state == 'BUSY'){
|
if (arg.busy_state == 'BUSY') {
|
||||||
document.getElementById("busy_state").className = "btn btn-danger";
|
document.getElementById("busy_state").className = "btn btn-danger";
|
||||||
} else if(arg.busy_state == 'IDLE'){
|
} else if (arg.busy_state == 'IDLE') {
|
||||||
document.getElementById("busy_state").className = "btn btn-success";
|
document.getElementById("busy_state").className = "btn btn-success";
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("busy_state").className = "btn btn-secondary"
|
document.getElementById("busy_state").className = "btn btn-secondary"
|
||||||
}
|
}
|
||||||
|
|
||||||
// ARQ STATE
|
// ARQ STATE
|
||||||
if(arg.arq_state == 'DATA'){
|
if (arg.arq_state == 'DATA') {
|
||||||
document.getElementById("arq_state").className = "btn btn-warning";
|
document.getElementById("arq_state").className = "btn btn-warning";
|
||||||
} else if(arg.arq_state == 'IDLE'){
|
} else if (arg.arq_state == 'IDLE') {
|
||||||
document.getElementById("arq_state").className = "btn btn-secondary";
|
document.getElementById("arq_state").className = "btn btn-secondary";
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("arq_state").className = "btn btn-secondary"
|
document.getElementById("arq_state").className = "btn btn-secondary"
|
||||||
}
|
}
|
||||||
|
|
||||||
// RMS
|
// RMS
|
||||||
document.getElementById("rms_level").setAttribute("aria-valuenow", arg.rms_level)
|
document.getElementById("rms_level").setAttribute("aria-valuenow", arg.rms_level)
|
||||||
document.getElementById("rms_level").setAttribute("style", "width:" + arg.rms_level + "%;")
|
document.getElementById("rms_level").setAttribute("style", "width:" + arg.rms_level + "%;")
|
||||||
|
|
||||||
// CHANNEL STATE
|
// CHANNEL STATE
|
||||||
if(arg.channel_state == 'RECEIVING_SIGNALLING'){
|
if (arg.channel_state == 'RECEIVING_SIGNALLING') {
|
||||||
document.getElementById("signalling_state").className = "btn btn-success";
|
document.getElementById("signalling_state").className = "btn btn-success";
|
||||||
document.getElementById("data_state").className = "btn btn-secondary";
|
document.getElementById("data_state").className = "btn btn-secondary";
|
||||||
|
|
||||||
} else if(arg.channel_state == 'SENDING_SIGNALLING'){
|
} else if (arg.channel_state == 'SENDING_SIGNALLING') {
|
||||||
document.getElementById("signalling_state").className = "btn btn-danger";
|
document.getElementById("signalling_state").className = "btn btn-danger";
|
||||||
document.getElementById("data_state").className = "btn btn-secondary";
|
document.getElementById("data_state").className = "btn btn-secondary";
|
||||||
|
|
||||||
} else if(arg.channel_state == 'RECEIVING_DATA'){
|
} else if (arg.channel_state == 'RECEIVING_DATA') {
|
||||||
document.getElementById("signalling_state").className = "btn btn-secondary";
|
document.getElementById("signalling_state").className = "btn btn-secondary";
|
||||||
document.getElementById("data_state").className = "btn btn-success";
|
document.getElementById("data_state").className = "btn btn-success";
|
||||||
|
|
||||||
} else if(arg.channel_state == 'SENDING_DATA'){
|
} else if (arg.channel_state == 'SENDING_DATA') {
|
||||||
document.getElementById("signalling_state").className = "btn btn-secondary";
|
document.getElementById("signalling_state").className = "btn btn-secondary";
|
||||||
document.getElementById("data_state").className = "btn btn-danger";
|
document.getElementById("data_state").className = "btn btn-danger";
|
||||||
} else {
|
} else {
|
||||||
|
@ -261,23 +174,23 @@ ipcRenderer.on('action-update-tnc-state', (event, arg) => {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SET FREQUENCY
|
// SET FREQUENCY
|
||||||
document.getElementById("frequency").value = arg.frequency
|
document.getElementById("frequency").value = arg.frequency
|
||||||
|
|
||||||
// SET MODE
|
// SET MODE
|
||||||
document.getElementById("mode").value = arg.mode
|
document.getElementById("mode").value = arg.mode
|
||||||
|
|
||||||
// SET BANDWITH
|
// SET BANDWITH
|
||||||
document.getElementById("bandwith").value = arg.bandwith
|
document.getElementById("bandwith").value = arg.bandwith
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ipcRenderer.on('action-update-daemon-state', (event, arg) => {
|
ipcRenderer.on('action-update-daemon-state', (event, arg) => {
|
||||||
// UPDATE AUDIO INPUT
|
// UPDATE AUDIO INPUT
|
||||||
|
|
||||||
if(document.getElementById("audio_input_selectbox").length != arg.input_devices.length){
|
if (document.getElementById("audio_input_selectbox").length != arg.input_devices.length) {
|
||||||
document.getElementById("audio_input_selectbox").innerHTML = ""
|
document.getElementById("audio_input_selectbox").innerHTML = ""
|
||||||
for (i = 0; i < arg.input_devices.length; i++) {
|
for (i = 0; i < arg.input_devices.length; i++) {
|
||||||
var option = document.createElement("option");
|
var option = document.createElement("option");
|
||||||
|
@ -289,7 +202,7 @@ ipcRenderer.on('action-update-daemon-state', (event, arg) => {
|
||||||
}
|
}
|
||||||
// UPDATE AUDIO OUTPUT
|
// UPDATE AUDIO OUTPUT
|
||||||
|
|
||||||
if(document.getElementById("audio_output_selectbox").length != arg.output_devices.length){
|
if (document.getElementById("audio_output_selectbox").length != arg.output_devices.length) {
|
||||||
document.getElementById("audio_output_selectbox").innerHTML = ""
|
document.getElementById("audio_output_selectbox").innerHTML = ""
|
||||||
for (i = 0; i < arg.output_devices.length; i++) {
|
for (i = 0; i < arg.output_devices.length; i++) {
|
||||||
var option = document.createElement("option");
|
var option = document.createElement("option");
|
||||||
|
@ -299,9 +212,9 @@ ipcRenderer.on('action-update-daemon-state', (event, arg) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TNC RUNNING STATE
|
// TNC RUNNING STATE
|
||||||
document.getElementById("tnc_running_state").innerHTML = arg.tnc_running_state;
|
document.getElementById("tnc_running_state").innerHTML = arg.tnc_running_state;
|
||||||
if(arg.tnc_running_state == "running"){
|
if (arg.tnc_running_state == "running") {
|
||||||
document.getElementById('hamlib_deviceid').disabled = true
|
document.getElementById('hamlib_deviceid').disabled = true
|
||||||
document.getElementById('hamlib_deviceport').disabled = true
|
document.getElementById('hamlib_deviceport').disabled = true
|
||||||
document.getElementById('hamlib_ptt').disabled = true
|
document.getElementById('hamlib_ptt').disabled = true
|
||||||
|
@ -328,55 +241,32 @@ document.getElementById("tnc_running_state").innerHTML = arg.tnc_running_state;
|
||||||
document.getElementById('saveMyGrid').disabled = true
|
document.getElementById('saveMyGrid').disabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
});
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
ipcRenderer.on('action-update-daemon-connection', (event, arg) => {
|
ipcRenderer.on('action-update-daemon-connection', (event, arg) => {
|
||||||
|
|
||||||
|
if (arg.daemon_connection == 'open') {
|
||||||
if(arg.daemon_connection == 'open'){
|
|
||||||
document.getElementById("daemon_connection_state").className = "btn btn-success";
|
document.getElementById("daemon_connection_state").className = "btn btn-success";
|
||||||
}
|
}
|
||||||
if(arg.daemon_connection == 'opening'){
|
if (arg.daemon_connection == 'opening') {
|
||||||
document.getElementById("daemon_connection_state").className = "btn btn-warning";
|
document.getElementById("daemon_connection_state").className = "btn btn-warning";
|
||||||
}
|
}
|
||||||
if(arg.daemon_connection == 'closed'){
|
if (arg.daemon_connection == 'closed') {
|
||||||
document.getElementById("daemon_connection_state").className = "btn btn-danger";
|
document.getElementById("daemon_connection_state").className = "btn btn-danger";
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
ipcRenderer.on('run-tnc-command', (event, arg) => {
|
||||||
|
if (arg.command == 'saveMyCall') {
|
||||||
|
|
||||||
ipcRenderer.on('run-tnc-command', (event, arg) => {
|
|
||||||
if (arg.command == 'saveMyCall'){
|
|
||||||
sock.saveMyCall(arg.callsign)
|
sock.saveMyCall(arg.callsign)
|
||||||
}
|
}
|
||||||
if (arg.command == 'saveMyGrid'){
|
if (arg.command == 'saveMyGrid') {
|
||||||
sock.saveMyGrid(arg.grid)
|
sock.saveMyGrid(arg.grid)
|
||||||
}
|
}
|
||||||
if (arg.command == 'ping'){
|
if (arg.command == 'ping') {
|
||||||
sock.sendPing(arg.dxcallsign)
|
sock.sendPing(arg.dxcallsign)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
ipcRenderer.on('run-daemon-command', (event, arg) => {
|
|
||||||
if (arg.command == 'startTNC'){
|
|
||||||
daemon.startTNC(arg.rx_audio, arg.tx_audio, arg.deviceid, arg.deviceport, arg.ptt)
|
|
||||||
|
|
||||||
}
|
|
||||||
if (arg.command == 'stopTNC'){
|
|
||||||
daemon.stopTNC()
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
95
gui/sock.js
95
gui/sock.js
|
@ -1,31 +1,21 @@
|
||||||
var net = require('net');
|
var net = require('net');
|
||||||
var config = require('./config.json');
|
var config = require('./config.json');
|
||||||
|
const {
|
||||||
|
ipcRenderer
|
||||||
|
} = require('electron');
|
||||||
|
|
||||||
const { ipcRenderer } = require('electron');
|
|
||||||
|
|
||||||
//var client = new net.Socket();
|
|
||||||
var client = new net.Socket();
|
var client = new net.Socket();
|
||||||
var msg = ''; // Current message, per connection.
|
var msg = ''; // Current message, per connection.
|
||||||
|
|
||||||
setTimeout(connectTNC, 3000)
|
setTimeout(connectTNC, 3000)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function connectTNC(){
|
|
||||||
//exports.connectTNC = function(){
|
|
||||||
|
|
||||||
|
function connectTNC() {
|
||||||
|
//exports.connectTNC = function(){
|
||||||
console.log('connecting to TNC...')
|
console.log('connecting to TNC...')
|
||||||
|
|
||||||
//clear message buffer after reconnecting or inital connection
|
//clear message buffer after reconnecting or inital connection
|
||||||
msg = '';
|
msg = '';
|
||||||
|
|
||||||
console.log(exports)
|
|
||||||
|
|
||||||
//tnc_host = '192.168.178.163'
|
|
||||||
//tnc_port = 3000
|
|
||||||
client.connect(config.tnc_port, config.tnc_host)
|
client.connect(config.tnc_port, config.tnc_host)
|
||||||
//client.setTimeout(5000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
client.on('connect', function(data) {
|
client.on('connect', function(data) {
|
||||||
|
@ -40,10 +30,10 @@ client.on('error', function(data) {
|
||||||
busy_state: "-",
|
busy_state: "-",
|
||||||
arq_state: "-",
|
arq_state: "-",
|
||||||
channel_state: "-",
|
channel_state: "-",
|
||||||
frequency : "-",
|
frequency: "-",
|
||||||
mode: "-",
|
mode: "-",
|
||||||
bandwith: "-",
|
bandwith: "-",
|
||||||
rms_level : 0
|
rms_level: 0
|
||||||
|
|
||||||
};
|
};
|
||||||
ipcRenderer.send('request-update-tnc-state', Data);
|
ipcRenderer.send('request-update-tnc-state', Data);
|
||||||
|
@ -71,25 +61,24 @@ client.on('end', function(data) {
|
||||||
|
|
||||||
|
|
||||||
//exports.writeTncCommand = function(command){
|
//exports.writeTncCommand = function(command){
|
||||||
writeTncCommand = function(command){
|
writeTncCommand = function(command) {
|
||||||
|
|
||||||
console.log(command)
|
console.log(command)
|
||||||
// we use the writingCommand function to update our TCPIP state because we are calling this function a lot
|
// we use the writingCommand function to update our TCPIP state because we are calling this function a lot
|
||||||
// if socket openend, we are able to run commands
|
// if socket openend, we are able to run commands
|
||||||
if(client.readyState == 'open'){
|
if (client.readyState == 'open') {
|
||||||
//uiMain.setTNCconnection('open')
|
//uiMain.setTNCconnection('open')
|
||||||
client.write(command + '\n');
|
client.write(command + '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(client.readyState == 'closed'){
|
if (client.readyState == 'closed') {
|
||||||
//uiMain.setTNCconnection('closed')
|
//uiMain.setTNCconnection('closed')
|
||||||
console.log("CLOSED!!!!!")
|
console.log("CLOSED!!!!!")
|
||||||
}
|
}
|
||||||
|
|
||||||
if(client.readyState == 'opening'){
|
if (client.readyState == 'opening') {
|
||||||
//uiMain.setTNCconnection('opening')
|
//uiMain.setTNCconnection('opening')
|
||||||
console.log("OPENING!!!!!")
|
console.log("OPENING!!!!!")
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,29 +86,13 @@ client.on('end', function(data) {
|
||||||
|
|
||||||
client.on('data', function(data) {
|
client.on('data', function(data) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
stackoverflow.com questions 9070700 nodejs-net-createserver-large-amount-of-data-coming-in
|
stackoverflow.com questions 9070700 nodejs-net-createserver-large-amount-of-data-coming-in
|
||||||
*/
|
*/
|
||||||
|
|
||||||
data = data.toString('utf8'); // convert data to string
|
data = data.toString('utf8'); // convert data to string
|
||||||
msg += data.toString('utf8'); // append data to buffer so we can stick long data together
|
msg += data.toString('utf8'); // append data to buffer so we can stick long data together
|
||||||
|
|
||||||
/*
|
|
||||||
if (msg.charCodeAt(msg.length - 1) == 0) {
|
|
||||||
client.emit('message', msg.substring(0, msg.length - 1));
|
|
||||||
msg = '';
|
|
||||||
console.log("END OF FILE")
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (msg.startsWith('{"COMMAND":')) {
|
|
||||||
msg = '';
|
|
||||||
msg += data.toString('utf8');
|
|
||||||
console.log("BOF detected!")
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// check if we reached an EOF, if true, clear buffer and parse JSON data
|
// check if we reached an EOF, if true, clear buffer and parse JSON data
|
||||||
if (data.endsWith('}')) {
|
if (data.endsWith('}')) {
|
||||||
//console.log(msg)
|
//console.log(msg)
|
||||||
|
@ -133,32 +106,29 @@ stackoverflow.com questions 9070700 nodejs-net-createserver-large-amount-of-data
|
||||||
/* console.log("EOF detected!") */
|
/* console.log("EOF detected!") */
|
||||||
|
|
||||||
|
|
||||||
|
if (data['COMMAND'] == 'TNC_STATE') {
|
||||||
|
|
||||||
|
|
||||||
if(data['COMMAND'] == 'TNC_STATE'){
|
|
||||||
let Data = {
|
let Data = {
|
||||||
ptt_state: data['PTT_STATE'],
|
ptt_state: data['PTT_STATE'],
|
||||||
busy_state: data['TNC_STATE'],
|
busy_state: data['TNC_STATE'],
|
||||||
arq_state: data['ARQ_STATE'],
|
arq_state: data['ARQ_STATE'],
|
||||||
channel_state: data['CHANNEL_STATE'],
|
channel_state: data['CHANNEL_STATE'],
|
||||||
frequency : data['FREQUENCY'],
|
frequency: data['FREQUENCY'],
|
||||||
mode: data['MODE'],
|
mode: data['MODE'],
|
||||||
bandwith: data['BANDWITH'],
|
bandwith: data['BANDWITH'],
|
||||||
rms_level : (data['AUDIO_RMS']/1000)*100
|
rms_level: (data['AUDIO_RMS'] / 1000) * 100
|
||||||
};
|
};
|
||||||
console.log(Data)
|
console.log(Data)
|
||||||
ipcRenderer.send('request-update-tnc-state', Data);
|
ipcRenderer.send('request-update-tnc-state', Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data['COMMAND'] == 'DATA_STATE'){
|
if (data['COMMAND'] == 'DATA_STATE') {
|
||||||
let Data = {
|
let Data = {
|
||||||
rx_buffer_length: data['RX_BUFFER_LENGTH'],
|
rx_buffer_length: data['RX_BUFFER_LENGTH'],
|
||||||
tx_n_max_retries: data['TX_N_MAX_RETRIES'],
|
tx_n_max_retries: data['TX_N_MAX_RETRIES'],
|
||||||
arq_tx_n_frames_per_burst: data['ARQ_TX_N_FRAMES_PER_BURST'],
|
arq_tx_n_frames_per_burst: data['ARQ_TX_N_FRAMES_PER_BURST'],
|
||||||
arq_tx_n_bursts: data['ARQ_TX_N_BURSTS'],
|
arq_tx_n_bursts: data['ARQ_TX_N_BURSTS'],
|
||||||
arq_tx_n_current_arq_frame: data['ARQ_TX_N_CURRENT_ARQ_FRAME'],
|
arq_tx_n_current_arq_frame: data['ARQ_TX_N_CURRENT_ARQ_FRAME'],
|
||||||
arq_tx_n_total_arq_frames : data['ARQ_TX_N_TOTAL_ARQ_FRAMES'],
|
arq_tx_n_total_arq_frames: data['ARQ_TX_N_TOTAL_ARQ_FRAMES'],
|
||||||
arq_rx_frame_n_bursts: data['ARQ_RX_FRAME_N_BURSTS'],
|
arq_rx_frame_n_bursts: data['ARQ_RX_FRAME_N_BURSTS'],
|
||||||
arq_rx_n_current_arq_frame: data['ARQ_RX_N_CURRENT_ARQ_FRAME'],
|
arq_rx_n_current_arq_frame: data['ARQ_RX_N_CURRENT_ARQ_FRAME'],
|
||||||
arq_n_arq_frames_per_data_frame: data['ARQ_N_ARQ_FRAMES_PER_DATA_FRAME'],
|
arq_n_arq_frames_per_data_frame: data['ARQ_N_ARQ_FRAMES_PER_DATA_FRAME'],
|
||||||
|
@ -167,7 +137,7 @@ stackoverflow.com questions 9070700 nodejs-net-createserver-large-amount-of-data
|
||||||
ipcRenderer.send('request-update-data-state', Data);
|
ipcRenderer.send('request-update-data-state', Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data['COMMAND'] == 'HEARD_STATIONS'){
|
if (data['COMMAND'] == 'HEARD_STATIONS') {
|
||||||
let Data = {
|
let Data = {
|
||||||
dxcallsign: data['DXCALLSIGN'],
|
dxcallsign: data['DXCALLSIGN'],
|
||||||
dxgrid: data['DXGRID'],
|
dxgrid: data['DXGRID'],
|
||||||
|
@ -179,7 +149,6 @@ stackoverflow.com questions 9070700 nodejs-net-createserver-large-amount-of-data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// check if EOF ...
|
// check if EOF ...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,49 +165,45 @@ function hexToBytes(hex) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Save myCall
|
//Save myCall
|
||||||
exports.saveMyCall = function(callsign){
|
exports.saveMyCall = function(callsign) {
|
||||||
command = '{"type" : "SET", "command": "MYCALLSIGN" , "parameter": "'+ callsign +'" }'
|
command = '{"type" : "SET", "command": "MYCALLSIGN" , "parameter": "' + callsign + '" }'
|
||||||
writeTncCommand(command)
|
writeTncCommand(command)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save myGrid
|
// Save myGrid
|
||||||
exports.saveMyGrid = function(grid){
|
exports.saveMyGrid = function(grid) {
|
||||||
command = '{"type" : "SET", "command": "MYGRID" , "parameter": "'+ grid +'" }'
|
command = '{"type" : "SET", "command": "MYGRID" , "parameter": "' + grid + '" }'
|
||||||
writeTncCommand(command)
|
writeTncCommand(command)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get TNC State
|
//Get TNC State
|
||||||
exports.getTncState = function(){
|
exports.getTncState = function() {
|
||||||
command = '{"type" : "GET", "command": "TNC_STATE"}';
|
command = '{"type" : "GET", "command": "TNC_STATE"}';
|
||||||
writeTncCommand(command)
|
writeTncCommand(command)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get DATA State
|
//Get DATA State
|
||||||
exports.getDataState = function(){
|
exports.getDataState = function() {
|
||||||
command = '{"type" : "GET", "command": "DATA_STATE"}';
|
command = '{"type" : "GET", "command": "DATA_STATE"}';
|
||||||
writeTncCommand(command)
|
writeTncCommand(command)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get Heard Stations
|
//Get Heard Stations
|
||||||
exports.getHeardStations = function(){
|
exports.getHeardStations = function() {
|
||||||
command = '{"type" : "GET", "command": "HEARD_STATIONS"}';
|
command = '{"type" : "GET", "command": "HEARD_STATIONS"}';
|
||||||
writeTncCommand(command)
|
writeTncCommand(command)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Send Ping
|
// Send Ping
|
||||||
exports.sendPing = function(dxcallsign){
|
exports.sendPing = function(dxcallsign) {
|
||||||
command = '{"type" : "PING", "command" : "PING", "dxcallsign" : "' + dxcallsign + '"}'
|
command = '{"type" : "PING", "command" : "PING", "dxcallsign" : "' + dxcallsign + '"}'
|
||||||
writeTncCommand(command)
|
writeTncCommand(command)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send CQ
|
// Send CQ
|
||||||
exports.sendCQ = function(){
|
exports.sendCQ = function() {
|
||||||
command = '{"type" : "CQ", "command" : "CQCQCQ"}'
|
command = '{"type" : "CQ", "command" : "CQCQCQ"}'
|
||||||
writeTncCommand(command)
|
writeTncCommand(command)
|
||||||
}
|
}
|
Loading…
Reference in a new issue