def sendSamplepack():
    ## send values to Sample sensor
    ## sample Arduino
    IOT.DeviceId = "ucbSbmSsfTS3MpDOdP780pW"
    IOT.connect()
    val = random.uniform(29,31)
    IOT.sendValueHTTP(val,0)
    sleep(2)
    val = randint(0,1)
    if val== 0:
        IOT.sendValueHTTP("False",1)
    elif val == 1:
        IOT.sendValueHTTP("True",1)
    else:
        pass
    sleep(2)
def sendSamplepack():
    ## send values to Sample sensor
    ## sample Arduino
    IOT.DeviceId = "ucbSbmSsfTS3MpDOdP780pW"
    IOT.connect()
    val = random.uniform(29, 31)
    IOT.sendValueHTTP(val, 0)
    sleep(2)
    val = randint(0, 1)
    if val == 0:
        IOT.sendValueHTTP("False", 1)
    elif val == 1:
        IOT.sendValueHTTP("True", 1)
    else:
        pass
    sleep(2)
def sendpack():
    ###### sending vallues to created devices
    results=[]
    with open('devicess.txt') as inputfile:
        results = list(csv.reader(inputfile))
    str1 =  ""
    
    for line in results:
        
        str1 = ''.join(line)
        a = str1.split('\t')
        name= a[0]
        idd = 0
        IOT.DeviceId = str(a[1])
        print "This id deviceid:" + '\n'
        print IOT.DeviceId
        idd = int(a[3])
        IOT.connect()
        
        if  a[2] == 'T':
            val = random.uniform(float(a[4]),float(a[5]))
            IOT.sendValueHTTP(val,idd)
            #IOT.send(val,idd)
            sleep(1)
        elif  a[2] == 'L':
            val = randint(int(a[4]),int(a[5]))
            IOT.sendValueHTTP(val,idd)
            sleep(1)
        elif  a[2] == 'D':
            val = randint(0,1)
            if val== 0:
               booll= "True"
            else:
               booll = "False"
                                     
            IOT.sendValueHTTP(booll,idd)
            sleep(1)

        else :
            print "Wromg entry"
Esempio n. 4
0
def sendpack():
    ###### sending vallues to created devices
    results = []
    with open('devicess.txt') as inputfile:
        results = list(csv.reader(inputfile))
    str1 = ""

    for line in results:

        str1 = ''.join(line)
        a = str1.split('\t')
        name = a[0]
        idd = 0
        IOT.DeviceId = str(a[1])
        print "This id deviceid:" + '\n'
        print IOT.DeviceId
        idd = int(a[3])
        IOT.connect()

        if a[2] == 'T':
            val = random.uniform(float(a[4]), float(a[5]))
            IOT.sendValueHTTP(val, idd)
            #IOT.send(val,idd)
            sleep(1)
        elif a[2] == 'L':
            val = randint(int(a[4]), int(a[5]))
            IOT.sendValueHTTP(val, idd)
            sleep(1)
        elif a[2] == 'D':
            val = randint(0, 1)
            if val == 0:
                booll = "True"
            else:
                booll = "False"

            IOT.sendValueHTTP(booll, idd)
            sleep(1)

        else:
            print "Wromg entry"
inlist= [N,R,A,E]
#print inlist

#
IOT.connect()

##### add assets to sample devices
#### sample arduino DeviceId
#### sample Edison DeviceId
#### sample Raspberry DeviceId
IOT.DeviceId = "ucbSbmSsfTS3MpDOdP780pW"
IOT.connect()
#IOT.subscribe()
IOT.addAsset(0, "Pressure sensor", "Pressure sensor in inches", False, "number", "Undefined")
IOT.addAsset(1, "Lock On/Off sensor", "Digital lock on or off", False, "boolean", "Undefined")
IOT.sendValueHTTP(15,0)
IOT.sendValueHTTP("True",1)

def sendSamplepack():
    ## send values to Sample sensor
    ## sample Arduino
    IOT.DeviceId = "ucbSbmSsfTS3MpDOdP780pW"
    IOT.connect()
    val = random.uniform(29,31)
    IOT.sendValueHTTP(val,0)
    sleep(2)
    val = randint(0,1)
    if val== 0:
        IOT.sendValueHTTP("False",1)
    elif val == 1:
        IOT.sendValueHTTP("True",1)
encoding = False
#IOT.deleteDeviceAll()
#print "deleted all devices*************************!!!!!"

##### add assets to sample devices
#### sample arduino DeviceId
#### sample Edison DeviceId
#### sample Raspberry DeviceId
IOT.DeviceId = "ucbSbmSsfTS3MpDOdP780pW"
IOT.connect()
#IOT.subscribe()
IOT.addAsset(0, "Pressure sensor", "Pressure sensor in inches", False,
             "number", "Undefined")
IOT.addAsset(1, "Lock On/Off sensor", "Digital lock on or off", False,
             "boolean", "Undefined")
IOT.sendValueHTTP(15, 0)
IOT.sendValueHTTP("True", 1)


def sendSamplepack():
    ## send values to Sample sensor
    ## sample Arduino
    IOT.DeviceId = "ucbSbmSsfTS3MpDOdP780pW"
    IOT.connect()
    val = random.uniform(29, 31)
    IOT.sendValueHTTP(val, 0)
    sleep(2)
    val = randint(0, 1)
    if val == 0:
        IOT.sendValueHTTP("False", 1)
    elif val == 1: