<?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 get the characteristic data with array?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/36405/how-to-get-the-characteristic-data-with-array</link><description>Hi. 
 I have a customize characteristic that allow user to typing 8 bytes of data send from cell phone, 
 And I want to get this buffer out to go with my process, but I used sd_ble_gatts_value_get() I get the data seems like the register address. 
 Also</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 17 Jul 2018 03:40:17 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/36405/how-to-get-the-characteristic-data-with-array" /><item><title>RE: How to get the characteristic data with array?</title><link>https://devzone.nordicsemi.com/thread/140315?ContentTypeID=1</link><pubDate>Tue, 17 Jul 2018 03:40:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a570c850-cd17-49dd-bfa9-44c0af899183</guid><dc:creator>Max Liao</dc:creator><description>&lt;p&gt;Hi Edvin&lt;/p&gt;
&lt;p&gt;Thanks for your help, now I known relation of that.&lt;/p&gt;
&lt;p&gt;The problem has resolved, thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get the characteristic data with array?</title><link>https://devzone.nordicsemi.com/thread/140248?ContentTypeID=1</link><pubDate>Mon, 16 Jul 2018 14:40:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:438f826d-2b5a-4c0b-86c8-baf5fc1eb755</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;If you see in the ble_gatts.h file in the SDK on line 353 (in SDK15), it says:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;  uint8_t                     data[1];            /**&amp;lt; Received data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
                                                       See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So the data coming at the event is longer than 1 byte. The length of the array is&amp;nbsp;&lt;/p&gt;
&lt;p&gt;ble_gatts_evt_write_t-&amp;gt;len;&lt;/p&gt;
&lt;p&gt;the 1 is only a placeholder for the compilator.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can check out the ble_app_uart example found in SDK\examples\ble_peripheral\ble_app_uart. In main.c, you will see a function called&amp;nbsp;nus_data_handler(...)&lt;/p&gt;
&lt;p&gt;It is actually a ble_gatts_evt_write_t event, but it is &amp;quot;translated&amp;quot; to a NUS (Nordic UART Service) event in ble_nus.c, in the on_write() function, then calling the nus_data_handler(...) with the translated event.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can see that&amp;nbsp;&lt;/p&gt;
&lt;p&gt;evt.params.rx_data.p_data = p_evt_write-&amp;gt;data;&lt;/p&gt;
&lt;p&gt;evt.params.rx_data.length = p_evt_write-&amp;gt;len;&lt;/p&gt;
&lt;p&gt;and that these are used in the nus_data_handler(...) in main.c.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>