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

Configure nRF52840 Dongle working parameters for "heart_rate_collector" example in windows 10

Hi,

We are using nRF52840 Dongle to receive BLE peripheral Device 240 Bytes notifications for Win10 program. And we used "pc-ble-driver-4.1.1\examples\heart_rate_collector"(win10) as starting point.

"Bluetooth Low Energy" APP in "nRF Connect" can configure several parameters, such as data length, mtu and phy data rate:

Is there any API to configure these parameters for "heart_rate_collector" in win10?

Best regards

Parents
  • Hi,

    pc-ble-driver implements our serialization libraries, which gives you access to the full softdevice API. You can add functionality in the examples in the same way that the API is used in our SDK.

    Note that the application needs to handle the corresponding events to the API calls for the changes to work correctly.

    Best regards,
    Jørgen

  • Hi,

    The first time,

    static uint32_t ble_cfg_set(uint8_t conn_cfg_tag)

    {

    ...

        ble_gap_data_length_params_t const dlp =
        {
            .max_rx_octets = 251,
            .max_tx_octets = 251,
            .max_rx_time_us = 2120,
            .max_tx_time_us = 2120,
        };
        error_code = sd_ble_gap_data_length_update(m_adapter, m_connection_handle, &dlp, NULL);//error_code==0x3001

    ...

    }

    But "0x3001' is not defined  in "Global Error". What does "0x3001" mean?

    The second time,

    static uint32_t ble_cfg_set(uint8_t conn_cfg_tag)
    {
        const uint32_t ram_start = 0; // Value is not used by ble-driver
        uint32_t error_code;
        ble_cfg_t ble_cfg;

        memset(&ble_cfg, 0x00, sizeof(ble_cfg));
        ble_cfg.conn_cfg.conn_cfg_tag = conn_cfg_tag;
        ble_cfg.conn_cfg.params.gap_conn_cfg.event_length = 24;
        error_code = sd_ble_cfg_set(m_adapter, BLE_CONN_CFG_GATTC, &ble_cfg, ram_start);//error_code == NRF_SUCCESS

    ...

    }

    static void ble_evt_dispatch(adapter_t* adapter, ble_evt_t* p_ble_evt)

    {

    ...

    switch (p_ble_evt->header.evt_id)
    {

        case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST:

        uint16_t i1 = p_ble_evt->evt.gap_evt.params.data_length_update.effective_params.max_rx_octets;
        uint16_t i2 = p_ble_evt->evt.gap_evt.params.data_length_update.effective_params.max_tx_octets;
        uint16_t i3 = p_ble_evt->evt.gap_evt.params.data_length_update.effective_params.max_rx_time_us;
        uint16_t i4 = p_ble_evt->evt.gap_evt.params.data_length_update.effective_params.max_tx_time_us;
        printf("i1=%d, i2=%d, i3=%d, i4=%d\n", i1, i2, i3,i4);//i1==251, i2==251, i3==2120, i4==2120

        ble_gap_data_length_params_t const dlp =
        {
            .max_rx_octets = 251,
            .max_tx_octets = 251,
            .max_rx_time_us = 2120,
            .max_tx_time_us = 2120,
        };

        ble_gap_data_length_limitation_t dll;
        uint32_t error_code = sd_ble_gap_data_length_update(m_adapter, m_connection_handle, &dlp, &dll);//error_code ==NRF_ERROR_RESOURCES

        i1 = dll.rx_payload_limited_octets;//i1==52428
        i2 = dll.tx_payload_limited_octets;//i2==52428
        i3 = dll.tx_rx_time_limited_us; //i3==52428

    }

    ...

    }

    "event_length" has been configured successfully in In ble_cfg_set() , but when I called sd_ble_gap_data_length_update() in "case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST", it returned NRF_ERROR_RESOURCES.

    Best regards

Reply
  • Hi,

    The first time,

    static uint32_t ble_cfg_set(uint8_t conn_cfg_tag)

    {

    ...

        ble_gap_data_length_params_t const dlp =
        {
            .max_rx_octets = 251,
            .max_tx_octets = 251,
            .max_rx_time_us = 2120,
            .max_tx_time_us = 2120,
        };
        error_code = sd_ble_gap_data_length_update(m_adapter, m_connection_handle, &dlp, NULL);//error_code==0x3001

    ...

    }

    But "0x3001' is not defined  in "Global Error". What does "0x3001" mean?

    The second time,

    static uint32_t ble_cfg_set(uint8_t conn_cfg_tag)
    {
        const uint32_t ram_start = 0; // Value is not used by ble-driver
        uint32_t error_code;
        ble_cfg_t ble_cfg;

        memset(&ble_cfg, 0x00, sizeof(ble_cfg));
        ble_cfg.conn_cfg.conn_cfg_tag = conn_cfg_tag;
        ble_cfg.conn_cfg.params.gap_conn_cfg.event_length = 24;
        error_code = sd_ble_cfg_set(m_adapter, BLE_CONN_CFG_GATTC, &ble_cfg, ram_start);//error_code == NRF_SUCCESS

    ...

    }

    static void ble_evt_dispatch(adapter_t* adapter, ble_evt_t* p_ble_evt)

    {

    ...

    switch (p_ble_evt->header.evt_id)
    {

        case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST:

        uint16_t i1 = p_ble_evt->evt.gap_evt.params.data_length_update.effective_params.max_rx_octets;
        uint16_t i2 = p_ble_evt->evt.gap_evt.params.data_length_update.effective_params.max_tx_octets;
        uint16_t i3 = p_ble_evt->evt.gap_evt.params.data_length_update.effective_params.max_rx_time_us;
        uint16_t i4 = p_ble_evt->evt.gap_evt.params.data_length_update.effective_params.max_tx_time_us;
        printf("i1=%d, i2=%d, i3=%d, i4=%d\n", i1, i2, i3,i4);//i1==251, i2==251, i3==2120, i4==2120

        ble_gap_data_length_params_t const dlp =
        {
            .max_rx_octets = 251,
            .max_tx_octets = 251,
            .max_rx_time_us = 2120,
            .max_tx_time_us = 2120,
        };

        ble_gap_data_length_limitation_t dll;
        uint32_t error_code = sd_ble_gap_data_length_update(m_adapter, m_connection_handle, &dlp, &dll);//error_code ==NRF_ERROR_RESOURCES

        i1 = dll.rx_payload_limited_octets;//i1==52428
        i2 = dll.tx_payload_limited_octets;//i2==52428
        i3 = dll.tx_rx_time_limited_us; //i3==52428

    }

    ...

    }

    "event_length" has been configured successfully in In ble_cfg_set() , but when I called sd_ble_gap_data_length_update() in "case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST", it returned NRF_ERROR_RESOURCES.

    Best regards

Children
No Data
Related