Conflicts: python3-gps303
Replaces: python3-gps303
Description: Suite of modules to collect reports from xz303 GPS trackers
- Consists of collector, storagae, lookaside, and termconfig
+ Consists of collector, storagae, rectifier, and termconfig
python3-loctrkd: systemd-service-file-refers-to-unusual-wantedby-target loctrkd.target [lib/systemd/system/loctrkd.collector.service]
-python3-loctrkd: systemd-service-file-refers-to-unusual-wantedby-target loctrkd.target [lib/systemd/system/loctrkd.lookaside.service]
+python3-loctrkd: systemd-service-file-refers-to-unusual-wantedby-target loctrkd.target [lib/systemd/system/loctrkd.rectifier.service]
python3-loctrkd: systemd-service-file-refers-to-unusual-wantedby-target loctrkd.target [lib/systemd/system/loctrkd.storage.service]
python3-loctrkd: systemd-service-file-refers-to-unusual-wantedby-target loctrkd.target [lib/systemd/system/loctrkd.termconfig.service]
[storage]
dbfn = /var/lib/loctrkd/trkloc.sqlite
-[lookaside]
+[rectifier]
# "opencellid" and "googlemaps" can be here. Both require an access token,
# though googlemaps is only online, while opencellid backend looks up a
# local database, that can be updated once a week or once a month.
# Environment for loctrkd suite
# Common command-line option for all daemons
#OPTIONS="-c /etc/loctrkd.conf -d"
-# Which lookaside service to use: opencellid or googleloc
+# Which rectifier service to use: opencellid or googleloc
LOOKASIDE=opencellid
+++ /dev/null
-[Unit]
-Description=GPS303 Lookaside Service
-PartOf=loctrkd.target
-
-[Service]
-Type=simple
-EnvironmentFile=-/etc/default/loctrkd
-ExecStart=python3 -m loctrkd.lookaside $OPTIONS
-KillSignal=INT
-Restart=on-failure
-StandardOutput=journal
-StandardError=inherit
-User=loctrkd
-Group=loctrkd
-
-[Install]
-WantedBy=loctrkd.target
--- /dev/null
+[Unit]
+Description=GPS303 Lookaside Service
+PartOf=loctrkd.target
+
+[Service]
+Type=simple
+EnvironmentFile=-/etc/default/loctrkd
+ExecStart=python3 -m loctrkd.rectifier $OPTIONS
+KillSignal=INT
+Restart=on-failure
+StandardOutput=journal
+StandardError=inherit
+User=loctrkd
+Group=loctrkd
+
+[Install]
+WantedBy=loctrkd.target
Requires=loctrkd.collector.service \
loctrkd.storage.service \
loctrkd.termconfig.service \
- loctrkd.lookaside.service \
+ loctrkd.rectifier.service \
loctrkd.wsgateway.service
After=loctrkd.collector.service \
loctrkd.storage.service \
loctrkd.termconfig.service \
- loctrkd.lookaside.service \
+ loctrkd.rectifier.service \
loctrkd.wsgateway.service
[Install]
dh_installsystemd --name=loctrkd
dh_installsystemd --name=loctrkd.collector
dh_installsystemd --name=loctrkd.storage
- dh_installsystemd --name=loctrkd.lookaside
+ dh_installsystemd --name=loctrkd.rectifier
dh_installsystemd --name=loctrkd.termconfig
dh_installsystemd --name=loctrkd.wsgateway
dh_installsystemd --name=loctrkd.ocid-dload
+++ /dev/null
-""" Estimate coordinates from WIFI_POSITIONING and send back """
-
-from configparser import ConfigParser
-from datetime import datetime, timezone
-from importlib import import_module
-from logging import getLogger
-from os import umask
-from struct import pack
-import zmq
-
-from . import common
-from .zx303proto import parse_message, proto_name, WIFI_POSITIONING
-from .zmsg import Bcast, Resp, topic
-
-log = getLogger("loctrkd/lookaside")
-
-
-def runserver(conf: ConfigParser) -> None:
- qry = import_module("." + conf.get("lookaside", "backend"), __package__)
- qry.init(conf)
- # Is this https://github.com/zeromq/pyzmq/issues/1627 still not fixed?!
- zctx = zmq.Context() # type: ignore
- zsub = zctx.socket(zmq.SUB) # type: ignore
- zsub.connect(conf.get("collector", "publishurl"))
- zsub.setsockopt(zmq.SUBSCRIBE, topic(proto_name(WIFI_POSITIONING)))
- zpush = zctx.socket(zmq.PUSH) # type: ignore
- zpush.connect(conf.get("collector", "listenurl"))
-
- try:
- while True:
- zmsg = Bcast(zsub.recv())
- msg = parse_message(zmsg.packet)
- log.debug(
- "IMEI %s from %s at %s: %s",
- zmsg.imei,
- zmsg.peeraddr,
- datetime.fromtimestamp(zmsg.when).astimezone(tz=timezone.utc),
- msg,
- )
- try:
- lat, lon = qry.lookup(
- msg.mcc, msg.mnc, msg.gsm_cells, msg.wifi_aps
- )
- resp = Resp(
- imei=zmsg.imei,
- when=zmsg.when, # not the current time, but the original!
- packet=msg.Out(latitude=lat, longitude=lon).packed,
- )
- log.debug("Response for lat=%s, lon=%s: %s", lat, lon, resp)
- zpush.send(resp.packed)
- except Exception as e:
- log.warning("Lookup for %s resulted in %s", msg, e)
-
- except KeyboardInterrupt:
- zsub.close()
- zpush.close()
- zctx.destroy() # type: ignore
- qry.shut()
-
-
-if __name__.endswith("__main__"):
- runserver(common.init(log))
--- /dev/null
+""" Estimate coordinates from WIFI_POSITIONING and send back """
+
+from configparser import ConfigParser
+from datetime import datetime, timezone
+from importlib import import_module
+from logging import getLogger
+from os import umask
+from struct import pack
+import zmq
+
+from . import common
+from .zx303proto import parse_message, proto_name, WIFI_POSITIONING
+from .zmsg import Bcast, Resp, topic
+
+log = getLogger("loctrkd/rectifier")
+
+
+def runserver(conf: ConfigParser) -> None:
+ qry = import_module("." + conf.get("rectifier", "backend"), __package__)
+ qry.init(conf)
+ # Is this https://github.com/zeromq/pyzmq/issues/1627 still not fixed?!
+ zctx = zmq.Context() # type: ignore
+ zsub = zctx.socket(zmq.SUB) # type: ignore
+ zsub.connect(conf.get("collector", "publishurl"))
+ zsub.setsockopt(zmq.SUBSCRIBE, topic(proto_name(WIFI_POSITIONING)))
+ zpush = zctx.socket(zmq.PUSH) # type: ignore
+ zpush.connect(conf.get("collector", "listenurl"))
+
+ try:
+ while True:
+ zmsg = Bcast(zsub.recv())
+ msg = parse_message(zmsg.packet)
+ log.debug(
+ "IMEI %s from %s at %s: %s",
+ zmsg.imei,
+ zmsg.peeraddr,
+ datetime.fromtimestamp(zmsg.when).astimezone(tz=timezone.utc),
+ msg,
+ )
+ try:
+ lat, lon = qry.lookup(
+ msg.mcc, msg.mnc, msg.gsm_cells, msg.wifi_aps
+ )
+ resp = Resp(
+ imei=zmsg.imei,
+ when=zmsg.when, # not the current time, but the original!
+ packet=msg.Out(latitude=lat, longitude=lon).packed,
+ )
+ log.debug("Response for lat=%s, lon=%s: %s", lat, lon, resp)
+ zpush.send(resp.packed)
+ except Exception as e:
+ log.warning("Lookup for %s resulted in %s", msg, e)
+
+ except KeyboardInterrupt:
+ zsub.close()
+ zpush.close()
+ zctx.destroy() # type: ignore
+ qry.shut()
+
+
+if __name__.endswith("__main__"):
+ runserver(common.init(log))
"dbfn": self.tmpfilebase + ".opencellid.sqlite",
"downloadurl": f"http://localhost:{freeports[2]}/test/262.csv.gz",
}
- self.conf["lookaside"] = {
+ self.conf["rectifier"] = {
"backend": "opencellid",
}
self.conf["wsgateway"] = {
class Storage(TestWithServers):
def setUp(self, *args: str, **kwargs: Any) -> None:
super().setUp(
- "collector", "storage", "lookaside", "termconfig", verbose=True
+ "collector", "storage", "rectifier", "termconfig", verbose=True
)
with connect(self.conf.get("opencellid", "dbfn")) as ldb:
ldb.execute(SCHEMA)