def get_voltage(addr_extended): out = {} sample = WPAN.ddo_get_param(addr_extended, '%V') result = ord(sample[0]) * 256 + ord(sample[1]) voltage_level = adc_convert(result, "") out['U_mV'] = voltage_level return out
def get_sensor_data(addr_extended): out = {} for pin in ['D1','D2','D3']: WPAN.ddo_set_param(addr_extended, pin, 2) buf = WPAN.ddo_get_param(addr_extended, 'is') buf1 = parse_is(buf)["AI1"] out['Light'] = round(adc_convert(buf1, "Light")) buf2 = parse_is(buf)["AI2"] out['Temp_C'] = round(adc_convert(buf2, "Temp")[0]) buf3 = parse_is(buf)["AI3"] out['Humid'] = round(adc_convert(buf3, "Humidity")) return out
sd.sendto("0", 0, DESTINATION) buf2,addr2 = sd.recvfrom(72) try: print "%s"% (buf2) DPost['report[ADuC]'] = buf2 except Exception, e: print "ERROR:%s"% (e) for node in node_list: SampleP = WPANManagementN.get_voltage(node.addr_extended) if node.device_type == 131080: buf1 = WPANManagementN.get_sensor_data(node.addr_extended) SampleP.update(buf1) buf1.clear() elif node.device_type <> 196610: SampleD = WPAN.ddo_get_param(node.addr_extended,'IS') buf1 = WPANManagementN.parse_is(SampleD) SampleP.update(buf1) buf1.clear() for key, val in SampleP.items(): SampleP['report[%s]' % (key+' data '+node.label)] = val del SampleP[key] DPost['report[addr_extended '+node.label+']'] = node.addr_extended DPost.update(SampleP) SampleP.clear() print "%24s" %(DPost.items()) enc_data = urllib.urlencode(DPost.items()) f = urllib.urlopen("http://192.168.0.101:3000/reports", enc_data)