Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » OM2M » Use of the retargeting concept in the oneM2M version
Use of the retargeting concept in the oneM2M version [message #1730968] Sun, 01 May 2016 07:36 Go to next message
Klemen Petrovcic is currently offline Klemen PetrovcicFriend
Messages: 34
Registered: November 2015
Member
I would like to perform specific operations on a device using the retargeting concept. For the 0.8 platform version, an example was already provided here.

Could you possible also provide an example for the oneM2M version of the platform?

I have a device with an ip of 192.168.0.118:80 which toggles its state using the /toggle URI.

I tried using it by specifying the poa element while creating the device:

<om2m:ae xmlns:om2m="http://www.onem2m.org/xml/protocols">
    <api>app-sensor</api>
    <lbl>Type/sensor Category/temperature Location/home</lbl>
    <rr>true</rr>
    <poa>http://192.168.0.118:80</poa>
</om2m:ae>


And modified the uri od the specific operation in the DESCRIPTOR contentInstance:

<om2m:cin xmlns:om2m="http://www.onem2m.org/xml/protocols">
    <cnf>message</cnf>
    <con>
        &lt;obj&gt;
            &lt;str name=&quot;type&quot; val=&quot;Temperature_Sensor&quot;/&gt;
            &lt;str name=&quot;location&quot; val=&quot;Home&quot;/&gt;
            &lt;str name=&quot;appId&quot; val=&quot;MY_SENSOR&quot;/&gt;
            &lt;op name=&quot;Toggle&quot; href=&quot;/in-cse/MY_SENSOR/toggle&quot; 
         in=&quot;obix:Nil&quot; out=&quot;obix:Nil&quot; is=&quot;execute&quot;/&gt;
        &lt;/obj&gt;
    </con>
</om2m:cin>


Upon clicking on the button in the web interface this returns an error. Could you, please, explain what I'm missing?

[Updated on: Thu, 05 May 2016 18:26]

Report message to a moderator

Re: Use of the retargeting concept in the oneM2M version [message #1731498 is a reply to message #1730968] Fri, 06 May 2016 08:56 Go to previous messageGo to next message
Guillaume Garzone is currently offline Guillaume GarzoneFriend
Messages: 54
Registered: April 2015
Member
Hello Klemen,

I understand what you are trying to do, unfortunately this kind of mechanism is not present in the oneM2M standard. The POA of an AE can be used to send a notification to a specific target. To do so, you have to send a POST request on an AE uri (without any other term in the URI) and the request will be transmitted to that POA keeping its query strings etc.

However you can have a similar behavior by sending a POST to your AE with a custom query string (such as ?op=toggle) and you can handle it on the listening part.

Hope this helps clarifiying the situation.
Guillaume
Re: Use of the retargeting concept in the oneM2M version [message #1731517 is a reply to message #1731498] Fri, 06 May 2016 11:56 Go to previous messageGo to next message
Klemen Petrovcic is currently offline Klemen PetrovcicFriend
Messages: 34
Registered: November 2015
Member
Hi Guillaume.

I understand that the "?op=toggle" query string could be specified and that its value could be checked in the controller class of a custom IPE plugin.

What I don't understand is how will, for example, the http binding translate that operation to the corresponding URL of the AE (in my example http://192.168.0.118/toggle)?

I tried the following, which didn't work:

1.) Registered the device with this snippet:

<om2m:ae xmlns:om2m="http://www.onem2m.org/xml/protocols">
    <api>app-sensor</api>
    <lbl>Type/sensor Category/temperature Location/home</lbl>
    <rr>true</rr>
    <poa>http://192.168.0.118:80</poa>
</om2m:ae>



2.) Created the DESCRIPTOR container

3.) Created the DESCRIPTOR content instance with:

<om2m:cin xmlns:om2m="http://www.onem2m.org/xml/protocols">
    <cnf>message</cnf>
    <con>
        &lt;obj&gt;
            &lt;str name=&quot;type&quot; val=&quot;Temperature_Sensor&quot;/&gt;
            &lt;str name=&quot;location&quot; val=&quot;Home&quot;/&gt;
            &lt;str name=&quot;appId&quot; val=&quot;MY_SENSOR&quot;/&gt;
            &lt;op name=&quot;getValue&quot; href=&quot;/in-cse/in-name/MY-SENSOR?op=toggle&quot; 
         in=&quot;obix:Nil&quot; out=&quot;obix:Nil&quot; is=&quot;retrieve&quot;/&gt;
        &lt;/obj&gt;
    </con>
