This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Session Run Time BLE CGMS characteristic

Hello all,

I'm developing a BLE CGMS application based on the experimental example on the SDK folder.

Now I working in the timing characteristics and I could see that the session run time (SRT) is not implemented on the example. When I try to use the function nrf_ble_cgms_srt_set() the input value parameter is in hours units, but my application runs in the seconds time base and I can't see where can I customize this characteristic.

Is this established inside the Softdevices? Can I change this for minutes for example? Are there other examples that implements similar characteristics with the Softdevices?

Following the functions that access this characteristic:

/**@brief Function for adding a characteristic for the Session Run Time.
 *
 * @param[in]   p_cgms   Service instance.
 *
 * @return      NRF_SUCCESS if characteristic was successfully added, otherwise an error code.
 */
static uint32_t srt_char_add(nrf_ble_cgms_t * p_cgms)
{
    uint8_t               len = 0;
    uint8_t               encoded_initial_srt[NRF_BLE_CGMS_SRT_LEN];
    ble_add_char_params_t add_char_params;

    memset(&add_char_params, 0, sizeof(add_char_params));


    len += uint16_encode(p_cgms->session_run_time, &(encoded_initial_srt[len]));

    add_char_params.uuid            = BLE_UUID_CGM_SESSION_RUN_TIME;
    add_char_params.max_len         = NRF_BLE_CGMS_SRT_LEN;
    add_char_params.init_len        = len;
    add_char_params.p_init_value    = encoded_initial_srt;
    add_char_params.read_access     = SEC_JUST_WORKS;
    add_char_params.write_access    = SEC_NO_ACCESS;
    add_char_params.char_props.read = true;

    return characteristic_add(p_cgms->service_handle,
                              &add_char_params,
                              &p_cgms->char_handles.srt);
}

ret_code_t nrf_ble_cgms_srt_set(nrf_ble_cgms_t * p_cgms, uint16_t run_time)
{
    ble_gatts_value_t srt_val;
    uint8_t           encoded_session_run_time[NRF_BLE_CGMS_SRT_LEN];
    uint8_t           gatts_value_set_len = 0;

    gatts_value_set_len = uint16_encode(run_time, encoded_session_run_time); // (p_sst, encoded_start_session_time);

    memset(&srt_val, 0, sizeof(ble_gatts_value_t));
    srt_val.len     = gatts_value_set_len;
    srt_val.p_value = encoded_session_run_time;
    srt_val.offset  = 0;

    return (sd_ble_gatts_value_set(p_cgms->conn_handle, p_cgms->char_handles.srt.value_handle,
                                   &srt_val));
}

Related