<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Coap message type, confirmable/non-confirmable</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/65569/coap-message-type-confirmable-non-confirmable</link><description>Hello, 
 I am using the coap Client example from nRF Connect SDK, which uses the Coap utils library https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/include/net/coap_utils.html 
 As stated in the documentation, this library only enables</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 01 Oct 2020 16:08:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/65569/coap-message-type-confirmable-non-confirmable" /><item><title>RE: Coap message type, confirmable/non-confirmable</title><link>https://devzone.nordicsemi.com/thread/272613?ContentTypeID=1</link><pubDate>Thu, 01 Oct 2020 16:08:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eeb03615-0cc9-40a9-ae04-06ab7353da17</guid><dc:creator>Amadeus</dc:creator><description>&lt;p&gt;When I send a confirmable message, I do something like this:&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;em&gt;otCoapSendRequest(srv_context.ot,&amp;nbsp;request,&amp;nbsp;&amp;amp;messageInfo,&amp;nbsp;ack_handler,&amp;nbsp;NULL);&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;Upon receiving a confirmable message, i.e.:&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;em&gt;otCoapMessageGetType(message)&amp;nbsp;==&amp;nbsp;OT_COAP_TYPE_CONFIRMABLE&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;I do the following for acking:&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;em&gt;&lt;/em&gt;&lt;em&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void send_acknowledgement(const otMessage *message, const otMessageInfo *message_info)
{
	otMessageInfo messageInfo = get_message_info((const uint8_t*)message_info-&amp;gt;mPeerAddr.mFields.m8);

	otMessage* response = otCoapNewMessage(srv_context.ot, NULL);
	if (response == NULL) {
		printk(&amp;quot;New message error\n&amp;quot;);
		return;
	}

	otCoapMessageInitResponse(response, message, OT_COAP_TYPE_ACKNOWLEDGMENT, OT_COAP_CODE_CONTENT);

	otError error = otCoapMessageAppendUriPathOptions(response, COMMUNICATION_URI_PATH);
	if (error != OT_ERROR_NONE) {
		printk(&amp;quot;URI error\n&amp;quot;);
		return;
	}

	error = otCoapSendResponse(srv_context.ot, response, &amp;amp;messageInfo);
	if (error != OT_ERROR_NONE) {
		printk(&amp;quot;Send error\n&amp;quot;);
		return;
	}
}&lt;/pre&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;When I use the PUT coap code, I get a timeout error in the &lt;em&gt;ack_handler() &lt;/em&gt;provided in&amp;nbsp;&lt;em&gt;otCoapSendRequest(), &lt;/em&gt;whereas when I use CONTENT it works as expected.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;No, I have not tried to sniff the communication. I will try to do that when I have time to do so.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Coap message type, confirmable/non-confirmable</title><link>https://devzone.nordicsemi.com/thread/272456?ContentTypeID=1</link><pubDate>Thu, 01 Oct 2020 09:15:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb2c06ca-d4b7-4d6f-a12d-bf92734142ee</guid><dc:creator>Edvin</dc:creator><description>[quote user="Edvin Holmseth"]In what function call did you use OT_COAP_CODE_CONTENT instread of OT_COAP_CODE_PUT?[/quote]
&lt;p&gt;&amp;nbsp;I am sorry if this is really obvious, but can you please let me know where you use this?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Have you tried sniffing the connection when you use OT_CPAP_CODE_CONTENT and OT_COAP_CODE_PUT? Does it behave different? I obviously does, but if this is a bug, then a sniffer trace like this can help resolve what the issue is.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Coap message type, confirmable/non-confirmable</title><link>https://devzone.nordicsemi.com/thread/272380?ContentTypeID=1</link><pubDate>Wed, 30 Sep 2020 16:50:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c34c758-ad0f-48de-858c-d104d62f5d4d</guid><dc:creator>Amadeus</dc:creator><description>&lt;p&gt;Yes, I have seen that documentation and it virtually says nothing.&lt;/p&gt;
&lt;p&gt;When I acknowledge a confirmable message, I now use&amp;nbsp;&lt;span&gt;OT_COAP_CODE_CONTENT instead of&amp;nbsp;OT_COAP_CODE_PUT and the sender receives the acknowledgement and stops resending the confirmable message. When I used&amp;nbsp;OT_COAP_CODE_PUT, the sender never received an ack and eventually timed out. Therefore, there has to be something very different going on in the openthread api depending on the coap codes, and it would be advantageous for me to know what.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have not tried other coap types as it works with OT_COAP_CODE_CONTENT. As you can see, there is quite many - without any particular documentation on what the differences are. Indeed, one could use it as an &amp;quot;opcode&amp;quot; and dispatch the receiver to the right event handler, but there have to be more happening &amp;quot;under the hood&amp;quot; since there are api side effects depending on what coap type you choose.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Coap message type, confirmable/non-confirmable</title><link>https://devzone.nordicsemi.com/thread/272204?ContentTypeID=1</link><pubDate>Wed, 30 Sep 2020 08:53:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:42ec46aa-fffd-45f9-b68c-3bbeb6d69f43</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;The enumeration that defines OT_COAP_CODE_CONTENT is part of the &lt;a href="https://github.com/openthread/openthread"&gt;openthread repository&lt;/a&gt;&amp;nbsp;(particularly &lt;a href="https://github.com/openthread/openthread/blob/0c0e1dfe67acbd56fe29e735736dcaee19038fa5/include/openthread/coap.h"&gt;this file&lt;/a&gt;), so I don&amp;#39;t know any more than what this says.&lt;/p&gt;
&lt;p&gt;In what function call did you use OT_COAP_CODE_CONTENT instread of OT_COAP_CODE_PUT?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Coap message type, confirmable/non-confirmable</title><link>https://devzone.nordicsemi.com/thread/270251?ContentTypeID=1</link><pubDate>Fri, 18 Sep 2020 08:05:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5888811-dd5b-4bfa-a464-b0700c8ffcc1</guid><dc:creator>Amadeus</dc:creator><description>&lt;p&gt;Hello, I fixed the problem by using the coap type&amp;nbsp;OT_COAP_CODE_CONTENT instead of&amp;nbsp;OT_COAP_CODE_PUT in the ack response.&lt;/p&gt;
&lt;p&gt;I cannot find any documentation of what the different otCoapCode enumerations really means in terms of the coap api implementations. What difference did this change make?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Coap message type, confirmable/non-confirmable</title><link>https://devzone.nordicsemi.com/thread/270134?ContentTypeID=1</link><pubDate>Thu, 17 Sep 2020 14:01:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff9745d4-5c97-418c-8b4e-5d8394e771ed</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Where is otCoapResponseHandler implemented, and what does it look like? Do you seee any Result or messageinfo? Anything that can be relevant?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Would it be possible to share a project so that I can look at what you are talking about? Is this related to the coap_client example?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Coap message type, confirmable/non-confirmable</title><link>https://devzone.nordicsemi.com/thread/270002?ContentTypeID=1</link><pubDate>Thu, 17 Sep 2020 08:11:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c68b82a-8e38-4da7-951e-7a8c2f9404d7</guid><dc:creator>Amadeus</dc:creator><description>&lt;p&gt;I zeroed the uninitialized messageInfo struct and then it worked as expected.&lt;/p&gt;
&lt;p&gt;Now I have some questions about confirmable messaging:&lt;/p&gt;
&lt;p&gt;- When I send a confirmable message, should I&amp;nbsp;always add an&amp;nbsp;&lt;em&gt;otCoapResponseHandler&amp;nbsp;&lt;/em&gt;in&amp;nbsp;&lt;em&gt;otCoapSendRequest()?&amp;nbsp;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;- At the receiving side, when receiving a confirmable message, should I always respond with a message taking an&amp;nbsp;OT_COAP_TYPE_ACKNOWLEDGMENT type, by calling&amp;nbsp;&lt;em&gt;otCoapMessageInitResponse()&lt;/em&gt;&amp;nbsp;(which uses the message ID and token of the received message) and &lt;em&gt;otCoapSendResponse()?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;When trying to do this, the&amp;nbsp;&lt;em&gt;otCoapResponseHandler&amp;nbsp;&lt;/em&gt;&lt;em&gt;&lt;/em&gt;gets called at the sender after something like 20 seconds after the confirmable request, and sometimes keeps getting called, which I reckon isn&amp;#39;t right. What can be the reason for that?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Coap message type, confirmable/non-confirmable</title><link>https://devzone.nordicsemi.com/thread/269801?ContentTypeID=1</link><pubDate>Wed, 16 Sep 2020 09:22:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd1c4224-ed12-4b34-8282-dc0795c59243</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Is there some way for me to reproduce this? Can you verify that the behavior is the same in NCS Version 1.3.0? If so, is it possible to zip the project folder and attach it here? I can&amp;#39;t see anything wrong in the snippets you have sent, but I am not sure I would detect any bugs just by looking at it. Also, I am not sure of what changes you did (URI options). And I don&amp;#39;t know what your merge looks like. Is it reproducible on nRF52840 DKs?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;br /&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Coap message type, confirmable/non-confirmable</title><link>https://devzone.nordicsemi.com/thread/269377?ContentTypeID=1</link><pubDate>Mon, 14 Sep 2020 12:57:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c37b0686-e79c-4fda-99eb-57ed493cd129</guid><dc:creator>Amadeus</dc:creator><description>&lt;p&gt;I understand, thank you.&lt;/p&gt;
&lt;p&gt;I tried to change to the OpenThread CoAP API by doing this:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/OpenThread.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;However, nothing is received by the server. No error messages are printed either, the program executes the whole function.&lt;/p&gt;
&lt;p&gt;If I use the Zephyr CoAP API&amp;nbsp;with the same IPv6 address as I have used in the example above, it works fine:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/Zephyr.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;Is there anything obviously wrong with the function calls in the OpenThread CoAP example? Indeed, I have added the resources with the appropriate URI options, which I guess is confirmed by the fact that it works with the Zephyr implementation.&lt;/p&gt;
&lt;p&gt;For the record, I have merged together the client and server example in the ncs so both are able to initiate traffic on the same port.&lt;/p&gt;
&lt;div style="left:651px;position:absolute;top:494px;" id="gtx-trans"&gt;
&lt;div class="gtx-trans-icon"&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Coap message type, confirmable/non-confirmable</title><link>https://devzone.nordicsemi.com/thread/269092?ContentTypeID=1</link><pubDate>Fri, 11 Sep 2020 08:09:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:06b953b9-0a68-4356-a908-2bcaac2a4a46</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Sorry for the late reply. I had to check in with our Thread team.&lt;/p&gt;
&lt;p&gt;The coap_utils does not support confirmable communication for now. The easiest way to acheive confirmable coap communication is to use OpenThread CoAP API in a similar way to how it is presented in the coap_server sample.&lt;/p&gt;
&lt;p&gt;There is a bug in the coap_utils.h description. In fact, coap_send_request() returns retval &amp;gt;= 0 on sucess, and retval &amp;lt; 0 on failure.&lt;/p&gt;
&lt;p&gt;Zephyr sendto() description:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.zephyrproject.org/latest/reference/networking/sockets.html?highlight=sendto#c.zsock_sendto"&gt;https://docs.zephyrproject.org/latest/reference/networking/sockets.html?highlight=sendto#c.zsock_sendto&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thank you for reporting the retval description bug. It has been fixed now:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/pull/2899/commits"&gt;https://github.com/nrfconnect/sdk-nrf/pull/2899/commits&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Hopefully, this answers some of your questions.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>