<?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 string without terminal</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/11349/send-string-without-terminal</link><description>Hi, 
 I try to send a string using example code ble_app_uart_pca10028 without input from terminal
,but directly from inside the code 
 All of the tutorials I&amp;#39;ve search send data from terminal 
 Below are what I&amp;#39;ve done, but no value appears in nRF</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 13 Mar 2016 19:24:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/11349/send-string-without-terminal" /><item><title>RE: Send string without terminal</title><link>https://devzone.nordicsemi.com/thread/42738?ContentTypeID=1</link><pubDate>Sun, 13 Mar 2016 19:24:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f459c419-0449-47c3-bfab-f43b58d2d184</guid><dc:creator>Adnan Alvee</dc:creator><description>&lt;p&gt;I am also looking a way to send a string without the terminal, ble_nus_string_send function only works in the uart_event_handle()  and APP_UART_DATA_READY is only triggered when pressing enter in the terminal(termite). Can someone please post a solution&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send string without terminal</title><link>https://devzone.nordicsemi.com/thread/42737?ContentTypeID=1</link><pubDate>Tue, 19 Jan 2016 12:39:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0994e342-bc5c-45f3-a970-14411945b6d7</guid><dc:creator>10Hsin</dc:creator><description>&lt;p&gt;I think I have a better description of my problem.
nus_data_handler() is called in service_init(), uart_event_handle() is called in uart init().&lt;/p&gt;
&lt;p&gt;So if I want to keep sending a string, which part should this function related to?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send string without terminal</title><link>https://devzone.nordicsemi.com/thread/42735?ContentTypeID=1</link><pubDate>Mon, 18 Jan 2016 03:20:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:07b1ae19-cfe1-44c8-a9df-d19dcd95df06</guid><dc:creator>10Hsin</dc:creator><description>&lt;p&gt;I ask this question because I put your code in main&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    uint8_t data_array[12] = {&amp;#39;H&amp;#39;, &amp;#39;e &amp;#39;, &amp;#39;l&amp;#39;, &amp;#39;l&amp;#39;, &amp;#39;o&amp;#39;, &amp;#39;W&amp;#39;, &amp;#39;o&amp;#39;, &amp;#39;r&amp;#39;, &amp;#39;l&amp;#39;, &amp;#39;d&amp;#39;, &amp;#39;\n&amp;#39;};
    uint8_t length_of_data = 12;
    err_code = ble_nus_string_send(&amp;amp;m_nus, data_array, length_of_data);
    APP_ERROR_CHECK(err_code);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;but the device become unconnectable
or I should call ble_nus_string_send() in some specific place&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send string without terminal</title><link>https://devzone.nordicsemi.com/thread/42733?ContentTypeID=1</link><pubDate>Sun, 17 Jan 2016 17:14:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:768b8a13-2f47-4046-bf20-4d592efc857a</guid><dc:creator>fredriksundt</dc:creator><description>&lt;p&gt;I am not sure if I understand your question.
I believe the function uart_event_handle() handles the events from the terminal.
If you want to write something to tx you can use the function ble_nus_string_send () as shown above.
It can be called from different parts of the program.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send string without terminal</title><link>https://devzone.nordicsemi.com/thread/42734?ContentTypeID=1</link><pubDate>Sun, 17 Jan 2016 13:23:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:626ced09-5200-4d75-85de-7be2b3f261f8</guid><dc:creator>10Hsin</dc:creator><description>&lt;p&gt;So, if I want to write directly to Tx, I modify this function uart_event_handle, right?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send string without terminal</title><link>https://devzone.nordicsemi.com/thread/42736?ContentTypeID=1</link><pubDate>Sun, 17 Jan 2016 10:18:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:49fe9332-d61c-4243-9a66-cf94e0778cd1</guid><dc:creator>10Hsin</dc:creator><description>&lt;p&gt;Thanks a lot, fredriksundt. This works wel!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send string without terminal</title><link>https://devzone.nordicsemi.com/thread/42732?ContentTypeID=1</link><pubDate>Sun, 17 Jan 2016 09:31:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec60e1a8-c17b-4a9e-9793-24472698acba</guid><dc:creator>fredriksundt</dc:creator><description>&lt;p&gt;Hello.
Are you using the softdevice s110?
If you are, you should use the function ble_nus_string_send(   ) to send the data from the nrf51 chip. As an example I have changed the nus_data_handler(  ), which handles the data received from the App. Here you see how the nrf51 chip can send data to the application, and also how it can react to data received:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void nus_data_handler(ble_nus_t * p_nus, uint8_t * p_data, uint16_t length)
{
	uint32_t       err_code;
	if (p_data[0] == &amp;#39;a&amp;#39;) { //If first character is &amp;#39;a&amp;#39;
		uint8_t data_array[12] = {&amp;#39;a&amp;#39;, &amp;#39; &amp;#39;, &amp;#39;r&amp;#39;, &amp;#39;e&amp;#39;, &amp;#39;c&amp;#39;, &amp;#39;e&amp;#39;, &amp;#39;i&amp;#39;, &amp;#39;v&amp;#39;, &amp;#39;e&amp;#39;, &amp;#39;d&amp;#39;, &amp;#39;\n&amp;#39;};
		uint8_t length_of_data = 12;
		err_code = ble_nus_string_send(&amp;amp;m_nus, data_array, length_of_data);
		APP_ERROR_CHECK(err_code);
    }
	else {
		err_code = ble_nus_string_send(&amp;amp;m_nus,  p_data, length);
		APP_ERROR_CHECK(err_code);
	 }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If the first character is &amp;#39;a&amp;#39; then the string &amp;quot;a received&amp;quot; is sent back to the application. If not the received characters is echoed back to the application.&lt;/p&gt;
&lt;p&gt;ble_nus_string_send can be called from other parts of the code, for instance from a function that reads some sensor data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>