X-Git-Url: http://www.average.org/gitweb/?p=loctrkd.git;a=blobdiff_plain;f=loctrkd%2Frectifier.py;h=5926377ee76ad4dc5665b72dec551a5e279bc661;hp=1da57528d733a52df0be0955f18d7d29ce86d49b;hb=2cf0fd9d215dda17eae4261ab7967367f6aa0028;hpb=f24ba18e34cbfe34bf648459f0e80bd874334fe4 diff --git a/loctrkd/rectifier.py b/loctrkd/rectifier.py index 1da5752..5926377 100644 --- a/loctrkd/rectifier.py +++ b/loctrkd/rectifier.py @@ -31,7 +31,7 @@ class QryModule: mnc: int, gsm_cells: List[Tuple[int, int, int]], wifi_aps: List[Tuple[str, int]], - ) -> Tuple[float, float]: + ) -> Tuple[float, float, float]: ... @@ -51,7 +51,9 @@ def runserver(conf: ConfigParser) -> None: zpush = zctx.socket(zmq.PUSH) # type: ignore zpush.connect(conf.get("collector", "listenurl")) zpub = zctx.socket(zmq.PUB) # type: ignore + oldmask = umask(0o117) zpub.bind(conf.get("rectifier", "publishurl")) + umask(oldmask) try: while True: @@ -66,20 +68,26 @@ def runserver(conf: ConfigParser) -> None: datetime.fromtimestamp(zmsg.when).astimezone(tz=timezone.utc), msg, ) - rect: Report = msg.rectified() + pmod, rect = msg.rectified() log.debug("rectified: %s", rect) if isinstance(rect, (CoordReport, StatusReport)): - zpub.send(Rept(imei=zmsg.imei, payload=rect.json).packed) + zpub.send( + Rept(imei=zmsg.imei, pmod=pmod, payload=rect.json).packed + ) elif isinstance(rect, HintReport): try: - lat, lon = qry.lookup( + lat, lon, acc = qry.lookup( rect.mcc, rect.mnc, rect.gsm_cells, list((mac, strng) for _, mac, strng in rect.wifi_aps), ) log.debug( - "Approximated lat=%s, lon=%s for %s", lat, lon, rect + "Approximated lat=%s, lon=%s, acc=%s for %s", + lat, + lon, + acc, + rect, ) if proto_needanswer.get(zmsg.proto, False): resp = Resp( @@ -92,10 +100,10 @@ def runserver(conf: ConfigParser) -> None: rept = CoordReport( devtime=rect.devtime, battery_percentage=rect.battery_percentage, - accuracy=-1, - altitude=-1, - speed=-1, - direction=-1, + accuracy=acc, + altitude=None, + speed=None, + direction=None, latitude=lat, longitude=lon, ) @@ -107,7 +115,7 @@ def runserver(conf: ConfigParser) -> None: ).packed ) except Exception as e: - log.warning( + log.exception( "Lookup for %s rectified as %s resulted in %s", msg, rect,