<?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 simple string data ?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/22032/how-to-send-simple-string-data</link><description>I am receiving data from a phone, i want to send back a word . 
 So , this is probably wrong but , to send : 
 void sendBluetoothData( uint8_t data[], uint16_t length)
 {
 uint32_t err_code;
 static uint8_t data_array[BLE_NUS_MAX_DATA_LEN];
 err_code</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 05 Mar 2019 01:27:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/22032/how-to-send-simple-string-data" /><item><title>RE: How to send simple string data ?</title><link>https://devzone.nordicsemi.com/thread/174110?ContentTypeID=1</link><pubDate>Tue, 05 Mar 2019 01:27:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d0e477c5-48b8-4ae2-9ce2-179b9793e664</guid><dc:creator>Vroon</dc:creator><description>&lt;p&gt;Hi, is there a way I can push this data out via UART and view it in putty?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send simple string data ?</title><link>https://devzone.nordicsemi.com/thread/132447?ContentTypeID=1</link><pubDate>Thu, 17 May 2018 20:00:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d33c20e4-7505-44bf-a13a-e3e27cff2ed5</guid><dc:creator>kphalak</dc:creator><description>&lt;p&gt;Use the typecast (uint16_t *) before length&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send simple string data ?</title><link>https://devzone.nordicsemi.com/thread/128712?ContentTypeID=1</link><pubDate>Wed, 18 Apr 2018 03:48:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dfdf72b1-d67d-46b5-a3f6-e98666afa20c</guid><dc:creator>luiskjuarez</dc:creator><description>&lt;p&gt;Hi, in the function &amp;quot;ble_nus_string_send&amp;quot; the length cause a&amp;nbsp; NOTE when i compile, the function expected a pointer, &lt;span lang="en"&gt;Will this cause me problems?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span lang="en"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span lang="en"&gt;This is the note that generate&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;opt/nrf52/components/ble/ble_services/ble_nus/ble_nus.h:206:10: note: expected &amp;#39;uint16_t * {aka short unsigned int *}&amp;#39; but argument is of type &amp;#39;int&amp;#39;&lt;br /&gt;&amp;nbsp;uint32_t ble_nus_string_send(ble_nus_t * p_nus, uint8_t * p_string, uint16_t * p_length);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ^~~~~~~~~~~~~~~~~~~&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send simple string data ?</title><link>https://devzone.nordicsemi.com/thread/86456?ContentTypeID=1</link><pubDate>Mon, 15 May 2017 16:51:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59ef7124-3749-4c8d-afaa-5e5da2481769</guid><dc:creator>Bndit</dc:creator><description>&lt;p&gt;Thanks a lot ! works.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send simple string data ?</title><link>https://devzone.nordicsemi.com/thread/86455?ContentTypeID=1</link><pubDate>Mon, 15 May 2017 13:23:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e7f9c04d-bd0e-4b8a-b42b-b542ec2b6b1f</guid><dc:creator>erltot</dc:creator><description>&lt;p&gt;This is from the ble_peripheral/ble_app_uart example in SDK 12.2 in my case, I guess it&amp;#39;s not very different from SDK13.&lt;/p&gt;
&lt;p&gt;Simple equivalent of hello world:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/**@snippet [Handling the data received over BLE] */
static void nus_data_handler(ble_nus_t * p_nus, uint8_t * p_data, uint16_t length){
    if(p_data[0] == &amp;#39;?&amp;#39;){
        unsigned char data_arr[20] = {&amp;quot;Hello world!\t-Pong!\n&amp;quot;}; // 20 byte msg
        ble_nus_string_send(&amp;amp;m_nus, data_arr, 20);
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;p_data[0] contains the first character in whatever you recieved from your phone, in this case if it&amp;#39;s a &amp;quot;?&amp;quot; it replies with a string..&lt;/p&gt;
&lt;p&gt;I prefer to use nRF Toolbox on my iphone with the UART profile for testing&lt;/p&gt;
&lt;p&gt;From here it was fairly easy to go to strtok() and compare strings/characters in switches to handle incomming text, it&amp;#39;s not so pretty but it works.&lt;/p&gt;
&lt;p&gt;Screenshot from phone: &lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/uart.JPG" alt="UART APP" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send simple string data ?</title><link>https://devzone.nordicsemi.com/thread/86454?ContentTypeID=1</link><pubDate>Mon, 15 May 2017 07:28:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e9ef3fde-9250-4462-b03d-37fa2fa53671</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Where are you calling your function &lt;code&gt;sendBluetoothData(tosend,4)&lt;/code&gt; ? in &lt;code&gt;uart_event_handle()&lt;/code&gt;?&lt;/p&gt;
&lt;p&gt;Also take a look at the &lt;a href="http://www.asciitable.com/"&gt;ascii table&lt;/a&gt; for how the nRF-Toolbox UART app will display your data. You are here sending &amp;quot;Dec&amp;quot;, and it will be displayed as &amp;quot;Char&amp;quot; in the app.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>