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

How to connect my nRF52840 DONGLE to a BLE sensor using "sd_ble_gap_connect" function

Hello,

I'm currently using the nRF52840 Dongle  and i need some help.
On the other hand, i have BLE ela identifiers/sensors : elainnovation.com/bluetooth-low-energy.html

The fact is that i've already developed the code that handles the advertising mode. Now i try to implement the connected mode between nRF52840 Dongle  and BLE ela sensors

In BLE ela datasheets, it is said that when you connect to one of there Bluetooth Low Energy (BLE) Identifiers and Sensors, you can receive all data stored in it's stack just by sending an L to the sensor.
I've tried that with nfR connect APP it works, here is the result :


Now I want to do the same thing with my nrf C project based on NRF52840-Beacon_Scanner example . To my mind i need to do these steps

1/ connect with the device by using the "sd_ble_gap_connect" function

Here is the code :

err_code = sd_ble_gap_connect(&m_peer_addr, &m_scan_param_connected, &m_connection_param, APP_BLE_CONN_CFG_TAG);
if (err_code != NRF_SUCCESS)
{
    NRF_LOG_RAW_INFO("Connection Request Failed, reason %d", err_code);
}


and the parameters

--> m_peer_addr

static const ble_gap_addr_t m_peer_addr =
{
    .addr_type = BLE_GAP_ADDR_TYPE_PUBLIC,
    .addr = {0x00, 0x02, 0xA6, 0x81, 0x2A, 0x5F}
};

--> m_scan_param_connected

static const ble_gap_scan_params_t m_scan_param_connected =
{
     .active         = 0,                          // Passive scanning.
     .filter_policy  = BLE_GAP_SCAN_FP_ACCEPT_ALL, // Do not use whitelist.
     .interval       = (uint16_t)SCAN_INTERVAL,    // Scan interval.
     .window         = (uint16_t)SCAN_WINDOW,      // Scan window.
     .timeout        = 0,                          // Never stop scanning unless explicit asked to.
     .scan_phys      = BLE_GAP_PHY_AUTO            // Automatic PHY selection.
};

--> m_connection_param

static const ble_gap_conn_params_t m_connection_param =
{
    .min_conn_interval = (uint16_t) NRF_BLE_SCAN_MIN_CONNECTION_INTERVAL,   // Minimum connection
    .max_conn_interval = (uint16_t) NRF_BLE_SCAN_MAX_CONNECTION_INTERVAL,   // Maximum connection
    .slave_latency     = NRF_BLE_SCAN_SLAVE_LATENCY,                                   // Slave latency
    .conn_sup_timeout  = (uint16_t) NRF_BLE_SCAN_SUPERVISION_TIMEOUT        // Supervision time-out
};

I'm blocked in this step 1, the function return error code 7 (wrong params). What is wrong in my code ?

--> It's not about whitelist because i'm not using it.

--> Maybe it's about invalid parameter(s) in p_scan_params or p_conn_params.

--> But I think that peer address is not present in the device identity list so

Q1 : How can i add a peer address in the device identity list ?

2/ sending the L to the sensor

Q2 : How can i send an L to the BLE ela sensor after connection establishment ? By using the Nordic UART Service Client ?



3/ store all data sent by BLE ela Sensor

I'll check that later after understanding both previous parts.

Thank you

Regards,

AJT

Parents Reply
  • Hi again,

    I've understood a little bit more how connections are handled on your devices (in theory) but i do not find the call of "sd_ble_gap_connect" function in your ble_app_blinky and ble_app_blinky_c main.c files.

    I've also checked this tutorial : https://devzone.nordicsemi.com/nordic/short-range-guides/b/bluetooth-low-energy/posts/ble-central-tutorial

    In the "connecting" part, it is said that a connexion is done thanks to "sd_ble_gap_connect" function.

    Any help ? I still have the same wrong parameters error... and i can't go through this function with my debugger

    I'll try tomorrow to test ble_app_uart_c example.

    Regards,

    AJT

    [EDIT]

    Ok, after checking ble ble_app_blinky_c and ble_app_blinky projects, i've understood that you can connect to a device by setting connect_if_match nrf_ble_scan_init_t parameter to true and then enabling/setting filters like that :

    err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_NAME_FILTER, false);
    APP_ERROR_CHECK(err_code);
    
    err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_NAME_FILTER, p_target_periph_name);
    APP_ERROR_CHECK(err_code);

    Do not forget to set NRF_BLE_SCAN_NAME_CNT in sdk_config file !

    So i've found a solution by not using directly the sd_ble_gap_connect function.

    Thanks anyway

Children
No Data
Related