<?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>Receiving data from Mobile APP</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/23841/receiving-data-from-mobile-app</link><description>Hi 
 Firstly i am coming from 8 bit world(PIC and Arduino) and not so good at c programming. ( just writing all code in main and sometimes using function) (not even use pointer much but knowing principle) 
 But now, i start to work with 32 bit microprocessor</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 23 Jan 2019 06:59:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/23841/receiving-data-from-mobile-app" /><item><title>RE: Receiving data from Mobile APP</title><link>https://devzone.nordicsemi.com/thread/167265?ContentTypeID=1</link><pubDate>Wed, 23 Jan 2019 06:59:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e4fe4667-95ec-4591-90e8-32aced165f02</guid><dc:creator>Abhimanyu K K</dc:creator><description>&lt;p&gt;Sir,&lt;/p&gt;
&lt;p&gt;what we need to written in the main function?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving data from Mobile APP</title><link>https://devzone.nordicsemi.com/thread/93801?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2017 14:07:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aaa5cc59-6840-4b12-9e22-0e7cbbc02b36</guid><dc:creator>VS60</dc:creator><description>&lt;p&gt;Thanks sir :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving data from Mobile APP</title><link>https://devzone.nordicsemi.com/thread/93802?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2017 13:26:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:efbbc7b8-5594-485d-985e-981f07ddd350</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;I believe you got it right, congrats!:)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving data from Mobile APP</title><link>https://devzone.nordicsemi.com/thread/93800?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2017 13:16:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:acfee549-9461-4fef-a34b-034f3599ce5b</guid><dc:creator>VS60</dc:creator><description>&lt;p&gt;Hi again.&lt;/p&gt;
&lt;p&gt;I am here to confess my answer. (Cersei Talkin&amp;#39;)&lt;/p&gt;
&lt;p&gt;To remember, my main goal is transmitting a char from mobile app to nrf51822 Beacon module.&lt;/p&gt;
&lt;p&gt;So last 3-4 days, i decide to sharpen my C programming skills, I worked on pointers, structs, callback functions etc.&lt;/p&gt;
&lt;p&gt;And i returned to the ble_app_uart examples and caught this.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    static void services_init(void) {
       uint32_t       err_code;
       ble_nus_init_t nus_init;
    
       memset(&amp;amp;nus_init, 0, sizeof(nus_init));

       nus_init.data_handler = nus_data_handler;
    
       err_code = ble_nus_init(&amp;amp;m_nus, &amp;amp;nus_init);
       APP_ERROR_CHECK(err_code); 
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and this.&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) {
for (uint32_t i = 0; i &amp;lt; length; i++)
{
		getData(p_data, bleRecData, i);
    //while(app_uart_put(p_data[i]) != NRF_SUCCESS);
}
//while(app_uart_put(&amp;#39;\n&amp;#39;) != NRF_SUCCESS); }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This functions handle receiving process.&lt;/p&gt;
&lt;p&gt;As you can see i changed something little bit.&lt;/p&gt;
&lt;p&gt;What i have learn is, app_uart_put function is transmitting data which is received from mobile app, TO THE UART (TERMINAL).&lt;/p&gt;
&lt;p&gt;So that means (not sure), when you send characters from mobile app, this default functions &lt;code&gt;take&lt;/code&gt; the data and send it to the terminal. I think i need some debugger for that terminal to open but not sure.&lt;/p&gt;
&lt;p&gt;Anyway, i don&amp;#39;t need a terminal for my job, so I move on and create a new char string which is&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; uint8_t bleRecData[256];
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;with this i have a global data area. I can read and write in it easily now.&lt;/p&gt;
&lt;p&gt;As you can see above, there is a function which is not in  &lt;code&gt;ble_app_uart&lt;/code&gt; example. i wrote this &lt;code&gt;getData&lt;/code&gt; function.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void getData(uint8_t* recData,uint8_t* saveData, uint8_t index){
		saveData[index] = recData[index];
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It is so simple, maybe sounds stupid meh :)  no need for that but i did this. it takes data from &lt;code&gt;nus_data_handler&lt;/code&gt; and putting it to the my &lt;code&gt;bleRecData[]&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;So guys, this is how you can get data to anywhere you want.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Summary : &lt;code&gt;nus_data_handler&lt;/code&gt; default version is just getting character from mobile app and send it to UART module. If you want to use data directly just delete app_uart_put section and try to get p_data[] to anywhere else.&lt;/p&gt;
&lt;p&gt;As I say, I am a new learner, so some part maybe sounds ridiculous. I am still open for guidance and advices.&lt;/p&gt;
&lt;p&gt;See ya.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving data from Mobile APP</title><link>https://devzone.nordicsemi.com/thread/93799?ContentTypeID=1</link><pubDate>Thu, 27 Jul 2017 09:24:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:adc9adcc-3049-416b-b442-41e8c8f91e00</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Sure indeed, &lt;a href="https://devzone.nordicsemi.com/question/64222/i-am-new-to-the-nrf51-dk-and-would-like-some-insight-on-bluetooth/?answer=64254#post-id-64254"&gt;here are links&lt;/a&gt; to several entry points, it will give you material for several weeks of study;) To be honest if you want to achieve any &amp;quot;production&amp;quot; quality BLE app it&amp;#39;s hard to avoid that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving data from Mobile APP</title><link>https://devzone.nordicsemi.com/thread/93798?ContentTypeID=1</link><pubDate>Thu, 27 Jul 2017 09:21:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef375bbc-3368-4816-9eb0-1f88ccd39639</guid><dc:creator>VS60</dc:creator><description>&lt;p&gt;Thank you for information. I am going to check it out this in examples and surely will come back to ask questions about mentioned event handlers. This type of information little hard for me to understand. I am really new at that kind of structures.&lt;/p&gt;
&lt;p&gt;Also, do you got any advice about how to learn basic of BLE ( like GAP, GATT or how to set up Nordic&amp;#39;s basic BLE stack purely) I saw &amp;quot;hello world of ble tutorials&amp;quot; but little bit scared when i read.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving data from Mobile APP</title><link>https://devzone.nordicsemi.com/thread/93797?ContentTypeID=1</link><pubDate>Thu, 27 Jul 2017 07:58:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e2a7dc3-453e-4416-b207-97a4532ae3f0</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Note that actual events linked to data transfer over Nordic BLE UART (NUS) protocol in &lt;code&gt;examples\ble_peripheral\ble_app_uart&lt;/code&gt; SDK example are little bit hidden from you because they are not handled in main.c but in ble_nus_on_ble_evt() function which is implemented in &lt;code&gt;components\ble\ble_services\ble_nus\ble_nus.c&lt;/code&gt; file. The idea of Nordic BLE UART project is that in your &amp;quot;main&amp;quot; program it behaves like classic serial UART line where you call PUT(char) and GET(char) meta-functions and all the magic to translate it to BLE logic happens underneath and you don&amp;#39;t need to care. But of course you can see it and debug it as it comes in source code if you want.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving data from Mobile APP</title><link>https://devzone.nordicsemi.com/thread/93796?ContentTypeID=1</link><pubDate>Thu, 27 Jul 2017 07:53:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0f10d71-82b7-4576-9ad6-07f3af3960f5</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;If you set all BLE stack (Soft Device) basics (like setting parameters, enabling it, provisioning GAP and GATT layer parameters and starting advertising or scanning - depending on what GAP role you&amp;#39;ve chosen) then you will be getting asynchronous events to handler function which you&amp;#39;ve provided to SD in &lt;code&gt;softdevice_ble_evt_handler_set&lt;/code&gt; function call. then depending on phase of the BLE connection and roles/objects you&amp;#39;ve defined you will be acting upon receiving of certain events like &lt;code&gt;BLE_GAP_EVT_CONNECTED&lt;/code&gt; (connection just established, still some basic establishment of higher layers is needed), &lt;code&gt;BLE_GATTS_EVT_WRITE&lt;/code&gt; (this is basically what you are looking for if you implement GATT Server on nRF5x = Client writes to some GATT object like Characteristic&amp;#39;s Value handle or Descriptor, you should check where it wrote and then interpret written data accordingly), &lt;code&gt;BLE_GAP_EVT_DISCONNECTED&lt;/code&gt; (connection was terminated) etc.&lt;/p&gt;
&lt;p&gt;This of course gets little bit more complicated if you use other BLE layers like Security manage (pairing/bonding, connection link encryption) etc. But if you choose your GAP architecture (which device is Central/Master and which Peripheral/Slave) and GATT architecture (which side will be Server and which Client) then the rest can be found after little bit of archeology in SDK examples and Infocenter sequence charts (you need to find the right API matching your SD version, e.g. &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v4.0.2/s132_msc_overview.html?cp=2_3_0_1_1_1"&gt;here are MSCs for latest production version for nRF52832 aka S132 V4.0.x&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>