diff --git a/modem/config.py b/modem/config.py index 032e7283..a977e3f5 100644 --- a/modem/config.py +++ b/modem/config.py @@ -77,14 +77,15 @@ class CONFIG: 'explorer': data[17], 'stats': data[19], 'fsk': data[13], - 'tx_delay': data[21] - } + 'tx_delay': data[21], + 'transmit_morse_identifier' : data[25] + } self.config['TCI'] = {'#TCI settings': None, 'ip': data[22], 'port': data[23] } - self.config['MESH'] = {'#TCI settings': None, + self.config['MESH'] = {'#Mesh settings': None, 'enable_protocol': data[24] } diff --git a/modem/daemon.py b/modem/daemon.py index dca02653..2c993a32 100755 --- a/modem/daemon.py +++ b/modem/daemon.py @@ -496,6 +496,12 @@ class DAEMON: if data[24] == "True": options.append("--mesh") + #Morse identifier + print(data[25]) + if data[25] == "True": + options.append("--morse") + + # safe data to config file config.write_entire_config(data) diff --git a/modem/data_handler.py b/modem/data_handler.py index ed65412c..63f7a72a 100644 --- a/modem/data_handler.py +++ b/modem/data_handler.py @@ -1966,6 +1966,10 @@ class DATA: # we need to send disconnect frame before doing arq cleanup # we would lose our session id then self.send_disconnect_frame() + + # transmit morse identifier if configured + if Modem.transmit_morse_identifier: + modem.MODEM_TRANSMIT_QUEUE.put(["morse", 1, 0, self.mycallsign]) self.arq_cleanup() def received_session_close(self, data_in: bytes): @@ -2856,7 +2860,8 @@ class DATA: self.enqueue_frame_for_tx([cq_frame], c2_mode=FREEDV_MODE.fsk_ldpc_0.value) else: self.enqueue_frame_for_tx([cq_frame], c2_mode=FREEDV_MODE.sig0.value, copies=1, repeat_delay=0) - #modem.MODEM_TRANSMIT_QUEUE.put(["morse", 1, 0, self.mycallsign]) + if Modem.transmit_morse_identifier: + modem.MODEM_TRANSMIT_QUEUE.put(["morse", 1, 0, self.mycallsign]) def received_cq(self, data_in: bytes) -> None: """ diff --git a/modem/main.py b/modem/main.py index b96be8e1..0a1cc7a9 100755 --- a/modem/main.py +++ b/modem/main.py @@ -261,6 +261,15 @@ if __name__ == "__main__": help="Enable and set hmac message salt", ) + PARSER.add_argument( + "--morse", + dest="transmit_morse_identifier", + action="store_true", + default=True, + help="Enable and send a morse identifier on disconnect an beacon", + ) + + ARGS = PARSER.parse_args() # set save to folder state for allowing downloading files to local file system @@ -316,7 +325,7 @@ if __name__ == "__main__": ModemParam.tx_delay = ARGS.tx_delay MeshParam.enable_protocol = ARGS.enable_mesh Modem.enable_hmac = ARGS.enable_hmac - + Modem.transmit_morse_identifier = ARGS.transmit_morse_identifier except Exception as e: log.error("[DMN] Error reading config file", exception=e) @@ -368,6 +377,8 @@ if __name__ == "__main__": TCIParam.port = int(conf.get('TCI', 'tci_port', '50001')) ModemParam.tx_delay = int(conf.get('Modem', 'tx_delay', '0')) MeshParam.enable_protocol = conf.get('MESH','mesh_enable','False') + MeshParam.transmit_morse_identifier = conf.get('Modem','transmit_morse_identifier','False') + except KeyError as e: log.warning("[CFG] Error reading config file near", key=str(e)) except Exception as e: diff --git a/modem/static.py b/modem/static.py index e63d2956..3ccca594 100644 --- a/modem/static.py +++ b/modem/static.py @@ -151,6 +151,7 @@ class Modem: heard_stations = [] listen: bool = True enable_hmac: bool = True + transmit_morse_identifier: bool = False # ------------