Difference between revisions of "Micropython Bluemix"

From wiki.emacinc.com
Jump to: navigation, search
Line 37: Line 37:
 
**AUTH_TOKEN    The secret authentication token for the board that is connecting.
 
**AUTH_TOKEN    The secret authentication token for the board that is connecting.
 
**ssl          Keyword only. False by default. Will use the port: 8883.
 
**ssl          Keyword only. False by default. Will use the port: 8883.
 +
 +
===Methods===
 +
*<syntaxhighlight lang=python>
 +
Bluemix.connect()
 +
</syntaxhighlight>
 +
 +
*<syntaxhighlight lang=python>
 +
Bluemix.disconnect()
 +
</syntaxhighlight>
 +
 +
*<syntaxhighlight lang=python>
 +
Bluemix.publish(topic, message)
 +
</syntaxhighlight>
 +
 +
*<syntaxhighlight lang=python>
 +
Bluemix.set_cb(callback)
 +
</syntaxhighlight>
 +
 +
*<syntaxhighlight lang=python>
 +
Bluemix.subscribe(topic)
 +
</syntaxhighlight>
 +
 +
*<syntaxhighlight lang=python>
 +
Bluemix.wait_msg()
 +
</syntaxhighlight>

Revision as of 13:05, 5 June 2018

Bluemix is a cloud computing service developed by IBM.

Bluemix has the capabilities to host a variety of services from web services to crypto-currencies.

This Wiki contains information on how to use the methods that EMAC has developed for Micropython to interact with IBM Bluemix IoT.

EMAC methods for Micropython with IBM Bluemix

class Bluemix

  • This class provides a tailored interface to the MQTTClient class, for the purpose of connecting to the IBM Bluemix IoT service. It is imported from the 'bluemix' module. The following is an example usage.
  • client = bluemix.Bluemix(ORG, DEVICE_ID, DEVICE_TYPE, AUTH_TOKEN)
    client.connect()
    msg = '{d:{value:"42"}}'
    client.publish('desired/topic/to/use', msg)
    

Constructor

  • bluemix.Bluemix(ORG, DEVICE_ID, DEVICE_TYPE, AUTH_TOKEN, ssl=False)
    
  • This constructor creates the Bluemix object, which inherits the MQTTClient Class. Returns the Bluemix object. Arguments are:
    • ORG The organization ID of the Bluemix service that is to be connected to
    • DEVICE_ID The unique Bluemix identifier for the board that is connecting.
    • DEVICE_TYPE The Bluemix board type.
    • AUTH_TOKEN The secret authentication token for the board that is connecting.
    • ssl Keyword only. False by default. Will use the port: 8883.

Methods

  • Bluemix.connect()
    
  • Bluemix.disconnect()
    
  • Bluemix.publish(topic, message)
    
  • Bluemix.set_cb(callback)
    
  • Bluemix.subscribe(topic)
    
  • Bluemix.wait_msg()