more boilerplate

This commit is contained in:
2025-11-20 15:31:35 -06:00
parent 9b40430fbe
commit c837f29930
2 changed files with 88 additions and 4 deletions

View File

@@ -5,7 +5,25 @@ yap yap yap
import getopt import getopt
import sys import sys
from typing import Final
from skitter.usage import print_help 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(): def main():
'''main''' '''main'''
@@ -17,22 +35,76 @@ def main():
print_help() print_help()
sys.exit(2) 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: for o, a in opts:
if o in ('-h', '--help'): if o in ('-h', '--help'):
print_help() print_help()
sys.exit() sys.exit()
if o in ('-b', '--band'): 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'): 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'): 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'): 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__': if __name__ == '__main__':
main() main()

12
skitter/rtl.py Normal file
View File

@@ -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}")