<?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 16 bits instead of 8 bits over BLE</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/26369/send-16-bits-instead-of-8-bits-over-ble</link><description>Hello, 
 I&amp;#39;d like to send 16 bits data over ble instead of 8 bits 
 gatts_value.offset = 0;
gatts_value.len = len;
gatts_value.p_value = data;

err_code = sd_ble_gatts_value_set(conn_handle, value_handle, &amp;amp;gatts_value);
 
 for len I set the value</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 10 Nov 2017 14:23:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/26369/send-16-bits-instead-of-8-bits-over-ble" /><item><title>RE: Send 16 bits instead of 8 bits over BLE</title><link>https://devzone.nordicsemi.com/thread/103770?ContentTypeID=1</link><pubDate>Fri, 10 Nov 2017 14:23:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:930de23a-5b78-42e6-92fd-3665eb07bb4b</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;Ok, I&amp;#39;m glad it worked :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send 16 bits instead of 8 bits over BLE</title><link>https://devzone.nordicsemi.com/thread/103769?ContentTypeID=1</link><pubDate>Fri, 10 Nov 2017 14:19:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a1698d9-93fb-42df-b398-5294c91fc6df</guid><dc:creator>Awi</dc:creator><description>&lt;p&gt;Hi Stian, both your answers helped. Thank you very much. My other side was f***ing up. Sorry!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send 16 bits instead of 8 bits over BLE</title><link>https://devzone.nordicsemi.com/thread/103774?ContentTypeID=1</link><pubDate>Thu, 09 Nov 2017 11:11:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f0c8caf-0e11-46e9-b257-d7daea4c6acf</guid><dc:creator>Awi</dc:creator><description>&lt;p&gt;Hi Stian,&lt;/p&gt;
