<?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>basic sample to send data from peripheral to smartphone with nrf connect sdk</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/74290/basic-sample-to-send-data-from-peripheral-to-smartphone-with-nrf-connect-sdk</link><description>Hi, 
 
 I need to test the data rate capacity between a nrf52840 and a smartphone. Smartphone being the central device and nrf52840 being the peripheral device. I have an eval nrf25840 dk board. 
 My point is to write from peripheral to central device</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 22 Apr 2021 12:42:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/74290/basic-sample-to-send-data-from-peripheral-to-smartphone-with-nrf-connect-sdk" /><item><title>RE: basic sample to send data from peripheral to smartphone with nrf connect sdk</title><link>https://devzone.nordicsemi.com/thread/306334?ContentTypeID=1</link><pubDate>Thu, 22 Apr 2021 12:42:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb2402f6-ebcf-41c2-b2b8-da7f0f784999</guid><dc:creator>rpt</dc:creator><description>&lt;p&gt;My mistake, it seems I did not empty the tx characterisitic on phone side....&lt;/p&gt;
&lt;p&gt;Sorry for previous message....&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: basic sample to send data from peripheral to smartphone with nrf connect sdk</title><link>https://devzone.nordicsemi.com/thread/306320?ContentTypeID=1</link><pubDate>Thu, 22 Apr 2021 12:13:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bf6be8e0-e619-45c0-b118-1f94610d4b9a</guid><dc:creator>rpt</dc:creator><description>&lt;p&gt;Thank you Einar for your response. I have finally managed to use the uart example.&amp;nbsp; I would like to modify it to be able to send bigger chunks of data. I took the img_file from throughput example and in a loop I push it into the fifo queue. it works, but I need to slow it down to be sure the queue is emptied before being oversized. So I have tried to not bother with the fifo and move the &amp;quot;bt_nus_send&amp;quot; call into my main thread and push data from there. Doing this does not work... the call ends in &amp;quot;Failed to send data over BLE connection&amp;quot; with this log:&lt;/p&gt;
&lt;p&gt;&amp;quot;bt_conn: Unable to allocate TX context&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;in the same time if I send &amp;quot;aaa&amp;quot; from putty it works fine, i do have it coming on my mobile phone on nrf connect...&lt;/p&gt;
&lt;p&gt;does the &amp;quot;bt_nus_send&amp;quot; has to be launched from a separate thread? Do I miss some init?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;here is the code I have added / modified:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;int write_image()
{
	int err;
        sentSize = 0;
#define BUFFSIZE 20
        static char buf[BUFFSIZE];
        int loadedSize = 0;
	for (uint16_t pos = 0; pos != IMG_SIZE;) {
       
                int buffered = 0;
                if((IMG_SIZE - pos) &amp;gt; BUFFSIZE)
                {
                  buffered = BUFFSIZE;
                  memcpy(buf, img[pos / IMG_X][pos % IMG_X], BUFFSIZE);
                }
                else
                {
                  buffered = (IMG_SIZE - pos);
                  memcpy(buf, img[pos / IMG_X][pos % IMG_X], (IMG_SIZE - pos));
                }
		pos += buffered;

              printk(&amp;quot;writing data: %d\n&amp;quot;, buffered);
 
              if (bt_nus_send(NULL, buf, buffered)) {
			LOG_WRN(&amp;quot;Failed to send data over BLE connection&amp;quot;);
		}
                k_sleep(K_MSEC(500));

                sentSize += buffered;     
	}
	return 0;
}


void button_changed(uint32_t button_state, uint32_t has_changed)
{
	uint32_t buttons = button_state &amp;amp; has_changed;

	if (auth_conn) {
		if (buttons &amp;amp; KEY_PASSKEY_ACCEPT) {
			num_comp_reply(true);
		}

		if (buttons &amp;amp; KEY_PASSKEY_REJECT) {
			num_comp_reply(false);
		}
	}

        	if (buttons &amp;amp; DK_BTN3_MSK) {
			write_image();
		}

}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;thanks for your help!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;renaud&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: basic sample to send data from peripheral to smartphone with nrf connect sdk</title><link>https://devzone.nordicsemi.com/thread/306312?ContentTypeID=1</link><pubDate>Thu, 22 Apr 2021 11:52:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a8e0cc9-c3d2-46ab-994f-f3eee972ad11</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Renaud,&lt;/p&gt;
&lt;p&gt;The Nordic UART Service which is demonstrated by the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/bluetooth/peripheral_uart/README.html"&gt;Bluetooth: Peripheral UART sample&lt;/a&gt;&amp;nbsp;demonstrates a simple way to transfer data both ways.&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>