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

leshan demo server: endpoint in COAPLOG #845

Closed
th1j5 opened this issue May 13, 2020 · 5 comments
Closed

leshan demo server: endpoint in COAPLOG #845

th1j5 opened this issue May 13, 2020 · 5 comments
Labels
demo Impact our demo (not libraries) new feature New feature from LWM2M specification server Impact LWM2M server

Comments

@th1j5
Copy link

th1j5 commented May 13, 2020

For a university project, we wrote an application which hooks into the RESTful API of the leshan demo server.
We used the events emitted by the server.
We started with NOTIFICATION events, which contain the endpoint in their JSON object ("ep": "iot-device1")
Then we switched to COAPLOG events (because we needed also Read and the first Observe answers), but there we saw that there is no JSON property indicating from which endpoint this comes.

This might (or might not) be a little enhancement for the demo server to be more directly useful.

We (roughly) fixed it with this code in EventServlet.java:

 import com.google.gson.JsonElement;

@Override
        public void trace(CoapMessage message) {
	    JsonElement coapLog = EventServlet.this.gson.toJsonTree(message);
            coapLog.getAsJsonObject().addProperty("ep",this.endpoint);
            String coapLogWithEndPoint = EventServlet.this.gson.toJson(coapLog);
            sendEvent(EVENT_COAP_LOG, coapLogWithEndPoint, endpoint);
        }

where trace is the function we replaced

Greetings

@sbernard31
Copy link
Contributor

I'm not sure to understand why you are now using NOTIFICATIONS events + read/observe RESPONSE from ClientServlet ? 🤔

But looking at EVENT_COAP_LOG point of view I think it makes sense to add the "ep" property.
Do you want to provide a PR ? (in this case you should have a look at this process)
Or I can just copy/paste the code (as it is really short) but you will not be the author.

@sbernard31 sbernard31 added demo Impact our demo (not libraries) new feature New feature from LWM2M specification server Impact LWM2M server labels May 14, 2020
@th1j5
Copy link
Author

th1j5 commented May 14, 2020

You can just copy/paste the code (I don't mind not being the author)

As for why: we're doing a project where we wanted to save all sensor measurements in a Solid pod, but if you want to read for example the Sensor Units, you won't get there with observe (since they don't change).

We wanted the leshan demo server web interface to remain the control interface and we just hook our application into the event stream.

@sbernard31
Copy link
Contributor

You can just copy/paste the code

Ok I will add it.

We wanted the leshan demo server web interface to remain the control interface and we just hook our application into the event stream

Ok I don't know so much about Solid Pod, but keep in mind you actually plug on CoAP layer and not LWM2M one.
So payload are still encoded and if blockwise transfer is use you will see each block instead of the "rebuilt" payload.

@sbernard31
Copy link
Contributor

(added in master : 02b3c5d)

@th1j5 th1j5 closed this as completed May 15, 2020
@th1j5
Copy link
Author

th1j5 commented May 15, 2020

Thanks for the headsup around blockwise transfer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
demo Impact our demo (not libraries) new feature New feature from LWM2M specification server Impact LWM2M server
Projects
None yet
Development

No branches or pull requests

2 participants