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);

Parents Reply
  • Hello,

    Now I am trying to change the value of power:

    cps_measurement.power_measurement = 1000;        
                err_code = ble_cps_measurement_send(&m_cps, &cps_measurement);
                err_code_CPS = err_code;
                    if ((err_code != NRF_SUCCESS) &&
                            (err_code != NRF_ERROR_INVALID_STATE) &&
                            (err_code != BLE_ERROR_NO_TX_PACKETS) &&
                            (err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING)
                            )
                    {
                            APP_ERROR_HANDLER(err_code);
                    }

    But an error jumps:  NRF_ERROR_INVALID_STATE

    I see that it is because if (p_cps->conn_handle != BLE_CONN_HANDLE_INVALID){ in ble_cps_measurement_send.

    I see that you initialize cps_init.evt_handler = NULL; in the init_services.

    Do you undestand why it happens?

Children
No Data
Related