示例#1
0
"""
	This sample code demo receive value from QIoT Suite Lite by HTTPS protocol
	requirement:
	-- opkg update
	-- opkg install distribute
	-- opkg install python-openssl
	-- easy_install pip
	-- pip install requests
	run command: python https_get.py
"""

"""
	Setup connection options
"""
connection = qiot.connection(qiot.protocol.HTTPS)
connection_options = connection.read_resource('./res/resourceinfo.json')
connection.set_ca("./ssl/mycert.pem")

"""
	Receive data of QIoT Suite Lite.
"""
def on_message(event_trigger,data):
	message =json.loads(data["message"])
	if(data['id']=='temp'):
		print "temp : " + str(message['value'])
    	print "------------------------"

connection.on("message",on_message)

示例#2
0
import json
from lib import qiot
"""
	This sample code demo receive value from QIoT Suite Lite by HTTP protocol
	requirement:
	-- opkg update
	-- opkg install distribute
	-- opkg install python-openssl
	-- easy_install pip
	-- pip install requests
	run command: python http_get.py
"""
"""
	Setup connection options
"""
connection = qiot.connection(qiot.protocol.HTTP)
connection_options = connection.read_resource('./res/resourceinfo.json')
"""
	Receive data of QIoT Suite Lite.
"""


def on_message(event_trigger, data):
    message = json.loads(data["message"])
    if (data['id'] == 'temp'):
        print "temp : " + str(message['value'])
        print "------------------------"


connection.on("message", on_message)
示例#3
0
	-- opkg install python-openssl
	-- easy_install pip
	-- pip install paho-mqtt
    
	configure the system to allow various Bridge related services to run, command as follow 
	-- uci set yunbridge.config.disabled=’0’
	-- uci commit
	-- reboot
	run command: python dht11.py
"""

"""
	Setup connection options
"""
connection = None
connection = qiot.connection(qiot.protocol.MQTT)
connection_options = connection.read_resource('./res/resourceinfo.json', '/ssl/')
connection.connect(connection_options)

"""
	Send sensor's data to QIoT Suite Lite by Resourcetype.
"""
while 1:	
	h = bridge_client.get("humidity")
	t = bridge_client.get("temperature")
	
	connection.publish_by_id("temp", str(t))
	connection.publish_by_id("hum", str(h))
	time.sleep(1)

示例#4
0
import sys
from lib import qiot
"""
	This sample code demo random number value send to QIoT Suite 
	requirement:
	-- opkg update
	-- opkg install distribute
	-- opkg install python-openssl
	-- easy_install pip
	-- pip install coapthon
	run command: python coap.py
"""
"""
	Setup connection options
"""
connection = qiot.connection(qiot.protocol.COAP)
connection_options = connection.read_resource('./res/resourceinfo.json')
"""
	Send data to QIoT Suite Lite.
"""
connection.connect(connection_options)


def signal_handler(signal, frame):
    print('You pressed Ctrl+C!')
    connection.stop()
    sys.exit(0)


signal.signal(signal.SIGINT, signal_handler)
示例#5
0
from lib import qiot
"""
	This sample code demo random number value send to QIoT Suite 
	requirement:
	-- opkg update
	-- opkg install distribute
	-- opkg install python-openssl
	-- easy_install pip
	-- pip install paho-mqtt
	run command: python mqtt.py
"""
"""
	Setup connection options
"""
connection = None
connection = qiot.connection(qiot.protocol.MQTT)
connection_options = connection.read_resource('./res/resourceinfo.json',
                                              '/ssl/')
"""
	Send data to QIoT Suite Lite.
"""


def on_connect(event_trigger, data):
    print "client ready"


connection.on("connect", on_connect)
connection.connect(connection_options)

while 1:
示例#6
0
"""
	This sample code demo random number value send to QIoT Suite 
	requirement:
	-- opkg update
	-- opkg install distribute
	-- opkg install python-openssl
	-- easy_install pip
	-- pip install coapthon
	run command: python coap.py
"""

"""
	Setup connection options
"""
connection = qiot.connection(qiot.protocol.COAP)
connection_options = connection.read_resource('./res/resourceinfo.json')

"""
	Send data to QIoT Suite Lite.
"""
connection.connect(connection_options)

def signal_handler(signal, frame):
        print('You pressed Ctrl+C!')
        connection.stop()
        sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)

while 1:
    """