diff --git a/gamutrf/mqtt_reporter.py b/gamutrf/mqtt_reporter.py index f51a85ee..7316a8e3 100755 --- a/gamutrf/mqtt_reporter.py +++ b/gamutrf/mqtt_reporter.py @@ -34,8 +34,6 @@ def connect(self): self.mqttc = mqtt.Client() self.mqttc.connect(self.mqtt_server) self.mqttc.loop_start() - if self.gps_server: - gpsd.connect(host=self.gps_server, port=2947) def get_heading(self): try: @@ -61,6 +59,8 @@ def add_gps(self, publish_args): try: if self.compass: self.get_heading() + if gpsd.gpsd_stream is None: + gpsd.connect(host=self.gps_server, port=2947) packet = gpsd.get_current() publish_args.update( {