adjusted some command handling

This commit is contained in:
DJ2LS 2023-11-09 13:52:27 +01:00
parent bb73d897f9
commit a6aabd1bc4
6 changed files with 34 additions and 33 deletions

View file

@ -11,12 +11,11 @@ const settings = useSettingsStore(pinia);
import { useStateStore } from "../store/stateStore.js";
const state = useStateStore(pinia);
import { sendCQ, sendPing, startBeacon, stopBeacon } from "../js/sock.js";
import { sendPing, startBeacon, stopBeacon } from "../js/sock.js";
import { postToServer } from "../js/rest.js";
function transmitCQ() {
sendCQ();
postToServer("localhost", 5000, "modem/cqcqcq", null);
}

View file

@ -3,37 +3,40 @@ let retries = 0;
let maxRetries = 15;
function connect() {
socket = new WebSocket("ws://localhost:5000/events");
// handle opening
socket.addEventListener("open", function (event) {
console.log("Connected to the WebSocket server");
retries = 0; // Reset the retries back to 0 since the connection was successful
});
socket = new WebSocket("ws://localhost:5000/events");
// handle data
socket.addEventListener("message", function (event) {
console.log("Message from server:", event.data);
});
// handle opening
socket.addEventListener('open', function (event) {
console.log('Connected to the WebSocket server');
retries = 0; // Reset the retries back to 0 since the connection was successful
});
// handle errors
socket.addEventListener("error", function (event) {
console.error("WebSocket error:", event);
});
// handle data
socket.addEventListener('message', function (event) {
console.log('Message from server:', event.data);
console.log('Message from server:', event);
// handle closing and reconnect
socket.addEventListener("close", function (event) {
console.log("WebSocket connection closed:", event.code);
});
// Reconnect handler
if (!event.wasClean && retries < maxRetries) {
setTimeout(() => {
console.log("Reconnecting to websocket. Attempt: " + retries);
connect();
}, 1000);
retries++;
}
});
// handle errors
socket.addEventListener('error', function (event) {
console.error('WebSocket error:', event);
});
// handle closing and reconnect
socket.addEventListener('close', function (event) {
console.log('WebSocket connection closed:', event.code);
// Reconnect handler
if (!event.wasClean && retries < maxRetries) {
setTimeout(() => {
console.log("Reconnecting to websocket. Attempt: " + retries)
connect();
}, 1000);
retries++;
}
});
}
// Initial connection attempt

View file

@ -19,7 +19,7 @@ export async function getFromServer(host, port, endpoint) {
const data = await response.json();
// move received data to our data dispatcher
restDataDispatcher(endpoint, data.data);
restDataDispatcher(endpoint, data);
}
export async function postToServer(host, port, endpoint, data) {

View file

@ -34,7 +34,7 @@ var setTxAudioLevelOnce = true;
var setRxAudioLevelOnce = true;
// network connection Timeout
setTimeout(connectModem, 2000);
//setTimeout(connectModem, 2000);
function connectModem() {
//exports.connectModem = function(){

View file

@ -583,7 +583,6 @@ class RF:
tci_timeout_reached = False
else:
tci_timeout_reached = True
threading.Event().wait(0.01)
# if we're transmitting FreeDATA signals, reset channel busy state
ModemParam.channel_busy = False
@ -598,7 +597,6 @@ class RF:
self.modem_transmit_queue.task_done()
Modem.transmitting = False
threading.Event().set()
end_of_transmission = time.time()
transmission_time = end_of_transmission - start_of_transmission
@ -843,6 +841,7 @@ class RF:
)
except Exception as e:
self.log.warning("[MDM] [demod_audio] Stream not active anymore", e=e)
return nin
def init_codec2(self):

View file

@ -1,4 +1,4 @@
from queues import DATA_QUEUE_TRANSMIT
def cqcqcq():
DATA_QUEUE_TRANSMIT.put(["CQ"])
DATA_QUEUE_TRANSMIT.put(["CQ"])