mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
first test with fetching settings
This commit is contained in:
parent
8bbfa57304
commit
0e21c33376
6 changed files with 103 additions and 86 deletions
|
@ -19,7 +19,7 @@ import chat from "./chat.vue";
|
|||
import infoScreen from "./infoScreen.vue";
|
||||
|
||||
import { stopTransmission } from "../js/sock.js";
|
||||
|
||||
import { fetchSettings } from "../js/rest.js";
|
||||
function stopAllTransmissions() {
|
||||
console.log("stopping transmissions");
|
||||
stopTransmission();
|
||||
|
@ -112,6 +112,7 @@ function stopAllTransmissions() {
|
|||
role="tab"
|
||||
aria-controls="list-settings"
|
||||
title="Settings"
|
||||
@click="fetchSettings"
|
||||
><i class="bi bi-gear-wide-connected h3"></i
|
||||
></a>
|
||||
|
||||
|
|
44
gui/src/js/rest.js
Normal file
44
gui/src/js/rest.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
// ----------------- init pinia stores -------------
|
||||
import { setActivePinia } from "pinia";
|
||||
import pinia from "../store/index";
|
||||
setActivePinia(pinia);
|
||||
|
||||
import { useSettingsStore } from "../store/settingsStore.js";
|
||||
const settings = useSettingsStore(pinia);
|
||||
|
||||
import { processModemConfig } from "../js/settingsHandler.ts";
|
||||
|
||||
|
||||
|
||||
export function fetchSettings(){
|
||||
// fetch Settings
|
||||
getFromServer('localhost', 5000, 'config')
|
||||
}
|
||||
|
||||
async function getFromServer(host, port, endpoint) {
|
||||
// our central function for fetching the modems REST API by a specific endpoint
|
||||
// TODO make this function using the host and port, specified in settings
|
||||
// include better error handling
|
||||
|
||||
const url = 'http://' + host + ':' + port + '/' + endpoint
|
||||
const response = await fetch(url);
|
||||
const data = await response.json();
|
||||
|
||||
// move received data to our data dispatcher
|
||||
restDataDispatcher(endpoint, data.data)
|
||||
}
|
||||
|
||||
function restDataDispatcher(endpoint, data){
|
||||
// dispatch received data by endpoint
|
||||
|
||||
switch (endpoint) {
|
||||
case 'config':
|
||||
processModemConfig(data)
|
||||
break;
|
||||
|
||||
default:
|
||||
console.log('Wrong endpoint:' + endpoint);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -8,6 +8,8 @@ setActivePinia(pinia);
|
|||
|
||||
import { useSettingsStore } from "../store/settingsStore.js";
|
||||
const settings = useSettingsStore(pinia);
|
||||
|
||||
|
||||
// ---------------------------------
|
||||
|
||||
console.log(process.env);
|
||||
|
@ -47,69 +49,18 @@ if (!fs.existsSync(configFolder)) {
|
|||
}
|
||||
|
||||
// create config file if not exists with defaults
|
||||
const configDefaultSettings =
|
||||
'{\
|
||||
"modem_host": "127.0.0.1",\
|
||||
"modem_port": 3000,\
|
||||
"daemon_host": "127.0.0.1",\
|
||||
"daemon_port": 3001,\
|
||||
"rx_audio" : "",\
|
||||
"tx_audio" : "",\
|
||||
"tx_audio_level" : 0,\
|
||||
"rx_audio_level" : 0,\
|
||||
"mycall": "AA0AA-0",\
|
||||
"myssid": "0",\
|
||||
"mygrid": "JN40aa",\
|
||||
"radiocontrol" : "disabled",\
|
||||
"hamlib_deviceid": 6,\
|
||||
"hamlib_deviceport": "ignore",\
|
||||
"hamlib_stop_bits": "ignore",\
|
||||
"hamlib_data_bits": "ignore",\
|
||||
"hamlib_handshake": "ignore",\
|
||||
"hamlib_serialspeed": "ignore",\
|
||||
"hamlib_dtrstate": "ignore",\
|
||||
"hamlib_pttprotocol": "ignore",\
|
||||
"hamlib_ptt_port": "ignore",\
|
||||
"hamlib_dcd": "ignore",\
|
||||
"hamlbib_serialspeed_ptt": 9600,\
|
||||
"hamlib_rigctld_port" : 4532,\
|
||||
"hamlib_rigctld_ip" : "127.0.0.1",\
|
||||
"hamlib_rigctld_path" : "",\
|
||||
"hamlib_rigctld_server_port" : 4532,\
|
||||
"hamlib_rigctld_custom_args": "",\
|
||||
"tci_port" : 50001,\
|
||||
"tci_ip" : "127.0.0.1",\
|
||||
"spectrum": "waterfall",\
|
||||
"enable_scatter" : "False",\
|
||||
"enable_fft" : "False",\
|
||||
"enable_fsk" : "False",\
|
||||
"low_bandwidth_mode" : "False",\
|
||||
"theme" : "default",\
|
||||
"screen_height" : 430,\
|
||||
"screen_width" : 1050,\
|
||||
"update_channel" : "latest",\
|
||||
"beacon_interval" : 300,\
|
||||
"received_files_folder" : "None",\
|
||||
"tuning_range_fmin" : "-50.0",\
|
||||
"tuning_range_fmax" : "50.0",\
|
||||
"respond_to_cq" : "True",\
|
||||
"rx_buffer_size" : 16, \
|
||||
"enable_explorer" : "False", \
|
||||
"wftheme": 2, \
|
||||
"high_graphics" : "True",\
|
||||
"explorer_stats" : "False", \
|
||||
"auto_tune" : "False", \
|
||||
"enable_is_writing" : "True", \
|
||||
"shared_folder_path" : ".", \
|
||||
"enable_request_profile" : "True", \
|
||||
"enable_request_shared_folder" : "False", \
|
||||
"max_retry_attempts" : 5, \
|
||||
"enable_auto_retry" : "False", \
|
||||
"tx_delay" : 0, \
|
||||
"auto_start": 0, \
|
||||
"enable_sys_notification": 1, \
|
||||
"enable_mesh_features": "False" \
|
||||
}';
|
||||
const configDefaultSettings = `{
|
||||
"modem_host": "127.0.0.1",
|
||||
"modem_port": 3000,
|
||||
"spectrum": "waterfall",
|
||||
"theme": "default",
|
||||
"screen_height": 430,
|
||||
"screen_width": 1050,
|
||||
"update_channel": "latest",
|
||||
"wftheme": 2,
|
||||
"enable_sys_notification": 1
|
||||
}`;
|
||||
var parsedConfig = JSON.parse(configDefaultSettings);
|
||||
|
||||
if (!fs.existsSync(configPath)) {
|
||||
fs.writeFileSync(configPath, configDefaultSettings);
|
||||
|
@ -124,7 +75,6 @@ export function loadSettings() {
|
|||
// if parameter not exists, add it to running config to prevent errors
|
||||
console.log("CONFIG VALIDATION ----------------------------- ");
|
||||
|
||||
var parsedConfig = JSON.parse(configDefaultSettings);
|
||||
for (var key in parsedConfig) {
|
||||
if (config.hasOwnProperty(key)) {
|
||||
console.log("FOUND SETTTING [" + key + "]: " + config[key]);
|
||||
|
@ -155,3 +105,14 @@ export function saveSettingsToFile() {
|
|||
console.log(config);
|
||||
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
||||
}
|
||||
|
||||
export function processModemConfig(data){
|
||||
console.log(data)
|
||||
// basic test if we received settings
|
||||
// we should iterate through JSON, by using equal variables here like in modem config
|
||||
// STATION SETTINGS
|
||||
settings.mycall = data["STATION"].mycall
|
||||
settings.mygrid = data["STATION"].mygrid
|
||||
|
||||
|
||||
}
|
|
@ -33,6 +33,6 @@ const tooltipList = [...tooltipTriggerList].map(
|
|||
loadSettings();
|
||||
|
||||
//import './js/settingsHandler.js'
|
||||
import "./js/daemon";
|
||||
import "./js/sock.js";
|
||||
//import "./js/daemon";
|
||||
//import "./js/sock.js";
|
||||
//import './js/settingsHandler.js'
|
||||
|
|
|
@ -4,15 +4,16 @@ modemport = 3000
|
|||
|
||||
[STATION]
|
||||
#station settings
|
||||
mycall = F4JAW-0
|
||||
mygrid = JN18cv
|
||||
mycall = DJ2LS
|
||||
mygrid = JN20aa
|
||||
ssid_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||
|
||||
[AUDIO]
|
||||
#audio settings
|
||||
rx = 2
|
||||
tx = 3
|
||||
txaudiolevel = 28
|
||||
rx = 0
|
||||
tx = 0
|
||||
rxaudiolevel = 0
|
||||
txaudiolevel = 0
|
||||
auto_tune = False
|
||||
|
||||
[RADIO]
|
||||
|
@ -21,27 +22,18 @@ radiocontrol = disabled
|
|||
rigctld_ip = 127.0.0.1
|
||||
rigctld_port = 4532
|
||||
|
||||
[Modem]
|
||||
# Send scatter information via network
|
||||
[TNC]
|
||||
scatter = False
|
||||
fft = True
|
||||
# AKA low_bandwidth_mode
|
||||
narrowband = False
|
||||
# Tuning range fmin and fmax
|
||||
fmin = -50.0
|
||||
fmax = 50.0
|
||||
# Enable sending a QRV frame if CQ received - AKA respond_to_cq
|
||||
fmin = -50
|
||||
fmax = 50
|
||||
qrv = True
|
||||
rx_buffer_size = 16
|
||||
explorer = False
|
||||
stats = False
|
||||
# Enable FSK mode for ping, beacon and CQ
|
||||
fsk = False
|
||||
tx_delay = 0
|
||||
# Save received data to local folder
|
||||
save_to_folder = False
|
||||
# Enable and set hmac message salt
|
||||
enable_hmac = False
|
||||
|
||||
[TCI]
|
||||
#tci settings
|
||||
|
@ -49,5 +41,20 @@ ip = 127.0.0.1
|
|||
port = 50001
|
||||
|
||||
[MESH]
|
||||
enable_protocol = False
|
||||
#tci settings
|
||||
enable_protocol = True
|
||||
|
||||
[Modem]
|
||||
#modem settings
|
||||
scatter = False
|
||||
fft = True
|
||||
narrowband = False
|
||||
fmin = -50
|
||||
fmax = 50
|
||||
qrv = True
|
||||
rx_buffer_size = 16
|
||||
explorer = False
|
||||
stats = False
|
||||
fsk = False
|
||||
tx_delay = 0
|
||||
|
||||
|
|
|
@ -206,7 +206,11 @@ class RF:
|
|||
self.log.info("[MDM] init: opened audio devices")
|
||||
except Exception as err:
|
||||
self.log.error("[MDM] init: can't open audio device. Exit", e=err)
|
||||
sys.exit(1)
|
||||
# TODO Disabled sys.exit in case of wrong audio devices. We need to ensure flask server is running.
|
||||
# This needs to be optimized when working on modem startup without daemon
|
||||
# We also get problems with old configs, using ID instead of CRC as identifier, so
|
||||
# we need some error handling here
|
||||
#sys.exit(1)
|
||||
|
||||
try:
|
||||
self.log.debug("[MDM] init: starting pyaudio callback")
|
||||
|
|
Loading…
Reference in a new issue