</om2m:cin>



Thank you for taking the time for helping me out.
Re: Use of the retargeting concept in the oneM2M version [message #1732109 is a reply to message #1731517] Thu, 12 May 2016 16:18 Go to previous messageGo to next message
Mahdi Ben Alaya is currently offline Mahdi Ben AlayaFriend
Messages: 229
Registered: November 2013
Senior Member
Dear Klemen,

It is not working because you are sending an HTTP GET request to "/in-cse/in-name/MY-SENSOR?op=toggle".
You need to change "retrieve" with "execute" in the "is" attribute of the "op" tag in your XML representation to tell the web interface JS to send an HTTP POST to the CSE which then will retarget it to the PoA of your application.

For more details you can take a look at our tutorial "add your plugin" section IPE oBIX Util
http://wiki.eclipse.org/OM2M/one/Developer

Please try this and tell me if it work.
Mahdi

[Updated on: Thu, 12 May 2016 16:19]

Report message to a moderator

Re: Use of the retargeting concept in the oneM2M version [message #1732128 is a reply to message #1732109] Thu, 12 May 2016 18:15 Go to previous messageGo to next message
Klemen Petrovcic is currently offline Klemen PetrovcicFriend
Messages: 34
Registered: November 2015
Member
Hi Mahdi,

thanks for helping. I tried repeating the above prodecure with the "execute" value for the "is" parameter. Again, no luck. Sad I've since replaced the "toggle" query string with "true".

I am attaching some pictures, to better depict my issue:

https://dl.dropboxusercontent.com/u/55075286/1createAE.PNG

https://dl.dropboxusercontent.com/u/55075286/2createDESC.PNG

https://dl.dropboxusercontent.com/u/55075286/3createDESCCI.PNG

[Updated on: Thu, 12 May 2016 18:21]

Report message to a moderator

Re: Use of the retargeting concept in the oneM2M version [message #1732129 is a reply to message #1732128] Thu, 12 May 2016 18:18 Go to previous messageGo to next message
Mahdi Ben Alaya is currently offline Mahdi Ben AlayaFriend
Messages: 229
Registered: November 2013
Senior Member
Could you please show me the log ?

[Updated on: Thu, 12 May 2016 18:19]

Report message to a moderator

Re: Use of the retargeting concept in the oneM2M version [message #1732130 is a reply to message #1732129] Thu, 12 May 2016 18:22 Go to previous messageGo to next message
Klemen Petrovcic is currently offline Klemen PetrovcicFriend
Messages: 34
Registered: November 2015
Member
Do you mean the log.out file?

[Updated on: Thu, 12 May 2016 18:31]

Report message to a moderator

Re: Use of the retargeting concept in the oneM2M version [message #1732131 is a reply to message #1732130] Thu, 12 May 2016 18:24 Go to previous messageGo to next message
Mahdi Ben Alaya is currently offline Mahdi Ben AlayaFriend
Messages: 229
Registered: November 2013
Senior Member
In the console.
There is also a log file in the CSE directory.
Re: Use of the retargeting concept in the oneM2M version [message #1732133 is a reply to message #1732131] Thu, 12 May 2016 18:30 Go to previous messageGo to next message
Klemen Petrovcic is currently offline Klemen PetrovcicFriend
Messages: 34
Registered: November 2015
Member
Log.out file

The device responds if I navigate to its url (http://192.168.0.118:80/true) manually (with a browser).

[Updated on: Thu, 12 May 2016 18:36]

Report message to a moderator

Re: Use of the retargeting concept in the oneM2M version [message #1732134 is a reply to message #1732133] Thu, 12 May 2016 18:38 Go to previous messageGo to next message
Mahdi Ben Alaya is currently offline Mahdi Ben AlayaFriend
Messages: 229
Registered: November 2013
Senior Member
OM2M is working correctly. The error is returned from your AE listener server.

According to the log, the error message is:
<h1>404 Not Found</h1>
No context found for request

I am pretty sure that a part of your URI is missing.
Try to append the context of your listener server to the address defined in your AE PoA Wink

Hope this can help
Re: Use of the retargeting concept in the oneM2M version [message #1732136 is a reply to message #1732134] Thu, 12 May 2016 18:49 Go to previous messageGo to next message
Klemen Petrovcic is currently offline Klemen PetrovcicFriend
Messages: 34
Registered: November 2015
Member
By "listener server" you mean the plugin which handles the request? It's the http binding (I am not using a custom plugin). The http binding's context is "/" (obtained from the config.ini file of the cse).

So, if I understand correctly, I should append the "/" char to get: "http://192.168.0.118:80/true/" ? Tried this, it didn't work.

Thanks for answering.

[Updated on: Thu, 12 May 2016 19:03]

Report message to a moderator

Re: Use of the retargeting concept in the oneM2M version [message #1732137 is a reply to message #1732136] Thu, 12 May 2016 18:55 Go to previous messageGo to next message
Mahdi Ben Alaya is currently offline Mahdi Ben AlayaFriend
Messages: 229
Registered: November 2013
Senior Member
I though you are using an external server for your AE where you want to send your requests.
If you are using an IPE plugin then you should put as PoA for your AE the String returned by getAPOCPath() in your IPE Controller class.
check it here: http://wiki.eclipse.org/OM2M/one/Developer
Re: Use of the retargeting concept in the oneM2M version [message #1732138 is a reply to message #1732137] Thu, 12 May 2016 18:59 Go to previous messageGo to next message
Klemen Petrovcic is currently offline Klemen PetrovcicFriend
Messages: 34
Registered: November 2015
Member
Mahdi Ben Alaya wrote on Thu, 12 May 2016 18:55
I though you are using an external server for your AE where you want to send your requests.


Yes, Im using an external device (but located in my LAN).

Mahdi Ben Alaya wrote on Thu, 12 May 2016 18:55

If you are using an IPE plugin then you should put as PoA for your AE the String returned by getAPOCPath() in your IPE Controller class.
check it here: http://wiki.eclipse.org/OM2M/one/Developer


I'm only using the http binding plugin provided with the platform.

[Updated on: Thu, 12 May 2016 19:00]

Report message to a moderator

Re: Use of the retargeting concept in the oneM2M version [message #1732140 is a reply to message #1732138] Thu, 12 May 2016 19:07 Go to previous messageGo to next message
Mahdi Ben Alaya is currently offline Mahdi Ben AlayaFriend
Messages: 229
Registered: November 2013
Senior Member
Ok. What is the exact address that you want to trigger from your device ?

http://192.168.0.118:80/true
http://192.168.0.118:80/op=true
http://192.168.0.118:80/somethign/true
etc.

[Updated on: Thu, 12 May 2016 19:08]

Report message to a moderator

Re: Use of the retargeting concept in the oneM2M version [message #1732141 is a reply to message #1732140] Thu, 12 May 2016 19:11 Go to previous messageGo to next message
Klemen Petrovcic is currently offline Klemen PetrovcicFriend
Messages: 34
Registered: November 2015
Member
It would be http://192.168.0.118:80/true. This is the url the device reacts to, if I navigate to it with my browser.

[Updated on: Thu, 12 May 2016 19:12]

Report message to a moderator

Re: Use of the retargeting concept in the oneM2M version [message #1732142 is a reply to message #1732141] Thu, 12 May 2016 19:20 Go to previous messageGo to next message
Mahdi Ben Alaya is currently offline Mahdi Ben AlayaFriend
Messages: 229
Registered: November 2013
Senior Member
Then simply put for your href in xml:
/in-cse/in-name/MY-SENSOR/true
Re: Use of the retargeting concept in the oneM2M version [message #1732143 is a reply to message #1732142] Thu, 12 May 2016 19:31 Go to previous messageGo to next message
Klemen Petrovcic is currently offline Klemen PetrovcicFriend
Messages: 34
Registered: November 2015
Member
Still no luck. I'm attaching some images. Thanks for sticking around. Smile

https://dl.dropboxusercontent.com/u/55075286/1.PNG

https://dl.dropboxusercontent.com/u/55075286/2.PNG

https://dl.dropboxusercontent.com/u/55075286/3.PNG

[Updated on: Thu, 12 May 2016 19:32]

Report message to a moderator

Re: Use of the retargeting concept in the oneM2M version [message #1732155 is a reply to message #1732143] Fri, 13 May 2016 03:35 Go to previous messageGo to next message
Mahdi Ben Alaya is currently offline Mahdi Ben AlayaFriend
Messages: 229
Registered: November 2013
Senior Member
Klemen,

Don't worry, we will find the solution Wink

After investigation, I can say that the error comes from a typo in your XML descriptor "href" attribute.
You wrote MY-SENSOR with a dash. It should be MY_SENSOR with underscore according to your AE name Smile
Please correct this and keep me informed.

Mahdi

[Updated on: Fri, 13 May 2016 03:35]

Report message to a moderator

Re: Use of the retargeting concept in the oneM2M version [message #1732230 is a reply to message #1732155] Fri, 13 May 2016 15:01 Go to previous messageGo to next message
Klemen Petrovcic is currently offline Klemen PetrovcicFriend
Messages: 34
Registered: November 2015
Member
I tried again with the corrected sensor name. No success.

I'm attaching the images and the log.

Registration of the AE device:
https://dl.dropboxusercontent.com/u/55075286/111.PNG

DESCRIPTOR content instance:
https://dl.dropboxusercontent.com/u/55075286/222.PNG

Log:
https://dl.dropboxusercontent.com/u/55075286/log.out


Re: Use of the retargeting concept in the oneM2M version [message #1732325 is a reply to message #1732230] Mon, 16 May 2016 01:42 Go to previous messageGo to next message
Mahdi Ben Alaya is currently offline Mahdi Ben AlayaFriend
Messages: 229
Registered: November 2013
Senior Member
Dear Klemen,

I think that when using this kind of URI "/in-cse/in-name/MY-SENSOR/true", the CSE handles the "true" as a sub resource under the AE and so fire a 404 Not found error. The parameter(e.g. true or false) shall be provided in the query string.

Is it possible to update your external device to listen to:
http://192.168.0.118:80?op=true

Then try to use the following URI in your descriptor to trigger the deivice:
/in-cse/in-name/MY-SENSOR?op=true

Waiting for your feedback,
Mahdi
Re: Use of the retargeting concept in the oneM2M version [message #1732381 is a reply to message #1732325] Mon, 16 May 2016 16:57 Go to previous messageGo to next message
Klemen Petrovcic is currently offline Klemen PetrovcicFriend
Messages: 34
Registered: November 2015
Member
I tried modifying the listening context on my device. No success.

I think the url http://192.168.0.118:80?op=true is an invalid url since it doesn't contains a context (at least a '/' char). A browser automatically inserts a slash before the "?" char to make the url look like this:

http://192.168.0.118/?op=true

I also checked this by making a small modification to the monitor.jar (source is in the attachment) and tried the following context values:

// private static String context = "?op=true";   // this wont work (throws an exception, illegal path)
// private static String context = "/?op=true";   // this wont work (allows the server to be created, wont accept requests)
private static String context = "/";   // works,  can pass the query string 'op=true' 


For the last context which worked ("/"), I tried creating the AE with poa parameter set to "127.0.0.1:1400/" and specifying the following URI in the descriptor: /in-cse/in-name/MY-SENSOR?op=true. Same error was returned.

[Updated on: Mon, 16 May 2016 17:26]

Report message to a moderator

Re: Use of the retargeting concept in the oneM2M version [message #1732567 is a reply to message #1732381] Wed, 18 May 2016 09:59 Go to previous messageGo to next message
Mahdi Ben Alaya is currently offline Mahdi Ben AlayaFriend
Messages: 229
Registered: November 2013
Senior Member
Hello,
Could you try this:

Device can be turned on by sening a POST to http://192.168.0.118:80/app?op=true

AE poa = http://192.168.0.118:80/app

Descriptor op: href = /in-cse/in-name/MY-SENSOR?op=true
Re: Use of the retargeting concept in the oneM2M version [message #1732625 is a reply to message #1732567] Wed, 18 May 2016 15:32 Go to previous message
Klemen Petrovcic is currently offline Klemen PetrovcicFriend
Messages: 34
Registered: November 2015
Member
This appears to be working (only had to change the "-" to a "_" in the href attribute to suit my example). Smile Tested with the small http server posted in an earlier post, with the context "/app".

Thank you, Mahdi!

[Updated on: Wed, 18 May 2016 15:40]

Report message to a moderator

Previous Topic:REST API in smartM2M version
Next Topic:semantic description in om2m
Goto Forum:
  


Current Time: Thu Mar 28 09:50:47 GMT 2024

Powered by FUDForum. Page generated in 0.06723 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top