<?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>Send data to SED devices</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/102847/send-data-to-sed-devices</link><description>Hi, 
 I have a functioning CoAP client/server based OpenThread mesh network. My clients are SEDs. I can send data from clients to the CoAP server. Now I want to do the opposite, to send data from server to the SED clients. I have the unicast IPV6 of the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 25 Aug 2023 02:56:57 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/102847/send-data-to-sed-devices" /><item><title>RE: Send data to SED devices</title><link>https://devzone.nordicsemi.com/thread/443071?ContentTypeID=1</link><pubDate>Fri, 25 Aug 2023 02:56:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f4c56cf4-7e54-47f5-9006-d39d3e3e5a20</guid><dc:creator>kaushalyasat</dc:creator><description>&lt;p&gt;Thanks Susheel, your help is much appreciated.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send data to SED devices</title><link>https://devzone.nordicsemi.com/thread/442833?ContentTypeID=1</link><pubDate>Wed, 23 Aug 2023 16:57:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:91951ffa-2651-402f-8e9b-e5cc7a623d5b</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi, My colleague says that she does not see any issues with your solution and this method is acceptable.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send data to SED devices</title><link>https://devzone.nordicsemi.com/thread/442766?ContentTypeID=1</link><pubDate>Wed, 23 Aug 2023 12:01:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:16a8e04a-4395-4055-8746-85f565a13dc0</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I am requesting my colleague to quickly review your changes. Will give you her feedback soon.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send data to SED devices</title><link>https://devzone.nordicsemi.com/thread/442653?ContentTypeID=1</link><pubDate>Wed, 23 Aug 2023 00:58:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:37aa5b3c-97a4-468f-bdc3-5b29424827b6</guid><dc:creator>kaushalyasat</dc:creator><description>&lt;p&gt;Hi Susheel,&lt;/p&gt;
&lt;p&gt;Thanks. I think I managed to get it done. Still I dont know if the way I have done it is acceptable. So good to get some Thread expert run through this.&lt;/p&gt;
&lt;p&gt;What I have done is in the host or coap server&lt;/p&gt;
&lt;div&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static otCoapResource host_resource = {	
	.mUriPath = HOST_URI_PATH,
	.mHandler = NULL,
	.mContext = NULL,
	.mNext = NULL,
};

static const char *const host_option[] = {HOST_URI_PATH, NULL};

static void sensor_send_handler(void *context, otMessage *message, const otMessageInfo *message_info) {
..
}

int ot_coap_init (...) {

    coap_init(AF_INET6, NULL);
    .
    .
    .
    srv_context.on_sensor_data_request = on_sensor_data_request;
    .
    srv_context.ot = openthread_get_default_instance();
    .
    host_resource.mContext = srv_context.ot;
	host_resource.mHandler = sensor_send_handler;
	.
	otCoapAddResource(srv_context.ot, &amp;amp;sensor_resource);
}

&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;On coap client side&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static otCoapResource host_resource = {
	.mUriPath = HOST_URI_PATH,
	.mHandler = NULL,
	.mContext = NULL,
	.mNext = NULL,
};

struct server_context {
	struct otInstance *ot;
	host_data_request_callback_t on_host_data_request;
};

static struct server_context srv_context = {
	.ot = NULL,
	.on_host_data_request = NULL
};

