|
|
|
|
|
|
Re: Subscriptions [message #1600706 is a reply to message #1599904] |
Wed, 04 February 2015 12:29 |
Ghada Gharbi Messages: 4 Registered: July 2014 |
Junior Member |
|
|
Hello,
You are right. Indeed, the "setState" method of the Sensor class is not correct.
I made the following changes on the wiki:
- In Sensor class: the setState(String appId) method was removed and replaced with the getState() that returns a random value to simulate a sensor measurement. The appId parameter is useless here.
- In Lamp class: the appId parameter is also removed from the getState(String appId) method like this: boolean getState().
- In IpuControlor class: Now, in the doRetrieve() method we get the value of the sensor from Sensor.getState(), then it is converted to an oBIX represented.
Thank you,
Ghada
[Updated on: Wed, 04 February 2015 12:43] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
Re: Subscriptions [message #1737311 is a reply to message #1737219] |
Thu, 07 July 2016 08:45 |
Can LIU Messages: 29 Registered: May 2016 |
Junior Member |
|
|
Hello mahdi,
I am doing the same thing as Trung, and i already write some lines of code. I pasted it below, i juste don't know how to give the notificationURI to this function? Could you help me and Trung for this?
Code in my RequestSender:
private RequestSender(){}
public static ResponsePrimitive createResource(String targetId, String name, Resource resource, int resourceType){
RequestPrimitive request = new RequestPrimitive();
request.setFrom(Constants.ADMIN_REQUESTING_ENTITY);
request.setTargetId(targetId);
request.setResourceType(BigInteger.valueOf(resourceType));
request.setRequestContentType(MimeMediaType.OBJ);
request.setReturnContentType(MimeMediaType.OBJ);
request.setContent(resource);
request.setName(name);
request.setOperation(Operation.CREATE);
return CSE.doRequest(request);
}
///////////////////request for subscription////////////////////
public static ResponsePrimitive createSubscription(String targetId, String name, Subscription resource){
return createResource(targetId, name, resource, ResourceType.SUBSCRIPTION);
}
//////////////////////////////////////////////////////////////
relative Code in my monitor():
public void createSensorResources(){
String targetId, content;
targetId = "/" + CSE_ID + "/" + CSE_NAME;
AE ae = new AE();
ae.setRequestReachability(true);
ae.setAppID(ipeId);
ae.getPointOfAccess().add(ipeId);
ResponsePrimitive response = RequestSender.createAE(ae, sensorId);
if(response.getResponseStatusCode().equals(ResponseStatusCode.CREATED)){
// Create the subscription for the monitor in IN
targetId = "/" + CSE_ID + "/" + CSE_NAME + "/" + sensorId + "/" + DATA;
ContentInstance sub = new ContentInstance();
sub.setContent(content);
sub.setContentInfo(MimeMediaType.OBIX);
RequestSender.createSubscription(targetId,); (here i don't know how to give the "nu"!!!!)
///////////////////////////////////////
Recording to my understand, create a subscription is just like to create a contentinstance in DATA container? but where should i give my value of "nu" to this function?
Thanks in advance.
Can
[Updated on: Thu, 07 July 2016 08:50] Report message to a moderator
|
|
|
|
Re: Subscriptions [message #1737391 is a reply to message #1737318] |
Thu, 07 July 2016 17:29 |
Mahdi Ben Alaya Messages: 229 Registered: November 2013 |
Senior Member |
|
|
Dear Can LIU,
Trung is right. You should use the resource type "Subscription".
By the way, you can find all resource types on the plugin "org.eclipse.om2m.commons" under the "resources" folder.
Example:
Subscription sub = new Subscription();
sub.getNotificationURI().add("http://192.168.0.10:1400/monitor");
sub.setNotificationContentType(BigInteger.valueOf(2));
You can also set your "AE resourceID" as NotificationURI in your Subscription (e.g. /cse-id/cse-name/ae-id) instead of setting a protocol-dependent URI.
Then, you have to set the protocol-dependent URI "http://192.168.0.10:1400/monitor" as PoA in your AE resource and so keep your subscription clean.
The event will be re targeted from CSE to another based on the AE resourceID, and the final CSE will check the hosted AE resource and notification the PoA.
Regards,
Mahdi
[Updated on: Thu, 07 July 2016 17:30] Report message to a moderator
|
|
|
|
Re: Subscriptions [message #1738068 is a reply to message #1737391] |
Fri, 15 July 2016 14:13 |
Can LIU Messages: 29 Registered: May 2016 |
Junior Member |
|
|
Hi Mahdi,
Thank you very much.
I changed my code like this:
targetId = "/" + CSE_ID + "/" + CSE_NAME + "/" + sensorId + "/"
+ DATA;
Subscription sub = new Subscription();
sub.getNotificationURI().add("http://XX.XX.XX.223:1400/Monitor");
sub.setNotificationContentType(BigInteger.valueOf(2));
RequestSender.createSubscription(targetId,SUB,sub);
And in my requestsender:
public static ResponsePrimitive createSubscription(String targetId, String name, Subscription resource){
return createResource(targetId, name, resource, ResourceType.SUBSCRIPTION);
There is no error shows up.
But i have another question. In fact, i download the source of Monitor.jar and i made it into a plugin in my IN side.
My question is How do i give the "nu" value if it is a plugin in IN?
Thanks in advance and have a good day!
Can
|
|
|
Powered by
FUDForum. Page generated in 0.04637 seconds