-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpcom.py
49 lines (42 loc) · 1.29 KB
/
cpcom.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import WPANManagement
import WPANManagementN
import zigbee
import time
import WPAN
import urllib
from time import sleep
from select import *
node_list=zigbee.getnodelist()
DPost = {}
DPost['report[device_code]'] = 'aa452 73'
DPost['report[latitude]'] = 56.3
DPost['report[longitude]'] = 33
sd = WPANManagement.get_serial_endpoint_socket()
DESTINATION=("00:13:a2:00:40:3a:ed:6e!", 0xe8, 0xc105, 0x11)
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)