From ccce4cfe63ff8c3bf32a9ffc5f0d056dda105bcb Mon Sep 17 00:00:00 2001 From: Mashintime Date: Tue, 8 Aug 2023 16:32:35 -0400 Subject: [PATCH 1/8] Fix for messages not resetting when stuck in transmitting --- gui/preload-chat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/preload-chat.js b/gui/preload-chat.js index a20a549d..6411e7ac 100644 --- a/gui/preload-chat.js +++ b/gui/preload-chat.js @@ -1060,7 +1060,7 @@ update_chat = function (obj) { } // check if wrong status message - if (obj.status == "transmit" && obj.type == "transmit" && obj.percent < 100) { + if (obj.status == "transmitting" && obj.type == "transmit" && obj.percent < 100) { var TimeDifference = new Date().getTime() / 1000 - obj.timestamp; if (TimeDifference > 21600) { //Six hours From f29efac943a8c0d76575ec7726942ecd23036934 Mon Sep 17 00:00:00 2001 From: Mashintime Date: Tue, 8 Aug 2023 21:11:10 -0400 Subject: [PATCH 2/8] Fix for #466 --- gui/preload-chat.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/gui/preload-chat.js b/gui/preload-chat.js index 6411e7ac..4fc5a19f 100644 --- a/gui/preload-chat.js +++ b/gui/preload-chat.js @@ -1283,6 +1283,17 @@ update_chat = function (obj) { //get user information getSetUserInformation(selected_callsign); getSetUserSharedFolder(selected_callsign); + if (selected_callsign.startsWith("BC-")) { + document + .getElementById("chatModuleMessage") + .setAttribute("maxlength", 16); + //console.log("Setting max message size to 16") + } else { + document + .getElementById("chatModuleMessage") + .setAttribute("maxlength", 524288); + //console.log("Setting max message size to big#") + } }); // if callsign entry already exists - update @@ -2467,14 +2478,8 @@ function getSetUserInformation(selected_callsign) { if (selected_callsign.startsWith("BC-")) { var userIcon = defaultGroupIcon; - document - .getElementById("chatModuleMessage") - .setAttribute("maxlength", 16); } else { var userIcon = defaultUserIcon; - document - .getElementById("chatModuleMessage") - .setAttribute("maxlength", 524288); } document.getElementById("user-image-" + selected_callsign).src = @@ -2536,15 +2541,9 @@ function getSetUserInformation(selected_callsign) { console.log(err); if (selected_callsign.startsWith("BC-")) { - document - .getElementById("chatModuleMessage") - .setAttribute("maxlength", 16); var userIcon = defaultGroupIcon; } else { var userIcon = defaultUserIcon; - document - .getElementById("chatModuleMessage") - .setAttribute("maxlength", 524288); } // Callsign list elements From c03b4b0cd9e7920d954374150046948d94d69d05 Mon Sep 17 00:00:00 2001 From: Mashintime Date: Wed, 9 Aug 2023 21:56:09 -0400 Subject: [PATCH 3/8] Update logging in check for waitingmsgs --- gui/preload-chat.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/preload-chat.js b/gui/preload-chat.js index 4fc5a19f..30bf38b7 100644 --- a/gui/preload-chat.js +++ b/gui/preload-chat.js @@ -2776,7 +2776,6 @@ function changeGuiDesign(design) { } function checkForWaitingMessages(dxcall) { - console.log(dxcall); db.find({ selector: { dxcallsign: dxcall, @@ -2786,6 +2785,7 @@ function checkForWaitingMessages(dxcall) { }, }) .then(function (result) { + console.log("Found " + result.docs.length + " messages waiting for " + dxcall) // handle result if (result.docs.length > 0) { // only want to process the first available item object, then return @@ -2820,7 +2820,7 @@ function checkForWaitingMessages(dxcall) { } return; } else { - console.log("nope"); + //console.log("nope"); } }) .catch(function (err) { From 299ae1e44d04b077f6f96400ab102d39ace3404b Mon Sep 17 00:00:00 2001 From: Mashintime Date: Fri, 11 Aug 2023 22:21:11 -0400 Subject: [PATCH 4/8] Check for waitingmsgs on ipcrenderer message instead of when adding to chat window to prevent refresh causing waitingmsgs to be triggered --- gui/preload-chat.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gui/preload-chat.js b/gui/preload-chat.js index 30bf38b7..47ffb417 100644 --- a/gui/preload-chat.js +++ b/gui/preload-chat.js @@ -827,6 +827,10 @@ ipcRenderer.on("action-new-msg-received", (event, arg) => { add_obj_to_database(obj); update_chat_obj_by_uuid(obj.uuid); + // check for messages which failed and try to transmit them + if (config.enable_auto_retry.toUpperCase() == "TRUE") { + checkForWaitingMessages(obj.dxcallsign); + } // handle ping-ack } else if (item.ping == "acknowledge") { @@ -865,7 +869,10 @@ ipcRenderer.on("action-new-msg-received", (event, arg) => { obj.new = 0; add_obj_to_database(obj); update_chat_obj_by_uuid(obj.uuid); - + // check for messages which failed and try to transmit them + if (config.enable_auto_retry.toUpperCase() == "TRUE") { + checkForWaitingMessages(obj.dxcallsign); + } // handle ARQ transmission } else if (item.arq == "transmission" && item.status == "received") { //var encoded_data = atob(item.data); @@ -904,6 +911,7 @@ ipcRenderer.on("action-new-msg-received", (event, arg) => { obj.filetype = "null"; obj.file = "null"; obj.new = 0; + // check for messages which failed and try to transmit them if (config.enable_request_profile == "True") { sendUserData(item.dxcallsign); } @@ -1322,10 +1330,6 @@ update_chat = function (obj) { if (!document.getElementById("msg-" + obj._id)) { if (obj.type == "ping") { - // check for messages which failed and try to transmit them - if (config.enable_auto_retry.toUpperCase() == "TRUE") { - checkForWaitingMessages(obj.dxcallsign); - } //if (obj.new == 1) //{ // showOsPopUp("Ping from " + obj.dxcallsign,"You've been ping'd!"); @@ -1344,10 +1348,6 @@ update_chat = function (obj) { `; } if (obj.type == "beacon") { - // check for messages which failed and try to transmit them - if (config.enable_auto_retry.toUpperCase() == "TRUE") { - checkForWaitingMessages(obj.dxcallsign); - } var new_message = `

