openwebrx/owrx/ism/rtl433.py
2023-09-01 23:37:40 +02:00

29 lines
717 B
Python

from pycsdr.modules import ExecModule
from pycsdr.types import Format
from csdr.module import LineBasedModule
import json
import logging
logger = logging.getLogger(__name__)
class Rtl433Module(ExecModule):
def __init__(self):
super().__init__(
Format.COMPLEX_FLOAT,
Format.CHAR,
["rtl_433", "-r", "cf32:-", "-F", "json", "-M", "time:unix", "-C", "si"]
)
class JsonParser(LineBasedModule):
def process(self, line):
try:
msg = json.loads(line.decode())
msg["mode"] = "ISM"
logger.debug(msg)
return msg
except json.JSONDecodeError:
logger.exception("error parsing rtl433 json")