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

Initializing Cycling Power Service 0x1818

Hello!

I am trying to implement the Cycling Power from https://devzone.nordicsemi.com/f/nordic-q-a/9169/cycling-power-service-0x1818

Please, could you show how we need to configure the service?
This way is not working:
memset(&cp_init, 0, sizeof(cp_init));
            
            cp_init.ctrlpt_evt_handler    = NULL;
            cp_init.feature                     = BLE_CPS_FEATURE_WHEEL_REV_BIT | BLE_CPS_FEATURE_CRANK_REV_BIT | BLE_CPS_FEATURE_MULTIPLE_SENSORS_BIT;
            
            // Here the sec level for the Cycling Speed and Cadence Service can be changed/increased.
            BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cp_init.cp_meas_attr_md.cccd_write_perm);   // for the measurement characteristic, only the CCCD write permission can be set by the application, others are mandated by service specification
            BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cp_init.cp_feature_attr_md.read_perm);      // for the feature characteristic, only the read permission can be set by the application, others are mandated by service specification
            
            
            //cp_init.ctrlpt_evt_handler            = sc_ctrlpt_event_handler;
            
            
            err_code = ble_cps_init(&m_cp, &cp_init);
            APP_ERROR_CHECK(err_code);

  • Hi Juan,

    You said that the above mentioned code is not working. Can you describe more of what is not working and what is the meaning of this?

    It would be also nice if you attach more code snippet (possibly your project) so that we are able to reproduce the failures you are observing. That way it is faster and most likely that we will be able to find the problem.

  • Hello,

    I am trying to initialize the service Power Cycling from the files of this link https://devzone.nordicsemi.com/f/nordic-q-a/9169/cycling-power-service-0x1818

    I get the CSC example from Nordic and I tried to initialize the service of Power Cycling from the files that I downloaded.
    That's all

  • the code does not compile with SDK15 and SDv6.0.0. Can you tell me which versions are you using so that i can give it a try

  • Hello,

     

    You can get the example of Nordic --> ble_app_cscs with s132_nrf52_2.0.0-7.alpha_softdevice

     

  • in services init you call this

        ble_cps_init_t        cps_init;
        
        // Initialize Cycling Power Service module
        memset(&cps_init, 0, sizeof(cps_init));
    
        cps_init.evt_handler = NULL;
        cps_init.feature     = BLE_CPS_FEATURE_WHEEL_REV_BIT | BLE_CSCS_FEATURE_CRANK_REV_BIT |
                                BLE_CSCS_FEATURE_MULTIPLE_SENSORS_BIT;
    
        // Here the sec level for the Cycling Speed and Cadence Service can be changed/increased.
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cps_init.cp_meas_attr_md.cccd_write_perm);   // for the measurement characteristic, only the CCCD write permission can be set by the application, others are mandated by service specification
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cps_init.cp_feature_attr_md.read_perm);      // for the feature characteristic, only the read permission can be set by the application, others are mandated by service specification
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cps_init.cp_ctrlpt_attr_md.write_perm);      // for the SC control point characteristic, only the write permission and CCCD write can be set by the application, others are mandated by service specification
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cps_init.cp_ctrlpt_attr_md.cccd_write_perm); // for the SC control point characteristic, only the write permission and CCCD write can be set by the application, others are mandated by service specification
        
        cps_init.ctrplt_supported_functions    = BLE_SRV_SC_CTRLPT_CUM_VAL_OP_SUPPORTED
                                                  |BLE_SRV_SC_CTRLPT_SENSOR_LOCATIONS_OP_SUPPORTED
                                                  |BLE_SRV_SC_CTRLPT_START_CALIB_OP_SUPPORTED;
        cps_init.ctrlpt_evt_handler            = sc_ctrlpt_event_handler;
        cps_init.list_supported_locations      = supported_locations;
        cps_init.size_list_supported_locations = sizeof(supported_locations) / sizeof(ble_sensor_location_t);            
        
        sensor_location           = BLE_SENSOR_LOCATION_FRONT_WHEEL;                    // initializes the sensor location to add the sensor location characteristic.
        cps_init.sensor_location = &sensor_location;
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cps_init.cp_sensor_loc_attr_md.read_perm);    // for the sensor location characteristic, only the read permission can be set by the application, others are mendated by service specification
    
        err_code = ble_cps_init(&m_cps, &cps_init);
        APP_ERROR_CHECK(err_code);

    in ble_srv_common.h file you add below

    #define BLE_UUID_CYCLING_POWER                                   0x1818     /**< Cycling Power UUID. */
    
    #define BLE_UUID_CYCLING_POWER_MEASUREMENT_CHAR                  0x2A63     /**< Cycling Power Feature characteristic UUID. */
    #define BLE_UUID_CYCLING_POWER_FEATURE_CHAR                      0x2A65     /**< Cycling Power Measurement characteristic UUID. */
    

    I guess that should be enough.

Related