]> www.average.org Git - loctrkd.git/commitdiff
do not respond to hibernation; minor cleanup
authorEugene Crosser <crosser@average.org>
Mon, 9 May 2022 19:53:29 +0000 (21:53 +0200)
committerEugene Crosser <crosser@average.org>
Mon, 9 May 2022 19:53:29 +0000 (21:53 +0200)
gps303/collector.py
gps303/gps303proto.py
gps303/wsgateway.py

index b8cc379a16a5cbac14615ead70e84b841e7425ab..de65394d4f4b5eefb0527bea384746cea5d5b2a0 100644 (file)
@@ -167,15 +167,6 @@ def runserver(conf):
                         try:
                             msg = zpull.recv(zmq.NOBLOCK)
                             zmsg = Resp(msg)
-                            zpub.send(
-                                Bcast(
-                                    is_incoming=False,
-                                    proto=proto_of_message(zmsg.packet),
-                                    when=zmsg.when,
-                                    imei=zmsg.imei,
-                                    packet=zmsg.packet,
-                                ).packed
-                            )
                             tosend.append(zmsg)
                         except zmq.Again:
                             break
@@ -210,7 +201,7 @@ def runserver(conf):
                                 tostop.append(sk)
                             respmsg = inline_response(packet)
                             if respmsg is not None:
-                                clients.response(
+                                tosend.append(
                                     Resp(imei=imei, when=when, packet=respmsg)
                                 )
                 else:
@@ -220,6 +211,15 @@ def runserver(conf):
                 poller.unregister(fd)
                 clients.stop(fd)
             for zmsg in tosend:
+                zpub.send(
+                    Bcast(
+                        is_incoming=False,
+                        proto=proto_of_message(zmsg.packet),
+                        when=zmsg.when,
+                        imei=zmsg.imei,
+                        packet=zmsg.packet,
+                    ).packed
+                )
                 log.debug("Sending to the client: %s", zmsg)
                 clients.response(zmsg)
             for clntsock, clntaddr in topoll:
index 8f4ffcce124e23fd1a4baeb236e434578cbcae5f..e3e7cf18cd634f2ab1261f26dcbb3643e7798738 100755 (executable)
@@ -297,7 +297,6 @@ class STATUS(GPS303Pkt):
 
 class HIBERNATION(GPS303Pkt):  # Server can send to send devicee to sleep
     PROTO = 0x14
-    RESPOND = Respond.INL
 
 
 class RESET(GPS303Pkt):
index 2f6811e45225e6b478a9dcf8796ec4c63b9e68d0..d66070e2f57a7781fe76a8249ac176536e3192d4 100644 (file)
@@ -287,28 +287,18 @@ def runserver(conf):
                             zmsg = Bcast(zsub.recv(zmq.NOBLOCK))
                             msg = parse_message(zmsg.packet, zmsg.is_incoming)
                             log.debug("Got %s with %s", zmsg, msg)
-                            if isinstance(msg, GPS_POSITIONING):
-                                tosend.append(
-                                    {
-                                        "imei": zmsg.imei,
-                                        "timestamp": str(msg.devtime),
-                                        "longitude": msg.longitude,
-                                        "latitude": msg.latitude,
-                                    }
-                                )
-                            elif isinstance(msg, WIFI_POSITIONING):
-                                tosend.append(
-                                    {
-                                        "imei": zmsg.imei,
-                                        "timestamp": str(
-                                            datetime.fromtimestamp(
-                                                zmsg.when
-                                            ).astimezone(tz=timezone.utc)
-                                        ),
-                                        "longitude": msg.longitude,
-                                        "latitude": msg.latitude,
-                                    }
-                                )
+                            tosend.append(
+                                {
+                                    "imei": zmsg.imei,
+                                    "timestamp": str(
+                                        datetime.fromtimestamp(
+                                            zmsg.when
+                                        ).astimezone(tz=timezone.utc)
+                                    ),
+                                    "longitude": msg.longitude,
+                                    "latitude": msg.latitude,
+                                }
+                            )
                         except zmq.Again:
                             break
                 elif sk == tcpfd: