improved channel busy detection

This commit is contained in:
DJ2LS 2022-11-18 00:03:18 +01:00
parent 5a1eb7a8b8
commit 7d99f89911
6 changed files with 73 additions and 9 deletions

View file

@ -668,6 +668,11 @@ ipcMain.on('request-show-arq-toast-session-connecting',(event,data)=>{
win.webContents.send('action-show-arq-toast-session-connecting', data);
});
// ARQ SESSION WAITING
ipcMain.on('request-show-arq-toast-session-waiting',(event,data)=>{
win.webContents.send('action-show-arq-toast-session-waiting', data);
});
// ARQ SESSION CONNECTED
ipcMain.on('request-show-arq-toast-session-connected',(event,data)=>{
win.webContents.send('action-show-arq-toast-session-connected', data);

View file

@ -2284,15 +2284,15 @@ ipcRenderer.on('action-show-arq-toast-transmission-received', (event, data) => {
ipcRenderer.on('action-show-arq-toast-transmission-receiving', (event, data) => {
document.getElementById("transmission_progress").className = "progress-bar progress-bar-striped progress-bar-animated bg-primary";
var toastARQreceiving = document.getElementById('toastARQreceiving');
var toast = bootstrap.Toast.getOrCreateInstance(toastARQreceiving); // Returns a Bootstrap toast instance
var toastARQsessionreceiving = document.getElementById('toastARQreceiving');
var toast = bootstrap.Toast.getOrCreateInstance(toastARQsessionreceiving); // Returns a Bootstrap toast instance
toast.show();
});
// ARQ SESSION CONNECTING
ipcRenderer.on('action-show-arq-toast-session-connecting', (event, data) => {
var toastARQreceiving = document.getElementById('toastARQsessionconnecting');
var toastARQsessionconnecting = document.getElementById('toastARQsessionconnecting');
var toast = bootstrap.Toast.getOrCreateInstance(toastARQsessionconnecting); // Returns a Bootstrap toast instance
toast.show();
});
@ -2300,15 +2300,24 @@ ipcRenderer.on('action-show-arq-toast-session-connecting', (event, data) => {
// ARQ SESSION CONNECTED
ipcRenderer.on('action-show-arq-toast-session-connected', (event, data) => {
var toastARQreceiving = document.getElementById('toastARQsessionconnected');
var toastARQsessionconnected = document.getElementById('toastARQsessionconnected');
var toast = bootstrap.Toast.getOrCreateInstance(toastARQsessionconnected); // Returns a Bootstrap toast instance
toast.show();
});
// ARQ SESSION CONNECTED
ipcRenderer.on('action-show-arq-toast-session-waiting', (event, data) => {
var toastARQsessionwaiting = document.getElementById('toastARQsessionwaiting');
var toast = bootstrap.Toast.getOrCreateInstance(toastARQsessionwaiting); // Returns a Bootstrap toast instance
toast.show();
});
// ARQ SESSION CLOSE
ipcRenderer.on('action-show-arq-toast-session-close', (event, data) => {
var toastARQreceiving = document.getElementById('toastARQsessionclose');
var toastARQsessionclose = document.getElementById('toastARQsessionclose');
var toast = bootstrap.Toast.getOrCreateInstance(toastARQsessionclose); // Returns a Bootstrap toast instance
toast.show();
});
@ -2316,7 +2325,7 @@ ipcRenderer.on('action-show-arq-toast-session-close', (event, data) => {
// ARQ SESSION FAILED
ipcRenderer.on('action-show-arq-toast-session-failed', (event, data) => {
var toastARQreceiving = document.getElementById('toastARQsessionfailed');
var toastARQsessionfailed = document.getElementById('toastARQsessionfailed');
var toast = bootstrap.Toast.getOrCreateInstance(toastARQsessionfailed); // Returns a Bootstrap toast instance
toast.show();
});

View file

@ -305,6 +305,10 @@ client.on('data', function(socketdata) {
} else if (data['status'] == 'connected') {
ipcRenderer.send('request-show-arq-toast-session-connected', {data: [data]});
// ARQ OPENING
} else if (data['status'] == 'waiting') {
ipcRenderer.send('request-show-arq-toast-session-waiting', {data: [data]});
// ARQ OPENING
} else if (data['status'] == 'close') {
ipcRenderer.send('request-show-arq-toast-session-close', {data: [data]});

View file

@ -231,6 +231,13 @@
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
</div>
<!-- ARQ SESSION WAITING-->
<div class="toast align-items-center text-white bg-warning border-0" id="toastARQsessionwaiting" role="alert" aria-live="assertive" aria-atomic="true">
<div class="d-flex">
<div class="toast-body">CHANNEL BUSY - Waiting...</div>
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
</div>
<!-- ARQ SESSION CLOSE-->
<div class="toast align-items-center text-white bg-success border-0" id="toastARQsessionclose" role="alert" aria-live="assertive" aria-atomic="true">
<div class="d-flex">

View file

@ -1293,6 +1293,32 @@ class DATA:
state=static.ARQ_SESSION_STATE,
)
# Let's check if we have a busy channel
if static.CHANNEL_BUSY:
self.log.warning("[TNC] Channel busy, waiting until free...")
self.send_data_to_socket_queue(
freedata="tnc-message",
arq="session",
status="waiting",
)
# wait while timeout not reached and our busy state is busy
channel_busy_timeout = time.time() + 30
while static.CHANNEL_BUSY and time.time() < channel_busy_timeout:
time.sleep(0.01)
# if channel busy timeout reached stop connecting
if time.time() > channel_busy_timeout:
self.log.warning("[TNC] Channel busy, try again later...")
static.ARQ_SESSION_STATE = "failed"
self.send_data_to_socket_queue(
freedata="tnc-message",
arq="session",
status="failed",
reason="busy",
)
return False
self.open_session()
# wait until data channel is open
@ -1596,7 +1622,7 @@ class DATA:
# for calculating transmission statistics
# static.ARQ_COMPRESSION_FACTOR = len(data_out) / len(zlib.compress(data_out))
# Let's check if we have a busy channel and we are not in a running arq session.
# Let's check if we have a busy channel and if we are not in a running arq session.
if static.CHANNEL_BUSY and not static.ARQ_SESSION:
self.log.warning("[TNC] Channel busy, waiting until free...")
self.send_data_to_socket_queue(
@ -1606,9 +1632,22 @@ class DATA:
)
# wait while timeout not reached and our busy state is busy
while static.CHANNEL_BUSY and not self.datachannel_timeout:
channel_busy_timeout = time.time() + 30
while static.CHANNEL_BUSY and time.time() < channel_busy_timeout:
time.sleep(0.01)
# if channel busy timeout reached, stop connecting
if time.time() > channel_busy_timeout:
self.log.warning("[TNC] Channel busy, try again later...")
static.ARQ_SESSION_STATE = "failed"
self.send_data_to_socket_queue(
freedata="tnc-message",
arq="transmission",
status="failed",
reason="busy",
)
return False
self.arq_open_data_channel(mode, n_frames_per_burst, mycallsign)
# wait until data channel is open

View file

@ -335,7 +335,7 @@ def process_tnc_commands(data):
try:
DATA_QUEUE_TRANSMIT.put(["DISCONNECT"])
# set early disconnecting state so we can interrupt connection attemtps
# set early disconnecting state so we can interrupt connection attempts
static.ARQ_SESSION_STATE = "disconnecting"
command_response("disconnect", True)
except Exception as err: