from . import common
from .evstore import initdb, fetch
-from .gps303proto import (
+from .zx303proto import (
GPS_POSITIONING,
STATUS,
WIFI_POSITIONING,
parse_message,
+ proto_name,
)
from .zmsg import Bcast, topic
result = []
for is_incoming, timestamp, packet in fetch(
imei,
- [(True, GPS_POSITIONING.PROTO), (False, WIFI_POSITIONING.PROTO)],
+ [
+ (True, proto_name(GPS_POSITIONING)),
+ (False, proto_name(WIFI_POSITIONING)),
+ ],
numback,
):
msg = parse_message(packet, is_incoming=is_incoming)
global htmlfile
initdb(conf.get("storage", "dbfn"))
- htmlfile = conf.get("wsgateway", "htmlfile")
+ htmlfile = conf.get("wsgateway", "htmlfile", fallback=None)
# Is this https://github.com/zeromq/pyzmq/issues/1627 still not fixed?!
zctx = zmq.Context() # type: ignore
zsub = zctx.socket(zmq.SUB) # type: ignore
for imei in neededsubs - activesubs:
zsub.setsockopt(
zmq.SUBSCRIBE,
- topic(GPS_POSITIONING.PROTO, True, imei),
+ topic(proto_name(GPS_POSITIONING), True, imei),
)
zsub.setsockopt(
zmq.SUBSCRIBE,
- topic(WIFI_POSITIONING.PROTO, False, imei),
+ topic(proto_name(WIFI_POSITIONING), False, imei),
)
zsub.setsockopt(
zmq.SUBSCRIBE,
- topic(STATUS.PROTO, True, imei),
+ topic(proto_name(STATUS), True, imei),
)
for imei in activesubs - neededsubs:
zsub.setsockopt(
zmq.UNSUBSCRIBE,
- topic(GPS_POSITIONING.PROTO, True, imei),
+ topic(proto_name(GPS_POSITIONING), True, imei),
)
zsub.setsockopt(
zmq.UNSUBSCRIBE,
- topic(WIFI_POSITIONING.PROTO, False, imei),
+ topic(proto_name(WIFI_POSITIONING), False, imei),
)
zsub.setsockopt(
zmq.UNSUBSCRIBE,
- topic(STATUS.PROTO, True, imei),
+ topic(proto_name(STATUS), True, imei),
)
activesubs = neededsubs
log.debug("Subscribed to: %s", activesubs)
towait &= trywrite
towait |= morewait
except KeyboardInterrupt:
- pass
+ zsub.close()
+ zctx.destroy() # type: ignore
+ tcpl.close()
if __name__.endswith("__main__"):