Skip to content

Commit

Permalink
Add CLI Option to client demo to control if endpoint name should be sent
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Oct 3, 2024
1 parent 8e5e952 commit 88f161a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.eclipse.leshan.client.LeshanClient;
import org.eclipse.leshan.client.LeshanClientBuilder;
import org.eclipse.leshan.client.endpoint.LwM2mClientEndpointsProvider;
import org.eclipse.leshan.client.engine.DefaultClientEndpointNameProvider;
import org.eclipse.leshan.client.engine.DefaultRegistrationEngineFactory;
import org.eclipse.leshan.client.object.LwM2mTestObject;
import org.eclipse.leshan.client.object.Oscore;
Expand Down Expand Up @@ -323,7 +324,8 @@ protected DtlsConnectorConfig.Builder createRootDtlsConnectorConfigBuilder(
endpointsProvider.add(new JavaCoapsTcpClientEndpointsProvider());

// Create client
LeshanClientBuilder builder = new LeshanClientBuilder(cli.main.endpoint);
LeshanClientBuilder builder = new LeshanClientBuilder(
new DefaultClientEndpointNameProvider(cli.main.endpoint, cli.main.endpointNameMode));
builder.setObjects(enablers);
builder.setEndpointsProviders(
endpointsProvider.toArray(new LwM2mClientEndpointsProvider[endpointsProvider.size()]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import org.eclipse.californium.core.coap.CoAP;
import org.eclipse.californium.scandium.dtls.cipher.CipherSuite;
import org.eclipse.leshan.client.engine.DefaultClientEndpointNameProvider;
import org.eclipse.leshan.client.engine.DefaultClientEndpointNameProvider.Mode;
import org.eclipse.leshan.core.CertificateUsage;
import org.eclipse.leshan.core.endpoint.Protocol;
import org.eclipse.leshan.core.node.LwM2mPath;
Expand Down Expand Up @@ -173,6 +175,13 @@ public static class GeneralSection {
converter = ResourcePathConverter.class)

public Map<LwM2mPath, String> factoryBootstrap;

@Option(names = { "-nm", "--endpoint-name-mode" },
description = { //
"Can be used to set if client should or should not send client endpoint name during registration or bootstrap.", //
"Default : ${DEFAULT-VALUE}.",//
})
public DefaultClientEndpointNameProvider.Mode endpointNameMode = Mode.ALWAYS;
}

/* ********************************** Location Section ******************************** */
Expand Down

0 comments on commit 88f161a

Please sign in to comment.