This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

cycling power measurement value field

hello,

i have a rather basic question concerning the design of the cycling power measurement value field.

  1. how does a simple example for this value look like (variable declaration + setting of each field)? what data type should it be (each data field is described as a different type)?

  2. does the nrf connect app for android recognize each field like it is specified by BT SIG? or why does it show 21 hex fields for me?

thank you

Parents
  • Hi,

    1 ) You can declare the flag as a uint16_t number, and each bit in the number corresponds to a value. E.g. if bit 4 is set, then “Wheel Revolution Data Present” is true. You can also split each bit field into a bool. This is done in the SDK for e.g. the CSC Measurement characteristic as shown below. Then you define the other values and types as specified by the Bluetooth SIG.

    /**@brief Cycling Speed and Cadence Service measurement structure. This contains a Cycling Speed and
     *        Cadence Service measurement. */
    typedef struct ble_cscs_meas_s
    {
        bool      is_wheel_rev_data_present;  /**< True if Wheel Revolution Data is present in the measurement. */
        bool      is_crank_rev_data_present;  /**< True if Crank Revolution Data is present in the measurement. */
        uint32_t  cumulative_wheel_revs;      /**< Cumulative Wheel Revolutions. */
        uint16_t  last_wheel_event_time;      /**< Last Wheel Event Time. */
        uint16_t  cumulative_crank_revs;      /**< Cumulative Crank Revolutions. */
        uint16_t  last_crank_event_time;      /**< Last Crank Event Time. */
    } ble_cscs_meas_t;
    

    2) The fields of a characteristic can either be mandatory or optional. The “Flags” field are used to indicate which of the optional fields that are present/active in the characteristic.

  • For the attr_char_value.p_value you will need to pass an array that holds the pointers to the attribute structures. Note that in the tutorial a custom 128-bit UUID characteristics was implemented, while the Cycling Power Measurement characteristic is a 16-bit characteristics.

    I recommend taking a look at the Cycling Speed and Cadence example in the SDK. This profile implements the CSC Measurement characteristics, which is quite similar to the Cycling Power Measurement characteristic. The implementation of this characteristics can be found in more detail in the file ble_cscs.c, found in sdk_install_folder/components/ble/ble_services/ble_ccs/

Reply Children
No Data
Related