]> www.average.org Git - loctrkd.git/blobdiff - gps303/gps303proto.py
collector: get rid of more protocol specifics
[loctrkd.git] / gps303 / gps303proto.py
index baa9a6cf64ac7af7b6fcb5605de3783f02b35955..e597b2bbc564da0e24e37f39aa69b5e725b68e2b 100755 (executable)
@@ -879,6 +879,18 @@ def proto_of_message(packet: bytes) -> int:
     return packet[1]
 
 
+def imei_from_packet(packet: bytes) -> Optional[str]:
+    if proto_of_message(packet) == LOGIN.PROTO:
+        msg = parse_message(packet)
+        if isinstance(msg, LOGIN):
+            return msg.imei
+    return None
+
+
+def is_goodbye_packet(packet: bytes) -> bool:
+    return proto_of_message(packet) == HIBERNATION.PROTO
+
+
 def inline_response(packet: bytes) -> Optional[bytes]:
     proto = proto_of_message(packet)
     if proto in CLASSES: