]> www.average.org Git - loctrkd.git/blobdiff - gps303/termconfig.py
fill in `when` in Resp packet
[loctrkd.git] / gps303 / termconfig.py
index fe1f2cd78f2410696ee53fe7ff8a11ef1f063dbc..9f9168409d6ddd21b0abf746d2d21ce5eae251c8 100644 (file)
@@ -7,7 +7,7 @@ import zmq
 
 from . import common
 from .gps303proto import *
-from .zmsg import Bcast, Resp
+from .zmsg import Bcast, Resp, topic
 
 log = getLogger("gps303/termconfig")
 
@@ -22,8 +22,8 @@ def runserver(conf):
         "SETUP",
         "POSITION_UPLOAD_INTERVAL",
     ):
-        topic = pack("B", proto_by_name(protoname))
-        zsub.setsockopt(zmq.SUBSCRIBE, topic)
+        tosub = topic(proto_by_name(protoname))
+        zsub.setsockopt(zmq.SUBSCRIBE, tosub)
     zpush = zctx.socket(zmq.PUSH)
     zpush.connect(conf.get("collector", "listenurl"))
 
@@ -38,7 +38,7 @@ def runserver(conf):
                 datetime.fromtimestamp(zmsg.when).astimezone(tz=timezone.utc),
                 msg,
             )
-            if msg.DIR is not Dir.EXT:
+            if msg.RESPOND is not Respond.EXT:
                 log.error(
                     "%s does not expect externally provided response", msg
                 )
@@ -63,7 +63,9 @@ def runserver(conf):
                 ):
                     if key in termconfig:
                         kwargs[key] = termconfig[key]
-            resp = Resp(imei=zmsg.imei, packet=msg.response(**kwargs))
+            resp = Resp(
+                imei=zmsg.imei, when=zmsg.when, packet=msg.Out(**kwargs).packed
+            )
             log.debug("Response: %s", resp)
             zpush.send(resp.packed)