Skip to content

Commit a0cb9f6

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

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Adafruit_IO/errors.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@
2020
# SOFTWARE.
2121

2222
import json, requests
23+
from paho.mqtt.client import error_string
2324

24-
# MQTT RC Error Types
25+
# MQTT RC Error Types *** OBSOLETE ***
26+
# See error_string() in client.py and enums.py from paho instead
27+
# https://github.com/eclipse/paho.mqtt.python/blob/4eeb431f5ae72b42474cec42641fca1daa91c4b0/src/paho/mqtt/client.py#L291-L404
2528
MQTT_ERRORS = [ 'Connection successful',
2629
'Incorrect protocol version',
2730
'Invalid Client ID',
@@ -63,6 +66,6 @@ class MQTTError(Exception):
6366
"""Handles connection attempt failed errors.
6467
"""
6568
def __init__(self, response):
66-
error = MQTT_ERRORS[response]
69+
error = error_string(response)
6770
super(MQTTError, self).__init__(error)
6871
pass

examples/mqtt/mqtt_shared_feeds.py

Lines changed: 1 addition & 1 deletion
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)