Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Functioning of Characteristic Presentation Format Descriptor (CPFD)

Hi,

I would like to know the functioning of CPFD (I would like to represent the characteristic value as IEEE754 float32) I am not aware of how can I implement this. for example, if I am measuring the acceleration (float value), but I would like to send the data as int32 type (which following method should I chose in case of CPFD?)

1. Convert the float measuured value to corresponding hexadecimal value according to IEEE754 Floating point representation and mention in the descriptor that I uses IEEE754 so that, master can convert back it in to the float point

2. or I can use float datatype for the characteristic value by mentioning CPFD as #define BLE_GATT_CPF_FORMAT_FLOAT32 (according to  Characteristic Presentation Formats (nordicsemi.com) )?

all together I just want to know what is CPFD, how to implement this and how this helps me with my project of reading acceleration value (with fractional value).

 

Thanks in advance for your time and effort.

with Regards,

Sreejith

Parents
  • Hi Sreejith

    Are you implementing some standard Bluetooth service, or a proprietary one that you can configure as you wish?

    The characteristic presentation format descriptor is just a piece of optional metadata that you can add to your characteristic, in order for the client to be able to tell how the characteristic data is formatted. Changing the CPDF value has no impact on the actual characteristic data, and if you use the CPFD it is up to you do make sure that the data you send is formatted correctly, and in accordance with the value stored in the CPFD. 

    Using the CPFD only really makes sense if you could have different peripheral devices using different formats, since it would then allow the client to adjust the way the data is interpreted depending on which peripheral it connects to. 

    If all your devices will use the same presentation format then you don't really need to use the CPFD, since you could just hard code the presentation format on the client side. 

    Best regards
    Torbjørn

Reply
  • Hi Sreejith

    Are you implementing some standard Bluetooth service, or a proprietary one that you can configure as you wish?

    The characteristic presentation format descriptor is just a piece of optional metadata that you can add to your characteristic, in order for the client to be able to tell how the characteristic data is formatted. Changing the CPDF value has no impact on the actual characteristic data, and if you use the CPFD it is up to you do make sure that the data you send is formatted correctly, and in accordance with the value stored in the CPFD. 

    Using the CPFD only really makes sense if you could have different peripheral devices using different formats, since it would then allow the client to adjust the way the data is interpreted depending on which peripheral it connects to. 

    If all your devices will use the same presentation format then you don't really need to use the CPFD, since you could just hard code the presentation format on the client side. 

    Best regards
    Torbjørn

Children
  • Hi Torbjørn,

    Many thanks for your fast response.

    I am implementing a proprietary one but I have to follow some predefined structure, for example datatype of the value.

    here is my characteristic,

    1. Acceleration sensor measurement character, with fields

         a. Value (int32)

         b. Timestamp (uint32 (seconds)

         c. Alert (flags- uint8)

    As you can see here, acceleration can be fractional (float value), but I can make it only int32 or uint32. I am planning here to use IEE754 float standard, that is 1 bit sign, 8 bit exponent and 23 bit Mantissa. But I have to mention in the format descriptor that I am using this standard. How can I update CPFD with these information. Is there any example project/ code available? 

    I have seen the continous glucose measurement service (cgms), here the measurement data glucose concentraion measures in uint16_t (4 bit exponent, 12 bit mantissa) but I could not find where the format descriptor defined in this example or how the client interpret the glucose measurement.

    is it possible for me to go with int32 datatype for acceleration by converting the float measured data to int32 (using IEEE 754 float point standard) and by mentioning the CPFD by myself. If so how should I define the CPFD (what is the syntax in defining CPFD)

    I am really interested hear from you,

    Thanks and Regards,

    Sreejith

        

Related