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

sd_ble_gatts_value_set not working SDK11

We are having a project where temperature values will update whenever the temperature changes ,So I'm writing code like this

uint32_t ble_sh35_update_temp(ble_sh35_t *p_sh35, uint32_t temper_value)
{
	uint16_t len = 4;
    ble_gatts_hvx_params_t hvx_params;

    if (p_sh35 == NULL)
    {
        return NRF_ERROR_NULL;
    }

    if ((p_sh35->conn_handle == BLE_CONN_HANDLE_INVALID))
    {
    	 ble_gatts_value_t gatts_value;
    	 memset(&gatts_value, 0, sizeof(gatts_value));

    	 gatts_value.len     = len;
    	 gatts_value.offset  = 0;
    	 gatts_value.p_value = (uint8_t *)temper_value ;

    	 uint32_t err_code = sd_ble_gatts_value_set(p_sh35->conn_handle,p_sh35->temper_handles.value_handle,&gatts_value);
    	 printf("err_code = %d\n",err_code);
    	 
    }

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

    hvx_params.handle = p_sh35->temper_handles.value_handle;
    hvx_params.p_data = (uint8_t *)&temper_value;
    hvx_params.p_len  = &len;
    hvx_params.type   = BLE_GATT_HVX_NOTIFICATION;

    return sd_ble_gatts_hvx(p_sh35->conn_handle, &hvx_params);
}

My intention is if the phone is connected it will notify, if not it update the value so that whenever the app connects it will read the latest reading, But surprisingly it leading to hard fault, its not even printing the error code, I'm not sure what was the problem, can any one please suggest me where I went wrong,

Thanks in advance.

Parents Reply Children
No Data
Related