]> www.average.org Git - loctrkd.git/blobdiff - gps303/zmsg.py
Show coordinates on the map
[loctrkd.git] / gps303 / zmsg.py
index 898918cab10204384986bf2b36ae710148dbab9c..28c233a3cafe7b45f89fc6b0c44f94c8a98d5251 100644 (file)
@@ -145,7 +145,7 @@ class LocEvt(_Zmsg):
     @property
     def packed(self):
         return (
-            self.imei.encode()
+                ("0000000000000000" + self.imei)[-16:].encode()
             + dumps(
                 {
                     "devtime": str(self.devtime),
@@ -156,6 +156,19 @@ class LocEvt(_Zmsg):
             ).encode()
         )
 
+    # And this is full json that can be sent over websocket etc.
+    @property
+    def json(self):
+        return dumps(
+            {
+                "imei": self.imei,
+                "devtime": str(self.devtime),
+                "latitude": self.lat,
+                "longitude": self.lon,
+                "is-gps": self.is_gps,
+            }
+        )
+
     def decode(self, buffer):
         self.imei = buffer[:16].decode()
         json_data = loads(buffer[16:])