Skip to content
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

Add very simple Queue mode support to Leshan Server Demo. #1645

Merged
merged 1 commit into from
Aug 29, 2024

Conversation

sbernard31
Copy link
Contributor

@sbernard31 sbernard31 commented Aug 29, 2024

Queue Mode

LWM2M define "Queue Mode" to handle some specific scenario (sleeping device or device behind NAT). This mode is used when device could be sometime unreachable and so requests could only be sent when device initiates a communication with the server. IMHO it should be named "Device Initiated mode"...

Current Leshan Behavior

Leshan library doesn't provide an out of the box way to store requests and send it later when "device is awake".
But there is API to help user to implement it using PresenceService to know when the device is awake.

Until now, Leshan Server Demo just show an error message if you try to send a request to a "sleeping device" :

Warning

Invalid request: The destination client is sleeping, request cannot be sent.
Some users express the need to have a simple queue mode in Leshan Server Demo to better understand the feature.

Community request

Following discussion at #1598, some users wanted a simple In Memorry implementation for Leshan Server Demo where request should be stored when device is sleeping and automatically send next time it is awake.

In this PR

So this PR aims to provide this.

The backend part written in java and based on Leshan Library is pretty easy to code.
But the javascript web UI is not really adapted to do that so the feature is here but not so user friendly.
The mains issue is when you click on a button to execute a LWM2M operation, this trigger syncronouly :
an http request which lead to a lwm2m request which lead to lwm2m response which lead to http response.
Ideally with queue mode we would like a more async mode.

Anyway with this PR when you try to send a request to a sleeping device.
LWM2M operation button state will be reset (there is no indicator on the button)
Capture d’écran du 2024-08-29 11-52-11
Then you get this kind of message :
Capture d’écran du 2024-08-29 11-51-23
At server side we store the last request for a given device.
When device is awake we execute, the stored request.
In the UI if this is a Read / ReadComposite request you will see the value updated :
Capture d’écran du 2024-08-29 11-52-03

@sbernard31 sbernard31 merged commit baa124f into master Aug 29, 2024
1 check passed
@sbernard31 sbernard31 deleted the demo_queuemode branch January 13, 2025 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant