aellwein / lwm2mclient Goto Github PK
View Code? Open in Web Editor NEWLWM2M client written in Python 3
License: MIT License
LWM2M client written in Python 3
License: MIT License
The correct way to implement signed ints according to the new specification is to use two's complement.
Implement Write operation on Object/Instance/Resource
I am trying to run your client.py code on macOS, by connecting to the Leshan demo server, and get the following error:
2020-06-09 16:27:01,726 [DEBUG] Using selector: KqueueSelector
2020-06-09 16:27:01,731 [ERROR] Task exception was never retrieved
future: <Task finished coro=<Client.run() done, defined at client.py:151> exception=ValueError('The transport can not be bound to any-address.')>
Traceback (most recent call last):
File "client.py", line 153, in run
self.context = await Context.create_server_context(self, bind=('::', 0))
File "/usr/local/lib/python3.7/site-packages/aiocoap-0.4a1-py3.7.egg/aiocoap/protocol.py", line 576, in create_server_context
self.transport_endpoints.append((yield from TransportEndpointSimpleServer.create_server(bind, new_message_callback=self._dispatch_message, new_error_callback=self._dispatch_error, log=self.log, loop=loop)))
File "/usr/local/lib/python3.7/site-packages/aiocoap-0.4a1-py3.7.egg/aiocoap/transports/simplesocketserver.py", line 117, in create_server
self._pool = yield from _DatagramServerSocketSimple.create(server_address, log, self._loop, self._received_datagram, self._received_exception)
File "/usr/local/lib/python3.7/site-packages/aiocoap-0.4a1-py3.7.egg/aiocoap/transports/simplesocketserver.py", line 60, in create
raise ValueError("The transport can not be bound to any-address.")
ValueError: The transport can not be bound to any-address.
I did find the aiocoap issue chrysn/aiocoap#101.
But, when trying by setting an explicit IP address (IPv4, as I am not assigned an IPv6 address), I get the following error:
ValueError: Passing reuse_address=True
is no longer supported, as the usage of SO_REUSEPORT in UDP poses a significant security concern.
I am running the client on a Windows machine. The client registers to a Leshan server. After that, I try to read a value (6/0/0 - Latitue ) from Leshan, I get the follwoing error alert in Leshan:
Unable to read resource /6/0/0 for python-client : 500 Invalid Response:Unable to decode response payload of request [ReadRequest [path=/6/0/0 format=ContentFormat [name=TLV, code=11542]]] from client [python-client]
In the client I see the following log:
2020-06-24 15:00:55,246 [DEBUG] read on 6/0/0
Received read
2020-06-24 15:00:55,247 [DEBUG] encode_resource(): 00000000: 32 37 2E 39 38 36 30 36 35 27.986065
2020-06-24 15:00:55,247 [DEBUG] Sending message <aiocoap.Message at 0x40963b8: Type.ACK 2.05 Content (MID 12371, token f4ca15c20d4affe1) remote <_Connection at 0x4090c28 on transport <_ProactorDatagramTransport fd=788 read=<_OverlappedFuture pending overlapped=<pending, 0x4075d38> cb=[_ProactorDatagramTransport._loop_reading()]>>, active>, 9 byte(s) payload>
After this issue with aiocoap has been fixed.
Hi,
Is there available any update of code?
Currently I have tried to run your code of client and after modification of Cleient connection as below:
[...]
if __name__ == '__main__':
client = Client(server="leshan.eclipseprojects.io",server_port=5683)
[...]
Client is registering into LwM2M Leshan Server but any READ request from Leshan GUI give me following error:
/app# python3 client.py
2019-05-16 20:42:43,561 [DEBUG] Using selector: EpollSelector
2019-05-16 20:42:43,588 [DEBUG] Sending message <aiocoap.Message at 0x7fbebf635ac8: Type.CON POST (ID 38485, token b'\x00\x00\xe2L') remote <UDP6EndpointAddress [::ffff:23.97.187.154]:5683>, 4 option(s), 27 byte(s) payload>
2019-05-16 20:42:43,589 [DEBUG] Exchange added, message ID: 38485.
2019-05-16 20:42:43,591 [DEBUG] Timeout is 93.0
2019-05-16 20:42:43,592 [DEBUG] Sending request - Token: 0000e24c, Remote: <UDP6EndpointAddress [::ffff:23.97.187.154]:5683>
2019-05-16 20:42:43,607 [DEBUG] Incoming message <aiocoap.Message at 0x7fbebf387470: Type.ACK 2.01 Created (ID 38485, token b'\x00\x00\xe2L') remote <UDP6EndpointAddress [::ffff:23.97.187.154]:5683 with local address>, 1 option(s)>
2019-05-16 20:42:43,608 [DEBUG] New unique message received
2019-05-16 20:42:43,609 [DEBUG] Exchange removed, message ID: 38485.
2019-05-16 20:42:43,611 [DEBUG] Received Response: <aiocoap.Message at 0x7fbebf387470: Type.ACK 2.01 Created (ID 38485, token b'\x00\x00\xe2L') remote <UDP6EndpointAddress [::ffff:23.97.187.154]:5683 with local address>, 1 option(s)>
Result: 2.01 Created
('rd', 'OHsZuDkjW9')
2019-05-16 20:42:43,613 [INFO] client registered at location OHsZuDkjW9
2019-05-16 20:43:00,578 [DEBUG] Incoming message <aiocoap.Message at 0x7fbebf392860: Type.CON GET (ID 54886, token b'\xfa\xb3\xd7\xd9\xb8k.\xc4') remote <UDP6EndpointAddress [::ffff:23.97.187.154]:5683 with local address>, 2 option(s)>
2019-05-16 20:43:00,579 [DEBUG] New unique message received
2019-05-16 20:43:00,579 [DEBUG] New responder created, key (('1', '0'), <UDP6EndpointAddress [::ffff:23.97.187.154]:5683 with local address>)
2019-05-16 20:43:00,580 [DEBUG] read on
2019-05-16 20:43:00,580 [INFO] Sending error response: b''
2019-05-16 20:43:00,580 [DEBUG] Preparing response...
2019-05-16 20:43:00,580 [DEBUG] Sending token: fab3d7d9b86b2ec4
2019-05-16 20:43:00,580 [DEBUG] Sending response, type = Type.ACK (request type = Type.CON)
2019-05-16 20:43:00,581 [DEBUG] Sending message <aiocoap.Message at 0x7fbebf3b60f0: Type.ACK 5.00 Internal Server Error (ID 54886, token b'\xfa\xb3\xd7\xd9\xb8k.\xc4') remote <UDP6EndpointAddress [::ffff:23.97.187.154]:5683 with local address>>
2019-05-16 20:43:00,581 [ERROR] An exception occurred while rendering a resource: AttributeError('invalid path length: 0.')
2019-05-16 20:43:00,581 [ERROR] invalid path length: 0.
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/aiocoap/protocol.py", line 990, in dispatch_request
response = yield from self.protocol.serversite.render(request)
File "/usr/local/lib/python3.7/asyncio/coroutines.py", line 123, in coro
res = yield from res
File "/usr/local/lib/python3.7/asyncio/coroutines.py", line 123, in coro
res = yield from res
File "/usr/local/lib/python3.7/asyncio/coroutines.py", line 120, in coro
res = func(*args, **kw)
File "client.py", line 82, in render_get
return self.handle_read(request.opt.uri_path)
File "client.py", line 25, in handle_read
return self.encoder.encode(path)
File "/app/lwm2mclient/encdec.py", line 355, in encode
if not self.model.is_path_valid(path):
File "/app/lwm2mclient/model.py", line 73, in is_path_valid
raise AttributeError("invalid path length: %d." % len(path))
AttributeError: invalid path length: 0.
data.json
could be validated on startup by checking it with definitions provided by lwm2m-object-definitions.json
.
I would like to connect to a remote lwm2m server. Is this feasible with this repository?
Provide a Dockerfile to be able to deploy in a Docker container.
Before doing so, IMHO the configuration must be settable over the cmdline/env variables.
Provide a REST API for client instrumentation.
Possible operations could be:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.