<?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 identify two or more CoAP clients connected to the same Server</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/92625/how-to-identify-two-or-more-coap-clients-connected-to-the-same-server</link><description>Hi, How can I get the RLOC16 or similar ID from the CoAP clients connected to my CoAP server? I need to get this information from the messages that the clients send. 
 Cheers,</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 13 Oct 2022 12:22:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/92625/how-to-identify-two-or-more-coap-clients-connected-to-the-same-server" /><item><title>RE: How to identify two or more CoAP clients connected to the same Server</title><link>https://devzone.nordicsemi.com/thread/390642?ContentTypeID=1</link><pubDate>Thu, 13 Oct 2022 12:22:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d0cd5d82-54f3-4805-9c4b-183bf938d1cd</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I think I solved it!&lt;/p&gt;
&lt;p&gt;Now that I know the solution, I feel like I should have found it earlier, but as they say &amp;quot;better late then never&amp;quot;.&lt;/p&gt;
&lt;p&gt;I found the IP address in &lt;a href="https://github.com/nrfconnect/sdk-openthread/blob/0d19f9112101e87722ec80b3a247bc7a1c54b232/include/openthread/ip6.h#L226-L240"&gt;struct otMessageInfo&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Here is some code for the coap server sample&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;diff --git a/samples/openthread/coap_server/src/ot_coap_utils.c b/samples/openthread/coap_server/src/ot_coap_utils.c
index 65f1dad17..83ce14f7e 100644
--- a/samples/openthread/coap_server/src/ot_coap_utils.c
+++ b/samples/openthread/coap_server/src/ot_coap_utils.c
@@ -130,6 +130,11 @@ static void light_request_handler(void *context, otMessage *message,
        uint8_t command;
 
        ARG_UNUSED(context);
+    char ipurd[OT_IP6_ADDRESS_STRING_SIZE]; 
+    otIp6Address from = message_info-&amp;gt;mPeerAddr;
+    otIp6AddressToString(&amp;amp;from, ipurd, sizeof(ipurd));
+
+    printk(&amp;quot;Peer IP: %s\n&amp;quot;,ipurd);
 
        if (otCoapMessageGetType(message) != OT_COAP_TYPE_NON_CONFIRMABLE) {
                LOG_ERR(&amp;quot;Light handler - Unexpected type of message&amp;quot;);
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellesvik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to identify two or more CoAP clients connected to the same Server</title><link>https://devzone.nordicsemi.com/thread/390526?ContentTypeID=1</link><pubDate>Wed, 12 Oct 2022 22:14:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:057ddc95-d62e-4167-b0c8-3fcaf439000f</guid><dc:creator>kaushalyasat</dc:creator><description>&lt;p&gt;I am greatly appreciating your efforts in solving this, thank you.&lt;/p&gt;
&lt;p&gt;This is done in the client isn&amp;#39;t it? It looks like client is getting the server&amp;#39;s IP? In my case I want to do the opposite. I need&amp;nbsp;the server to figure out who sent the message. So looks like it should be initiated from the server, if possible. Now the servrer must be getting the clients address details, some for or the other.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Worst case I can encode the clients address info (Extended MAC?) in the application level packet, where I put my data to be send to the server. Then server can see that the same way it gets my data. This will extend my packet size and also power consumption, but to how much I have to test it. For that I need an API call for the client to get its own address like extended MAC. Can you point me to some thing like that?&lt;/p&gt;
&lt;p&gt;Thanks again,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to identify two or more CoAP clients connected to the same Server</title><link>https://devzone.nordicsemi.com/thread/390267?ContentTypeID=1</link><pubDate>Tue, 11 Oct 2022 12:47:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a132b25-d9be-41fa-b0b9-01fae238859c</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;One step closer: I am able to print the server IP from the client I think.&lt;/p&gt;
&lt;p&gt;From the provisioning coap command I were able to print the IP address as such:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;diff --git a/samples/openthread/coap_client/src/coap_client_utils.c b/samples/openthread/coap_client/src/coap_client_utils.c
index 52772ace6..f86d0c725 100644
--- a/samples/openthread/coap_client/src/coap_client_utils.c
+++ b/samples/openthread/coap_client/src/coap_client_utils.c
@@ -110,6 +110,13 @@ static int on_provisioning_reply(const struct coap_packet *response,
 
        payload = coap_packet_get_payload(response, &amp;amp;payload_size);
 
+    char ipurd[40];
+
+    net_addr_ntop(AF_INET6, from, ipurd, sizeof(ipurd));
+
+    printk(&amp;quot;AAAA %s AAA\n&amp;quot;, ipurd);
+    
+
        if (payload == NULL ||
            payload_size != sizeof(unique_local_addr.sin6_addr)) {
                LOG_ERR(&amp;quot;Received data is invalid&amp;quot;);
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellesvik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to identify two or more CoAP clients connected to the same Server</title><link>https://devzone.nordicsemi.com/thread/390182?ContentTypeID=1</link><pubDate>Tue, 11 Oct 2022 08:10:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b68981c-fdb4-4970-a291-a34c1d32565a</guid><dc:creator>kaushalyasat</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Sigurd, Many thanks for your efforts, highly appreciated. So the suggested&amp;nbsp;way is to use IP6 from client message? How can we retrieve this info from message itself? Any API calls?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks again,&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to identify two or more CoAP clients connected to the same Server</title><link>https://devzone.nordicsemi.com/thread/390168?ContentTypeID=1</link><pubDate>Tue, 11 Oct 2022 07:43:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d67682c1-ac01-479c-af8a-384a00cac89d</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Sorry for the delay.&lt;br /&gt;I were looking for a way to do this yesterday, but have not been able to do so yet.&lt;/p&gt;
&lt;p&gt;I asked our developers about this, and this is what they said:&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;br /&gt;Notice that the RLOC16 is used by the child as MAC source address, by this is a Link Layer parameter, not propagated to the Application Layer (CoAP).&lt;br /&gt;The customer should find better ways to identify the end point at an application level.&lt;br /&gt;IPv6 are available at CoAP level, so that could be a way to identify, combined with network diagnostigs:&lt;br /&gt;&lt;a href="https://github.com/openthread/openthread/blob/main/src/cli/README.md#networkdiagnostic-get-addr-type-"&gt;https://github.com/openthread/openthread/blob/main/src/cli/README.md#networkdiagnostic-get-addr-type-&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;So that at least gives us some pointers to where we could look.&lt;/p&gt;
&lt;p&gt;I will keep digging for some way to do this.&lt;/p&gt;
&lt;p&gt;Let me know if you find anything yourself as well.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellesvik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to identify two or more CoAP clients connected to the same Server</title><link>https://devzone.nordicsemi.com/thread/390119?ContentTypeID=1</link><pubDate>Tue, 11 Oct 2022 00:51:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8474b931-4622-4567-b2a0-722c88068a40</guid><dc:creator>kaushalyasat</dc:creator><description>&lt;p&gt;Hi, Any reply to this? I think RLOC16 is not a static value which identifies the client accurately. So I am thinking of getting the extended MAC or something similar. Any idea?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to identify two or more CoAP clients connected to the same Server</title><link>https://devzone.nordicsemi.com/thread/389883?ContentTypeID=1</link><pubDate>Sat, 08 Oct 2022 04:06:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:66399c62-34c2-4a19-bcf9-45e11152e994</guid><dc:creator>kaushalyasat</dc:creator><description>&lt;p&gt;thanks, I am using the CLI commands to query the child table and other info. It is a great tool. I can trace that CLI uses &amp;#39;otThreadGetChildInfoByIndex()&amp;#39; function to get &amp;#39;&lt;span&gt;childInfo&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;mRloc16&lt;/span&gt;&amp;#39;. But that does not help my case as I need to decode RLOC16 from the message itself to identify who send it. I can encode the client RLOC16 with the message itself, but that I feel like wasting radio bandwidth. I think definitely the senders RLOC16 (or some other address parameter) is available at app level based on the message. So what I am looking for is an API call to extract that from the message, inside the message handler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to identify two or more CoAP clients connected to the same Server</title><link>https://devzone.nordicsemi.com/thread/389797?ContentTypeID=1</link><pubDate>Fri, 07 Oct 2022 10:55:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0894f20-8a3a-42c6-abc2-4ef04d235663</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="kaushalyasat"]I tried the&amp;nbsp;otThreadGetRloc16 () function, but it only got the RLOC16 of the server.[/quote]
&lt;p&gt;Ah right yes. I misunderstood the question.&lt;/p&gt;
&lt;p&gt;For the child RLOC16:&lt;/p&gt;
&lt;p&gt;On my OTBR I run &amp;quot;sudo ot-ctl child table&amp;quot; which gives me the following:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1665140001954v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;See &lt;a href="https://openthread.io/reference/cli/commands#child_table"&gt;child table&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This links to an API command that you should be able to call to get the RLOC value.&lt;/p&gt;
&lt;p&gt;PS: You can also test these CLI commands using our &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.1.0/nrf/samples/openthread/cli/README.html"&gt;OpenThread CLI sample&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellesvik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to identify two or more CoAP clients connected to the same Server</title><link>https://devzone.nordicsemi.com/thread/389735?ContentTypeID=1</link><pubDate>Fri, 07 Oct 2022 02:41:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd058684-7db1-4f13-b108-af255d7ea34a</guid><dc:creator>kaushalyasat</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/sigurd-hellesvik"&gt;Sigurd&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;Thanks for your reply. Wouldn&amp;#39;t this retrieve the RLOC of the server?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I tried the&amp;nbsp;otThreadGetRloc16 () function, but it only got the RLOC16 of the server.&lt;/p&gt;
&lt;p&gt;In my instance more than one coap clients will be sending messages to the server. So server needs to get the RLOC16 of each client based on each message.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;My client handler in the server is like this&amp;nbsp;&lt;/p&gt;
&lt;div&gt;&lt;span&gt;static&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;void&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;temp_request_handler&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;void&lt;/span&gt;&lt;span&gt; *&lt;/span&gt;&lt;span&gt;context&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;otMessage&lt;/span&gt;&lt;span&gt; *&lt;/span&gt;&lt;span&gt;message&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;otMessageInfo&lt;/span&gt;&lt;span&gt; *&lt;/span&gt;&lt;span&gt;message_info&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;
&lt;div&gt;{&lt;/div&gt;
&lt;div&gt;...&lt;/div&gt;
&lt;div&gt;}&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;I tried looking at each of the variables passed into the handler, but I couldn&amp;#39;t find any RLOC16 parameter anywhere.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&amp;nbsp;Cheers,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to identify two or more CoAP clients connected to the same Server</title><link>https://devzone.nordicsemi.com/thread/389584?ContentTypeID=1</link><pubDate>Thu, 06 Oct 2022 10:50:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c6b5a37-6078-473b-ba2f-fa4087693570</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;See &lt;a href="https://github.com/nrfconnect/sdk-nrfxlib/blob/ef455434921b5a57801fcb6eeeacaf0839e32660/openthread/include/openthread/thread.h#L461"&gt;otThreadGetRloc(otInstance *aInstance)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellesvik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>