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 Transport Layer abstraction at Bootstrap server side. #1336

Merged
merged 2 commits into from
Jan 6, 2023

Conversation

sbernard31
Copy link
Contributor

@sbernard31 sbernard31 commented Oct 20, 2022

This aims to implement #1025 at Bootstrap Server side.

This is is largely inspired by #1318

The API looks like :

// You create your LeshanServer with the builder like before
LeshanBootstrapServerBuilder builder = new LeshanBootstrapServerBuilder();

// But builder does not allow to configure any details about transport layer anymore
// instead you need to provide a LwM2mBootstrapServerEndpointsProvider
// LwM2mBootstrapServerEndpointsProvider will provide 1 or several LwM2mBootstrapServerEndpoint

// For Californium (coap/coaps), Endpoint Provider API looks like this :
// --------------------------------------------------------
CaliforniumBootstrapServerEndpointsProvider.Builder endpointsBuilder = new CaliforniumBootstrapServerEndpointsProvider.Builder(
		    new CoapBootstrapServerProtocolProvider(), new CoapsBootstrapServerProtocolProvider());

// Change Californium configuration :
Configuration californiumConfig = endpointsBuilder.createDefaultConfiguration();
californiumConfig.set(DtlsConfig.DTLS_RECOMMENDED_CIPHER_SUITES_ONLY, true);
endpointsBuilder.setConfiguration(californiumConfig);

// By default the Californium Builder will create 1 endpoint by protocolProvider
// But you can create it manually like this :
endpointsBuilder.addEndpoint(new InetSocketAddress(0), Protocol.COAP);
endpointsBuilder.addEndpoint("coaps://localhost:5684");

// then add the endpoints provider to LeshanServerBuilder
builder.setEndpointsProvider(endpointsBuilder.build());

More tasks for later :

  • there is not so much javadoc and so it should be added later.
  • there is still some TODO TL : ... to implement.
  • Currently we can add only 1 LwM2mEndpointsProvider but we should be able to add several one.
  • I think we should have new interface to separate LWM2M request and LWM2M bootstrap request.
  • of course code should also be moved to follow new Transport Layer Module design. #1295

'Fun' Fact (or not ...)

Coding this one, I faced an issue which makes me crazy ... 🤯
I was unable to compile some code which does not contain any issue at all.

After investigation I find this was a java compiler issue on java 8 : https://stackoverflow.com/questions/34273176/maven-compilation-fails-with-cannot-find-symbol-while-with-eclipse-it-compile

So in BootstrapHandlerTest if import was in this order :

import org.eclipse.leshan.core.response.LwM2mResponse;
import org.eclipse.leshan.core.response.ResponseCallback;
import org.eclipse.leshan.core.response.SendableResponse;
import org.eclipse.leshan.server.bootstrap.BootstrapHandlerTest.MockRequestSender.Mode;
import org.eclipse.leshan.server.bootstrap.request.BootstrapDownlinkRequestSender;
import org.junit.Test;

you get a :

BootstrapHandlerTest.java:[160,54] cannot find symbol
 symbol: class BootstrapDownlinkRequestSender
 location: class org.eclipse.leshan.server.bootstrap.BootstrapHandlerTest

But this below is OK :

import org.eclipse.leshan.core.response.LwM2mResponse;
import org.eclipse.leshan.core.response.ResponseCallback;
import org.eclipse.leshan.core.response.SendableResponse;
import org.eclipse.leshan.server.bootstrap.request.BootstrapDownlinkRequestSender;
import org.eclipse.leshan.server.bootstrap.BootstrapHandlerTest.MockRequestSender.Mode;
import org.junit.Test;

As I can change the order because we check that import are well sorted with maven.
I just moved the Mode enum from BootstrapHandlerTest.MockRequestSender to BootstrapHandlerTest ;

@sbernard31 sbernard31 changed the base branch from endpoint_client to master January 6, 2023 14:25
@sbernard31 sbernard31 merged commit a963d77 into master Jan 6, 2023
@sbernard31 sbernard31 deleted the endpoint_bootstrap branch January 26, 2023 16:28
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