From bdd8888f1b87dee4ab2870e5ba270ba3b34cfdb7 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Mon, 25 Mar 2024 19:29:30 +0100 Subject: [PATCH] enable/disable socket interface --- modem/config.ini.example | 1 + modem/config.py | 3 ++- modem/service_manager.py | 10 +++++++--- modem/socket_interface.py | 2 ++ modem/socket_interface_commands.py | 1 + tests/test_p2p_connection.py | 2 +- 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/modem/config.ini.example b/modem/config.ini.example index c0a2b5bf..1f077baa 100644 --- a/modem/config.ini.example +++ b/modem/config.ini.example @@ -49,6 +49,7 @@ enable_morse_identifier = False respond_to_cq = True tx_delay = 50 maximum_bandwidth = 1700 +enable_socket_interface = False [SOCKET_INTERFACE] enable = False diff --git a/modem/config.py b/modem/config.py index dcd234c1..0b7debca 100644 --- a/modem/config.py +++ b/modem/config.py @@ -59,7 +59,8 @@ class CONFIG: 'enable_morse_identifier': bool, 'maximum_bandwidth': int, 'respond_to_cq': bool, - 'tx_delay': int + 'tx_delay': int, + 'enable_socket_interface': bool, }, 'SOCKET_INTERFACE': { 'enable' : bool, diff --git a/modem/service_manager.py b/modem/service_manager.py index f19ecbab..a2f9a0c1 100644 --- a/modem/service_manager.py +++ b/modem/service_manager.py @@ -33,19 +33,23 @@ class SM: self.config = self.app.config_manager.read() self.start_radio_manager() self.start_modem() - self.socket_interface_manager = SocketInterfaceHandler(self.modem, self.app.config_manager, self.state_manager, self.event_manager).start_servers() + + if self.config['MODEM']['enable_socket_interface']: + self.socket_interface_manager = SocketInterfaceHandler(self.modem, self.app.config_manager, self.state_manager, self.event_manager).start_servers() elif cmd in ['stop'] and self.modem: self.stop_modem() self.stop_radio_manager() - self.socket_interface_manager.stop_servers() + if self.config['MODEM']['enable_socket_interface']: + self.socket_interface_manager.stop_servers() # we need to wait a bit for avoiding a portaudio crash threading.Event().wait(0.5) elif cmd in ['restart']: self.stop_modem() self.stop_radio_manager() - self.socket_interface_manager.stop_servers() + if self.config['MODEM']['enable_socket_interface']: + self.socket_interface_manager.stop_servers() # we need to wait a bit for avoiding a portaudio crash threading.Event().wait(0.5) diff --git a/modem/socket_interface.py b/modem/socket_interface.py index 62a2ae30..0b41b4fc 100644 --- a/modem/socket_interface.py +++ b/modem/socket_interface.py @@ -1,3 +1,5 @@ +""" WORK IN PROGRESS by DJ2LS""" + import socketserver import threading import structlog diff --git a/modem/socket_interface_commands.py b/modem/socket_interface_commands.py index 2db96532..fe4c18f4 100644 --- a/modem/socket_interface_commands.py +++ b/modem/socket_interface_commands.py @@ -1,3 +1,4 @@ +""" WORK IN PROGRESS by DJ2LS""" from command_p2p_connection import P2PConnectionCommand class SocketCommandHandler: diff --git a/tests/test_p2p_connection.py b/tests/test_p2p_connection.py index c8004646..44ceb5ae 100644 --- a/tests/test_p2p_connection.py +++ b/tests/test_p2p_connection.py @@ -148,7 +148,7 @@ class TestP2PConnectionSession(unittest.TestCase): length = random.randint(min_length, max_length) return ''.join(random.choices(string.ascii_letters, k=length))# - def testARQSessionSmallPayload(self): + def DisabledtestARQSessionSmallPayload(self): # set Packet Error Rate (PER) / frame loss probability self.loss_probability = 0