diff --git a/donkeycar/parts/telemetry.py b/donkeycar/parts/telemetry.py index f6a32aaca..64d7c40ec 100644 --- a/donkeycar/parts/telemetry.py +++ b/donkeycar/parts/telemetry.py @@ -14,6 +14,7 @@ import numpy as np from logging import StreamHandler from paho.mqtt.client import Client as MQTTClient +from paho.mqtt.enums import CallbackAPIVersion logger = logging.getLogger() @@ -40,7 +41,7 @@ def __init__(self, cfg): self._mqtt_broker = os.environ.get('DONKEY_MQTT_BROKER', cfg.TELEMETRY_MQTT_BROKER_HOST) # 'iot.eclipse.org' self._topic = cfg.TELEMETRY_MQTT_TOPIC_TEMPLATE % self._donkey_name self._use_json_format = cfg.TELEMETRY_MQTT_JSON_ENABLE - self._mqtt_client = MQTTClient() + self._mqtt_client = MQTTClient(callback_api_version=CallbackAPIVersion.VERSION2) self._mqtt_client.connect(self._mqtt_broker, cfg.TELEMETRY_MQTT_BROKER_PORT) self._mqtt_client.loop_start() self._on = True diff --git a/donkeycar/tests/test_telemetry.py b/donkeycar/tests/test_telemetry.py index 3159d7fe4..02a8f6907 100644 --- a/donkeycar/tests/test_telemetry.py +++ b/donkeycar/tests/test_telemetry.py @@ -7,7 +7,6 @@ import donkeycar.templates.cfg_complete as cfg from donkeycar.parts.telemetry import MqttTelemetry -import pytest from random import randint @@ -18,13 +17,9 @@ def test_mqtt_telemetry(): cfg.TELEMETRY_MQTT_JSON_ENABLE = True # Create receiver - sub = Client(callback_api_version=CallbackAPIVersion.API_VERSION2, + sub = Client(callback_api_version=CallbackAPIVersion.VERSION2, clean_session=True) - # def on_message(client, userdata, message): - # data = message.payload - # print(message) - on_message_mock = mock.Mock() sub.on_message = on_message_mock sub.connect(cfg.TELEMETRY_MQTT_BROKER_HOST)