forked from scottyphillips/pychonet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtroubleshoot.py
41 lines (31 loc) · 1.21 KB
/
troubleshoot.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
import asyncio
from pprint import pprint
from aioudp import UDPServer
from pychonet import ECHONETAPIClient as api
from pychonet import Factory, EchonetInstance
from pychonet.lib.const import VERSION, ENL_SETMAP, ENL_GETMAP, ENL_UID, ENL_MANUFACTURER
from pychonet.lib.epc import EPC_CODE
# This example will list the properties for all discovered instances on a given host
async def main():
print(f'pychonet verison is {VERSION}')
udp = UDPServer()
loop = asyncio.get_event_loop()
udp.run("0.0.0.0", 3610, loop=loop)
server = api(server=udp, loop=loop)
host = '192.168.1.50'
await server.discover(host)
device = EchonetInstance("192.168.1.50", 2,163,1, server)
# value = await device.getMessage(ENL_SETMAP)
# print(value)
getmap = await device.getMessage(ENL_GETMAP)
print(f"getmap is {getmap}")
setmap = await device.getMessage(ENL_SETMAP)
print(f"setmap is {setmap}")
for epc in getmap:
value = await device.getMessage(epc)
print(f"getmap value EPC code {epc} is {value}")
for epc in setmap:
value = await device.getMessage(epc)
print(f"setmap value EPC code {epc} is {value}")
if __name__ == "__main__":
asyncio.run(main())