Skip to content

Commit

Permalink
Fix telemetry test after paho upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
DocGarbanzo committed Mar 26, 2024
1 parent 996cad3 commit 055cac5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
3 changes: 2 additions & 1 deletion donkeycar/parts/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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
Expand Down
7 changes: 1 addition & 6 deletions donkeycar/tests/test_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import donkeycar.templates.cfg_complete as cfg
from donkeycar.parts.telemetry import MqttTelemetry
import pytest
from random import randint


Expand All @@ -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)
Expand Down

0 comments on commit 055cac5

Please sign in to comment.