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

  • 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

  • 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

        

  • Hi,

    Also want to update you that if I did not defined CPFD, master by default measure the value as int32 (Client not only reads my device also reads another sensor data with different datatype). So I have to define the CPFD. is there any template/project/sample syntax on how to define the CPFD on characteristic.

    Thanks and Regards,

    Sreejith 

  • Hi Sreejith

    Since you are using a proprietary service I assume you are also developing the client code? 

    If the client is provided by a third party, do they have some specification describing how you should set up the service, and how the data should be formatted?

    Do you know that the client is set up to read the CPFD descriptor, and which CPF values it will support?

    Are you planning to combine the value, timestamp and alert fields into a single characteristic?

    Sreejith Sundh said:
    Is there any example project/ code available? 

    Can you first tell me if you are planning to use the nRF5 SDK, or the nRF Connect SDK?
    Then I will see if I can find a relevant example. 

    Sreejith Sundh said:
    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)

    When doing something proprietary anything is possible ;)

    You could include a separate field in the characteristic data for switching between different data formats even. You just need to make sure that the peripheral (server) and central (client) is on the same page, and interpret the characteristics in the same way. 

    Best regards
    Torbjørn

  • HI,

    I am using nRF5 SDK, I am interested to learn how to define, update Presentation Format Descriptor with an example project / example syntax.

    regarding seconds explanation. I can explain my target. I would like to develop a slave acceleration service device which communicates with a master which also communicates with many other peripherals. so, Accelaration characteristic, I have to use floating point datatype, but the master programmed in such a way that if I did not describe the Presentation Format descriptor the master device by default consider it as int32 (but in my case I am defining the value of the characteristic as float). For this purpose I am requesting for the CPFD implementation.

    Thanks Torbjørn.

    Best Regards,

    Sreejith

Related