Esempio n. 1
0
def usage_response():
	package = usagecode.decode('hex')
	addr = (server, port)
	client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
	client.sendto(package, addr)
	data, ADDR = client.recvfrom(1024)
	usage_data = decrypt_hex(data)
	data = re.split('#|%' ,usage_data)[5]
	return data
Esempio n. 2
0
def environment_response():
	package = envicode.decode('hex')
	addr = (server, port)
	client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
	client.sendto(package, addr)
	data, ADDR = client.recvfrom(1024)
	usage_data = decrypt_hex(data)
	data_foo = re.split('#|%' ,usage_data)
	data = {'temp':float(data_foo[7]),'hum':float(data_foo[9]),'lum':float(data_foo[11])}
	return data