<?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>Thread CoAP Response Handler - How to get POST response code</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/35560/thread-coap-response-handler---how-to-get-post-response-code</link><description>My project is based on the Thread cloud coap client example. I would like to know if my CoAP POSTs to the cloud are successful. 
 I added a &amp;quot;post_response_handler&amp;quot; to the SendRequest: 
 
 The post_response_handler is firing after a successful post, but</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 20 Jul 2018 11:56:25 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/35560/thread-coap-response-handler---how-to-get-post-response-code" /><item><title>RE: Thread CoAP Response Handler - How to get POST response code</title><link>https://devzone.nordicsemi.com/thread/140821?ContentTypeID=1</link><pubDate>Fri, 20 Jul 2018 11:56:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0467fae5-1376-461d-a624-dc41837362a9</guid><dc:creator>Rob C</dc:creator><description>&lt;p&gt;Thank you Lukasz!&amp;nbsp; This works perfectly.&lt;/p&gt;
&lt;p&gt;Your first sentence was the piece of understanding I was missing -- that the response code is appended to the header of the outgoing message when the CoAP transaction is completed.&lt;/p&gt;
&lt;p&gt;This will allow me to track success of individual messages, if necessary, using a combination of&amp;nbsp;otCoapHeaderGetCode() and&amp;nbsp;&lt;span&gt;otCoapHeaderGetToken().&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;For others following along, reference the CoAP cheat sheet at&amp;nbsp;&lt;a href="https://github.com/markushx/coap-cheatsheet"&gt;https://github.com/markushx/coap-cheatsheet&lt;/a&gt;&amp;nbsp;for meanings of response codes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thread CoAP Response Handler - How to get POST response code</title><link>https://devzone.nordicsemi.com/thread/139356?ContentTypeID=1</link><pubDate>Mon, 09 Jul 2018 05:37:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:452024de-bf6f-45e8-838c-3a3298371f65</guid><dc:creator>Lukasz Duda</dc:creator><description>&lt;p&gt;Hello Rob,&lt;/p&gt;
&lt;p&gt;CoAP Response code is embedded to CoAP Header of the message. You can easily pull it out using following function:&lt;pre class="ui-code" data-mode="c_cpp"&gt;otCoapCode otCoapHeaderGetCode(const otCoapHeader *aHeader)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;As you can see, variable of otCoapHeader type is already provided to the application response handler.&lt;/p&gt;
&lt;p&gt;Specifically for your example, the last line of the code would look like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;NRF_LOG_INFO(&amp;quot;CoAP code: %d\r\n&amp;quot;, otCoapHeaderGetCode(p_header));&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You can read more about this function &lt;a href="https://github.com/openthread/openthread/blob/master/include/openthread/coap.h#L401"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thread CoAP Response Handler - How to get POST response code</title><link>https://devzone.nordicsemi.com/thread/137141?ContentTypeID=1</link><pubDate>Thu, 21 Jun 2018 14:53:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1fc70b40-09a0-4f35-8e38-79e93ac5cb32</guid><dc:creator>Rob C</dc:creator><description>&lt;p&gt;Thanks for your reply.&lt;/p&gt;
&lt;p&gt;Yes, result is returning 0.&amp;nbsp; Yes, I have set&amp;nbsp;&lt;span&gt;OT_COAP_TYPE_CONFIRMABLE.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Using the result=0 may be an acceptable short-term workaround, but I was hoping to be able to access the specific response code for further context and troubleshooting.&amp;nbsp; I was assuming this detail, along with the token, etc. would be returned so that I could get a reliable confirmation that a specific message was successfully delivered.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Does this make sense?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Thread CoAP Response Handler - How to get POST response code</title><link>https://devzone.nordicsemi.com/thread/136952?ContentTypeID=1</link><pubDate>Wed, 20 Jun 2018 16:32:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:956a6006-7de2-4179-a3a2-9955d779627a</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Rob,&lt;/p&gt;
&lt;p&gt;Have you checked the result value ? It should be 0 if it&amp;#39;s success response.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Do you have&amp;nbsp;OT_COAP_TYPE_CONFIRMABLE type in your header when you send the request ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>