|
1 |
| -IBM Internet of Things Foundation for Python |
2 |
| -============================================ |
| 1 | +##Bluemix Deployment |
| 2 | +The sample is specifically designed to be deployed into Bluemix. The application requires a binding to both an instance of the Internet of Things service & Cloudant services. |
3 | 3 |
|
4 |
| -Python module for interacting with the [IBM Internet of Things Foundation](https://internetofthings.ibmcloud.com). |
5 |
| - |
6 |
| -* [Python 3.4](https://www.python.org/downloads/release/python-343/) |
7 |
| -* [Python 2.7](https://www.python.org/downloads/release/python-279/) |
8 |
| - |
9 |
| -Note: Support for MQTT over SSL requires at least Python v2.7.9 or v3.4, and openssl v1.0.1 |
10 |
| - |
11 |
| - |
12 |
| -Dependencies |
13 |
| ------------- |
14 |
| -* [paho-mqtt](https://pypi.python.org/pypi/paho-mqtt) |
15 |
| -* [iso8601](https://pypi.python.org/pypi/iso8601) |
16 |
| -* [pytz](https://pypi.python.org/pypi/pytz) |
17 |
| -* [requests](https://pypi.python.org/pypi/requests) |
18 |
| - |
19 |
| - |
20 |
| -Installation |
21 |
| ------------- |
22 |
| -Install the latest version of the library with pip |
23 |
| -``` |
24 |
| -[root@localhost ~]# pip install ibmiotf |
25 |
| -``` |
26 |
| - |
27 |
| - |
28 |
| -Uninstall |
29 |
| ---------- |
30 |
| -Uninstalling the module is simple. |
31 |
| -``` |
32 |
| -[root@localhost ~]# pip uninstall ibmiotf |
33 |
| -``` |
34 |
| - |
35 |
| -Migrating from v0.0.x to v0.1.x |
36 |
| -------------------------------- |
37 |
| -There is a significant change between the 0.0.x releases and 0.1.x that will require changes to client code. Now that the library properly supports multiple |
38 |
| -message formats you will want to update calls to deviceClient.publishEvent, appClient.publishEvent and appClient.publishCommand to also supply the desired message format. |
39 |
| - |
40 |
| -Sample code v0.0.9: |
41 |
| -```python |
42 |
| -deviceOptions = {"org": organization, "type": deviceType, "id": deviceId, "auth-method": authMethod, "auth-token": authToken} |
43 |
| -deviceCli = ibmiotf.device.Client(deviceOptions) |
44 |
| -myData = { 'hello' : 'world', 'x' : x} |
45 |
| -deviceCli.publishEvent(event="greeting", data=myData) |
46 |
| -``` |
47 |
| - |
48 |
| -Sample code v0.1.1: |
49 |
| -```python |
50 |
| -deviceOptions = {"org": organization, "type": deviceType, "id": deviceId, "auth-method": authMethod, "auth-token": authToken} |
51 |
| -deviceCli = ibmiotf.device.Client(deviceOptions) |
52 |
| -myData = { 'hello' : 'world', 'x' : x} |
53 |
| -deviceCli.publishEvent(event="greeting", msgFormat="json", data=myData) |
54 |
| -``` |
55 |
| - |
56 |
| -Also, as part of this change, events and commands sent as format "json" will not be assumed to meet the [IOTF JSON Payload Specification](https://docs.internetofthings.ibmcloud.com/messaging/payload.html#iotf-json-payload-specification). The default client behaviour will be to parse commands and events with format "json" as a generic JSON object only. Only messages sent as format "json-iotf" will default to being decoded in this specification. This can be easily changed |
57 |
| -with the following code. |
58 |
| - |
59 |
| -```python |
60 |
| -import ibmiotf.device |
61 |
| -from ibmiotf.codecs import jsonIotfCodec |
62 |
| - |
63 |
| -deviceOptions = {"org": organization, "type": deviceType, "id": deviceId, "auth-method": authMethod, "auth-token": authToken} |
64 |
| -deviceCli = ibmiotf.device.Client(deviceOptions) |
65 |
| -# Revert to v0.0.x parsing for json messages -- assume all JSON events and commands use the IOTF JSON payload specification |
66 |
| -deviceCli.setMessageEncoderModule('json', jsonIotfCodec) |
67 |
| -``` |
68 |
| - |
69 |
| - |
70 |
| -Documentation |
71 |
| -------------- |
72 |
| -* [Device Client](https://docs.internetofthings.ibmcloud.com/libraries/python_cli_for_devices.html) |
73 |
| -* [Application Client](https://docs.internetofthings.ibmcloud.com/libraries/python_cli_for_apps.html) |
| 4 | +[![Deploy to Bluemix] |
| 5 | +(https://bluemix.net/deploy/button.png)] |
| 6 | +(https://bluemix.net/deploy?repository=https://github.com/D5YhtS0ofv/iot-python) |
0 commit comments