]> www.average.org Git - loctrkd.git/blobdiff - loctrkd/zx303proto.py
WIP converting wsgateway to multiprotocols
[loctrkd.git] / loctrkd / zx303proto.py
index 8c21418cd7a13c9af9f03c57d9d345f8c5592a50..bd19e108c770221e3a0132dfc7c863e23181622f 100755 (executable)
@@ -34,6 +34,8 @@ from typing import (
 __all__ = (
     "Stream",
     "class_by_prefix",
+    "enframe",
+    "exposed_protos",
     "inline_response",
     "proto_handled",
     "parse_message",
@@ -863,7 +865,7 @@ if True:  # just to indent the code, sorry!
 
 def class_by_prefix(
     prefix: str,
-) -> Union[Type[GPS303Pkt], List[Tuple[str, int]]]:
+) -> Union[Type[GPS303Pkt], List[str]]:
     if prefix.startswith(PROTO_PREFIX):
         pname = prefix[len(PROTO_PREFIX) :]
     else:
@@ -874,7 +876,7 @@ def class_by_prefix(
         if name.upper().startswith(prefix.upper())
     ]
     if len(lst) != 1:
-        return lst
+        return [name for name, _ in lst]
     _, proto = lst[0]
     return CLASSES[proto]
 
@@ -946,3 +948,11 @@ def parse_message(packet: bytes, is_incoming: bool = True) -> GPS303Pkt:
     retobj.PROTO = proto  # Override class attr with object attr
     retobj.cause = cause
     return retobj
+
+
+def exposed_protos() -> List[Tuple[str, bool]]:
+    return [
+        (proto_name(GPS_POSITIONING), True),
+        (proto_name(WIFI_POSITIONING), False),
+        (proto_name(STATUS), True),
+    ]