]> www.average.org Git - loctrkd.git/commitdiff
define more protocol units
authorEugene Crosser <crosser@average.org>
Thu, 17 Mar 2022 23:51:00 +0000 (00:51 +0100)
committerEugene Crosser <crosser@average.org>
Thu, 17 Mar 2022 23:51:00 +0000 (00:51 +0100)
gps303.conf
gps303/GT06mod.py
gps303/__main__.py

index ab4befa383be06c0ee85eee8c91574406e634f8c..97c9959fa6c14e8bc90a52e91f711c1b670bc1b2 100644 (file)
@@ -1,6 +1,6 @@
 [daemon]
 port = 4303
-dbfn = /tmp/gps303.sqlite
+dbfn = gps303.sqlite
 
 [device]
 uploadIntervalSeconds = 0x0300
index c3918c754b0e5350ad1601f9f66326b2a9758180..86cc8aacdc6542bab99a64a40b4befe90e42ddad 100755 (executable)
@@ -99,9 +99,15 @@ class LOGIN(_GT06pkt):
         return super().response(b"")
 
 
-class SUPERVISION(_GT06pkt):
+class SUPERVISION(_GT06pkt):  # Server sends supervision number status
     PROTO = 0x05
 
+    def response(self, supnum=0):
+        # 1: The device automatically answers Pickup effect
+        # 2: Automatically Answering Two-way Calls
+        # 3: Ring manually answer the two-way call
+        return super().response(b"")
+
 
 class HEARTBEAT(_GT06pkt):
     PROTO = 0x08
@@ -150,26 +156,41 @@ class STATUS(_GT06pkt):
     def from_packet(cls, length, proto, payload):
         self = super().from_packet(length, proto, payload)
         if len(payload) == 5:
-            self.batt, self.ver, self.intvl, self.signal, _ = unpack(
-                "BBBBB", payload
-            )
+            (
+                self.batt,
+                self.ver,
+                self.timezone,
+                self.intvl,
+                self.signal,
+            ) = unpack("BBBBB", payload)
         elif len(payload) == 4:
-            self.batt, self.ver, self.intvl, _ = unpack("BBBB", payload)
+            self.batt, self.ver, self.timezone, self.intvl = unpack(
+                "BBBB", payload
+            )
             self.signal = None
         return self
 
+    def response(self, upload_interval=25):  # Set interval in minutes
+        return super().response(pack("B", upload_interval))
+
 
 class HIBERNATION(_GT06pkt):
     PROTO = 0x14
 
 
-class RESET(_GT06pkt):
+class RESET(_GT06pkt):  # Device sends when it got reset SMS
     PROTO = 0x15
 
+    def response(self):  # Server can send to initiate factory reset
+        return super().response(b"")
+
 
-class WHITELIST_TOTAL(_GT06pkt):
+class WHITELIST_TOTAL(_GT06pkt):  # Server sends to initiage sync (0x58)
     PROTO = 0x16
 
+    def response(self, number=3):  # Number of whitelist entries
+        return super().response(pack("B", number))
+
 
 class _WIFI_POSITIONING(_GT06pkt):
     @classmethod
@@ -215,10 +236,24 @@ class TIME(_GT06pkt):
         return super().response(payload)
 
 
+class PROHIBIT_LBS(_GT06pkt):
+    PROTO = 0x33
+
+    def response(self, status=1):  # Server sent, 0-off, 1-on
+        return super().response(pack("B", status))
+
+
 class MOM_PHONE(_GT06pkt):
     PROTO = 0x43
 
 
+class STOP_UPLOAD(_GT06pkt):  # Server response to LOGIN to thwart the device
+    PROTO = 0x44
+
+    def response(self):
+        return super().response(b"")
+
+
 class STOP_ALARM(_GT06pkt):
     PROTO = 0x56
 
@@ -310,6 +345,10 @@ class POSITION_UPLOAD_INTERVAL(_GT06pkt):
         return super().response(pack("!H", self.interval))
 
 
+class SOS_ALARM(_GT06pkt):
+    PROTO = 0x99
+
+
 # Build a dict protocol number -> class
 CLASSES = {}
 if True:  # just to indent the code, sorry!
index 665615d81064d0ddde11bfe292d778f7c976f0f9..ddad2b780ea600df2b8da438d87d45d7e0fa39af 100755 (executable)
@@ -89,6 +89,7 @@ if __name__.endswith("__main__"):
                             except OSError as e:
                                 log.debug("sending to fd %d error %s", fd, e)
                     else:
+                        # TODO: Also disconnect on HIBERNATION
                         log.info("disconnect fd %d imei %s", fd, imei)
                         pollset.unregister(fd)
                         clntsock.close()