Java Code Examples for org.eclipse.californium.core.network.config.NetworkConfig#getStandard()
The following examples show how to use
org.eclipse.californium.core.network.config.NetworkConfig#getStandard() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TradfriGatewayHandler.java From smarthome with Eclipse Public License 2.0 | 6 votes |
private void establishConnection() { TradfriGatewayConfig configuration = getConfigAs(TradfriGatewayConfig.class); this.gatewayURI = "coaps://" + configuration.host + ":" + configuration.port + "/" + DEVICES; this.gatewayInfoURI = "coaps://" + configuration.host + ":" + configuration.port + "/" + GATEWAY + "/" + GATEWAY_DETAILS; try { URI uri = new URI(gatewayURI); deviceClient = new TradfriCoapClient(uri); } catch (URISyntaxException e) { logger.error("Illegal gateway URI '{}': {}", gatewayURI, e.getMessage()); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getMessage()); return; } DtlsConnectorConfig.Builder builder = new DtlsConnectorConfig.Builder(new InetSocketAddress(0)); builder.setPskStore(new StaticPskStore(configuration.identity, configuration.preSharedKey.getBytes())); dtlsConnector = new DTLSConnector(builder.build(), new InMemoryConnectionStore(100, 60)); endPoint = new TradfriCoapEndpoint(dtlsConnector, NetworkConfig.getStandard()); deviceClient.setEndpoint(endPoint); updateStatus(ThingStatus.UNKNOWN); // schedule a new scan every minute scanJob = scheduler.scheduleWithFixedDelay(this::startScan, 0, 1, TimeUnit.MINUTES); }
Example 2
Source File: CoapServer.java From SI with BSD 2-Clause "Simplified" License | 5 votes |
/** * Constructs a server with the specified configuration that listens to the * specified ports after method {@link #start()} is called. * * @param config the configuration, if <code>null</code> the configuration returned by * {@link NetworkConfig#getStandard()} is used. * @param ports the ports to bind to */ public CoapServer(NetworkConfig config, int... ports) { // global configuration that is passed down (can be observed for changes) if (config != null) { this.config = config; } else { this.config = NetworkConfig.getStandard(); } // resources this.root = createRoot(); this.deliverer = new ServerMessageDeliverer(root); CoapResource well_known = new CoapResource(".well-known"); well_known.setVisible(false); well_known.add(new DiscoveryResource(root)); root.add(well_known); // endpoints this.endpoints = new ArrayList<Endpoint>(); // sets the central thread pool for the protocol stage over all endpoints this.executor = Executors.newScheduledThreadPool( config.getInt(NetworkConfig.Keys.PROTOCOL_STAGE_THREAD_COUNT) ); // create endpoint for each port for (int port:ports) addEndpoint(new CoapEndpoint(port, this.config)); }
Example 3
Source File: CoapServer.java From SI with BSD 2-Clause "Simplified" License | 5 votes |
/** * Constructs a server with the specified configuration that listens to the * specified ports after method {@link #start()} is called. * * @param config the configuration, if <code>null</code> the configuration returned by * {@link NetworkConfig#getStandard()} is used. * @param ports the ports to bind to */ public CoapServer(NetworkConfig config, int... ports) { // global configuration that is passed down (can be observed for changes) if (config != null) { this.config = config; } else { this.config = NetworkConfig.getStandard(); } // resources this.root = createRoot(); this.deliverer = new ServerMessageDeliverer(root); CoapResource well_known = new CoapResource(".well-known"); well_known.setVisible(false); well_known.add(new DiscoveryResource(root)); root.add(well_known); // endpoints this.endpoints = new ArrayList<Endpoint>(); // sets the central thread pool for the protocol stage over all endpoints this.executor = Executors.newScheduledThreadPool( config.getInt(NetworkConfig.Keys.PROTOCOL_STAGE_THREAD_COUNT) ); // create endpoint for each port for (int port:ports) addEndpoint(new CoapEndpoint(port, this.config)); }
Example 4
Source File: TradfriGateway.java From ThingML-Tradfri with Apache License 2.0 | 4 votes |
protected void initCoap() { DtlsConnectorConfig.Builder builder = new DtlsConnectorConfig.Builder(); //new InetSocketAddress(0) builder.setPskStore(new StaticPskStore("", security_key.getBytes())); coap = new CoapEndpoint(new DTLSConnector(builder.build()), NetworkConfig.getStandard()); }
Example 5
Source File: CoapEndpoint.java From SI with BSD 2-Clause "Simplified" License | 2 votes |
/** * Instantiates a new endpoint with the specified address. * * @param address the address */ public CoapEndpoint(InetSocketAddress address) { this(address, NetworkConfig.getStandard()); }
Example 6
Source File: CoapServer.java From SI with BSD 2-Clause "Simplified" License | 2 votes |
/** * Constructs a default server. The server starts after the method * {@link #start()} is called. If a server starts and has no specific ports * assigned, it will bind to CoAp's default port 5683. */ public CoapServer() { this(NetworkConfig.getStandard()); }
Example 7
Source File: CoapServer.java From SI with BSD 2-Clause "Simplified" License | 2 votes |
/** * Constructs a server that listens to the specified port(s) after method * {@link #start()} is called. * * @param ports the ports to bind to */ public CoapServer(int... ports) { this(NetworkConfig.getStandard(), ports); }
Example 8
Source File: CoapEndpoint.java From SI with BSD 2-Clause "Simplified" License | 2 votes |
/** * Instantiates a new endpoint with the specified address. * * @param address the address */ public CoapEndpoint(InetSocketAddress address) { this(address, NetworkConfig.getStandard()); }
Example 9
Source File: CoapServer.java From SI with BSD 2-Clause "Simplified" License | 2 votes |
/** * Constructs a default server. The server starts after the method * {@link #start()} is called. If a server starts and has no specific ports * assigned, it will bind to CoAp's default port 5683. */ public CoapServer() { this(NetworkConfig.getStandard()); }
Example 10
Source File: CoapServer.java From SI with BSD 2-Clause "Simplified" License | 2 votes |
/** * Constructs a server that listens to the specified port(s) after method * {@link #start()} is called. * * @param ports the ports to bind to */ public CoapServer(int... ports) { this(NetworkConfig.getStandard(), ports); }