Subscriptions [message #1393947] |
Fri, 04 July 2014 14:27  |
Eclipse User |
|
|
|
How can the Network Application subscribe to GA resources ? Is this supported in the current implementation ? Can you please share code level details.
Also, what is the use of SubscriptionController in the Router and what functionality does it provide ?
|
|
|
Re: Subscriptions [message #1396457 is a reply to message #1393947] |
Tue, 08 July 2014 10:22   |
Eclipse User |
|
|
|
Hello Prem,
OM2M implements two subscription/notification scenarios:
Scenario 1: Notify a server-capable application:
A detailed example is available on our wiki here: https://wiki.eclipse.org/OM2M/REST_API
Scenario 2: Notify a non-server-capable application by redirecting notifications to one of its container.
Let's keep working on the same example described on the first scenario.
We have the "MY_SENSOR" application with its corresponding "DATA" containers deployed on the GSCL.
Now, create on the NSCL a new application "MONITOR" with its corresponding container "NOTIFICATION".
Then, subscribe the "MONITOR/containers/NOTIFICATION/contentInstances" resource to "MY_SENSOR/containers/DATA/contentInstances" resource using the following request:
POST 127.0.0.1:8080/om2m/gscl/applications/MY_SENSOR/containers/DATA/contentInstances/subscriptions
<?xml version="1.0" encoding="UTF-8"?>
<om2m:subscription xmlns:tns="http://uri.etsi.org/m2m" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<om2m:contact>nscl/applications/MONITOR/containers/NOTIFICATION/contentInstances</om2m:contact>
</om2m:subscription>
To check this, you can create a new contentInstance event on the GSCL on "MY_SENSOR/containers/DATA/contentInstances". The new event should be automatically forwarded to to the NSCL and stored on "MONITOR/containers/NOTIFICATION/contentInstances".
The ETSI M2M specification defines a third subscription/notification based for non-server-capable application based on the long polling mechanism (Not yet implemented in OM2M).
Don't hesitate to contact us if you have any question or remark.
|
|
|
|
Re: Subscriptions [message #1593363 is a reply to message #1403941] |
Fri, 30 January 2015 15:36   |
Eclipse User |
|
|
|
Hi, just wanted to get somethings clear.
The monitor server application described on the REST_API page
is a "server-capable application" right?
This does not appear in the resource tree, as it is not created on neither the NSCL nor on the GSCL.
The other type of application is the one you create on the NSCL in your response. Is this what you call scenario 2?
|
|
|
Re: Subscriptions [message #1597840 is a reply to message #1593363] |
Mon, 02 February 2015 15:46   |
Eclipse User |
|
|
|
Hello Daniel,
1) Yes, the monitor server application described on the REST_API page is a "server-capable application".
You can create an application resource for it if you want to use a specific requesting entity or to create some container sub resources.
We did not created an application resource for the monitor in the tutorial in order to make it simple.
2) Yes, the other type of application is created on the NSCL. A specific container of this applications is used as CotnactURI for the subscription.
And, this is what I called scenario 2 in my response.
Hope this can help.
|
|
|
Re: Subscriptions [message #1599904 is a reply to message #1597840] |
Tue, 03 February 2015 23:58   |
Eclipse User |
|
|
|
Hi, thanks for the response. It helped me.
Somethingelse!
Just wanted to say that i think something is wrong with the setState function in the Sensor class.
First the comment "Gets SensorState" and secondly the parameter passed to the function is not used.
This function is not used as I expected in the doRetrieve method of the IpuController class.
Could it be that the method should be called "getState" with the following signature " int getState(String appId) ", with the integer returned beeing Sensor.state?
|
|
|
Re: Subscriptions [message #1600706 is a reply to message #1599904] |
Wed, 04 February 2015 12:29   |
Eclipse User |
|
|
|
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] by Moderator Report message to a moderator
|
|
|
|
|
|
|
|
Re: Subscriptions [message #1737211 is a reply to message #1737188] |
Wed, 06 July 2016 12:50   |
Eclipse User |
|
|
|
Dear Trung,
Scenario 2 feature was provided only in OM2M 0.8 (SmartM2M-based) but not yet implemented in OM2M 1.0 (oneM2M-based).
Regards,
Mahdi
|
|
|
Re: Subscriptions [message #1737219 is a reply to message #1737211] |
Wed, 06 July 2016 13:02   |
Eclipse User |
|
|
|
Dear Mahdi,
So if I want to build a Subscribe/notify scenario such as the actuator in IN-CSE send subscribe message to sensor in MN-CSE and sensor in MN-CSE notify sensor value back to actuator, Can I build it in Java? and how can I do that? Thanks for your support.
Best Regards,
Trung
|
|
|
Re: Subscriptions [message #1737311 is a reply to message #1737219] |
Thu, 07 July 2016 08:45   |
Eclipse User |
|
|
|
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] by Moderator Report message to a moderator
|
|
|
Re: Subscriptions [message #1737318 is a reply to message #1737311] |
Thu, 07 July 2016 09:35   |
Eclipse User |
|
|
|
Dear Can LIU,
I think in monitor, you can replace ContentIntance sub = new ContentInstance(); by Subscription sub = new Subscription(); because OM2M supports this class.
Best Regards,
Trung
|
|
|
Re: Subscriptions [message #1737391 is a reply to message #1737318] |
Thu, 07 July 2016 17:29   |
Eclipse User |
|
|
|
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] by Moderator Report message to a moderator
|
|
|
|
Re: Subscriptions [message #1738068 is a reply to message #1737391] |
Fri, 15 July 2016 14:13  |
Eclipse User |
|
|
|
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.05457 seconds