-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Leshan: Add registration handler interface #34
Conversation
354d218
to
93ce8ee
Compare
Signed-off-by: Jonas Remmert <jremmert@gmx.net>
Make logging for the leshan lwm2m server easier to configure in file-level. Add the logback dependency and a logback.xml configuration file. Signed-off-by: Jonas Remmert <jremmert@gmx.net>
Try to make the code more readable by renaming logger into log and make the lines shorter. In addition some log levels send too much messages. Those messages are now configured as debug or trace to switch them off easier. Signed-off-by: Jonas Remmert <jremmert@gmx.net>
Endpoint events (registered, updated, unregistered) are send to django via LwM2M user defined resources (10240/0/0|1|2). This is allows to use the existing database model in Django. Build json data with jackson json library instead of manually. Migrate to new API (leshan_api/resource). Signed-off-by: Jonas Remmert <jremmert@gmx.net>
Add new initial data that includes endpoint registration, update and deregistration. Signed-off-by: Jonas Remmert <jremmert@gmx.net>
- Adapt serializer to new format Signed-off-by: Jonas Remmert <jremmert@gmx.net>
The django extension drf_spectacular allows to generate OpenAPI schema. Via redoc, this schema can be rendered into a detailed html api documentation. This api documentation is referenced by Sphinx to be available on the GitHub pages documentation. Signed-off-by: Jonas Remmert <jremmert@gmx.net>
Divide singleResource and compositeResource Serializers so that individual ReST Endpoints are responsible. This makes the deserialization as well as the documentation easier to read. There are now two resources: 1. /leshan_api/resource/composite 1. /leshan_api/resource/single Signed-off-by: Jonas Remmert <jremmert@gmx.net>
Switch to the new rest endpoints for single and composite resources. Signed-off-by: Jonas Remmert <jremmert@gmx.net>
- rename device to endpoint consistently - Add a status field, that allows to filter registered endpoints. Once Endpoints get registered, this bit is set to True on unregistration set to False. Signed-off-by: Jonas Remmert <jremmert@gmx.net>
The data type is set from Leshan and converting Opaque types is rare and never required for float and int values. The only conversion that is happening is to convert from LwM2M Types to database types (str, int, float). Signed-off-by: Jonas Remmert <jremmert@gmx.net>
Single and composite tests. Signed-off-by: Jonas Remmert <jremmert@gmx.net>
d1ff295
to
eddf65f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonas-rem what exactly do we mean by Django has to be informed of the registration status of endpoints.
? Like is this only when a new client is added ? Because once we have a new client registered , then there will be only certain endpoints that we would need to monitor.
@jonas-rem could you please explain the difference between simple and composite resources ? |
I like the idea of automatically generating API Documentation. That seems to be a very good addition and would help us keep track of the APIs and the changes in them as well. |
LwM2M maintains registrations of endpoints. As long as an endpoint updates its registration within the allowed time, the registration remains active. If the endpoint reports for an update too late, the endpoint will be deregistered from Leshan. It has to re-register as a consequence. The database should keep track of the past and current registration efforts and status. Therefore registrations, registration updates and deregistrations are send as a custom LwM2M Object. |
I will merge this PR and update the documentation in a new PR. |
Status: WIPDjango has to be informed of the registration status of endpoints. In Leshan there are callbacks that contain all relevant information such as 'lastUpdated', 'registered'. This information will be send to the matching Django ReST API.
- [ ] Define a better ReST API with Django-Rest-Framework (DRF)Document: Change Log Level for Leshan, custom device registration resource