moved callsign and grid to daemon settings

closes #101
This commit is contained in:
dj2ls 2022-01-05 14:15:59 +01:00
parent fcc5bec25a
commit 982569fa1a
8 changed files with 129 additions and 96 deletions

View file

@ -140,11 +140,13 @@ exports.getDaemonState = function() {
// START TNC
// ` `== multi line string
exports.startTNC = function(rx_audio, tx_audio, devicename, deviceport, pttprotocol, pttport, serialspeed, data_bits, stop_bits, handshake) {
exports.startTNC = function(mycall, mygrid, rx_audio, tx_audio, devicename, deviceport, pttprotocol, pttport, serialspeed, data_bits, stop_bits, handshake) {
var json_command = JSON.stringify({
type: 'SET',
command: 'STARTTNC',
parameter: [{
mycall: mycall,
mygrid: mygrid,
rx_audio: rx_audio,
tx_audio: tx_audio,
devicename: devicename,
@ -193,3 +195,17 @@ exports.testHamlib = function(devicename, deviceport, serialspeed, pttprotocol,
}
//Save myCall
exports.saveMyCall = function(callsign) {
command = '{"type" : "SET", "command": "MYCALLSIGN" , "parameter": "' + callsign + '", "timestamp" : "' + Date.now() + '"}'
writeDaemonCommand(command)
}
// Save myGrid
exports.saveMyGrid = function(grid) {
command = '{"type" : "SET", "command": "MYGRID" , "parameter": "' + grid + '", "timestamp" : "' + Date.now() + '"}'
writeDaemonCommand(command)
}

View file

@ -244,7 +244,7 @@ advancedHamlibSettingsModal
callsign = document.getElementById("myCall").value
config.mycall = callsign.toUpperCase()
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
sock.saveMyCall(callsign)
daemon.saveMyCall(callsign)
});
// saveMyGrid button clicked
@ -252,7 +252,7 @@ advancedHamlibSettingsModal
grid = document.getElementById("myGrid").value
config.mygrid = grid
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
sock.saveMyGrid(grid)
daemon.saveMyGrid(grid)
});
@ -294,6 +294,9 @@ advancedHamlibSettingsModal
// startTNC button clicked
document.getElementById("startTNC").addEventListener("click", () => {
var mycall = document.getElementById("myCall").value
mycall = mycall.toUpperCase()
var mygrid = document.getElementById("myGrid").value
var rx_audio = document.getElementById("audio_input_selectbox").value
var tx_audio = document.getElementById("audio_output_selectbox").value
var deviceid = document.getElementById("hamlib_deviceid").value
@ -325,7 +328,9 @@ advancedHamlibSettingsModal
config.tx_audio = device.text
}
}
config.mycall = mycall
config.mygrid = mygrid
config.deviceid = deviceid
config.deviceport = deviceport
config.serialspeed = serialspeed
@ -348,20 +353,15 @@ advancedHamlibSettingsModal
var collapseFourthRow = new bootstrap.Collapse(document.getElementById('collapseFourthRow'), {toggle: false})
collapseFourthRow.show()
daemon.startTNC(rx_audio, tx_audio, deviceid, deviceport, pttprotocol, pttport, serialspeed, data_bits, stop_bits, handshake)
daemon.startTNC(mycall, mygrid, rx_audio, tx_audio, deviceid, deviceport, pttprotocol, pttport, serialspeed, data_bits, stop_bits, handshake)
setTimeout(function() {
sock.saveMyCall(config.mycall);
}, 3000);
setTimeout(function() {
sock.saveMyGrid(config.mygrid);
}, 3500);
})
// stopTNC button clicked
document.getElementById("stopTNC").addEventListener("click", () => {
daemon.stopTNC()
@ -966,7 +966,6 @@ ipcRenderer.on('action-update-tnc-state', (event, arg) => {
document.getElementById("transmission_progress").className = "progress-bar progress-bar-striped bg-danger";
var toastARQtransmittingfailed = document.getElementById('toastARQtransmittingfailed')
var toast = bootstrap.Toast.getOrCreateInstance(toastARQtransmittingfailed) // Returns a Bootstrap toast instance
toast.show()
}
@ -995,12 +994,11 @@ ipcRenderer.on('action-update-daemon-state', (event, arg) => {
document.getElementById("progressbar_cpu").setAttribute("style", "width:" + arg.cpu_usage + "%;")
document.getElementById("progressbar_cpu_value").innerHTML = arg.cpu_usage + "%"
*/
document.getElementById("ram_load").innerHTML = "RAM " + arg.ram_usage + "%"
document.getElementById("cpu_load").innerHTML = "CPU " + arg.cpu_usage + "%"
document.getElementById("ram_load").innerHTML = arg.ram_usage + "%"
document.getElementById("cpu_load").innerHTML = arg.cpu_usage + "%"
// OPERATING SYSTEM
document.getElementById("operating_system").innerHTML = "OS " + os.type()
//document.getElementById("operating_system").innerHTML = "OS " + os.type()
// PYTHON VERSION

View file

@ -192,17 +192,6 @@ function hexToBytes(hex) {
return bytes;
}
//Save myCall
exports.saveMyCall = function(callsign) {
command = '{"type" : "SET", "command": "MYCALLSIGN" , "parameter": "' + callsign + '", "timestamp" : ' + Date.now() + '}'
writeTncCommand(command)
}
// Save myGrid
exports.saveMyGrid = function(grid) {
command = '{"type" : "SET", "command": "MYGRID" , "parameter": "' + grid + '", "timestamp" : ' + Date.now() + '}'
writeTncCommand(command)
}
//Get TNC State
exports.getTncState = function() {

View file

@ -220,7 +220,7 @@
<path d="M3.5 6.5A.5.5 0 0 1 4 7v1a4 4 0 0 0 8 0V7a.5.5 0 0 1 1 0v1a5 5 0 0 1-4.5 4.975V15h3a.5.5 0 0 1 0 1h-7a.5.5 0 0 1 0-1h3v-2.025A5 5 0 0 1 3 8V7a.5.5 0 0 1 .5-.5z"/>
</svg>
</span>
<select class="form-select form-select-sm" id="audio_input_selectbox" aria-label=".form-select-sm">
<select class="form-select form-select-sm" id="audio_input_selectbox" aria-label=".form-select-sm">
<!-- <option selected value="3011">USB Interface</option>-->
</select>
</div>
@ -233,10 +233,6 @@
</span>
<select class="form-select form-select-sm" id="audio_output_selectbox" aria-label=".form-select-sm"></select>
</div>
<div class="progress mb-1" style="height: 20px;">
<div class="progress-bar progress-bar-striped bg-primary" id="rms_level" role="progressbar" style="width: 0%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
<p class="justify-content-center d-flex position-absolute w-100">RX AUDIO LEVEL</p>
</div>
</div>
<div class="card-footer text-muted small">Please select audio device for RX and TX</div>
</div>
@ -248,6 +244,16 @@
<path d="M14 7.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0ZM2.5 6a.5.5 0 0 0 0 1h4a.5.5 0 0 0 0-1h-4Zm0 2a.5.5 0 0 0 0 1h4a.5.5 0 0 0 0-1h-4Z" />
<path fill-rule="evenodd" d="M0 6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2 1 1 0 0 1-1 1h-1a1 1 0 0 1-1-1H5a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1 2 2 0 0 1-2-2V6Zm2-1h12a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1Z" />
</svg> <strong>RADIO SETTINGS</strong>
<div class="btn-group" role="group" data-bs-placement="bottom" data-bs-toggle="tooltip" data-bs-html="true" title="Set advanced hamlib settings like stop_bits and data_bits or a different port for a ptt device">
<button type="button" id="advancedHamlibSettingsButton" data-bs-toggle="modal" data-bs-target="#advancedHamlibSettingsModal" class="btn btn-sm btn-secondary">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-sliders" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M11.5 2a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zM9.05 3a2.5 2.5 0 0 1 4.9 0H16v1h-2.05a2.5 2.5 0 0 1-4.9 0H0V3h9.05zM4.5 7a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zM2.05 8a2.5 2.5 0 0 1 4.9 0H16v1H6.95a2.5 2.5 0 0 1-4.9 0H0V8h2.05zm9.45 4a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm-2.45 1a2.5 2.5 0 0 1 4.9 0H16v1h-2.05a2.5 2.5 0 0 1-4.9 0H0v-1h9.05z" />
</svg>
</button>
</div>
<div class="btn-group" role="group">
<button type="button" id="testHamlib" class="btn btn-sm btn-outline-secondary" data-bs-placement="bottom" data-bs-toggle="tooltip" data-bs-html="true" title="Test your hamlib settings and toggle PTT once. Button will become <strong class='text-success'>green</strong> on success and <strong class='text-danger'>red</strong> if fails.">PTT Test</button>
</div>
</div>
<div class="card-body p-2">
<div class="input-group input-group-sm mb-1"> <span class="input-group-text" id="basic-addon1">
@ -563,12 +569,6 @@
<option value="115200">115200</option>
</select>
</div>
<div class="btn-group" role="group" data-bs-placement="bottom" data-bs-toggle="tooltip" data-bs-html="true" title="Set advanced hamlib settings like stop_bits and data_bits or a different port for a ptt device">
<button type="button" id="advancedHamlibSettingsButton" data-bs-toggle="modal" data-bs-target="#advancedHamlibSettingsModal" class="btn btn-sm btn-secondary">Advanced settings</button>
</div>
<div class="btn-group" role="group">
<button type="button" id="testHamlib" class="btn btn-sm btn-outline-secondary" data-bs-placement="bottom" data-bs-toggle="tooltip" data-bs-html="true" title="Test your hamlib settings and toggle PTT once. Button will become <strong class='text-success'>green</strong> on success and <strong class='text-danger'>red</strong> if fails.">Test settings</button>
</div>
</div>
<div class="card-footer text-muted small">Please select your radio settings. Starting the TNC saves them.</div>
</div>
@ -625,29 +625,6 @@
--></div>
<div class="row collapse multi-collapse show mt-2" id="collapseSecondRow">
<div class="col">
<div class="card text-dark bg-light mb-0">
<div class="card-header p-1">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-motherboard" viewBox="0 0 16 16">
<path d="M11.5 2a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 .5-.5Zm2 0a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 .5-.5Zm-10 8a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1h-6Zm0 2a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1h-6ZM5 3a1 1 0 0 0-1 1h-.5a.5.5 0 0 0 0 1H4v1h-.5a.5.5 0 0 0 0 1H4a1 1 0 0 0 1 1v.5a.5.5 0 0 0 1 0V8h1v.5a.5.5 0 0 0 1 0V8a1 1 0 0 0 1-1h.5a.5.5 0 0 0 0-1H9V5h.5a.5.5 0 0 0 0-1H9a1 1 0 0 0-1-1v-.5a.5.5 0 0 0-1 0V3H6v-.5a.5.5 0 0 0-1 0V3Zm0 1h3v3H5V4Zm6.5 7a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h2a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5h-2Z" />
<path d="M1 2a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2v-2H.5a.5.5 0 0 1-.5-.5v-1A.5.5 0 0 1 .5 9H1V8H.5a.5.5 0 0 1-.5-.5v-1A.5.5 0 0 1 .5 6H1V5H.5a.5.5 0 0 1-.5-.5v-2A.5.5 0 0 1 .5 2H1Zm1 11a1 1 0 0 0 1 1h11a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H3a1 1 0 0 0-1 1v11Z" />
</svg> <strong>SYSTEM STATUS</strong>
</div>
<div class="card-body p-2 mb-1">
<button class="btn btn-secondary btn-sm" id="python_version" type="button" disabled>Python</button>
<button class="btn btn-secondary btn-sm" id="node_version" type="button" disabled>Node</button>
<button class="btn btn-secondary btn-sm" id="hamlib_version" type="button" disabled>Hamlib</button>
<button class="btn btn-secondary btn-sm" id="operating_system" type="button" disabled>OS</button>
<button class="btn btn-secondary btn-sm" id="cpu_load" type="button" disabled>CPU</button>
<button class="btn btn-secondary btn-sm" id="ram_load" type="button" disabled>RAM</button>
</div>
</div>
</div>
</div>
</div>
<!--<hr class="m-1">-->
<div class="container mt-2 p-0">
<div class="row collapse multi-collapse" id="collapseThirdRow">
<div class="col-5">
<div class="card text-dark bg-light mb-1">
<div class="card-header p-1"><strong>MY STATION</strong>
</div>
@ -688,6 +665,49 @@
</div>
</div>
</div>
<div class="col">
<div class="card text-dark bg-light mb-0">
<div class="card-header p-1">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-motherboard" viewBox="0 0 16 16">
<path d="M11.5 2a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 .5-.5Zm2 0a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 .5-.5Zm-10 8a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1h-6Zm0 2a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1h-6ZM5 3a1 1 0 0 0-1 1h-.5a.5.5 0 0 0 0 1H4v1h-.5a.5.5 0 0 0 0 1H4a1 1 0 0 0 1 1v.5a.5.5 0 0 0 1 0V8h1v.5a.5.5 0 0 0 1 0V8a1 1 0 0 0 1-1h.5a.5.5 0 0 0 0-1H9V5h.5a.5.5 0 0 0 0-1H9a1 1 0 0 0-1-1v-.5a.5.5 0 0 0-1 0V3H6v-.5a.5.5 0 0 0-1 0V3Zm0 1h3v3H5V4Zm6.5 7a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h2a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5h-2Z" />
<path d="M1 2a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2v-2H.5a.5.5 0 0 1-.5-.5v-1A.5.5 0 0 1 .5 9H1V8H.5a.5.5 0 0 1-.5-.5v-1A.5.5 0 0 1 .5 6H1V5H.5a.5.5 0 0 1-.5-.5v-2A.5.5 0 0 1 .5 2H1Zm1 11a1 1 0 0 0 1 1h11a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H3a1 1 0 0 0-1 1v11Z" />
</svg> <strong>SYSTEM STATUS</strong>
</div>
<div class="card-body p-2 mb-1">
<button class="btn btn-secondary btn-sm" id="python_version" type="button" disabled>Python</button>
<button class="btn btn-secondary btn-sm" id="node_version" type="button" disabled>Node</button>
<button class="btn btn-secondary btn-sm" id="hamlib_version" type="button" disabled>Hamlib</button>
<!--<button class="btn btn-secondary btn-sm" id="operating_system" type="button" disabled>OS</button>-->
<button class="btn btn-secondary btn-sm" id="cpu_load_button" type="button" disabled>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-cpu" viewBox="0 0 16 16">
<path d="M5 0a.5.5 0 0 1 .5.5V2h1V.5a.5.5 0 0 1 1 0V2h1V.5a.5.5 0 0 1 1 0V2h1V.5a.5.5 0 0 1 1 0V2A2.5 2.5 0 0 1 14 4.5h1.5a.5.5 0 0 1 0 1H14v1h1.5a.5.5 0 0 1 0 1H14v1h1.5a.5.5 0 0 1 0 1H14v1h1.5a.5.5 0 0 1 0 1H14a2.5 2.5 0 0 1-2.5 2.5v1.5a.5.5 0 0 1-1 0V14h-1v1.5a.5.5 0 0 1-1 0V14h-1v1.5a.5.5 0 0 1-1 0V14h-1v1.5a.5.5 0 0 1-1 0V14A2.5 2.5 0 0 1 2 11.5H.5a.5.5 0 0 1 0-1H2v-1H.5a.5.5 0 0 1 0-1H2v-1H.5a.5.5 0 0 1 0-1H2v-1H.5a.5.5 0 0 1 0-1H2A2.5 2.5 0 0 1 4.5 2V.5A.5.5 0 0 1 5 0zm-.5 3A1.5 1.5 0 0 0 3 4.5v7A1.5 1.5 0 0 0 4.5 13h7a1.5 1.5 0 0 0 1.5-1.5v-7A1.5 1.5 0 0 0 11.5 3h-7zM5 6.5A1.5 1.5 0 0 1 6.5 5h3A1.5 1.5 0 0 1 11 6.5v3A1.5 1.5 0 0 1 9.5 11h-3A1.5 1.5 0 0 1 5 9.5v-3zM6.5 6a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5h-3z" />
</svg> <span id="cpu_load">---</span>
</button>
<button class="btn btn-secondary btn-sm" id="ram_load_button" type="button" disabled>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-memory" viewBox="0 0 16 16">
<path d="M1 3a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h4.586a1 1 0 0 0 .707-.293l.353-.353a.5.5 0 0 1 .708 0l.353.353a1 1 0 0 0 .707.293H15a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1H1Zm.5 1h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-4a.5.5 0 0 1 .5-.5Zm5 0h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-4a.5.5 0 0 1 .5-.5Zm4.5.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-4ZM2 10v2H1v-2h1Zm2 0v2H3v-2h1Zm2 0v2H5v-2h1Zm3 0v2H8v-2h1Zm2 0v2h-1v-2h1Zm2 0v2h-1v-2h1Zm2 0v2h-1v-2h1Z" />
</svg> <span id="ram_load">---</span>
</button>
</div>
</div>
</div>
</div>
</div>
<!--<hr class="m-1">-->
<div class="container mt-2 p-0">
<div class="row collapse multi-collapse" id="collapseThirdRow">
<div class="col-5">
<div class="card text-dark bg-light mb-1">
<div class="card-header p-1"><strong>AUDIO LEVEL</strong>
</div>
<div class="card-body p-2">
<div class="progress mb-1" style="height: 20px;">
<div class="progress-bar progress-bar-striped bg-primary" id="rms_level" role="progressbar" style="width: 0%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
<p class="justify-content-center d-flex position-absolute w-100">RX AUDIO LEVEL</p>
</div>
</div>
</div>
</div>
<div class="col">
<div class="card text-dark bg-light mb-1">
<div class="card-header p-1"><strong>PING, CQ & BEACON</strong>
@ -974,9 +994,7 @@
</svg>
</button>
</div>
</div>
<div class="container-fluid p-0" style="width:15rem">
<div class="input-group input-group-sm">
<!--<span class="input-group-text" id="basic-addon1"><strong>Freq</strong></span>--> <span class="input-group-text" id="frequency">---</span>
@ -984,25 +1002,20 @@
<!--<span class="input-group-text" id="basic-addon1"><strong>BW</strong></span>--> <span class="input-group-text" id="bandwith">---</span>
</div>
</div>
<div class="container-fluid p-0" style="width:12rem">
<div class="input-group input-group-sm"> <span class="input-group-text" id="basic-addon1"><strong>B/min</strong></span>
<span class="input-group-text" id="bytes_per_min" data-bs-placement="bottom" data-bs-toggle="tooltip" data-bs-html="false" title="raw data rate modem in bytes per minute">---</span>
<span class="input-group-text" id="bytes_per_min_compressed" data-bs-placement="bottom" data-bs-toggle="tooltip" data-bs-html="false" title="data rate including file compression in bytes per minute">---</span>
</div>
</div>
<div class="container-fluid p-0" style="width:10rem">
</div>
<div class="container-fluid p-0" style="width:10rem">
<div class="input-group input-group-sm"> <span class="input-group-text" id="basic-addon1"><strong>kBytes</strong></span>
<span class="input-group-text" id="total_bytes">---</span>
</div>
</div>
<div class="container-fluid p-0" style="width:15rem">
<div class="progress" style="height: 30px;">
<div class="progress-bar progress-bar-striped bg-success" id="transmission_progress" role="progressbar" style="width: 0%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
<div class="progress-bar progress-bar-striped bg-primary" id="transmission_progress" role="progressbar" style="width: 0%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
<!--<p class="justify-content-center d-flex position-absolute w-100">PROGRESS</p>-->
</div>
</div>
@ -1079,7 +1092,7 @@
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_ptt_port_advanced">
<!--<option selected value="/dev/ttyUSB0">/dev/ttyUSB0</option>
<option value="/dev/ttyUSB1">/dev/ttyUSB1</option>-->
<!--
<!--
</select> <span class="input-group-text" id="basic-addon1">PTT Speed</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_pttspeed_advanced">
<option value="1200">1200</option>

View file

@ -21,6 +21,7 @@ import static
import crcengine
import re
import logging, structlog, log_handler
import helpers
log_handler.setup_logging("daemon")
@ -149,8 +150,32 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
# print(received_json["type"])
# print(received_json["command"])
# try:
if received_json["type"] == 'SET' and received_json["command"] == 'MYCALLSIGN':
callsign = received_json["parameter"]
print(received_json)
if bytes(callsign, 'utf-8') == b'':
self.request.sendall(b'INVALID CALLSIGN')
structlog.get_logger("structlog").warning("[DMN] SET MYCALL FAILED", call=static.MYCALLSIGN, crc=static.MYCALLSIGN_CRC8)
else:
static.MYCALLSIGN = bytes(callsign, 'utf-8')
static.MYCALLSIGN_CRC8 = helpers.get_crc_8(static.MYCALLSIGN)
structlog.get_logger("structlog").info("[DMN] SET MYCALL", call=static.MYCALLSIGN, crc=static.MYCALLSIGN_CRC8)
if received_json["type"] == 'SET' and received_json["command"] == 'MYGRID':
mygrid = received_json["parameter"]
if bytes(mygrid, 'utf-8') == b'':
self.request.sendall(b'INVALID GRID')
else:
static.MYGRID = bytes(mygrid, 'utf-8')
structlog.get_logger("structlog").info("[DMN] SET MYGRID", grid=static.MYGRID)
if received_json["type"] == 'SET' and received_json["command"] == 'STARTTNC' and not static.TNCSTARTED:
mycall = str(received_json["parameter"][0]["mycall"])
mygrid = str(received_json["parameter"][0]["mygrid"])
rx_audio = str(received_json["parameter"][0]["rx_audio"])
tx_audio = str(received_json["parameter"][0]["tx_audio"])
devicename = str(received_json["parameter"][0]["devicename"])
@ -177,6 +202,10 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
# list of parameters, necessary for running subprocess command as a list
options = []
options.append('--mycall')
options.append(mycall)
options.append('--mygrid')
options.append(mygrid)
options.append('--rx')
options.append(rx_audio)
options.append('--tx')

View file

@ -8,10 +8,9 @@ Created on Fri Dec 25 21:25:14 2020
import time
import logging
import asyncio
import crcengine
import static
import data_handler
def wait(seconds):

View file

@ -13,6 +13,7 @@ import threading
import static
import subprocess
import sys
import helpers
import logging, structlog, log_handler
@ -24,7 +25,9 @@ import logging, structlog, log_handler
if __name__ == '__main__':
# --------------------------------------------GET PARAMETER INPUTS
PARSER = argparse.ArgumentParser(description='Simons TEST TNC')
PARSER = argparse.ArgumentParser(description='FreeDATA TNC')
PARSER.add_argument('--mycall', dest="mycall", default="AA0AA", help="My callsign", type=str)
PARSER.add_argument('--mygrid', dest="mygrid", default="JN12AA", help="My gridsquare", type=str)
PARSER.add_argument('--rx', dest="audio_input_device", default=0, help="listening sound card", type=int)
PARSER.add_argument('--tx', dest="audio_output_device", default=0, help="transmitting sound card", type=int)
PARSER.add_argument('--port', dest="socket_port", default=3000, help="Socket port", type=int)
@ -40,7 +43,11 @@ if __name__ == '__main__':
ARGS = PARSER.parse_args()
static.MYCALLSIGN = bytes(ARGS.mycall, 'utf-8')
static.MYCALLSIGN_CRC8 = helpers.get_crc_8(static.MYCALLSIGN)
static.MYGRID = bytes(ARGS.mygrid, 'utf-8')
static.AUDIO_INPUT_DEVICE = ARGS.audio_input_device
static.AUDIO_OUTPUT_DEVICE = ARGS.audio_output_device
static.PORT = ARGS.socket_port

View file

@ -196,25 +196,7 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
# SETTINGS AND STATUS ---------------------------------------------
if received_json["type"] == 'SET' and received_json["command"] == 'MYCALLSIGN':
callsign = received_json["parameter"]
if bytes(callsign, encoding) == b'':
self.request.sendall(b'INVALID CALLSIGN')
else:
static.MYCALLSIGN = bytes(callsign, encoding)
static.MYCALLSIGN_CRC8 = helpers.get_crc_8(static.MYCALLSIGN)
structlog.get_logger("structlog").info("[TNC] SET MYCALL", grid=static.MYCALLSIGN, crc=static.MYCALLSIGN_CRC8)
if received_json["type"] == 'SET' and received_json["command"] == 'MYGRID':
mygrid = received_json["parameter"]
if bytes(mygrid, encoding) == b'':
self.request.sendall(b'INVALID GRID')
else:
static.MYGRID = bytes(mygrid, encoding)
structlog.get_logger("structlog").info("[TNC] SET MYGRID", grid=static.MYGRID)
if received_json["type"] == 'GET' and received_json["command"] == 'STATION_INFO':
output = {