snr: ${obj.snr} - ${timestamp}

From 389e1e76760adc76f3605ea71ae648d151f4cd3b Mon Sep 17 00:00:00 2001 From: Mashintime Date: Sat, 12 Aug 2023 10:43:08 -0400 Subject: [PATCH 5/8] Pasted comment in the wrong spot --- gui/preload-chat.js | 1 - 1 file changed, 1 deletion(-) diff --git a/gui/preload-chat.js b/gui/preload-chat.js index 47ffb417..7f9e6ad2 100644 --- a/gui/preload-chat.js +++ b/gui/preload-chat.js @@ -911,7 +911,6 @@ ipcRenderer.on("action-new-msg-received", (event, arg) => { obj.filetype = "null"; obj.file = "null"; obj.new = 0; - // check for messages which failed and try to transmit them if (config.enable_request_profile == "True") { sendUserData(item.dxcallsign); } From a637a7f8ee616483f5c8b1cfdd7722ca7085fa79 Mon Sep 17 00:00:00 2001 From: Mashintime Date: Sat, 26 Aug 2023 23:15:22 -0400 Subject: [PATCH 6/8] Rework channel busy delay logic --- tnc/modem.py | 30 +++++++++++++++++------------- tnc/static.py | 1 + 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/tnc/modem.py b/tnc/modem.py index 182222e3..77ec31d0 100644 --- a/tnc/modem.py +++ b/tnc/modem.py @@ -1261,7 +1261,7 @@ class RF: whether the channel is "busy." """ # Initialize channel_busy_delay counter - channel_busy_delay = 0 + #channel_busy_delay = 0 # Initialize dbfs counter rms_counter = 0 @@ -1343,6 +1343,9 @@ class RF: slot3 = [120, 176] slot4 = [176, 231] slot5 = [231, len(dfftlist)] + + # Set to true if we should increment delay count; else false to decrement + addDelay=False for range in [slot1, slot2, slot3, slot4, slot5]: range_start = range[0] @@ -1354,22 +1357,23 @@ class RF: # If we have a signal, increment our channel_busy delay counter # so we have a smoother state toggle if np.sum(slotdfft[slotdfft > avg + 15]) >= 200 and not TNC.transmitting: - ModemParam.channel_busy = True + addDelay=True ModemParam.channel_busy_slot[slot] = True - # Limit delay counter to a maximum of 200. The higher this value, - # the longer we will wait until releasing state - channel_busy_delay = min(channel_busy_delay + 10, 200) else: - # Decrement channel busy counter if no signal has been detected. - channel_busy_delay = max(channel_busy_delay - 1, 0) - # When our channel busy counter reaches 0, toggle state to False - if channel_busy_delay == 0: - ModemParam.channel_busy = False - ModemParam.channel_busy_slot[slot] = False - + ModemParam.channel_busy_slot[slot] = False # increment slot slot += 1 - + if (addDelay): + # Limit delay counter to a maximum of 200. The higher this value, + # the longer we will wait until releasing state + ModemParam.channel_busy = True + ModemParam.channel_busy_delay = min(ModemParam.channel_busy_delay + 10, 200) + else: + # Decrement channel busy counter if no signal has been detected. + ModemParam.channel_busy_delay = max(ModemParam.channel_busy_delay - 1, 0) + # When our channel busy counter reaches 0, toggle state to False + if ModemParam.channel_busy_delay == 0: + ModemParam.channel_busy = False AudioParam.fft = dfftlist[:315] # 315 --> bandwidth 3200 except Exception as err: self.log.error(f"[MDM] calculate_fft: Exception: {err}") diff --git a/tnc/static.py b/tnc/static.py index e4cab283..c0534f19 100644 --- a/tnc/static.py +++ b/tnc/static.py @@ -106,6 +106,7 @@ class ModemParam: tx_delay: int = 0 # delay in ms before sending modulation for triggering VOX for example or slow PTT radios enable_scatter: bool = False scatter = [] + channel_busy_delay = 0 @dataclass class Station: From 19697da88b9a789f9a6d766a31ecf31854e41cc3 Mon Sep 17 00:00:00 2001 From: Mashintime Date: Sat, 26 Aug 2023 23:32:38 -0400 Subject: [PATCH 7/8] Set channel_busy if not set and codec2 data is detected --- tnc/modem.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tnc/modem.py b/tnc/modem.py index 77ec31d0..a68d1f97 100644 --- a/tnc/modem.py +++ b/tnc/modem.py @@ -875,7 +875,10 @@ class RF: # we need to disable this if in testmode as its causing problems with FIFO it seems if not TESTMODE: ModemParam.is_codec2_traffic = True - + if not ModemParam.channel_busy: + self.log.debug("[MDM] Setting channel_busy since codec2 data detected") + ModemParam.channel_busy=True + ModemParam.channel_busy_delay+=10 self.log.debug( "[MDM] [demod_audio] modem state", mode=mode_name, rx_status=rx_status, sync_flag=codec2.api.rx_sync_flags_to_text[rx_status] From 8919e45967a4f6d3e5b155d82e9b4add8f382738 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Sun, 27 Aug 2023 13:13:49 +0000 Subject: [PATCH 8/8] Prettified Code! --- gui/preload-chat.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/gui/preload-chat.js b/gui/preload-chat.js index 7f9e6ad2..1634b204 100644 --- a/gui/preload-chat.js +++ b/gui/preload-chat.js @@ -1067,7 +1067,11 @@ update_chat = function (obj) { } // check if wrong status message - if (obj.status == "transmitting" && obj.type == "transmit" && obj.percent < 100) { + if ( + obj.status == "transmitting" && + obj.type == "transmit" && + obj.percent < 100 + ) { var TimeDifference = new Date().getTime() / 1000 - obj.timestamp; if (TimeDifference > 21600) { //Six hours @@ -1292,14 +1296,14 @@ update_chat = function (obj) { getSetUserSharedFolder(selected_callsign); if (selected_callsign.startsWith("BC-")) { document - .getElementById("chatModuleMessage") - .setAttribute("maxlength", 16); - //console.log("Setting max message size to 16") + .getElementById("chatModuleMessage") + .setAttribute("maxlength", 16); + //console.log("Setting max message size to 16") } else { document - .getElementById("chatModuleMessage") - .setAttribute("maxlength", 524288); - //console.log("Setting max message size to big#") + .getElementById("chatModuleMessage") + .setAttribute("maxlength", 524288); + //console.log("Setting max message size to big#") } }); @@ -2784,7 +2788,9 @@ function checkForWaitingMessages(dxcall) { }, }) .then(function (result) { - console.log("Found " + result.docs.length + " messages waiting for " + dxcall) + console.log( + "Found " + result.docs.length + " messages waiting for " + dxcall, + ); // handle result if (result.docs.length > 0) { // only want to process the first available item object, then return