Files
Discord-Radio-Bot/gqrxHandler.py
Logan Cusano eac3fc4e39 Update: Working on SDR RX
- Switched to using GQRX
- Created a handler to connect over Telnet to local GQRS

TODO
- Need to find a way to close GQRX without closing the application; Can't start the app with the radio listening, so it must be opened manually
2022-01-03 22:54:18 -05:00

39 lines
1.2 KiB
Python

from telnetlib import Telnet
class GQRXHandler():
def __init__(self, hostname: str = "localhost", port: int = 7356):
self.hostname = hostname
self.port = port
self.telnet_connection = None
def create_telnet_connection(self):
tel_conn = Telnet(self.hostname, self.port)
tel_conn.read_until("Escape character is '^]'.")
return tel_conn
def change_freq(self, freq):
tel_conn = self.create_telnet_connection()
tel_conn.write(f"F {int(freq)}")
tel_conn.read_all()
tel_conn.close()
def change_squelch(self, squelch):
tel_conn = self.create_telnet_connection()
tel_conn.write(f"L SQL {float(squelch)}")
tel_conn.read_all()
tel_conn.close()
def change_mode(self, mode):
tel_conn = self.create_telnet_connection()
tel_conn.write(f"M {str(mode)}")
tel_conn.read_all()
tel_conn.close()
def set_all_settings(self, mode, squelch, freq):
tel_conn = self.create_telnet_connection()
tel_conn.write(f"F {int(freq)}")
tel_conn.write(f"M {str(mode)}")
tel_conn.write(f"L SQL {float(squelch)}")