当前位置: 首页>>代码示例>>Java>>正文


Java CoapResponse类代码示例

本文整理汇总了Java中org.eclipse.californium.core.CoapResponse的典型用法代码示例。如果您正苦于以下问题:Java CoapResponse类的具体用法?Java CoapResponse怎么用?Java CoapResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CoapResponse类属于org.eclipse.californium.core包,在下文中一共展示了CoapResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: set

import org.eclipse.californium.core.CoapResponse; //导入依赖的package包/类
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();
	}
}
 
开发者ID:hardillb,项目名称:TRADFRI2MQTT,代码行数:19,代码来源:Main.java

示例2: get

import org.eclipse.californium.core.CoapResponse; //导入依赖的package包/类
/**
 * perform a blocking get request
 * @param incomplete coap uri (e.g. '/15001/65538')
 * @return the Response
 */
public CoapResponse get(String uri){
	uri = "coaps://" + this.gatewayIP + uri;
	
	CoapResponse response = null;
	try {
		//construct an URI to check validity
		@SuppressWarnings("unused")
		URI temp = new URI(uri);
		
		client.setURI(uri);
		response = client.get();

	} catch (URISyntaxException e) {
		System.err.println("[GWConnection] Invalid URI in GWConnection.get: " + e.getMessage());
		System.exit(-1);
	}

	return response;
}
 
开发者ID:peterkappelt,项目名称:JTradfri,代码行数:25,代码来源:GWConnection.java

示例3: putJSON

import org.eclipse.californium.core.CoapResponse; //导入依赖的package包/类
/**
 * Do a Put-Request on a specified URI. The data gets the content type application/json
 * @param URI incomplete coap uri (e.g. '/15001/65538')
 * @return The response, null if the request wasn't successfull
 */
public CoapResponse putJSON(String uri, String payload){
	uri = "coaps://" + this.gatewayIP + uri;
	
	CoapResponse response = null;
	try {
		//construct an URI to check validity
		@SuppressWarnings("unused")
		URI temp = new URI(uri);
		
		client.setURI(uri);
		response = client.put(payload, MediaTypeRegistry.APPLICATION_JSON);

	} catch (URISyntaxException e) {
		System.err.println("[GWConnection] Invalid URI in GWConnection.putJSON: " + e.getMessage());
		System.exit(-1);
	}

	return response;
}
 
开发者ID:peterkappelt,项目名称:JTradfri,代码行数:25,代码来源:GWConnection.java

示例4: process

import org.eclipse.californium.core.CoapResponse; //导入依赖的package包/类
public OneM2mResponse process(OneM2mRequest reqMessage) throws Exception {
		OneM2mResponse resMessage = null;
//		try {
			Request request = CoapRequestCodec.encode(reqMessage);
			log.debug("SEND CoAP MESSAGE: ");
			log.debug(reqMessage.toString());
			log.debug(request.getPayloadString());
			
			CoapResponse response = client.advanced(request);
			if(response == null) {
				log.error("response is null");
				return null;
			}
			
			resMessage = CoapResponseCodec.decode(response);
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
		
		return resMessage;
	}
 
开发者ID:iotoasis,项目名称:SI,代码行数:22,代码来源:HCoapClient.java

示例5: onLoad

import org.eclipse.californium.core.CoapResponse; //导入依赖的package包/类
@Override
public void onLoad(CoapResponse response) {
	String content = response.getResponseText();
	System.out.println("-CO01----------");
	System.out.println(content);
	dimXMLStr = content;
	try {
		spo2DIM = new DomainInformationModel("Spo2 DS");

		readXML(content);
		String contentData = Spo2Device.getDIMRep(sensorId, spo2DIM);
		String targetID = sclId + "/applications/" + sensorId
				+ "/containers/DATA/contentInstances";
		core.doRequest(new RequestIndication("CREATE", targetID,
				reqEntity, contentData));

		System.out.println("DIM :" + " GET DIM " + "\n");
	} catch (Exception e) {
		// TODO: handle exception
		e.printStackTrace();
	}
}
 
开发者ID:AINLAB,项目名称:OHP-M2M,代码行数:23,代码来源:Spo2Monitor.java

示例6: onLoad

