<?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 receive array data sent from custom characteristic to application on Android Studio</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/48640/how-to-receive-array-data-sent-from-custom-characteristic-to-application-on-android-studio</link><description>Hello everyone, 
 I got a problem with receiving an array data on Android application sent from a custom characteristic. 
 Below is the code for sending an array data via BLE. 
 
 I used a timer to call this function. The RTT log showed my array data</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 18 Jun 2019 18:03:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/48640/how-to-receive-array-data-sent-from-custom-characteristic-to-application-on-android-studio" /><item><title>RE: How to receive array data sent from custom characteristic to application on Android Studio</title><link>https://devzone.nordicsemi.com/thread/193495?ContentTypeID=1</link><pubDate>Tue, 18 Jun 2019 18:03:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f3e3d86e-01de-4c5e-aec1-6bb9761eaae0</guid><dc:creator>Tai</dc:creator><description>&lt;p&gt;Thanks for your reply, Simonr!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to receive array data sent from custom characteristic to application on Android Studio</title><link>https://devzone.nordicsemi.com/thread/193406?ContentTypeID=1</link><pubDate>Tue, 18 Jun 2019 11:38:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:16509f07-87d4-46bf-8383-eb97ad2070cc</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Glad you were able to figure out your initial problem.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The&amp;nbsp;&lt;/span&gt;&lt;span&gt;sd_ble_gatts_value_set function() takes in a ble_gatts_value_t pointer which has a pointer p_value to a uint8_t array. You can, therefore, typecast your struct to an uint8_t array and send it with the sd_ble_gatts_value_set() function. The attribute value offset parameter can be used to specify which parts of the attribute that you want to change. This can be useful if you only want to change a certain part of the characteristic.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Documentation can be found &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.api.v6.1.1%2Fgroup___b_l_e___g_a_t_t_s___f_u_n_c_t_i_o_n_s.html&amp;amp;anchor=ga2760c51ea71853bd74e2e7e7117ef52a"&gt;here&lt;/a&gt;.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to receive array data sent from custom characteristic to application on Android Studio</title><link>https://devzone.nordicsemi.com/thread/193250?ContentTypeID=1</link><pubDate>Mon, 17 Jun 2019 16:22:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3bb8b37b-e893-4a7c-9810-e47d2bb4dae5</guid><dc:creator>Tai</dc:creator><description>&lt;p&gt;Well, I fixed that problem!&lt;/p&gt;
&lt;p&gt;The issue stemmed from the size of characteristic. I changed from 1 byte to 10 bytes (image blow), and it worked. Hope it is helpful for someone struggling with this tho.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/960x720/__key/communityserver-discussions-components-files/4/pastedimage1560788006669v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;Moreover, instead of using the function data.getIntValue() in the Android application, I used data.getValue() which returns a byte array that is array data I supposed to receive from BLE server.&lt;/p&gt;
&lt;p&gt;Last modification is to remove the portion of code which I supposed to use to update the value whenever some changes in my characteristic happen.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/960x720/__key/communityserver-discussions-components-files/4/Gatt_5F00_set.JPG" /&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m still confused about the function of sd_ble_gatts_value_set(). How should it be used properly? Dose that act like whenever updating value from client (our phone..) to server, this function will be called?&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>