Example #1
0
def on_readline(line):
    log("I: " + line)
    received = line.split(' ')
    nodeid = received[1]
    bytedata = received[2:]

    if nodeid in ehc.nodelist:

        decoded = ehc.decode_frame(nodeid, bytedata)

        if decoded:
            nodename = ehc.nodelist[nodeid]['nodename']

            nodevars = {}

            for i in range(len(decoded)):
                varname = ehc.nodelist[nodeid]['Rx']['names'][i]
                nodevars[varname] = decoded[i]
                log("  rx/" + nodename + "/" + varname + "/value " +
                    str(decoded[i]))
                mqttc.publish("rx/" + nodename + "/" + varname + "/value",
                              decoded[i],
                              retain=True)
                r.set("rx/%s/%s" % (nodename, varname), decoded[i])

            mqttc.publish("rx",
                          json.dumps({
                              "nodeid": nodeid,
                              "values": decoded
                          }))
Example #2
0
def on_readline(line):
    print "I: " + line
    received = line.split(',')
    nodeid = received[0]
    bytedata = received[1:]
    decoded = ehc.decode_frame(nodeid, bytedata)

    if decoded:
        nodename = ehc.nodelist[nodeid]['nodename']

        for i in range(len(decoded)):
            varname = ehc.nodelist[nodeid]['names'][i]
            print "  rx/" + nodename + "/" + varname + " " + str(decoded[i])
            mqttc.publish("rx/" + nodename + "/" + varname, decoded[i])

            r.set("rx/%s/%s" % (nodename, varname), decoded[i])
Example #3
0
def on_readline(line):
    print "I: "+line
    received = line.split(',')
    nodeid = received[0]
    bytedata = received[1:]
    decoded = ehc.decode_frame(nodeid,bytedata)
    
    if decoded:
        nodename = ehc.nodelist[nodeid]['nodename']
        
        for i in range(len(decoded)):
            varname = ehc.nodelist[nodeid]['names'][i];
            print "  rx/"+nodename+"/"+varname+" "+str(decoded[i])
            mqttc.publish("rx/"+nodename+"/"+varname,decoded[i])
            
            r.set("rx/%s/%s" % (nodename, varname),decoded[i])
Example #4
0
def on_readline(line):
    log("I: "+line)
    received = line.split(' ')
    nodeid = received[1]
    bytedata = received[2:]
    
    if nodeid in ehc.nodelist:
    
        decoded = ehc.decode_frame(nodeid,bytedata)
        
        if decoded:
            nodename = ehc.nodelist[nodeid]['nodename']
            
            nodevars = {}
            
            for i in range(len(decoded)):
                varname = ehc.nodelist[nodeid]['Rx']['names'][i]
                nodevars[varname] = decoded[i]
                log("  rx/"+nodename+"/"+varname+"/value "+str(decoded[i]))
                mqttc.publish("rx/"+nodename+"/"+varname+"/value",decoded[i],retain=True)
                r.set("rx/%s/%s" % (nodename, varname),decoded[i])
            
            mqttc.publish("rx",json.dumps({"nodeid":nodeid, "values":decoded}))
Example #5
0
            # Extract rssi
            rssi = -1 * int(received[-1][1:-1])
        else:
            bytepart = received
            rssi = 0

        try:
            # Only integers are expected
            bytepart = [int(val) for val in bytepart]
        except Exception:
            # self._log.warning("Misformed RX frame: " + str(bytepart))
            pass
        else:

            t = int(time.time())
            decoded = ehc.decode_frame(bytepart)

            nodeid = decoded[0]
            decoded = decoded[1:]

            try:
                nodes = json.loads(r.get("nodes"))
            except Exception:
                nodes = {}

            nodes[nodeid] = {}
            nodes[nodeid]['variables'] = []

            names = []
            if str(nodeid) in ehc.nodelist and 'names' in ehc.nodelist[str(
                    nodeid)]:
Example #6
0
            # Extract rssi
            rssi = -1 * int(received[-1][1:-1])
        else:
	    bytepart = received
            rssi = 0

        try:
            # Only integers are expected
            bytepart = [int(val) for val in bytepart]
        except Exception:
            # self._log.warning("Misformed RX frame: " + str(bytepart))
            pass
        else:
            
            t = int(time.time())
            decoded = ehc.decode_frame(bytepart)
            
            nodeid = decoded[0]
            decoded = decoded[1:]
            
            try:
                nodes = json.loads(r.get("nodes"))
            except Exception:
                nodes = {}
                
            nodes[nodeid] = {}
            nodes[nodeid]['variables'] = []
            
            names = []
            if str(nodeid) in ehc.nodelist and 'names' in ehc.nodelist[str(nodeid)]:
                names = ehc.nodelist[str(nodeid)]['names']