Home » Eclipse Projects » OM2M » Using CoAP based applications (Copper vs Erbium)
Using CoAP based applications (Copper vs Erbium) [message #1464204] |
Fri, 07 November 2014 09:43  |
Eclipse User |
|
|
|
Hey guys,
First of all much thanks for your hard work. OM2M is a great work.
I was trying to set up a test environment with a CoAP (Erbium) running sensor DA. The problem I have is, I can not successfully pass the Authentication (requestingEntity). While using Copper plugin as CoAP client, I can send a GET request like,
coap :// [2001:bbbb:dddd:0:2ff:ffff:ffff:ffff]<colon>5683/om2m/nscl?authorization=admin:admin
and it works fine. But with Erbium the same request would respond with error like,
osgi> Nov 06, 2014 6:16:45 PM org.eclipse.om2m.core.router.Router doRequest
INFORMATION: RequestIndication [method=RETRIEVE, base=, targetID=/nscl, representation=, requestingEntity=null, protocol=null]
Nov 06, 2014 6:16:45 PM org.eclipse.om2m.comm.coap.CoapMessageDeliverer service
INFORMATION: check point: requestIndication sent and waiting for responseConfirm
Nov 06, 2014 6:16:45 PM org.eclipse.om2m.comm.coap.CoapMessageDeliverer getCoapStatusCode
INFORMATION: The received code is STATUS_AUTHORIZATION_NOT_ADDED
Nov 06, 2014 6:16:45 PM org.eclipse.om2m.comm.coap.CoapMessageDeliverer service
INFORMATION: check point : The code is 4.01
Nov 06, 2014 6:16:45 PM org.eclipse.om2m.comm.coap.CoapMessageDeliverer service
INFORMATION: the responseConfirm: ResponseConfirm [statusCode=STATUS_AUTHORIZATION_NOT_ADDED, representation=<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<om2m:errorInfo xmlns:om2m="link" xmlns:xmime="link">
<om2m:statusCode>STATUS_AUTHORIZATION_NOT_ADDED</om2m:statusCode>
<om2m:additionalInfo>Requesting Entity should not be null</om2m:additionalInfo>
</om2m:errorInfo>
, resourceURI=null]
Nov 06, 2014 6:16:45 PM org.eclipse.om2m.comm.coap.CoapMessageDeliverer service
INFORMATION: CoAP Response parameters set
Nov 06, 2014 6:16:45 PM org.eclipse.om2m.comm.coap.CoapMessageDeliverer deliverRequest
INFORMATION: the response= ACK-4.01 MID=26068, Token=[], OptionSet=[], "<?xmlversion="1.0" ".. 22 bytes
Nov 06, 2014 6:16:45 PM org.eclipse.om2m.comm.coap.CoapMessageDeliverer deliverRequest
I know my question is more related to the CoAP client (CoAP header) but if you already have encountered the same problems please let me know.
regards,
Fesseha
|
|
|
Re: Using CoAP based applications (Copper vs Erbium) [message #1464410 is a reply to message #1464204] |
Fri, 07 November 2014 14:22   |
Eclipse User |
|
|
|
Hello,
Ok, let's try to investigate this issue.
Technically, I think that all URI parameters goes in the "Uri-Query" option of the CoAP protocol.
So, try to add the option: "Uri-Query" with the value: "authorization=admin:admin" to your CoAP request (instead of adding it as a URI parameter) and let's see.
Mahdi
|
|
| |
Re: Using CoAP based applications (Copper vs Erbium) [message #1516129 is a reply to message #1464423] |
Thu, 18 December 2014 17:26   |
Eclipse User |
|
|
|
hey guys,
Ive a small question.
By default in response messages the CoAP engine in OM2M sets the block size to 512bytes. For eg, just right after registering an Application resource, in the response the Application representation is included (as you know this representation is huge for small devices) and for this the first response is sent with szx = 512. Is it by any means possible to reduce this size????
regards
|
|
|
Re: Using CoAP based applications (Copper vs Erbium) [message #1516143 is a reply to message #1516129] |
Thu, 18 December 2014 17:39   |
Eclipse User |
|
|
|
I think that returning the representation of the created resource is useless in constraint environment.
So I suggest you to go to "org.eclipse.om2m.comm.coap" plugin and update the "CoapServer.java".
Update the following code (line 242) :
if(responseConfirm.getRepresentation()!=null){
//filling in the fields of the Coap response
response.setPayload(responseConfirm.getRepresentation());
}
like this:
if(responseConfirm.getRepresentation()!=null){
//filling in the fields of the Coap response
if(statusCode != 2.01){
response.setPayload(responseConfirm.getRepresentation());
}
}
Tell me is this update meets your need.
If yes, I will push a patch to the git.
cheers
[Updated on: Thu, 18 December 2014 17:40] by Moderator Report message to a moderator
|
|
|
Re: Using CoAP based applications (Copper vs Erbium) [message #1517551 is a reply to message #1516143] |
Fri, 19 December 2014 15:31   |
Eclipse User |
|
|
|
hallo,
I added that condition and the result was the same. The first message of the response to application registration is still 584bytes long (on the wire) with [Block2: NUM:0, M:8, SZX:512] header. I looked for this default response size even in 'Californium' but without success.
°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
°^°^°^°^°Merry Christmas and Happy 2015°^°^°^°^°
°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
regards,
|
|
| | |
Re: Using CoAP based applications (Copper vs Erbium) [message #1517677 is a reply to message #1517560] |
Fri, 19 December 2014 17:22   |
Eclipse User |
|
|
|
Yea I've done that. I also tried to add the 'protocol' query in the OM2M code if it could help, but it does not have change. Previously the protocol is always shown as null, whether set or unset in requests. I actually talked about this to let you know that I can actually see the effect of the changes I make to the code.
Look at the attached pics.
Attachment: OM2M.png
(Size: 146.41KB, Downloaded 668 times)
Attachment: CoAP POST.png
(Size: 127.42KB, Downloaded 672 times)
|
|
|
Re: Using CoAP based applications (Copper vs Erbium) [message #1517683 is a reply to message #1517677] |
Fri, 19 December 2014 17:25   |
Eclipse User |
|
|
|
The problem is clear here, you must use && instead of || in your if condition like this:
if(responseConfirm.getRepresentation()!=null){
//filling in the fields of the Coap response
if(statusCode != 2.01 && statusCode != 5.03 ){
response.setPayload(responseConfirm.getRepresentation());
}
}
|
|
| | | |
Re: Using CoAP based applications (Copper vs Erbium) [message #1585895 is a reply to message #1524448] |
Mon, 26 January 2015 14:51   |
Eclipse User |
|
|
|
hello guys,
Have you noticed a problem on the CoAP message deliverer during block wise transfer?
The situation is like this, an Application sends a request to the NSCL to get a resource of an already registered application (DA). By default the NSCL sends (forwards) a request without setting any CoAP block headers. But the response from the DA holds BLOCK2 header. The message id should be continuous in this case and the NSCL should continue with an incremented mid and the new BLOCK2 header. But the message id jumps to some new random value which makes it difficult for the other side (DA). Take a look at the attached Wireshark screen shot.
Any suggestions?
|
|
|
Re: Using CoAP based applications (Copper vs Erbium) [message #1597821 is a reply to message #1585895] |
Mon, 02 February 2015 15:32   |
Eclipse User |
|
|
|
Hello Fesseha,
What i see from the wireshark log is that there is a GET request which is divided in 2 blocks (block 0 and block 1). The error message is a SERVICE UNAVAILABLE (5.03). This means that all the blocks have been assembled but there is no service to respond to the GET request. I don't think there is an issue with the blockwise operation here. However to make sure of this, you should investigate a little deeper and be sure that the request is assembled correctly. i strongly believe it is not the CoAP client problem and you should see in the service part and check if it is available and why it is not responding.
Mahdi & Elvis
|
|
|
Re: Using CoAP based applications (Copper vs Erbium) [message #1740691 is a reply to message #1464410] |
Wed, 17 August 2016 10:34   |
Eclipse User |
|
|
|
Hi Mahdi,
I wonder that in OM2M version 1.0.0, how the authorization will be done. I tried to put the Query parameter: authorization=admin:admin to the request uri: coap://127.0.0.1:5683/~/in-cse/in-name?authorization=admin:admin, but the server responsed with an error 4.03 Unknown or unauthorized originator. Do you have any idea?
Thank you in advanced
Son
Mahdi Ben Alaya wrote on Fri, 07 November 2014 14:22Hello,
Ok, let's try to investigate this issue.
Technically, I think that all URI parameters goes in the "Uri-Query" option of the CoAP protocol.
So, try to add the option: "Uri-Query" with the value: "authorization=admin:admin" to your CoAP request (instead of adding it as a URI parameter) and let's see.
Mahdi
[Updated on: Wed, 17 August 2016 10:34] by Moderator Report message to a moderator
|
|
|
Re: Using CoAP based applications (Copper vs Erbium) [message #1741005 is a reply to message #1740691] |
Mon, 22 August 2016 10:52   |
Eclipse User |
|
|
|
Hi Son Duong.
The OneM2M version of the OM2M platform uses the Californium library to implement the general protocol binding. For a better
understanding of the binding, you can take a look at the protocols specifications.
I've looked at the two popular CoAP clients: the Copper plugin and the libcoap CLI tool. Both of them are, at this time,
not suitable to be used with this binding, since they do not support multiple custom options (you can read about them in the mentioned specifications).
I built a simple CoAP client, using the Californium library, with the purpose of demonstrating its usage with the general
CoAP binding. The provided examples are analogous to the ones of the HTTP tutorial.
I'd also like to mention the changed usage of the name attribute. In previous releases of the platform,
there was a special field (X-M2M-NM in HTTP), which was used for specifying the name of the resource, which was to be created.
In the latest version, this field is replaced, by a suitable attribute ("rn" or "nm"). This change is also included in the provided client.
I changed the default platform CoAP port to 5683, in the config.ini file of the suitable CSE unit, since the plugin doesn't use
the TLS encryption yet. The attached "coapmonitor.jar" application uses the 5685 port instead (just as an example).
[Updated on: Mon, 22 August 2016 10:53] by Moderator Report message to a moderator
|
|
|
Re: Using CoAP based applications (Copper vs Erbium) [message #1741030 is a reply to message #1741005] |
Mon, 22 August 2016 13:01   |
Eclipse User |
|
|
|
Hi Klemen,
this is exactly what I am looking for, thank you very much! 
Klemen Petrovcic wrote on Mon, 22 August 2016 10:52Hi Son Duong.
The OneM2M version of the OM2M platform uses the Californium library to implement the general protocol binding. For a better
understanding of the binding, you can take a look at the protocols specifications.
I've looked at the two popular CoAP clients: the Copper plugin and the libcoap CLI tool. Both of them are, at this time,
not suitable to be used with this binding, since they do not support multiple custom options (you can read about them in the mentioned specifications).
I built a simple CoAP client, using the Californium library, with the purpose of demonstrating its usage with the general
CoAP binding. The provided examples are analogous to the ones of the HTTP tutorial.
I'd also like to mention the changed usage of the name attribute. In previous releases of the platform,
there was a special field (X-M2M-NM in HTTP), which was used for specifying the name of the resource, which was to be created.
In the latest version, this field is replaced, by a suitable attribute ("rn" or "nm"). This change is also included in the provided client.
I changed the default platform CoAP port to 5683, in the config.ini file of the suitable CSE unit, since the plugin doesn't use
the TLS encryption yet. The attached "coapmonitor.jar" application uses the 5685 port instead (just as an example).
|
|
|
Re: Using CoAP based applications (Copper vs Erbium) [message #1741143 is a reply to message #1741030] |
Tue, 23 August 2016 10:41   |
Eclipse User |
|
|
|
Hallo Klemen,
I tried your Coap client and it works fine, thank you once again. May I ask you another question? In the OM2M package, there is already a LAMP example (plugin number 30) and I would like to switch on the lamp using Coap request. Based on your Coap client example, I created another request function, called: returnCreatePostRequestString() which is used to create the POST request to switch on the LAMP, and I post this request to the address: coap://127.0.0.1:5683/~/mn-cse/mn-name/LAMP_0?op=setOn&lampid=LAMP_0.
Here is my returnCreatePostRequestString() function to create the POST request:
public static Request returnCreatePostRequestString() {
// TODO Auto-generated method stub
// Used to POST something
Request createSrc = new Request(Code.POST);
byte[] b10 = new byte[8];
new Random().nextBytes(b10);
createSrc.setToken(b10);
createSrc.getOptions()
.setContentFormat(MediaTypeRegistry.APPLICATION_XML)
.setAccept(MediaTypeRegistry.APPLICATION_XML)
.addOption(new Option(256, "admin:admin"));
return createSrc;
}
In the request I just added the option authorization admin:admin, and it works fine with HTTP (tested using Simple REST Client) but unfortunatelly not for the CoAP, the Coap response show Error Code 4.00. It stacked with this Error Log:
[2016-08-23 12:40:44,580 INFO] - org.eclipse.om2m.core.router.Router
Received request in Router: RequestPrimitive [operation=5,
to=/mn-cse/mn-name/LAMP_0,
from=admin:admin,
returnContentType=application/xml,
requestContentType=application/xml,
queryStrings={}]
[2016-08-23 12:40:44,581 INFO] - org.eclipse.om2m.core.router.Router
Request handling in the current CSE: /mn-cse/mn-name/LAMP_0
[2016-08-23 12:40:44,582 INFO] - org.eclipse.om2m.core.redirector.Redirector
Sending notification to IPE: sample
May you help me where did I do wrong?
Thank you very much
Son
|
|
| | |
Re: Using CoAP based applications (Copper vs Erbium) [message #1741634 is a reply to message #1741005] |
Fri, 26 August 2016 13:25   |
Eclipse User |
|
|
|
hi Klemen,
I have another question about the CoAP Monitor server.
I tried to run the CoAP monitor jar file under port 5685. And I created a subscription container in my AE which set the notification uri (nu) as coap://127.0.0.1:5685/monitor. However when I run the plugin, it was not able to create the subscription container and it show the 5001 error:
[2016-08-26 15:17:03,149 INFO] - org.eclipse.om2m.core.router.Router
ResourceController to be used [SubscriptionController]
[2016-08-26 15:17:03,164 INFO] - org.eclipse.om2m.core.notifier.Notifier
Sending notify request to: coap://127.0.0.1:5685/monitor
[2016-08-26 15:17:03,164 INFO] - org.eclipse.om2m.core.comm.RestClient
the requestIndication RC: RequestPrimitive [operation=5,
to=coap://127.0.0.1:5685/monitor,
from=/mn-cse,
content=<?xml version="1.0" encoding="UTF-8"?>
<m2m:sgn xmlns:m2m="http://www.onem2m.org/xml/protocols">
<vrq>true</vrq>
<sud>false</sud>
</m2m:sgn>
,
returnContentType=application/xml,
requestContentType=application/xml,
]
[2016-08-26 15:17:03,164 INFO] - org.eclipse.om2m.core.router.Router
OM2M exception caught in Router: No RestClient service found for protocol: coap
[2016-08-26 15:17:03,164 INFO] - org.eclipse.om2m.core.router.Router
Response in Router= ResponsePrimitive [responseStatusCode=5001,
content=No RestClient service found for protocol: coap,
to=admin:admin,
from=/mn-cse,
contentType=text/plain,
]
I think the problem because it can not find the coap binding in the RestClient class.
Do you have any idea how to fix this problem. Did the coap monitor server work in your system?
Thank you
Son
|
|
|
Re: Using CoAP based applications (Copper vs Erbium) [message #1742555 is a reply to message #1741634] |
Mon, 05 September 2016 06:11   |
Eclipse User |
|
|
|
Hi Son Duong,
Thank you alot for helping me out earlier. I downloaded the files and imported it to Eclipse neon (this is a separate eclipse ide which does not deal with OM2M project at all). Attached with reply is an image please have a look and guide.
Thank you for your help.
Attachment: Untitled.png
(Size: 140.28KB, Downloaded 517 times)
|
|
| |
Re: Using CoAP based applications (Copper vs Erbium) [message #1743381 is a reply to message #1742562] |
Wed, 14 September 2016 18:19   |
Eclipse User |
|
|
|
Hi all,
I'm trying to apply CoAP into the subscribe/notify scenario with sensor create value and send to the actuator. I did with Http and it works normally; however, when I apply the coap monitor in the actuator, the actuator receives the value from sensor but the Response Status code in sensor console is 5000. I use the CoAPMonitor which provided above. Anyone has solution for this? Thanks in advanced!!
|
|
|
Re: Using CoAP based applications (Copper vs Erbium) [message #1743578 is a reply to message #1743381] |
Fri, 16 September 2016 14:05   |
Eclipse User |
|
|
|
Hi Trung Luu,
the 5000 response is probably due to an incorrect return coap code. In the HTTP monitor.jar, the application returns a response code 204 (no content). I didn't find a suitable corresponding code for the coap protocol, so I returned a hardcoded string, which is incorrect.
|
|
| |
Re: Using CoAP based applications (Copper vs Erbium) [message #1743764 is a reply to message #1743745] |
Mon, 19 September 2016 13:50   |
Eclipse User |
|
|
|
Son Duong wrote on Mon, 19 September 2016 12:03Hi Klemen,
I have one more question. When I tried to capture the traffic using wireshark, I searched for coap but it showed udp instead, do you know why this happed`?
Thank you!
This is correct. HTTP uses TCP, while CoAP is implemented on the UDP protocol stack.
|
|
|
Re: Using CoAP based applications (Copper vs Erbium) [message #1786289 is a reply to message #1741005] |
Mon, 30 April 2018 00:46   |
Eclipse User |
|
|
|
Hi Klemen Petrovcic.
First of all, thank you for uploading the sample application.
I tried to send CoAP message using your application. but null pointer exception appeared like a picture i uploaded when any message arrived to IN-CSE. so your application tried to send again but after time to live, it closed without explicit answer message.
how do i miss it?
|
|
| |
Re: Using CoAP based applications (Copper vs Erbium) [message #1787502 is a reply to message #1786747] |
Sun, 27 May 2018 12:38  |
Eclipse User |
|
|
|
Hi Paulo
i solved the problem by modifying CoAPServer class in OM2M source code
i think the problem was "to=coap://localhost/~/in-cse" in the picture i uploaded.
so i modified requestPrimitive.setTo(request.getURI())
to request.Primivice.setTo(request.getOptions().getURIString()) in CoAPServer class
I think this way is not good,
but i don't know how do i solve the problem without modifying the code..
if anyone knows any other way, let me know.
Thanks
Attachment: null.png
(Size: 83.73KB, Downloaded 211 times)
|
|
|
Goto Forum:
Current Time: Wed Feb 12 15:19:09 GMT 2025
Powered by FUDForum. Page generated in 0.07352 seconds
|