mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
adjusted some command handling
This commit is contained in:
parent
bb73d897f9
commit
a6aabd1bc4
6 changed files with 34 additions and 33 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,32 +3,35 @@ 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");
|
||||
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 data
|
||||
socket.addEventListener("message", function (event) {
|
||||
console.log("Message from server:", event.data);
|
||||
socket.addEventListener('message', function (event) {
|
||||
console.log('Message from server:', event.data);
|
||||
console.log('Message from server:', event);
|
||||
|
||||
});
|
||||
|
||||
// handle errors
|
||||
socket.addEventListener("error", function (event) {
|
||||
console.error("WebSocket error:", event);
|
||||
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);
|
||||
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);
|
||||
console.log("Reconnecting to websocket. Attempt: " + retries)
|
||||
connect();
|
||||
}, 1000);
|
||||
retries++;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -34,7 +34,7 @@ var setTxAudioLevelOnce = true;
|
|||
var setRxAudioLevelOnce = true;
|
||||
|
||||
// network connection Timeout
|
||||
setTimeout(connectModem, 2000);
|
||||
//setTimeout(connectModem, 2000);
|
||||
|
||||
function connectModem() {
|
||||
//exports.connectModem = function(){
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue