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

Related