Skip to content

Commit dc49ada

Browse files
committed
Update error codes + shared_feeds example
1 parent 29bed98 commit dc49ada

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

Adafruit_IO/errors.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,7 @@
2020
# SOFTWARE.
2121

2222
import json, requests
23-
24-
# MQTT RC Error Types
25-
MQTT_ERRORS = [ 'Connection successful',
26-
'Incorrect protocol version',
27-
'Invalid Client ID',
28-
'Server unavailable ',
29-
'Bad username or password',
30-
'Not authorized' ]
23+
from paho.mqtt.client import error_string
3124

3225
class AdafruitIOError(Exception):
3326
"""Base class for all Adafruit IO request failures."""
@@ -63,6 +56,6 @@ class MQTTError(Exception):
6356
"""Handles connection attempt failed errors.
6457
"""
6558
def __init__(self, response):
66-
error = MQTT_ERRORS[response]
59+
error = error_string(response)
6760
super(MQTTError, self).__init__(error)
6861
pass

examples/mqtt/mqtt_shared_feeds.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,5 @@ def message(client, feed_id, payload):
7070
while True:
7171
value = random.randint(0, 100)
7272
print('Publishing {0} to {1}.'.format(value, IO_FEED))
73-
client.publish(IO_FEED, value, IO_FEED_USERNAME)
73+
client.publish(IO_FEED, value, feed_user=IO_FEED_USERNAME)
7474
time.sleep(10)

0 commit comments

Comments
 (0)