<?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>How to send a confirmable packet</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/111568/how-to-send-a-confirmable-packet</link><description>Hi, 
 I have bunch of SEDs (sensors/clients) and one or more FTDs (hosts) working on CoAP protocol. SEDs send data packets once in a while and mostly sleeping. I have few questions. 
 1. Does confirmable packets consume more battery power from the SEDs</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 05 Jun 2024 10:52:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/111568/how-to-send-a-confirmable-packet" /><item><title>RE: How to send a confirmable packet</title><link>https://devzone.nordicsemi.com/thread/487479?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2024 10:52:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4a0adc0-741d-4008-ae24-f5cf87777275</guid><dc:creator>Charlie</dc:creator><description>[quote user="kaushalyasat"]Why are these two projects so different?[/quote]
&lt;p&gt;This is out of our support scope. They are two open source projects from different maintainers.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send a confirmable packet</title><link>https://devzone.nordicsemi.com/thread/487409?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2024 03:55:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:af43d2c5-88e1-40bd-9891-398a40a0b63c</guid><dc:creator>kaushalyasat</dc:creator><description>&lt;p&gt;Hi Charlie,&lt;/p&gt;
&lt;p&gt;My work is based on the openthread coap client server example. Strangely, that does not resemble anything like this. So what you mean is I have to add the functionality of&amp;nbsp;coap_server_process () in my code?&lt;/p&gt;
&lt;p&gt;Why are these two projects so different?&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Kaushalya&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send a confirmable packet</title><link>https://devzone.nordicsemi.com/thread/487287?ContentTypeID=1</link><pubDate>Tue, 04 Jun 2024 11:14:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c4b93af-75e9-4c73-bccb-ddd15ee2c856</guid><dc:creator>Charlie</dc:creator><description>&lt;p&gt;Hi Kaushalya,&lt;/p&gt;
&lt;p&gt;Your understanding is correct, but I am not sure which kind of CoAP server implementation you are using. You can refer to zephyr implementation, search &amp;quot;COAP_TYPE_CON&amp;quot; to find how ACK responses and make sure your codes or your coap server implementation has&amp;nbsp;a similar function.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/blob/main/subsys/net/lib/coap/coap_server.c"&gt;zephyr/subsys/net/lib/coap/coap_server.c at main · zephyrproject-rtos/zephyr (github.com)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Charlie&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send a confirmable packet</title><link>https://devzone.nordicsemi.com/thread/487183?ContentTypeID=1</link><pubDate>Mon, 03 Jun 2024 23:57:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f7bd649-fa1c-4fc6-b8ec-f61b38b83679</guid><dc:creator>kaushalyasat</dc:creator><description>&lt;p&gt;Hi Charlie,&lt;/p&gt;
&lt;p&gt;Thanks.&amp;nbsp;&lt;/p&gt;
[quote userid="93921" url="~/f/nordic-q-a/111568/how-to-send-a-confirmable-packet/487132"]Keep in mind you CoAP server need to send ACK when a CON message from client is received.[/quote]
&lt;p&gt;My understanding was CoAP server sends an ACK for us before passing the CON packet to my application level. May be my understanding is not correct.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If I have to send an ACK packet, could you please outline how to structure it?&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Kaushalya&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send a confirmable packet</title><link>https://devzone.nordicsemi.com/thread/487132?ContentTypeID=1</link><pubDate>Mon, 03 Jun 2024 12:56:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2cc47ef2-1333-4391-9f4d-70f4ac70d96d</guid><dc:creator>Charlie</dc:creator><description>[quote user="kaushalyasat"]I have implemented confirmable packets and it seems packets are sent to the intended router. In this instance my SED is connected to a parent router and I am sending confirmable packets to another router (destined router). But when I shutdown the destined router, I still get the confirm callback!!. Is the confirm coming from the parent?&amp;nbsp;[/quote]
&lt;p&gt;This sounds weird. Do you have a setup like following topology from&amp;nbsp;&lt;a href="https://datatracker.ietf.org/doc/html/rfc7252"&gt;RFC 7252&lt;/a&gt;? In theory, even with some routers in between CoAP client and server, the CoAP communication should only visible on application level, since CoAP is an application level protocol running on top of UDP/IP protocol. Keep in mind you CoAP server need to send ACK when a CON message from client is received.&lt;/p&gt;
&lt;p&gt;I suggest you play CoAP client and server with an Ethernet instead of Thread to understand how it works first.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Charlie&lt;/p&gt;
&lt;pre&gt;                        Client              Server
                           |                  |
                           |   CON [0x7d34]   |
                           +-----------------&amp;gt;|
                           |                  |
                           |   ACK [0x7d34]   |
                           |&amp;lt;-----------------+
                           |                  |

                  Figure 2: Reliable Message Transmission&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send a confirmable packet</title><link>https://devzone.nordicsemi.com/thread/487003?ContentTypeID=1</link><pubDate>Mon, 03 Jun 2024 00:31:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8f5904fc-268f-41df-b7f4-920a184d691b</guid><dc:creator>kaushalyasat</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt; Ragnorrak,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have implemented confirmable packets and it seems packets are sent to the intended router. In this instance my SED is connected to a parent router and I am sending confirmable packets to another router (destined router). But when I shutdown the destined router, I still get the confirm callback!!. Is the confirm coming from the parent?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;When the SED is sending the data packet, I am using &amp;#39;&lt;/span&gt;OT_COAP_CODE_PUT&lt;span&gt;&amp;#39;. I tried&amp;nbsp;&lt;/span&gt;OT_COAP_CODE_GET instead&amp;nbsp;but still result is the same. I get a callback in either case. Now I am trying to dig into the parameters passed onto the callback to determine if my intended router is in reachable or not.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;My cb is defined like this.&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;int&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;*&lt;/span&gt;&lt;span&gt;sensor_data_ack&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;coap_packet&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;*&lt;/span&gt;&lt;span&gt;response&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;coap_reply&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;*&lt;/span&gt;&lt;span&gt;reply&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;sockaddr&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;*&lt;/span&gt;&lt;span&gt;from&lt;/span&gt;&lt;span&gt;) {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;When I looked into *from, which is a sockaddr, I get the sa_family as 0x5c00, which is incorrect I think. This should be AE_INET6, which should evaluate to 2. What&amp;#39;s going wrong here?&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span&gt;Also, do we need to implement the ACK reply in application layer of the receiver?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Cheers,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Kaushalya&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send a confirmable packet</title><link>https://devzone.nordicsemi.com/thread/486973?ContentTypeID=1</link><pubDate>Sat, 01 Jun 2024 06:46:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e2d8241e-61e3-4dd3-b2a9-e039ae6e4f25</guid><dc:creator>Ragnorrak</dc:creator><description>&lt;p&gt;Yes, confirmable packets do consume more battery power from the SEDs because they require the sensors to wait for an acknowledgment (ACK) from the receiver, keeping the radio on for longer periods. You can set an application callback to handle failed ACKs, typically by setting a timeout and managing the event when no ACK is received within that timeframe. If the &amp;#39;coap_send_request()&amp;#39; function in coap_utils.c is hardwired to send non-confirmable packets and you don&amp;rsquo;t want to modify the SDK, you will likely need to implement your own version of this function to set the confirmable flag appropriately in the CoAP message. The reply callback in &amp;#39;coap_send_request()&amp;#39; is invoked when a response is received. For confirmable packets, it is called upon receiving the ACK, while for non-confirmable packets, it is triggered when the response arrives without an acknowledgment mechanism.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send a confirmable packet</title><link>https://devzone.nordicsemi.com/thread/486460?ContentTypeID=1</link><pubDate>Wed, 29 May 2024 12:59:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:83c74fbd-b466-491b-9f64-dc093e081f90</guid><dc:creator>Charlie</dc:creator><description>&lt;p&gt;Hi Kaushalya,&lt;/p&gt;
