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

send vector with ble

hello folks

I'm triyng to send a simple vector with ble but what i receive was different.

aniway what  i want to send is something like this:

        dati[0]=0;
        dati[1]=0;
        dati[2]=0;
        dati[3]=0;
        dati[4]=0;
        dati[5]=0;
        dati[6]=0;
        dati[7]=0;
        dati[8]=0;
        dati[9]=0;

and the function i used was :

        err_code = ble_os_value_update(&m_our_service,*dati);
        APP_ERROR_CHECK(err_code);

in my_service.c I initialize this function as:

uint32_t ble_os_value_update(ble_os_t * p_os, uint8_t custom_value)
{
   // NRF_LOG_INFO("In ble_os_custom_value_update. \r\n");
    if (p_os == NULL)
    {
        return NRF_ERROR_NULL;
    }

    uint32_t err_code = NRF_SUCCESS;
    ble_gatts_value_t gatts_value;


    // Initialize value struct.
    memset(&gatts_value, 0, sizeof(gatts_value));

    gatts_value.len     = sizeof(uint8_t);
    gatts_value.offset  = 0;
    gatts_value.p_value = &custom_value;
        if (gatts_value.p_value == NULL)
    {
        gatts_value.len==NULL;
    }

    // Update database.
    err_code = sd_ble_gatts_value_set(p_os->conn_handle,
                                      p_os->os_value_handles.value_handle,
                                      &gatts_value);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    // Send value if connected and notifying.
    if ((p_os->conn_handle != BLE_CONN_HANDLE_INVALID))
    {
        ble_gatts_hvx_params_t hvx_params;
        uint16_t               len = 10;
        memset(&hvx_params, 0, sizeof(hvx_params));

        hvx_params.handle = p_os->os_value_handles.value_handle;
        hvx_params.type   = BLE_GATT_HVX_NOTIFICATION;
        hvx_params.offset = gatts_value.offset;
        hvx_params.p_len  = &len;
        hvx_params.p_data = gatts_value.p_value;

        err_code = sd_ble_gatts_hvx(p_os->conn_handle, &hvx_params);
    }
    else
    {
        err_code = NRF_ERROR_INVALID_STATE;
    }


    return err_code;
}

but what i receive was :

in fact obviusly 00-CC-2D-00-20-00-00-00-00-10 is different from thw 10 zero vector i send....so what's wrong?

can someone help me?

Related