<?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>Ways of sending a Float array as a value of a characteristic</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/18040/ways-of-sending-a-float-array-as-a-value-of-a-characteristic</link><description>want to send a float as a value of a characteristic 
 I have successfully achieved this using the simple way 
 Below is the example of just two float variables in an array. 
 float temperature[2]= {1.1,2.2}; 

attr_char_value.init_len = 8;
attr_char_value</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 12 Dec 2016 11:42:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/18040/ways-of-sending-a-float-array-as-a-value-of-a-characteristic" /><item><title>RE: Ways of sending a Float array as a value of a characteristic</title><link>https://devzone.nordicsemi.com/thread/69533?ContentTypeID=1</link><pubDate>Mon, 12 Dec 2016 11:42:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c906eb5-9dc0-408c-8ca0-ab1dc5418523</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;You mean you can send more than 20 bytes via notification ? It could be that the phone actually support long ATT MTU. With Bluetooth 4.2 the ATT MTU can get upto 512 bytes instead of 23 bytes as before.
The longest notification can send is ATT MTU -3. That&amp;#39;s why I said it was 20 bytes.
We need to see the sniffer trace to check if actually long ATT MTU is used.&lt;/p&gt;
&lt;p&gt;It&amp;#39;s pretty new features, we only supported that from S132 v3.x&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Ways of sending a Float array as a value of a characteristic</title><link>https://devzone.nordicsemi.com/thread/69532?ContentTypeID=1</link><pubDate>Sun, 11 Dec 2016 06:03:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8f7125a8-0e45-48a3-9d6f-785d07605604</guid><dc:creator>nicko_f</dc:creator><description>&lt;p&gt;Hi sir, thank you for the response. When I try sending more than 20 bytes (e.g. 50 bytes) to my Android Device for that single characteristic I was able to still receive it. Why is that? I thought the maximum was 20 bytes. I am using the nrf52.  Thanks again. Nick&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Ways of sending a Float array as a value of a characteristic</title><link>https://devzone.nordicsemi.com/thread/69531?ContentTypeID=1</link><pubDate>Wed, 30 Nov 2016 13:56:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26b27b0a-ea4a-49ef-825d-e117dc623e11</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Nicko,&lt;/p&gt;
&lt;p&gt;In our example we have to do with IEEE-11073 float (with 24 bit mantissa and 8 bit exponent) because it&amp;#39;s defined in the spec as in &lt;a href="https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.temperature_measurement.xml"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you are fine with C float, you can simply convert it to 4 bytes like what you are doing now. Note that each float requires 4 bytes, if you have 180 values, you would need 720 bytes. This may exceed the max size of characteristic we support now. I would suggest you to send them in 20 bytes trunk, so you keep the characteristic size at 20 bytes, and send the result with 36 notification packets.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Ways of sending a Float array as a value of a characteristic</title><link>https://devzone.nordicsemi.com/thread/69530?ContentTypeID=1</link><pubDate>Tue, 29 Nov 2016 17:05:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e8c0697c-60f7-4f22-9086-7da21b2391ec</guid><dc:creator>AlekseyJ</dc:creator><description>&lt;p&gt;Read about floating point.
They just encode floating value (temp_in_celcius) into the 32 bit single precision format.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;encoded_temp = ((p_hts_meas-&amp;gt;temp_in_celcius.exponent &amp;lt;&amp;lt; 24) &amp;amp; 0xFF000000) |
                       ((p_hts_meas-&amp;gt;temp_in_celcius.mantissa &amp;lt;&amp;lt;  0) &amp;amp; 0x00FFFFFF);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Another very simple way is multiply your values &lt;code&gt;float temperature[2]= {1.1,2.2};&lt;/code&gt; by 10 to create 2 numbers 11 and 22 and then on a receiving side divide by 10.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>