15 package com.trouch.webiopi.client;
18 import com.
trouch.coap.messages.CoapRequest;
19 import com.
trouch.coap.messages.CoapResponse;
29 super(
"coap", host, DEFAULT_PORT);
30 client =
new CoapClient();
34 super(
"coap", host, port);
35 client =
new CoapClient();
39 public String
sendRequest(String method, String path)
throws Exception {
41 if (method ==
"GET") {
42 request =
new CoapGet(this.
urlBase + path);
44 else if (method ==
"POST") {
45 request =
new CoapPost(this.
urlBase + path);
47 else throw new Exception(
"Method not supported: " + method);
49 CoapResponse
response = client.sendRequest(request);
50 if (response != null) {
51 return response.getPayload();
PiCoapClient(String host, int port)
static final int DEFAULT_PORT
String sendRequest(String method, String path)
PiCoapClient(String host)