From ab433146190c235572d5a804096c7ffeb9327003 Mon Sep 17 00:00:00 2001 From: Mashintime Date: Thu, 30 Nov 2023 16:49:43 -0500 Subject: [PATCH 1/5] Initial gui event api handler --- gui/src/js/eventHandler.js | 77 ++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 29 deletions(-) diff --git a/gui/src/js/eventHandler.js b/gui/src/js/eventHandler.js index d724c64b..f37c6c8d 100644 --- a/gui/src/js/eventHandler.js +++ b/gui/src/js/eventHandler.js @@ -23,7 +23,7 @@ export function connectionFailed(endpoint, event) { } export function stateDispatcher(data) { data = JSON.parse(data); - console.log(data); + //console.log(data); stateStore.modem_connection = "connected"; @@ -143,38 +143,57 @@ export function eventDispatcher(data) { if (data["dxcallsign"] == "AA0AA-0" || data["dxcallsign"] == "ZZ9YY-0") { return; } + console.info(data); + switch (data["ptt"]) { + case true: + // get ptt state as a first test + console.warn("PTT state true") + stateStore.ptt_state = data.ptt; + return; + default: + console.warn("PTT state false") + // get ptt state as a first test + stateStore.ptt_state = false; + return; + } + switch (data["freedata"]) { + case ("modem-event"): + switch (data["event"]) { + case "start": + displayToast("success", "bi-arrow-left-right", "Modem started", 5000); + return; + + case "stop": + displayToast("success", "bi-arrow-left-right", "Modem stopped", 5000); + return; + + case "restart": + displayToast( + "secondary", + "bi-bootstrap-reboot", + "Modem restarted", + 5000, + ); + return; + + case "failed": + displayToast( + "danger", + "bi-bootstrap-reboot", + "Modem startup failed | bad config?", + 5000, + ); + return; + default: + console.error("Unknown event message received:"); + console.error(data); + break; + } - // get ptt state as a first test - stateStore.ptt_state = data.ptt; // catch modem related events if (data["freedata"] == "modem-event") { - switch (data["event"]) { - case "start": - displayToast("success", "bi-arrow-left-right", "Modem started", 5000); - return; - - case "stop": - displayToast("success", "bi-arrow-left-right", "Modem stopped", 5000); - return; - - case "restart": - displayToast( - "secondary", - "bi-bootstrap-reboot", - "Modem restarted", - 5000, - ); - return; - - case "failed": - displayToast( - "danger", - "bi-bootstrap-reboot", - "Modem startup failed | bad config?", - 5000, - ); - return; + } } From b7b51ad46973e4b97b4bf04ce83bf8ff9e2e5e40 Mon Sep 17 00:00:00 2001 From: Mashintime Date: Thu, 30 Nov 2023 16:50:10 -0500 Subject: [PATCH 2/5] PTT updates --- gui/src/components/main_footer_navbar.vue | 4 ++-- gui/src/store/stateStore.js | 2 +- modem/event_manager.py | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gui/src/components/main_footer_navbar.vue b/gui/src/components/main_footer_navbar.vue index 66a1edc3..bc821510 100644 --- a/gui/src/components/main_footer_navbar.vue +++ b/gui/src/components/main_footer_navbar.vue @@ -18,8 +18,8 @@ const state = useStateStore(pinia);