def authWithClearBlade(): authCB = auth.Auth() userClient = Client.UserClient("c8bdc0f60ad0ddd88c8da2e7b6e701", "C8BDC0F60AE6A4EF9EA2CF8F8816", "*****@*****.**", "PASSWORD", "PLATFORM_URL") authCB.Authenticate(userClient) return userClient
def Connect(self): cbAuth = auth.Auth() #Authenticate using device auth device = Client.DevClient(self.systemKey, self.systemSecret, self.username, self.password, self.platformURL) cbAuth.Authenticate(device) messagingClient = Messaging.Messaging(device) messagingClient.InitializeMQTT() return messagingClient
def _init_cb(self): # first authenticate to CB using device auth cb_auth = auth.Auth() if self.cb_device_client is None: self.cb_device_client = Client.DeviceClient(self.credentials['systemKey'], self.credentials['systemSecret'], self.credentials['deviceName'], self.credentials['activeKey'], self.credentials['platformURL']) cb_auth.Authenticate(self.cb_device_client) # init cb mqtt # if self.mqtt is None: # self.mqtt = MQTT(self.credentials) # init bacnet devices (comes from cb collection) if self.bacnet_devices is None: self.bacnet_devices = BACnetDevices(self.cb_device_client, self) # init bacnet sensors (comes from cb devices table) if self.bacnet_sensors is None: self.bacnet_sensors = BACnetSensors()
# Define the socket using the "Context" self.sock = context.socket(zmq.PUB) print "Bind Address is " + bindAddress self.sock.bind(bindAddress) self.mqttSub(self.message, self.sock) def mqttSub(self, message, sock): time.sleep(1) def onMessageCallback(client, obj, msg): print "Your message is : " + msg.payload data = msg.payload self.ZmqPub(data, self.sock) message.subscribe("zmq/subscribe", 1, onMessageCallback) while True: pass def ZmqPub(self, data, sock): time.sleep(1) message = "1#" + data self.sock.send(message) if __name__ == '__main__': userClient = Client.UserClient("cecdeef40a98c1e1cb87c58dad58", "CECDEEF40A869A818AC6D9D4C21F", "*****@*****.**", "edge", "http://localhost") bindAddress = "tcp://127.0.0.1:7777" mqtt2zmq = mqtt2zmq(userClient, bindAddress)
import OpenOPC import socket import clearblade from clearblade import auth from clearblade import Client from clearblade import Messaging from time import sleep gateway = "127.0.0.1" opcHost = "127.0.0.1" auth = auth.Auth() userClient = Client.UserClient("acc19f800bd2d69febc2c6869309", "ACC19F800BC4FAAFECEDF1EAAB4F", "*****@*****.**", "clearblade", "http://192.168.0.82:9000") auth.Authenticate(userClient) message = Messaging.Messaging(userClient) message.printValue() message.InitializeMQTT() opcServer = 'Matrikon.OPC.Simulation' taglist = ['Triangle Waves.UInt2'] print "Connecting to OPC gateway" opcConnect = OpenOPC.open_client(gateway) opcConnect.connect(opcServer, opcHost)
import RPi.GPIO as GPIO import json, time, math import clearblade from clearblade import auth from clearblade import Client from urlparse import urlparse #Fill init values systemKey = ______ secretKey = ______ userName = _______ userPW = _______ edgeIP = "http://_______:9000" auth = auth.Auth() userClient = Client.UserClient(systemKey, secretKey, userName, userPW, edgeIP) auth.Authenticate(userClient) print "Authenticated" sequence = [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1], [1, 0, 0, 1]] ccwseq = [[1, 0, 0, 1], [0, 0, 1, 1], [0, 1, 1, 0], [1, 1, 0, 0]] time.sleep(1) GPIO.setmode(GPIO.BOARD) controlPinArray = [31, 33, 35, 37] for pin in controlPinArray: GPIO.setup(pin, GPIO.OUT) GPIO.output(pin, 0)