Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Adafruit_IO/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.7.1"
__version__ = "2.7.2"
7 changes: 5 additions & 2 deletions Adafruit_IO/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
# SOFTWARE.

import json, requests
from paho.mqtt.client import error_string

# MQTT RC Error Types
# MQTT RC Error Types *** OBSOLETE ***
# See error_string() in client.py and enums.py from paho instead
# https://github.com/eclipse/paho.mqtt.python/blob/4eeb431f5ae72b42474cec42641fca1daa91c4b0/src/paho/mqtt/client.py#L291-L404
MQTT_ERRORS = [ 'Connection successful',
'Incorrect protocol version',
'Invalid Client ID',
Expand Down Expand Up @@ -63,6 +66,6 @@ class MQTTError(Exception):
"""Handles connection attempt failed errors.
"""
def __init__(self, response):
error = MQTT_ERRORS[response]
error = error_string(response)
super(MQTTError, self).__init__(error)
pass
2 changes: 1 addition & 1 deletion Adafruit_IO/mqtt_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self, username, key, service_host='io.adafruit.com', secure=True):
self.on_message = None
self.on_subscribe = None
# Initialize MQTT client.
self._client = mqtt.Client()
self._client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1)
if secure:
self._client.tls_set_context()
self._secure = True
Expand Down
2 changes: 1 addition & 1 deletion examples/mqtt/mqtt_shared_feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ def message(client, feed_id, payload):
while True:
value = random.randint(0, 100)
print('Publishing {0} to {1}.'.format(value, IO_FEED))
client.publish(IO_FEED, value, IO_FEED_USERNAME)
client.publish(IO_FEED, value, feed_user=IO_FEED_USERNAME)
time.sleep(10)
4 changes: 2 additions & 2 deletions examples/mqtt/mqtt_viewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ def on_connect(client, userdata, flags, rc):
def on_disconnect(client, userdata, rc):
print('Disconnected!')

def on_message(client, userdata, msg, retain):
def on_message(client, userdata, msg):
print('Received on {0}: {1}'.format(msg.topic, msg.payload.decode('utf-8')))


# Create MQTT client and connect to Adafruit IO.
client = mqtt.Client()
client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1)
client.username_pw_set(USERNAME, KEY)
client.on_connect = on_connect
client.on_disconnect = on_disconnect
Expand Down