forked from aellwein/lwm2mclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
leshan_client.py
31 lines (26 loc) · 862 Bytes
/
leshan_client.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import asyncio
from client import Client
from model import ClientModel
# Enable logging
import logging
import sys
#logging.basicConfig(level=logging.DEBUG, format="%(asctime)s [%(levelname)s] %(message)s")
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
logger = logging.getLogger("main")
logger.info("Starting...")
model = ClientModel()
client = Client(model=model)
client.set_server_uri('coaps://leshan.eclipse.org:5684')
client.set_endpoint('my_endpoint') # Leshan Client endpoint
client.set_identity('my_identity') # Leshan Identity
client.set_key('1234') # Leshan Key: 31323334
client.set_misc("123", 90, "U")
loop = asyncio.get_event_loop()
asyncio.ensure_future(client.run())
try:
loop.run_forever()
except KeyboardInterrupt:
loop.close()
exit(0)