static void on_host_data_request (uint8_t host_msg_ID) {
	switch (host_msg_ID) {
	.
	.
	.
}

static void host_request_handler(void *context, otMessage *message, const otMessageInfo *message_info) {
	uint8_t buff[50];
	uint16_t msgLen=0;
	uint16_t byteCnt=0;

	msgLen =  otMessageGetLength (message)-otMessageGetOffset(message);
	byteCnt = otMessageRead(message, otMessageGetOffset(message), buff, msgLen);	
	LOG_INF (&amp;quot;Bytes Read %d&amp;quot;, byteCnt);

	srv_context.on_host_data_request (buff[1]);	// host message ID
}

static void coap_default_handler(void *context, otMessage *message, const otMessageInfo *message_info)
{
	ARG_UNUSED(context);
	ARG_UNUSED(message);
	ARG_UNUSED(message_info);

	LOG_INF(&amp;quot;Received CoAP message that does not match any request &amp;quot;
		&amp;quot;or resource&amp;quot;);
}

void coap_client_utils_init (...) {
    .
    .
    .
    srv_context.on_host_data_request = on_host_data_request;   
    srv_context.ot = openthread_get_default_instance();
    
    host_resource.mContext = srv_context.ot;
	host_resource.mHandler = host_request_handler;
	
	otCoapSetDefaultHandler(srv_context.ot, coap_default_handler, NULL);
	otCoapAddResource(srv_context.ot, &amp;amp;host_resource);		

	err = otCoapStart(srv_context.ot, COAP_PORT);
	if (err != OT_ERROR_NONE) {
		LOG_ERR(&amp;quot;Failed to start OT CoAP. Error: %d&amp;quot;, err);
	}
    
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Basically I have done what the coap client has done on its side on coap server on initialization. I had to increase stack size for system workqueue to&amp;nbsp; 2048 in prj.conf (may be this can be lowered but I havent tested it).&lt;/p&gt;
&lt;p&gt;Is this method acceptable?&lt;/p&gt;
&lt;p&gt;&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: Send data to SED devices</title><link>https://devzone.nordicsemi.com/thread/442537?ContentTypeID=1</link><pubDate>Tue, 22 Aug 2023 11:58:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:81d42805-869f-48f8-8a19-604bdf763aa4</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Kaushalya,&amp;nbsp;&lt;br /&gt;Maria is away and I am not Thread expert. I will try to get some help on this. Sorry for the delays caused so far.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send data to SED devices</title><link>https://devzone.nordicsemi.com/thread/441815?ContentTypeID=1</link><pubDate>Thu, 17 Aug 2023 10:32:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bda888fb-ebad-4117-a42b-01e99815d9c5</guid><dc:creator>kaushalyasat</dc:creator><description>&lt;p&gt;Hi Maria,&lt;/p&gt;
&lt;p&gt;I have looked at using coap get/put methods to send payloads to SED clients using CLI.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;1. Client has to create a uri resource&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2. The host get this resource using &amp;#39;coap get&amp;#39;&lt;/p&gt;
&lt;p&gt;3. The host use the resource to send payloads to the SED client by using &amp;#39;coap put&amp;#39;&lt;/p&gt;
&lt;p&gt;I tried decoding the cli_coap.cpp to extract the APIs needed for this. I am not 100% sure on how to do that. Could you please help here?&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Kaushalya&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send data to SED devices</title><link>https://devzone.nordicsemi.com/thread/441720?ContentTypeID=1</link><pubDate>Wed, 16 Aug 2023 21:38:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:353bef03-bc9c-4a77-bc46-44f0ccd27e76</guid><dc:creator>kaushalyasat</dc:creator><description>&lt;p&gt;Hi Maria,&lt;/p&gt;
&lt;p&gt;Thanks for your help. Yes my SED wakes up periodically and send the server some data. This is the time I think the server data can be delivered. I think that mechanism is workable.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have gathered the IP6 info of the client (SED) from the data it is sending. I tried to use &amp;#39;coap_send_request()&amp;#39; in the server, but it failed giving error code 9. I couldn&amp;#39;t find what that error code means. I dont have a mechanism in the SED to receive data yet. I dont know if that is the reason for this failure.&lt;/p&gt;
&lt;p&gt;From ther server I can see it initiates server functionality by &amp;#39;otCoapStart ()&amp;#39; in &amp;#39;ot_coap_init()&amp;#39; in server FW. I am not sure I have to/can implement this same behavior in the SED.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What API mechanism should be used to receive data from a coap server?&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Kaushalya&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send data to SED devices</title><link>https://devzone.nordicsemi.com/thread/441629?ContentTypeID=1</link><pubDate>Wed, 16 Aug 2023 13:06:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:76b696e2-e7ea-41ac-bab2-ce9e55e2859d</guid><dc:creator>Maria Gilje</dc:creator><description>&lt;p&gt;Hello Kaushalya,&lt;/p&gt;
&lt;p&gt;I have some initial thoughts and I will look further into this as soon as I can.&lt;/p&gt;
&lt;p&gt;You need to factor in when the SEDs radio is active for it to receive the data. Does your SEDs wake up periodically?&lt;/p&gt;
&lt;p&gt;What kind of data do you want to send from the server to the client?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Maria&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>