public CC05(String serverURI) { super(CC05.class.getSimpleName()); // create the request Request request = Request.newGet(); request.setConfirmable(false); // set the parameters and execute the request executeRequest(request, serverURI, RESOURCE_URI); }
public CC06(String serverURI) { super(CC06.class.getSimpleName()); // create the request Request request = Request.newDelete(); request.setConfirmable(false); // set the parameters and execute the request executeRequest(request, serverURI, RESOURCE_URI); }
public CC09(String serverURI) { super(CC09.class.getSimpleName()); // create the request Request request = new Request(Code.GET); request.setConfirmable(true); // set the parameters and execute the request executeRequest(request, serverURI, RESOURCE_URI); }
public CC08(String serverURI) { super(CC08.class.getSimpleName()); // create the request Request request = new Request(Code.POST); request.setConfirmable(false); // add payload request.setPayload("TD_COAP_CORE_08"); request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN); // set the parameters and execute the request executeRequest(request, serverURI, RESOURCE_URI); }
public CC07(String serverURI) { super(CC07.class.getSimpleName()); // create the request Request request = new Request(Code.PUT); request.setConfirmable(false); // add payload request.setPayload("TD_COAP_CORE_07"); request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN); // set the parameters and execute the request executeRequest(request, serverURI, RESOURCE_URI); }
@Override public void visit(BootstrapDeleteRequest request) { coapRequest = Request.newDelete(); coapRequest.setConfirmable(true); EndpointContext context = EndpointContextUtil.extractContext(destination); coapRequest.setDestinationContext(context); setTarget(coapRequest, request.getPath()); }
@Override public void visit(BootstrapFinishRequest request) { coapRequest = Request.newPost(); coapRequest.setConfirmable(true); EndpointContext context = EndpointContextUtil.extractContext(destination); coapRequest.setDestinationContext(context); // root path if (rootPath != null) { for (String rootPathPart : rootPath.split("/")) { if (!StringUtils.isEmpty(rootPathPart)) { coapRequest.getOptions().addUriPath(rootPathPart); } } } coapRequest.getOptions().addUriPath("bs"); }
postSecurity.getOptions().addUriPath("0"); postSecurity.getOptions().addUriPath(key.toString()); postSecurity.setConfirmable(true); postSecurity.setDestination(targetAddress); postSecurity.setDestinationPort(targetPort);
postServer.getOptions().addUriPath("1"); postServer.getOptions().addUriPath(key.toString()); postServer.setConfirmable(true); postServer.setDestination(targetAddress); postServer.setDestinationPort(targetPort);
outgoingRequest.setConfirmable(type == Type.CON);
outgoingRequest.setConfirmable(incomingRequest.getType() == Type.CON);
@Override public void visit(BootstrapWriteRequest request) { coapRequest = Request.newPut(); coapRequest.setConfirmable(true); ContentFormat format = request.getContentFormat(); coapRequest.getOptions().setContentFormat(format.getCode()); coapRequest.setPayload(encoder.encode(request.getNode(), format, request.getPath(), model)); setTarget(coapRequest, request.getPath()); }
@Test public void testNonconfirmable() throws Exception { createSimpleServer(); // send request Request request = new Request(CoAP.Code.POST); request.setConfirmable(false); request.setDestination(InetAddress.getLoopbackAddress()); request.setDestinationPort(serverPort); request.setPayload("client says hi"); request.send(); System.out.println("client sent request"); // receive response and check Response response = request.waitForResponse(1000); assertNotNull("Client received no response", response); System.out.println("client received response"); assertEquals(response.getPayloadString(), SERVER_RESPONSE); }
Request deleteAll = Request.newDelete(); deleteAll.getOptions().addUriPath("/"); deleteAll.setConfirmable(true); deleteAll.setDestination(exchange.getSourceAddress()); deleteAll.setDestinationPort(exchange.getSourcePort());
@Test public void testNonConfirmable() throws Exception { // send request Request req2acc = new Request(Code.POST); req2acc.setConfirmable(false); req2acc.setURI(getUri(ACC_RESOURCE)); req2acc.setPayload("client says hi"); req2acc.send(); // receive response and check Response response = req2acc.waitForResponse(1000); assertPayloadIsOfCorrectType(response, SERVER_RESPONSE, Type.NON); Request req2noacc = new Request(Code.POST); req2noacc.setConfirmable(false); req2noacc.setURI(getUri(NO_ACC_RESOURCE)); req2noacc.setPayload("client says hi"); req2noacc.send(); // receive response and check response = req2noacc.waitForResponse(1000); assertPayloadIsOfCorrectType(response, SERVER_RESPONSE, Type.NON); }
@Test public void testConfirmable() throws Exception { // send request Request req2acc = new Request(Code.POST); req2acc.setConfirmable(true); req2acc.setURI(getUri(ACC_RESOURCE)); req2acc.setPayload("client says hi"); req2acc.send(); // receive response and check Response response = req2acc.waitForResponse(1000); assertPayloadIsOfCorrectType(response, SERVER_RESPONSE, Type.CON); Request req2noacc = new Request(Code.POST); req2noacc.setConfirmable(true); req2noacc.setURI(getUri(NO_ACC_RESOURCE)); req2noacc.setPayload("client says hi"); req2noacc.send(); // receive response and check response = req2noacc.waitForResponse(1000); assertPayloadIsOfCorrectType(response, SERVER_RESPONSE, Type.ACK); }