&lt;p&gt;Thank you for your help and time. Unfortunately, your solution doesn&amp;#39;t work. I&amp;#39;m not getting any errors, but all I am receiving is value 44.
Explanation of what I mean:
I have an uint16_t value in my embedded software set to constant 300 (for test). I have split it into two bytes (as mentioned above) and sending it like you told me to.
I&amp;#39;m receiving 44 (not 300) so it&amp;#39;s basically either staying on uint8_t or doesn&amp;#39;t send a part of the array!
... I&amp;#39;m out of ideas :&amp;#39;(&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send 16 bits instead of 8 bits over BLE</title><link>https://devzone.nordicsemi.com/thread/103773?ContentTypeID=1</link><pubDate>Tue, 07 Nov 2017 13:04:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9eb50342-5a62-4627-8a71-f82858aa3ade</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;I think the easiest way to debug this is to use the nRF Connect software, either on a computer or the Android/iOS version. You can get it from google play or app store. Then you can connect to the device, discover the services/characteristics and read out the value of the characteristc. And a lot more.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send 16 bits instead of 8 bits over BLE</title><link>https://devzone.nordicsemi.com/thread/103772?ContentTypeID=1</link><pubDate>Tue, 07 Nov 2017 12:34:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:047e3cf1-5efd-4919-b68b-a25a4684a5c1</guid><dc:creator>Awi</dc:creator><description>&lt;p&gt;Hello Stian,&lt;/p&gt;
&lt;p&gt;Thank you for your answer. Due to complexity of the code because of the previous developer, I managed to do what you said in both answer. I am not sure how I can check if the correct data is sent. Do you have any methods?&lt;/p&gt;
&lt;p&gt;Otherwise, If I am able to fix the receiver correctly (C#, to interpret the data), I can mark one of your answers as the correct one.&lt;/p&gt;
&lt;p&gt;I will let you know when I have finished it (due to limited time to work on this project it can have some delay)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send 16 bits instead of 8 bits over BLE</title><link>https://devzone.nordicsemi.com/thread/103771?ContentTypeID=1</link><pubDate>Tue, 07 Nov 2017 11:11:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a29e3979-fe8f-40b6-b6d1-51d2015d8d5a</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;Error 12 is &lt;code&gt;NRF_ERROR_DATA_SIZE&lt;/code&gt;. So a data size of 2 is probably too big for the characteristic. When you add the characterisic using the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v5.0.0/group___b_l_e___g_a_t_t_s___f_u_n_c_t_i_o_n_s.html#ga9ee07ea4b96dcca1537b01ff9a7692ba"&gt;sd_ble_gatts_characteristic_add()&lt;/a&gt; function, you specify the attribute max length in the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v5.0.0/structble__gatts__attr__t.html"&gt;attr_char_value&lt;/a&gt;. Maybe this is set to 1. Look for &lt;code&gt;attr_char_value.max_len&lt;/code&gt; or similar in the code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send 16 bits instead of 8 bits over BLE</title><link>https://devzone.nordicsemi.com/thread/103765?ContentTypeID=1</link><pubDate>Fri, 03 Nov 2017 11:13:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c8bb9d5-d615-4d9c-9336-ac0e44200404</guid><dc:creator>Awi</dc:creator><description>&lt;p&gt;So I tried doing this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint16_t val = 300;
static uint8_t data[2];
data[0] = (uint8_t)(val &amp;gt;&amp;gt; 8);
data[1] = (uint8_t)(val);
update_characteristic(conn_handle,value_handle, sizeof(data),(uint8_t*)data)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and in update_characteristic:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;gatts_value.offset = 0;
gatts_value.len = len;
gatts_value.p_value = data;
err_code = sd_ble_gatts_value_set(conn_handle, value_handle, &amp;amp;gatts_value);
APP_ERROR_CHECK(err_code);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Still getting error at the app error check:&lt;/p&gt;
&lt;p&gt;APP ERROR: 12, line: 105, file .....&lt;/p&gt;
&lt;p&gt;What am I doing wrong?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send 16 bits instead of 8 bits over BLE</title><link>https://devzone.nordicsemi.com/thread/103768?ContentTypeID=1</link><pubDate>Thu, 02 Nov 2017 11:36:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4953b47c-8e20-4724-bc7e-5ad5c67a61ca</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;If you want the attribute value to be two bytes (16 bits), set the &lt;code&gt;len&lt;/code&gt; value to 2 and represent the data as an &lt;code&gt;uint8_t&lt;/code&gt; array with size 2.&lt;/p&gt;
&lt;p&gt;How you choose to split the 16 bits and put them in to the array is up to you, as long as the reciever is able to decode it.&lt;/p&gt;
&lt;p&gt;Yes, the other side will have to decode this and represent it as needed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send 16 bits instead of 8 bits over BLE</title><link>https://devzone.nordicsemi.com/thread/103767?ContentTypeID=1</link><pubDate>Thu, 02 Nov 2017 08:20:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59421272-6455-41ba-9904-ee82f77c9ee3</guid><dc:creator>Awi</dc:creator><description>&lt;p&gt;I just cast is using (uint8_t *)
But I figured, I might have to do something like&lt;/p&gt;
&lt;p&gt;data = val&amp;gt;&amp;gt;8
then send
then
data=val
then send again&lt;/p&gt;
&lt;p&gt;the other side will have to interpret different too. Is that correct?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send 16 bits instead of 8 bits over BLE</title><link>https://devzone.nordicsemi.com/thread/103766?ContentTypeID=1</link><pubDate>Wed, 01 Nov 2017 11:59:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:271a8230-60e7-49b5-8090-248501df5d00</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;Can you please show us how you convert the 16 bits data too?&lt;br /&gt;
&lt;code&gt;p_value&lt;/code&gt; is supposed to be a pointer to an uint_8 array. So you need to split the 16 bits into two bytes in an array. &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v5.0.0/structble__gatts__value__t.html"&gt;infocenter.nordicsemi.com/.../structble__gatts__value__t.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>