Java Code Examples for org.eclipse.californium.core.CoapClient#put()
The following examples show how to use
org.eclipse.californium.core.CoapClient#put() .
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 |
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: Main.java From TRADFRI2MQTT with Apache License 2.0 | 6 votes |
private void set(String uriString, String payload) { //System.out.println("payload\n" + payload); try { URI uri = new URI(uriString); CoapClient client = new CoapClient(uri); client.setEndpoint(endPoint); CoapResponse response = client.put(payload, MediaTypeRegistry.TEXT_PLAIN); if (response != null && response.isSuccess()) { //System.out.println("Yay"); } else { System.out.println("Sending payload to " + uriString + " failed!"); } client.shutdown(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
Example 3
Source File: LinuxKernel.java From SoftwarePilot with MIT License | 5 votes |
public static void main(String args[]) throws Exception { String base = ""; String myIP = "127.0.0.1"; for (String arg : args) { String[] prm = arg.split("="); if (prm[0].equals("base") ){ base = prm[1]; } else if (prm[0].equals("myip") ){ myIP = prm[1]; } } LinuxKernel k = new LinuxKernel(); if (base.equals("") == false) { String mapAsString = "Active Drivers\n"; Set keys = k.n2p.keySet(); for (Iterator i = keys.iterator(); i.hasNext(); ) { String name = (String) i.next(); String value = (String) k.n2p.get(name); name = myIP + ":" + name; value = myIP + ":" + value; mapAsString = mapAsString + name + " --> " + value + "\n"; } CoapClient client = new CoapClient("coap://"+base+":5117/cr"); CoapResponse response = client.put("dn=add-"+mapAsString,0);//create response System.out.println(response); } }
Example 4
Source File: CaptureImageV2Driver.java From SoftwarePilot with MIT License | 5 votes |
public String invokeDriver(String dn, String params, CoapHandler ch) { params = params + "-dp=" + "AUAVsim"; if(this.d2p == null) { try { URI portStr = new URI("coap://127.0.0.1:5117/cr"); CoapClient e = new CoapClient(portStr); CoapResponse client = e.put("dn=list", 0); String ls = client.getResponseText(); this.d2p = new HashMap(); String[] lines = ls.split("\n"); for(int x = 0; x < lines.length; ++x) { String[] data = lines[x].split("-->"); if(data.length == 2) { this.d2p.put(data[0].trim(), data[1].trim()); } } } catch (Exception var12) { this.d2p = null; System.out.println("AUAVRoutine invokeDriver error"); var12.printStackTrace(); return "Invoke Error"; } } if(this.d2p != null) { String var13 = (String)this.d2p.get(dn); if(var13 != null) { try { URI var14 = new URI("coap://127.0.0.1:" + var13 + "/cr"); CoapClient var15 = new CoapClient(var14); var15.put(ch, params, 0); return "Success"; } catch (Exception var11) { return "Unable to reach driver " + dn + " at port: " + var13; } } else { return "Unable to find driver: " + dn; } } else { return "InvokeDriver: Unreachable code touched"; } }
Example 5
Source File: TradfriGateway.java From ThingML-Tradfri with Apache License 2.0 | 5 votes |
protected void set(String path, String payload) { Logger.getLogger(TradfriGateway.class.getName()).log(Level.INFO, "SET: " + "coaps://" + gateway_ip + "/" + path + " = " + payload); CoapClient client = new CoapClient("coaps://" + gateway_ip + "/" + path); client.setEndpoint(coap); CoapResponse response = client.put(payload, MediaTypeRegistry.TEXT_PLAIN); if (response != null && response.isSuccess()) { //System.out.println("Yay"); } else { logger.log(Level.SEVERE, "Sending payload to " + "coaps://" + gateway_ip + "/" + path + " failed!"); } client.shutdown(); }
Example 6
Source File: ManagerTradfri.java From helloiot with GNU General Public License v3.0 | 5 votes |
void requestPutCOAP(String topic, String payload) { LOGGER.log(Level.FINE, "requext PUT COAP: {0}, {1}", new Object[]{topic, payload}); try { URI uri = new URI("coaps://" + coapIP + "/" + topic); CoapClient client = new CoapClient(uri); client.setEndpoint(coapEndPoint); CoapResponse response = client.put(payload, MediaTypeRegistry.TEXT_PLAIN); if (response == null || !response.isSuccess()) { LOGGER.log(Level.WARNING, "COAP PUT error: {0}", response.getResponseText()); } client.shutdown(); } catch (URISyntaxException ex) { LOGGER.log(Level.WARNING, "COAP PUT error: {0}", ex.getMessage()); } }