diff --git a/skitter/__main__.py b/skitter/__main__.py index 8800e12..8bb47a1 100644 --- a/skitter/__main__.py +++ b/skitter/__main__.py @@ -5,7 +5,25 @@ yap yap yap import getopt import sys +from typing import Final + from skitter.usage import print_help +from skitter import rtl + +def proc_list(raw: str) -> list: + """ + Quality of life for the user. + """ + ret: list + delims: list = [',', '+', '/'] + + for ch in delims: + if ch in raw: + ret = raw.split(ch) + else: + ret = [raw] + + return ret def main(): '''main''' @@ -17,22 +35,76 @@ def main(): print_help() sys.exit(2) + BAND_DEFAULT: Final[list] = [87700000, 92500000, 98300000] + OUTDIR_DEFAULT: Final[str] = "Snoops" + SQUELCH_DEFAULT: Final[float] = -29.0 + RATE_DEFAULT: Final[int] = 1500 + + rate_ms: int + squelch_db: float + out_dir: str + band_hz: list + + bflag: bool = False + oflag: bool = False + sflag: bool = False + rflag: bool = False + + barg: str + oarg: str + sarg: float + rarg: int + for o, a in opts: if o in ('-h', '--help'): print_help() sys.exit() if o in ('-b', '--band'): - print(f"band {a}") # debug + bflag = True + barg = str(a) + #print(f"band {a}") # debug if o in ('-o', '--out-directory'): - print(f"dir {a}") # debug + oflag = True + oarg = str(a) + #print(f"dir {a}") # debug if o in ('-s', '--squelch'): - print(f"squelch {a}") # debug + sflag = True + sarg = float(a) + #print(f"squelch {a}") # debug if o in ('-r', '--rate'): - print(f"rate {a}") # debug + #print(f"rate {a}") # debug + rflag = True + rarg = int(a) + + # end for o, a in opts + + # Set defaults or user values + if bflag is False: + band_hz = BAND_DEFAULT + else: + band_hz = barg.split(',') + + if oflag is False: + out_dir = OUTDIR_DEFAULT + else: + out_dir = oarg + + if sflag is False: + squelch_db = SQUELCH_DEFAULT + else: + squelch_db = sarg + + if rflag is False: + rate_ms = RATE_DEFAULT + else: + rate_ms = rarg + + rtl.lock(band_hz, rate_ms, squelch_db) if __name__ == '__main__': main() + diff --git a/skitter/rtl.py b/skitter/rtl.py new file mode 100644 index 0000000..5ddec03 --- /dev/null +++ b/skitter/rtl.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 +"interactions with rtlsdr" + +def lock(band_hz: list, rate_ms: int, squelch_db: float): + """ + Locking into a set of frequencies. + - band_hz: array of desired frequencies i.e. channels in HERTZ ONLY + - rate_ms: time to wait between changing channels if no activity + - squelch_db: noise ceiling before a channel is considered active + """ + print(f"Band: {band_hz}\nSquelch: {squelch_db}\nRate: {rate_ms}") +