Skip to content

Commit

Permalink
Add coap+tcp support based on java-coap to server-demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Apr 23, 2024
1 parent cca3325 commit baa3d22
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
3 changes: 3 additions & 0 deletions leshan-server-core-demo/webapp/src/views/Server.vue
Expand Up @@ -183,10 +183,13 @@ export default {
"CoAP",
"UDP",
"DTLS",
"TCP",
"TLS",
"OSCORE",
"Californium",
"Scandium",
"java-coap",
"netty",
];
const strongKeywords = ["experimental"];
Expand Down
4 changes: 4 additions & 0 deletions leshan-server-demo/pom.xml
Expand Up @@ -53,6 +53,10 @@ Contributors:
<groupId>org.eclipse.leshan</groupId>
<artifactId>leshan-tl-javacoap-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.leshan</groupId>
<artifactId>leshan-tl-javacoap-server-coaptcp</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.californium</groupId>
<artifactId>californium-core</artifactId>
Expand Down
Expand Up @@ -62,6 +62,7 @@
import org.eclipse.leshan.server.redis.RedisSecurityStore;
import org.eclipse.leshan.server.security.EditableSecurityStore;
import org.eclipse.leshan.server.security.FileSecurityStore;
import org.eclipse.leshan.transport.javacoap.server.coaptcp.endpoint.JavaCoapTcpServerEndpointsProvider;
import org.eclipse.leshan.transport.javacoap.server.endpoint.JavaCoapServerEndpointsProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -257,8 +258,16 @@ public static LeshanServer createLeshanServer(LeshanServerDemoCLI cli) throws Ex
: new InetSocketAddress(cli.main.jlocalAddress, jcoapPort);
JavaCoapServerEndpointsProvider javacoapEndpointsProvider = new JavaCoapServerEndpointsProvider(jcoapAddr);

// Create CoAP over TCP endpoint based on java-coap
int coapTcpPort = cli.main.jTcpLocalPort;
InetSocketAddress coapTcpAddr = cli.main.jTcpLocalAddress == null ? new InetSocketAddress(coapTcpPort)
: new InetSocketAddress(cli.main.jTcpLocalAddress, coapTcpPort);
JavaCoapTcpServerEndpointsProvider javacoapTcpEndpointsProvider = new JavaCoapTcpServerEndpointsProvider(
coapTcpAddr);

// Create LWM2M server
builder.setEndpointsProviders(endpointsBuilder.build(), javacoapEndpointsProvider);
builder.setEndpointsProviders(endpointsBuilder.build(), javacoapEndpointsProvider,
javacoapTcpEndpointsProvider);
return builder.build();
}

Expand Down
Expand Up @@ -69,6 +69,19 @@ public static class ServerGeneralSection extends GeneralSection {
converter = PortConverter.class)
public Integer jlocalPort = 5685;

@Option(names = { "-th", "--java-coap-tcp-host" },
description = { //
"Set the local CoAP over TCP address of endpoint based on java-coap library.", //
"Default: any local address." })
public String jTcpLocalAddress;

@Option(names = { "-tp", "--java-coap-tcp-port" },
description = { //
"Set the local CoAP over TCP port of endpoint based on java-coap library.", //
"Default: ${DEFAULT-VALUE}" },
converter = PortConverter.class)
public Integer jTcpLocalPort = 5683;

@Option(names = { "-r", "--redis" },
description = { //
"Use redis to store registration and securityInfo.", //
Expand Down

0 comments on commit baa3d22

Please sign in to comment.