from queues import DATA_QUEUE_TRANSMIT import base64 import helpers import structlog log = structlog.get_logger("COMMANDS") def cqcqcq(): try: DATA_QUEUE_TRANSMIT.put(["CQ"]) except Exception as err: log.warning("[CMD] error while transmiting CQ", e=err) def ping_ping(data): try: dxcallsign = data["dxcallsign"] if not str(dxcallsign).strip(): return DATA_QUEUE_TRANSMIT.put(["PING", None, dxcallsign]) except Exception as err: log.warning( "[CMD] PING command execution error", e=err, command=data ) def beacon(data): beacon_state = data['enabled'] in ['True'] #Beacon.beacon_state = beacon_state log.info( "[CMD] Changing beacon state", state=beacon_state ) DATA_QUEUE_TRANSMIT.put(["BEACON", 300, beacon_state]) def modem_send_test_frame(): log.info( "[CMD] Send test frame" ) DATA_QUEUE_TRANSMIT.put(["SEND_TEST_FRAME"]) def modem_fec_transmit(data): log.info( "[CMD] Send fec frame" ) mode = data["mode"] wakeup = data["wakeup"] base64data = data["payload"] if len(base64data) % 4: raise TypeError payload = base64.b64decode(base64data) try: mycallsign = data["mycallsign"] except: mycallsign = None DATA_QUEUE_TRANSMIT.put(["FEC", mode, wakeup, payload, mycallsign]) def modem_fec_is_writing(data): try: mycallsign = data["mycallsign"] DATA_QUEUE_TRANSMIT.put(["FEC_IS_WRITING", mycallsign]) except Exception as err: log.warning( "[SCK] Send fec frame command execution error", e=err, command=data, )