GithubHelp home page GithubHelp logo

huhoo / iot-python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ibm-watson-iot/iot-python

0.0 3.0 0.0 610 KB

Client libraries and samples for connecting to the IBM Internet of Things Foundation using Python 2.7 or 3.4

Home Page: http://internetofthings.ibmcloud.com

License: Eclipse Public License 1.0

Python 100.00%

iot-python's Introduction

IBM Internet of Things Foundation for Python

Python module for interacting with the IBM Internet of Things Foundation.

Note: Support for MQTT over SSL requires at least Python v2.7.9 or v3.4, and openssl v1.0.1

Dependencies

Installation

Install the latest version of the library with pip

[root@localhost ~]# pip install ibmiotf

Uninstall

Uninstalling the module is simple.

[root@localhost ~]# pip uninstall ibmiotf

Migrating from v0.0.x to v0.1.x

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 message formats you will want to update calls to deviceClient.publishEvent, appClient.publishEvent and appClient.publishCommand to also supply the desired message format.

Sample code v0.0.9:

deviceOptions = {"org": organization, "type": deviceType, "id": deviceId, "auth-method": authMethod, "auth-token": authToken}
deviceCli = ibmiotf.device.Client(deviceOptions)
myData = { 'hello' : 'world', 'x' : x}
deviceCli.publishEvent(event="greeting", data=myData)

Sample code v0.1.1:

deviceOptions = {"org": organization, "type": deviceType, "id": deviceId, "auth-method": authMethod, "auth-token": authToken}
deviceCli = ibmiotf.device.Client(deviceOptions)
myData = { 'hello' : 'world', 'x' : x}
deviceCli.publishEvent(event="greeting", msgFormat="json", data=myData)

Also, as part of this change, events and commands sent as format "json" will not be assumed to meet the 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 with the following code.

import ibmiotf.device
from ibmiotf.codecs import jsonIotfCodec

deviceOptions = {"org": organization, "type": deviceType, "id": deviceId, "auth-method": authMethod, "auth-token": authToken}
deviceCli = ibmiotf.device.Client(deviceOptions)
# Revert to v0.0.x parsing for json messages -- assume all JSON events and commands use the IOTF JSON payload specification
deviceCli.setMessageEncoderModule('json', jsonIotfCodec)

Documentation

iot-python's People

Contributors

amitmangalvedkar avatar benbakowski avatar slaupster avatar ind1go avatar ehsanmasdar avatar mkilivan avatar timjacobi avatar dwc1 avatar jeffdare avatar vikkipaterson avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.