import org.eclipse.californium.core.CoapResponse; //导入依赖的package包/类
@Override
public void onLoad(CoapResponse response) {
	String content = response.getResponseText();
	System.out.println("-CO01----------");
	System.out.println(content);
	dimXMLStr = content;
	try {
		spo2DIM = new DomainInformationModel("Spo2 DS");

		readXML(content);
		String contentData = Spo2Device.getDIMRep(sensorId,
				spo2DIM);
		String targetID = sclId + "/applications/" + sensorId
				+ "/containers/DATA/contentInstances";
		core.doRequest(new RequestIndication("CREATE", targetID,
				reqEntity, contentData));

		System.out.println("DIM :" + " GET DIM " + "\n");
	} catch (Exception e) {
		// TODO: handle exception
		e.printStackTrace();
	}
}
 
开发者ID:AINLAB,项目名称:OHP-M2M,代码行数:24,代码来源:Spo2Monitor.java

示例7: onLoad

import org.eclipse.californium.core.CoapResponse; //导入依赖的package包/类
@Override
public void onLoad(CoapResponse response) {
	String content = response.getResponseText();
	

	dimXMLStr = content;
	try {
		tmDIM = new DomainInformationModel("Thermometer DS");
		readXML(dimXMLStr);
		
		String contentData = ThermometerDevice.getDIMRep(sensorId,
				tmDIM);
		String targetID = sclId + "/applications/" + sensorId
				+ "/containers/DATA/contentInstances";
	
		core.doRequest(new RequestIndication("CREATE", targetID,
				reqEntity, contentData));

		
	} catch (Exception e) {
		// TODO: handle exception
		e.printStackTrace();
	}
}
 
开发者ID:AINLAB,项目名称:OHP-M2M,代码行数:25,代码来源:ThermometerMonitor.java

示例8: onLoad

import org.eclipse.californium.core.CoapResponse; //导入依赖的package包/类
@Override
public void onLoad(CoapResponse response) {
	String content = response.getResponseText();
	// System.out.println("-CO01----------");
	System.out.println(content);
	dimXMLStr = content;
	try {
		bcDIM = new DomainInformationModel("BodyComposition DS");
		
		readXML(content);
		String contentData = BodyCompositionDevice.getDIMRep(sensorId,
				bcDIM);
		String targetID = sclId + "/applications/" + sensorId
				+ "/containers/DATA/contentInstances";
		core.doRequest(new RequestIndication("CREATE", targetID,
				reqEntity, contentData));

		System.out.println("DIM :" + " GET DIM " + "\n");
	} catch (Exception e) {
		// TODO: handle exception
		e.printStackTrace();
	}
}
 
开发者ID:AINLAB,项目名称:OHP-M2M,代码行数:24,代码来源:BodyCompositionMonitor.java

示例9: onLoad

import org.eclipse.californium.core.CoapResponse; //导入依赖的package包/类
@Override
public void onLoad(CoapResponse response) {
	String content = response.getResponseText();

	dimXMLStr = content;
	try {
		wsDIM = new DomainInformationModel("Weighingscale DS");
		
		readXML(dimXMLStr);

		
		String contentData = WeighingscaleDevice.getDIMRep(sensorId,
				wsDIM);
		String targetID = sclId + "/applications/" + sensorId
				+ "/containers/DATA/contentInstances";
		// ����data
		core.doRequest(new RequestIndication("CREATE", targetID,
				reqEntity, contentData));

		
	} catch (Exception e) {
		// TODO: handle exception
		e.printStackTrace();
	}
}
 
开发者ID:AINLAB,项目名称:OHP-M2M,代码行数:26,代码来源:WeighingscaleMonitor.java

示例10: onLoad

import org.eclipse.californium.core.CoapResponse; //导入依赖的package包/类
@Override
public void onLoad(CoapResponse response) {
	String content = response.getResponseText(); // Gets the response
													// from Coap
	dimXMLStr = content;

	try {
		cvDIM = new DomainInformationModel("CardioVascular DS");
		readXML(content);

		String contentData = CardioVascularDevice.getDIMRep(sensorId,
				cvDIM);
		String targetID = sclId + "/applications/" + sensorId
				+ "/containers/DATA/contentInstances";
		core.doRequest(new RequestIndication("CREATE", targetID,
				reqEntity, contentData));

		System.out.println("DIM :" + " GET DIM " + "\n");
	} catch (Exception e) {
		// TODO: handle exception
		e.printStackTrace();
	}
}
 
开发者ID:AINLAB,项目名称:OHP-M2M,代码行数:24,代码来源:CardioVascularMonitor.java

示例11: onLoad

