Closed peteryang closed 7 years ago
If you want a short term solution, you can implement your own DefaultLwM2mNodeDecoder.
Just for anyone that wants a Custom decoder that is tested and works with Bosch XDK's observe:
https://gist.github.com/hytromo/b9c5ec7a308e24ca7cec3afcb86642e2 (implements the text decoder if the format is null)
Use it like this:
// Prepare LWM2M server1
LeshanServerBuilder builder = new LeshanServerBuilder();
builder.setLocalAddress(localAddress, localPort);
builder.setLocalSecureAddress(secureLocalAddress, secureLocalPort);
builder.setEncoder(new DefaultLwM2mNodeEncoder());
LwM2mNodeDecoder decoder = new CustomLwM2mNodeDecoder();
builder.setDecoder(decoder);
I renamed this issue because the conclusion of the #204 discussion was to "handle response of observation like other response (catch+log+return it to application layer)"
Fixed as PR #244 and #245 are closed.
Even though the specs requires the client MUST send content format in the response, the server could have better handling strategy if this happens.
Please refer to the discussion in the pull request: https://github.com/eclipse/leshan/pull/204
One possible solution is to add Not spec compatible related APIs:
public class NotSpecCompatibleAPIs{ static void setResponseContentFormatIfNull(CaliforniumObservationRegistryImpl reg, ContentFormat cf){
} } I choose CaliforniumObservationRegistryImpl as the parameter because it will not change the public ObservationRegistry interface.
It is not elegant, but it helps to developers easy because it takes time to ask device manufacturers to fix their code.