Skip to content

Commit

Permalink
Updates to support paho-mqtt 1.0
Browse files Browse the repository at this point in the history
Fix for change in on_connect() callback parameters between paho-mqtt 0.9
and 1.0
  • Loading branch information
David Parker committed Sep 24, 2014
1 parent d97ab58 commit ed6d744
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
description='IBM Internet of Things Cloud for Python',
long_description=open('README.txt').read(),
install_requires=[
"paho-mqtt >= 0.9",
"iso8601 == 0.1.10",
"paho-mqtt >= 1.0",
"iso8601 >= 0.1.10",
]
)
8 changes: 4 additions & 4 deletions src/ibmiotc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import iso8601
from datetime import datetime

__version__ = "0.0.5"
__version__ = "0.0.6"

class Message:
def __init__(self, message):
Expand Down Expand Up @@ -105,9 +105,9 @@ def __logAndRaiseException(self, e):
def connect(self):
self.logger.debug("Connecting... (address = %s, port = %s, clientId = %s, username = %s, password = %s)" % (self.address, self.port, self.clientId, self.username, self.password))
try:
self.client.loop_start()
self.connectEvent.clear()
self.client.connect(self.address, port=self.port, keepalive=self.keepAlive)
self.client.loop_start()
if not self.connectEvent.wait(timeout=10):
self.__logAndRaiseException(ConnectionException("Operation timed out connecting to the IBM Internet of Things service: %s" % (self.address)))

Expand Down Expand Up @@ -143,12 +143,12 @@ def on_log(self, mqttc, obj, level, string):
4: Refused - bad user name or password (MQTT v3.1 broker only)
5: Refused - not authorised (MQTT v3.1 broker only)
'''
def on_connect(self, mosq, obj, rc):
def on_connect(self, client, userdata, flags, rc):
if rc == 0:
self.connectEvent.set()
self.logger.info("Connected successfully")
elif rc == 5:
self.__logAndRaiseException(ConnectionException("Not authorized: s (%s, %s)" % (self.clientId, self.username, self.password)))
self.__logAndRaiseException(ConnectionException("Not authorized: s (%s, %s, %s)" % (self.clientId, self.username, self.password)))
else:
self.__logAndRaiseException(ConnectionException("Connection failed: RC= %s" % (rc)))

Expand Down

0 comments on commit ed6d744

Please sign in to comment.