import org.eclipse.californium.core.CoapResponse; //导入依赖的package包/类
@Override
public void onLoad(CoapResponse response)
{
	String content = response.getResponseText(); // Gets the response from Coap
	dimXMLStr = content;
	
	try 
	{
		cvDIM = new DomainInformationModel("StrengthFitness DS");
		readXML(content);
		
		String contentData = StrengthFitnessDevice.getDIMRep(sensorId,
				cvDIM);
		String targetID = sclId + "/applications/" + sensorId
				+ "/containers/DATA/contentInstances";
		core.doRequest(new RequestIndication("CREATE", targetID,
				reqEntity, contentData));
		
		System.out.println("DIM :" + " GET DIM " + "\n");
	} 
	catch (Exception e) 
	{
		// TODO: handle exception
		e.printStackTrace();
	}
}
 
开发者ID:AINLAB,项目名称:OHP-M2M,代码行数:27,代码来源:StrengthFitnessMonitor.java

示例12: onLoad

import org.eclipse.californium.core.CoapResponse; //导入依赖的package包/类
@Override
public void onLoad(CoapResponse response)
{
	String content = response.getResponseText(); // Gets the response from Coap
	try {
		cvDIM = new DomainInformationModel("StrengthFitness DS");
	
		readXML(content);
	
		String contentData = MedicationMonitorDevice.getDIMRep(sensorId,
				cvDIM);
		String targetID = sclId + "/applications/" + sensorId
				+ "/containers/DATA/contentInstances";
		core.doRequest(new RequestIndication("CREATE", targetID,
				reqEntity, contentData));

	} 
	catch (Exception e) 
	{
		// TODO: handle exception
		e.printStackTrace();
	}
}
 
开发者ID:AINLAB,项目名称:OHP-M2M,代码行数:24,代码来源:MedicationMonitor.java

示例13: onLoad

import org.eclipse.californium.core.CoapResponse; //导入依赖的package包/类
@Override
public void onLoad(CoapResponse response) {
	// TODO Auto-generated method stub
	String content, targetID, spo2value, pulseratevalue;
	String message = response.getResponseText();
	String[] buf = message.split("OBX");
	
	
	String[] spo2buf = buf[buf.length-2].split("\\|");
	spo2value = spo2buf[spo2buf.length-2];
	String[] pulsebuf = buf[buf.length-1].split("\\|");
	pulseratevalue = pulsebuf[pulsebuf.length-2];
	
	
	content = D10404.getStateRep(D10404.TYPE, spo2value, pulseratevalue, message);
	targetID = SCLID+"/applications/"+D10404.TYPE+"/containers/"+DATA+"/contentInstances";
          SCL.doRequest(new RequestIndication(METHOD_CREATE,targetID,REQENTITY,new ContentInstance(content.getBytes())));
}
 
开发者ID:AINLAB,项目名称:OHP-M2M,代码行数:19,代码来源:D10404Monitor.java

示例14: onLoad

import org.eclipse.californium.core.CoapResponse; //导入依赖的package包/类
@Override
public void onLoad(CoapResponse response) {
	String content = response.getResponseText();
	// System.out.println("-CO01----------");
	System.out.println(content);
	dimXMLStr = content;
	try {
		blpDIM = new DomainInformationModel("BloodPressure DS");
		
		readXML(content);
		String contentData = BloodPressureDevice.getDIMRep(sensorId,
				blpDIM);
		String targetID = sclId + "/applications/" + sensorId
				+ "/containers/DATA/contentInstances";
		core.doRequest(new RequestIndication("CREATE", targetID,
				reqEntity, contentData));

		System.out.println("DIM :" + " GET DIM " + "\n");
	} catch (Exception e) {
		// TODO: handle exception
		e.printStackTrace();
	}
}
 
开发者ID:AINLAB,项目名称:OHP-M2M,代码行数:24,代码来源:BloodPressureMonitor.java

示例15: onLoad

import org.eclipse.californium.core.CoapResponse; //导入依赖的package包/类
@Override
public void onLoad(CoapResponse response) {
	String content = response.getResponseText();

	dimXMLStr = content;
	try {
		gmDIM = new DomainInformationModel("GlucoseMeter DS");
		
		readXML(dimXMLStr);

		
		String contentData = GlucoseMeterDevice.getDIMRep(sensorId,
				gmDIM);
		String targetID = sclId + "/applications/" + sensorId
				+ "/containers/DATA/contentInstances";
	
		core.doRequest(new RequestIndication("CREATE", targetID,
				reqEntity, contentData));

		
	} catch (Exception e) {
		// TODO: handle exception
		e.printStackTrace();
	}
}
 
开发者ID:AINLAB,项目名称:OHP-M2M,代码行数:26,代码来源:GlucoseMeterMonitor.java


注:本文中的org.eclipse.californium.core.CoapResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。