X-Git-Url: http://average.org/gitweb/?a=blobdiff_plain;f=gps303%2Fgps303proto.py;fp=gps303%2Fgps303proto.py;h=e597b2bbc564da0e24e37f39aa69b5e725b68e2b;hb=037939789ccc7ed56059cf9bc7522d3cd7e840a8;hp=baa9a6cf64ac7af7b6fcb5605de3783f02b35955;hpb=7bf96d53196eb6caf035335260a2dc25cec72e57;p=loctrkd.git diff --git a/gps303/gps303proto.py b/gps303/gps303proto.py index baa9a6c..e597b2b 100755 --- a/gps303/gps303proto.py +++ b/gps303/gps303proto.py @@ -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: