<?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>Characteristic value as an array of floats</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/64500/characteristic-value-as-an-array-of-floats</link><description>Hi, 
 Iam on SDK 15.2 would like to have a Characteristic value as an array of floats. 
 I have done it but it prints it like some bytes on the Nrf Connect app. So i have implemented a Presentation Format descriptor, but I don&amp;#39;t find the array format</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 07 Aug 2020 10:51:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/64500/characteristic-value-as-an-array-of-floats" /><item><title>RE: Characteristic value as an array of floats</title><link>https://devzone.nordicsemi.com/thread/263573?ContentTypeID=1</link><pubDate>Fri, 07 Aug 2020 10:51:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:869ba452-5ac5-4742-a910-7694ec51fd34</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again,&lt;br /&gt;&lt;br /&gt;It seems I misunderstood your previous comment, my mistake.&lt;br /&gt;&lt;a href="https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Descriptors/org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml"&gt;The Characteristic Presentation Format does not support an array of floats&lt;/a&gt;. This is why you are only seeing the first float in your array.&lt;br /&gt; If you are to use the CPF, then you will need to create multiple characteristics holding one float each. Alternatively you could create a custom characteristic that is parsed as an array of floats.&lt;br /&gt;&lt;br /&gt;Furthermore, it might be helpful to see &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/62110/multiple-value-in-one-characteristic"&gt;Awneil&amp;#39;s answer in this ticket&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Characteristic value as an array of floats</title><link>https://devzone.nordicsemi.com/thread/263422?ContentTypeID=1</link><pubDate>Thu, 06 Aug 2020 11:53:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eff99d92-da61-4cc0-869e-d9e0025fe667</guid><dc:creator>Beldramma</dc:creator><description>&lt;p&gt;Ok Karl.&lt;/p&gt;
&lt;p&gt;Here is my code to implement the characteristic:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;//Add a random float array characteristic
    static float values_t[] = {1.1,2.2,3.3};
    static ble_gatts_char_handles_t float_array_char;
    ble_gatts_char_pf_t char_pf;
    // Add Presentation format to the Characteristic
    memset(&amp;amp;char_pf, 0, sizeof(char_pf));
    //char_pf.unit = BLE_GATT_UNIT_CELSIUS_TEMPERATURE_DEGREE_CELSIUS;
    char_pf.format = BLE_GATT_CPF_FORMAT_FLOAT32;
    char_pf.name_space = BLE_GATT_CPF_NAMESPACE_BTSIG;
    char_pf.desc = BLE_GATT_CPF_NAMESPACE_DESCRIPTION_UNKNOWN;


    err_code = char_add(p_cus,
                        &amp;amp;char_pf,
                        CUSTOM_VALUE_CHAR_UUID+1,
                        (uint8_t*)values_t,
                        3*sizeof(float),
                        SEC_OPEN,
                        &amp;amp;float_array_char);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here is the code of char_add function :&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**@brief Function for adding the Characteristic.
 *
 * @param[in]   uuid           UUID of characteristic to be added.
 * @param[in]   p_char_value   Initial value of characteristic to be added.
 * @param[in]   char_len       Length of initial value. This will also be the maximum value.
 * @param[in]   rd_sec         Security requirement for reading characteristic value.
 * @param[out]  p_handles      Handles of new characteristic.
 *
 * @return      NRF_SUCCESS on success, otherwise an error code.
 */
static uint32_t char_add(ble_cus_t                     * p_cus,
                         ble_gatts_char_pf_t           * presentation_format,
                         uint16_t                        uuid,
                         uint8_t                       * p_char_value,
                         uint16_t                        char_len,
                         security_req_t const            rd_sec,
                         ble_gatts_char_handles_t      * p_handles)
{
    ble_add_char_params_t add_char_params;

    APP_ERROR_CHECK_BOOL(p_char_value != NULL);
    APP_ERROR_CHECK_BOOL(char_len &amp;gt; 0);

    memset(&amp;amp;add_char_params, 0, sizeof(add_char_params));

    add_char_params.uuid_type       = p_cus-&amp;gt;uuid_type;
    add_char_params.uuid            = uuid;
    add_char_params.max_len         = char_len;
    add_char_params.init_len        = char_len;
    add_char_params.p_init_value    = p_char_value;
    add_char_params.char_props.read = 1;
    add_char_params.read_access     = rd_sec;
    add_char_params.p_presentation_format = presentation_format;

    return characteristic_add(p_cus-&amp;gt;service_handle, &amp;amp;add_char_params, p_handles);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here is the picture of the Nrf app, and I have read the characteristic, but I haven&amp;#39;t read the cpf descriptor :&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://pasteboard.co/Jl6x75F.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://pasteboard.co/Jl6x75F.jpg"&gt;https://pasteboard.co/Jl6x75F.jpg&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here is the picture of my char when I have read the cpf.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://pasteboard.co/Jl6yk3X.jpg"&gt;https://pasteboard.co/Jl6yk3X.jpg&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can see that with the cpf i have only one value.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Characteristic value as an array of floats</title><link>https://devzone.nordicsemi.com/thread/263376?ContentTypeID=1</link><pubDate>Thu, 06 Aug 2020 08:55:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:747460a5-4112-494f-b323-3bc833b1f507</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user="Beldramma"]in byte I can see my three values&amp;nbsp;cdcc8c3f cdcc0c40 33335340, which correspond to&amp;nbsp;&lt;span&gt;{1.1, 2.2, 3.3}. My problem is, i would like to print the values as float&lt;/span&gt;[/quote]
&lt;p&gt;You can use the function&amp;nbsp;&lt;em&gt;bds_uint32_decode&amp;nbsp;&lt;/em&gt;to reverse the encoding applied before the transfer.&lt;/p&gt;
[quote user="Beldramma"]When I use the Float32 format, i canonly see 1.1.&amp;nbsp;[/quote]
&lt;p&gt;Are you saying that you then do not receive the first 4 bytes? I do not understand what you mean by this, please elaborate.&lt;br /&gt;&lt;br /&gt;Looking forward to resolving this issue together,&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Characteristic value as an array of floats</title><link>https://devzone.nordicsemi.com/thread/263193?ContentTypeID=1</link><pubDate>Wed, 05 Aug 2020 11:11:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad784564-1469-456e-834d-fbc2490672ed</guid><dc:creator>Beldramma</dc:creator><description>&lt;p&gt;On the Nrf Connect app, in byte I can see my three values&amp;nbsp;cdcc8c3f cdcc0c40 33335340, which correspond to&amp;nbsp;&lt;span&gt;{1.1, 2.2, 3.3}. My problem is, i would like to print the values as float, with the cpf,but there is no array format. When I use the Float32 format, i canonly see 1.1.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Characteristic value as an array of floats</title><link>https://devzone.nordicsemi.com/thread/263159?ContentTypeID=1</link><pubDate>Wed, 05 Aug 2020 09:37:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5168639-68ee-4ed7-8cd6-d1c6cec2e92d</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;So you need to debug your app to see why it isn&amp;#39;t doing the rest ...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Characteristic value as an array of floats</title><link>https://devzone.nordicsemi.com/thread/263156?ContentTypeID=1</link><pubDate>Wed, 05 Aug 2020 09:23:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:335dc915-1a24-4eb5-b30f-b8e2b2fd4a41</guid><dc:creator>Beldramma</dc:creator><description>&lt;p&gt;Sure, i think i can send them, but to print them as an array on the app, with the cpf descriptor, i do not succeed. I have tested with the array {1.1, 2.2, 3.3}, and I can only see 1.1&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Characteristic value as an array of floats</title><link>https://devzone.nordicsemi.com/thread/263123?ContentTypeID=1</link><pubDate>Wed, 05 Aug 2020 07:57:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40497a13-3a80-42fe-b5db-882e8d4d948a</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;The point is,&lt;/p&gt;
[quote userid="6462" url="~/f/nordic-q-a/63527/transfer-float-using-ble/259033"]it is all just bytes[/quote]
&lt;p&gt;Whether it&amp;#39;s just one float, or a whole series (an &amp;quot;array&amp;quot;) of floats.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Characteristic value as an array of floats</title><link>https://devzone.nordicsemi.com/thread/263118?ContentTypeID=1</link><pubDate>Wed, 05 Aug 2020 07:43:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b610608a-6fb4-4720-bb67-9433bd838c73</guid><dc:creator>Beldramma</dc:creator><description>&lt;p&gt;Thanks awneil, but maybe i understood not well the topic, but it doesn&amp;#39;t seem that the guy wants to send an array and print it on the app. He wants only a float.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Characteristic value as an array of floats</title><link>https://devzone.nordicsemi.com/thread/263072?ContentTypeID=1</link><pubDate>Tue, 04 Aug 2020 16:17:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1326b106-cb08-4b98-9aa9-7f72a1e1b304</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/63527/transfer-float-using-ble/259033#259033"&gt;devzone.nordicsemi.com/.../259033&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>