Пример #1
0
def add_cayenne_payload(channel=1):
    payload = bytes()
    """
    conversion au format Cayenne LPP : https://developers.mydevices.com/cayenne/docs/lora/#lora-cayenne-low-power-payload-overview
    Uplink Payload Structure
    1 Byte 	1 Byte 	N Bytes 	1 Byte 	1 Byte 	M Bytes 	…
    Data1 Ch. 	Data1 Type 	Data1 	Data2 Ch. 	Data2 Type 	Data2 	…
    Temperature Sensor 	3303 	103 	67 	2 	0.1 °C Signed MSB
    """
    # conversion en entier signé
    tempC = temp.temperature()
    time.sleep(1)
    temperature = int(tempC * 10)  # precision de 0.1 pour temp
    payload = (payload + bytes([channel]) + bytes([103]) +
               struct.pack('>l', temperature)[2:4])
    print(payload)
    return (payload)
Пример #2
0
def temp():
    return temperature()
Пример #3
0
while (True):
    try:
        commande = "sudo hcitool2 lescan;exit 0"
        device = subprocess.check_output(commande, shell=True)
        print device
        if (device.find("Set scan parameters failed: Input/output error") >=
                0):
            os.system(
                "sudo hciconfig hci0 down; sudo hciconfig hci0 up;exit 0")
        else:
            device_name = [str(x) for x in device.split('#')]
            device_name = device_name[1:3]
            print device_name
            if device_name[1] == "FORA IR21":
                t = temp.temperature(device_name[0])
                sender.save_data(["tem", int(time.time()), t[0]])
                speech.temperature(t[0])
            if device_name[1] == "FORA IR21b":
                t = temp.temperature(device_name[0])
                sender.save_data(["tem", int(time.time()), t[0]])
                speech.temperature(t[0])
            if device_name[1] == "KNV V125":
                p = poids.poids(device_name[0])
                print p, type(p)
                if (p == None) or (p <= 5.0):
                    speech.poidsbas()
                else:
                    sender.save_data(["poi", int(time.time()), p])
                    speech.poids(p)
            if device_name[1] == "Diamond Balance":
Пример #4
0
import time
import os

while (True):
    try:
        commande="sudo hcitool2 lescan;exit 0"
        device=subprocess.check_output(commande, shell=True)
        print device
        if (device.find("Set scan parameters failed: Input/output error")>=0):
            os.system("sudo hciconfig hci0 down; sudo hciconfig hci0 up;exit 0")
        else:
            device_name = [str(x) for x in device.split('#')]
            device_name=device_name[1:3]
            print device_name
            if device_name[1]=="FORA IR21":
                t=temp.temperature(device_name[0])
                sender.save_data(["tem",int(time.time()),t[0]])
                speech.temperature(t[0])
            if device_name[1]=="FORA IR21b":
                t=temp.temperature(device_name[0])
                sender.save_data(["tem",int(time.time()),t[0]])
                speech.temperature(t[0])
            if device_name[1]=="KNV V125":
                p=poids.poids(device_name[0])
                print p, type(p)
                if (p==None) or (p<=5.0):
                    speech.poidsbas()
                else:
                    sender.save_data(["poi",int(time.time()),p])
                    speech.poids(p)
            if device_name[1]=="Diamond Balance":