[quote user=""]1. Does confirmable packets consume more battery power from the SEDs?[/quote]
&lt;p&gt;In theory, it should be since the traffic increased and more power be used for &lt;span&gt;conformable packets&lt;/span&gt;, but I suggest you to do power evaluation in a practical measurement so you would get impression how big effect this will bring to you application.&lt;/p&gt;
[quote user=""]2. Can we set a application call back when ACK fails?[/quote]
&lt;p&gt;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/connectivity/networking/api/coap_client.html#api_reference"&gt;coap_client_response_cb_t&lt;/a&gt;&amp;nbsp;should give some error codes when ACK not get.&lt;/p&gt;
[quote user=""]3. The &amp;#39;coap_send_request ()&amp;#39; function in coap_utils.c seems hardwired to send non-confirmable packets. How can we send confirmable packets in this case? (I dont want to modify SDK functions as they can get overwritten if we update the SDK). Do we have to implement our own version of&amp;nbsp;&lt;span&gt;&amp;nbsp;&amp;#39;coap_send_request ()&amp;#39; function?&lt;/span&gt;[/quote]
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code dir="ltr"&gt;coap_send_request()&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;function in the CoAP utils library is indeed designed to send non-confirmable CoAP requests, which is specified in the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/libraries/networking/coap_utils.html#api_documentation" rel="noopener noreferrer" target="_blank"&gt;API documentation&lt;/a&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;for this function.&lt;/p&gt;
&lt;div&gt;
&lt;p&gt;If you need to send confirmable CoAP packets, you want to write your own function referring to &lt;span&gt;coap_send_request.&lt;/span&gt;&amp;nbsp;The Zephyr Project&amp;#39;s CoAP API provides a&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code dir="ltr"&gt;coap_packet_init()&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;function that allows you to specify the type of the message (confirmable or non-confirmable) as one of its parameters. In the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/connectivity/networking/api/coap_client.html#api_reference" rel="noopener noreferrer" target="_blank"&gt;CoAP client API reference&lt;/a&gt;, there is a&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code dir="ltr"&gt;confirmable&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;field in the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code dir="ltr"&gt;coap_client_request&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;structure, which can be set to&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code dir="ltr"&gt;true&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;to send a confirmable message.&lt;/p&gt;
[quote user=""]4. &amp;#39;coap_send_request ()&amp;#39; function has a reply call back as a parameter. How does this function in a non-confirmable/confirmable packets?[/quote]Since it only handles sending&amp;nbsp;&lt;span&gt;&lt;span&gt;non-confirmable CoAP requests, the reply call back will be trigger when it gets a reply. Search through NCS source codes, you will find one &amp;quot;n_provisioning_reply&amp;quot;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;example shows how to handle the reply after s&lt;/span&gt;&lt;/span&gt;ending &amp;#39;provisioning&amp;#39; request.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Since the CoAP library is original provided by zephyr project, I suggest you check the usage of it with the authors directly in&amp;nbsp;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/issues"&gt;Issues · zephyrproject-rtos/zephyr (github.com)&lt;/a&gt;.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Best regards,&lt;/div&gt;
&lt;div&gt;Charlie&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>