Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
DJ2LS 2023-11-17 22:45:20 +01:00
commit 145ac1533a
8 changed files with 81 additions and 18 deletions

View file

@ -20,6 +20,7 @@ import infoScreen from "./infoScreen.vue";
import { stopTransmission } from "../js/sock.js";
import { getModemConfig } from "../js/api";
import main_modem_healthcheck from "./main_modem_healthcheck.vue";
function stopAllTransmissions() {
console.log("stopping transmissions");
@ -53,14 +54,7 @@ function stopAllTransmissions() {
role="tablist"
style="margin-top: 100px"
>
<a
class="btn border btn-outline-secondary list-group-item mb-5"
data-bs-html="false"
data-bs-toggle="modal"
data-bs-target="#modemCheck"
title="Check FreeDATA status"
><i class="bi bi-activity h3"></i>
</a>
<main_modem_healthcheck />
<a
class="list-group-item list-group-item-dark list-group-item-action border-0 rounded-3 mb-2 active"

View file

@ -0,0 +1,42 @@
<script setup lang="ts">
import { setActivePinia } from "pinia";
import pinia from "../store/index";
setActivePinia(pinia);
import { useSettingsStore } from "../store/settingsStore.js";
const settings = useSettingsStore(pinia);
import { useStateStore } from "../store/stateStore.js";
const state = useStateStore(pinia);
function getOverallHealth() {
//Return a number indicating health for icon bg color; lower the number the healthier
let health = 0;
if (state.modem_connection !== "connected") health += 5;
if (!state.is_modem_running) health += 3;
if (
settings.radiocontrol === "rigctld" &&
(state.rigctld_started === undefined || state.rigctld_started === "false")
)
health += 2;
if (process.env.FDUpdateAvail === "1") health += 1;
return health;
}
</script>
<template>
<a
class="btn border btn-outline-secondary list-group-item mb-5"
data-bs-html="false"
data-bs-toggle="modal"
data-bs-target="#modemCheck"
title="Check FreeDATA status"
:class="
getOverallHealth() > 4
? 'bg-danger'
: getOverallHealth() < 2
? ''
: 'bg-warning'
"
><i class="bi bi-activity h3"></i>
</a>
</template>

View file

@ -20,7 +20,7 @@ import { useStateStore } from "../store/stateStore.js";
const state = useStateStore(pinia);
import { startModem, stopModem } from "../js/api";
import { getModemConfig } from "../js/api";
import { getModemConfig, getModemCurrentState } from "../js/api";
import { saveSettingsToFile } from "../js/settingsHandler";
import { startRigctld, stopRigctld } from "../js/deprecated_daemon";
@ -31,6 +31,7 @@ var updateAvailable = process.env.FDUpdateAvail;
// start modemCheck modal once on startup
onMounted(() => {
getModemConfig();
getModemCurrentState();
getModemVersion();
new Modal("#modemCheck", {}).show();
});

View file

@ -33,3 +33,6 @@ export function stopModem() {
export function getModemVersion() {
getFromServer(settings.modem_host, settings.modem_port, "version", null);
}
export function getModemCurrentState() {
getFromServer(settings.modem_host, settings.modem_port, "modem/state", null);
}

View file

@ -28,7 +28,10 @@ export function stateDispatcher(data) {
stateStore.modem_connection = "connected";
if (data["freedata-message"] == "state-change") {
if (
data["freedata-message"] == "state-change" ||
data["freedata-message"] == "state"
) {
stateStore.channel_busy = data["channel_busy"];
stateStore.is_codec2_traffic = data["is_codec2_traffic"];
stateStore.is_modem_running = data["is_modem_running"];

View file

@ -51,6 +51,8 @@ class CONFIG:
'rx_buffer_size': int,
'enable_scatter': bool,
'tx_delay': int,
'enable_hmac':bool,
'enable_morse_identifier':bool
},
}

View file

@ -92,6 +92,10 @@ def get_serial_devices():
devices = serial_ports.get_ports()
return api_response(devices)
@app.route('/modem/state', methods=['GET'])
def get_modem_state():
return api_response(app.states.sendState())
@app.route('/modem/cqcqcq', methods=['POST', 'GET'])
def post_cqcqcq():
if request.method not in ['POST']:
@ -198,7 +202,7 @@ def transmit_sock_data_worker(client_list, event_queue):
def sock_watchdog(sock, client_list, event_queue):
event_queue.put(json.dumps({"freedata-message": "hello-client"}))
client_list.add(sock)
while True:
try:
@ -224,6 +228,7 @@ def sock_fft(sock):
@sock.route('/states')
def sock_states(sock):
sock_watchdog(sock, states_client_list, app.state_queue)
# websocket multi client support for using with queued information.
# our client set which contains all connected websocket clients

View file

@ -39,21 +39,34 @@ class STATES:
self.radio_bandwidth = 0
self.radio_rf_power = 0
def sendState (self):
currentState = self.getAsJSON(False)
self.statequeue.put(currentState)
return currentState
def sendStateUpdate (self):
self.statequeue.put(self.newstate)
def set(self, key, value):
setattr(self, key, value)
updateCandence = 3
# only process data if changed
# but also send an update if more than a 'updateCadence' second(s) has lapsed
# Otherwise GUI can't tell if modem is active due to lack of state messages on startup
new_state = self.getAsJSON()
if new_state != self.newstate or time.time() - self.last > updateCandence:
self.statequeue.put(new_state)
new_state = self.getAsJSON(True)
if new_state != self.newstate:
self.newstate = new_state
self.last=time.time()
self.sendStateUpdate()
def getAsJSON(self, isChangedState):
msgtype = "state-change"
if (not isChangedState):
msgtype = "state"
def getAsJSON(self):
return json.dumps({
"freedata-message": "state-change",
"freedata-message": msgtype,
"channel_busy": self.channel_busy,
"is_codec2_traffic": self.is_codec2_traffic,
"is_modem_running": self.is_modem_running,