Skip to content

Commit 3f3c16e

Browse files
authored
Merge pull request #7 from myDevicesIoT/feature/secure-connection
Feature/secure connection
2 parents 41df3b5 + 30b68d4 commit 3f3c16e

File tree

7 files changed

+16
-8
lines changed

7 files changed

+16
-8
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The Cayenne MQTT Python Library provides functions to easily connect to the `Cay
44

55
Requirements
66
============
7-
* `Python 2.7 or 3.x <https://www.python.org/downloads/>`_.
7+
* `Python 2.7.9+ or 3.4+ <https://www.python.org/downloads/>`_.
88
* `This library <https://github.com/myDevicesIoT/Cayenne-MQTT-Python/archive/master.zip>`_.
99
* `Eclipse Paho MQTT Python client library <https://github.com/eclipse/paho.mqtt.python>`_. This is installed as part of the Cayenne library installation.
1010

cayenne/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.0.1"
1+
__version__ = "1.1.0"

cayenne/client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import paho.mqtt.client as mqtt
21
import time
2+
from ssl import PROTOCOL_TLSv1_2
3+
import paho.mqtt.client as mqtt
34
from cayenne import __version__
45

56
# Data types
@@ -140,8 +141,10 @@ def begin(self, username, password, clientid, hostname='mqtt.mydevices.com', por
140141
self.client.on_disconnect = on_disconnect
141142
self.client.on_message = on_message
142143
self.client.username_pw_set(username, password)
144+
if port == 8883:
145+
self.client.tls_set(tls_version=PROTOCOL_TLSv1_2)
143146
self.client.connect(hostname, port, 60)
144-
print("Connecting to %s..." % hostname)
147+
print("Connecting to {}:{}".format(hostname, port))
145148

146149
def loop(self):
147150
"""Process Cayenne messages.

examples/Example-01-SendData.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99

1010

1111
client = cayenne.client.CayenneMQTTClient()
12-
1312
client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID)
13+
# For a secure connection use port 8883 when calling client.begin:
14+
# client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID, port=8883)
1415

1516
i=0
1617
timestamp = 0

examples/Example-02-ReceiveData.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ def on_message(message):
1515
client = cayenne.client.CayenneMQTTClient()
1616
client.on_message = on_message
1717
client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID)
18+
# For a secure connection use port 8883 when calling client.begin:
19+
# client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID, port=8883)
1820
client.loop_forever()
1921

examples/Example-03-CayenneClient.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ def on_message(message):
1616
client = cayenne.client.CayenneMQTTClient()
1717
client.on_message = on_message
1818
client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID)
19+
# For a secure connection use port 8883 when calling client.begin:
20+
# client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID, port=8883)
1921

2022
i=0
2123
timestamp = 0

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
with open(path.join(here, 'README.rst'), encoding='utf-8') as readme:
1010
long_description = readme.read()
1111

12-
classifiers = ['Development Status :: 3 - Alpha',
12+
classifiers = ['Development Status :: 5 - Production/Stable',
1313
'Operating System :: MacOS :: MacOS X',
1414
'Operating System :: Microsoft :: Windows',
1515
'Operating System :: POSIX',
1616
'Programming Language :: Python',
1717
'License :: OSI Approved :: MIT License',
1818
'Intended Audience :: Developers',
1919
'Programming Language :: Python :: 2.7',
20-
'Programming Language :: Python :: 3',
20+
'Programming Language :: Python :: 3.4',
2121
'Topic :: Software Development',
2222
'Topic :: Communications',
2323
'Topic :: Internet',
@@ -36,6 +36,6 @@
3636
classifiers = classifiers,
3737
packages = ['cayenne'],
3838
install_requires = [
39-
'paho-mqtt >= 1.0',
39+
'paho-mqtt >= 1.3.0',
4040
],
4141
)

0 commit comments

Comments
 (0)