Java Code Examples for org.eclipse.californium.core.CoapClient#setTimeout()

The following examples show how to use org.eclipse.californium.core.CoapClient#setTimeout() . 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: AuavRoutines.java    From SoftwarePilot with MIT License 6 votes vote down vote up
public String invokeHostDriver(String command, String IP, CoapHandler ch, boolean gov){
		if(gov) {
				try {
						//System.out.println("URI = "+IP+":"+portStr);
						URI uri = new URI("coap://"+IP+":5117/cr");
						CoapClient client = new CoapClient(uri);
						client.setTimeout(TIMEOUT);

						client.put(ch,command,TEXT_PLAIN);
						return("Success");
						//return(response.getResponseText());
				}
				catch (Exception e) {
						return("Unable to reach driver host");
				}
		}
		return "InvokeDriver with Governor Executed";
}
 
Example 2
Source File: CoapClientTarget.java    From datacollector with Apache License 2.0 5 votes vote down vote up
private CoapClient getCoapClient() throws URISyntaxException {
  URI coapURI = new URI(conf.resourceUrl);
  CoapClient coapClient = new CoapClient(coapURI);
  coapClient.setTimeout(conf.connectTimeoutMillis);
  if (conf.requestType == RequestType.NONCONFIRMABLE) {
    coapClient.useNONs();
  } else if (conf.requestType == RequestType.CONFIRMABLE) {
    coapClient.useCONs();
  }
  // TODO: coaps (DTLS Support) - https://issues.streamsets.com/browse/SDC-5893
  return coapClient;
}