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

Cycling Speed and Cadence sensor central configuration using nRF52832

i am working on the Cycling Speed and Cadence sensor central configuration using nRF52832 DK in Segger Embedded Studio. I used the RSCS central example of nrf_sdk_v15.0 and have made changes according to my requirement for single sensor and it is working fine i.e i am able to get the correct data. Then i wanted to connect nearly 8 such CSCS beacons so i made small changes in my code accordingly using Multilink central example as reference. I have adjusted the RAM and memory allocation also.  My main doubt is once i run the program it gets connected to a single device and it starts reading the data. How am supposed to make it connect and read the next sensors simultaneously ? I need to store the 8 data in an array after connecting all the beacons. I have attached the RTT log for your reference. What am i supposed to do now ? How can i read all the data parallely ? 

  • Hello,

    if pm_whitelist_set() returns 5, it means NRF_ERROR_NOT_FOUND. Please see pm_whitelist_set() on infocenter.

     

    Can you please try to step through the function. If you set a breakpoint on line 619 after that the first peripheral has connected, and before the second connects. Is this the function that returns != 0?

    If so, can you step into this function to see where it returns?

    Is it after peer_data_find() or fds_record_open()? If you find out which one it is, try to step further in, and figure out which softdevice call, sd_...() that returns != NRF_SUCCESS.

     

    Best regards,

    Edvin

  • Hi Edvin, 

    Thanks for your reply. I will try to debug the issue and will let you know if i find any difficulty or doubt.

    With Regards,

    Santosh Krishnan 

  • Hi Edvin,

    Now i am able to connect with multiple cscs and heart rate sensors. But i am connecting it using their peripheral name. But i want to connect it with their mac address to differentiate and collect the values in an array and finally hard code the macs which something like whitelisting. How can i read multiple advertisement mac addresses and connect to those devices ? Kindly help me.  

  • Hello,

    Whenever you have scanning enabled, you will get some events called BLE_GAP_EVT_ADV_REPORT, which usually calls on_adv_report() in our examples from the SDK.

    Depending on what example the on_adv_report() is copied from, it will either filter on advertising name, or advertising UUID, but you can change this to bluetooth address if you like.

     

    In the ble_app_rscs_c example, this function looks like this:

    /**@brief Function for handling the advertising report BLE event.
     *
     * @param[in] p_adv_report  Advertising report from the SoftDevice.
     */
    static void on_adv_report(ble_gap_evt_adv_report_t const * p_adv_report)
    {
        ret_code_t err_code;
        ble_uuid_t target_uuid = {.uuid = TARGET_UUID, .type = BLE_UUID_TYPE_BLE};
    
        if (ble_advdata_uuid_find(p_adv_report->data.p_data, p_adv_report->data.len, &target_uuid))
        {
            // Stop scanning.
            (void) sd_ble_gap_scan_stop();
    
            err_code = bsp_indication_set(BSP_INDICATE_IDLE);
            APP_ERROR_CHECK(err_code);
    
            // Initiate connection.
            m_scan_param.filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL,
    
            err_code = sd_ble_gap_connect(&p_adv_report->peer_addr,
                                          &m_scan_param,
                                          &m_connection_param,
                                          APP_BLE_CONN_CFG_TAG);
    
            m_whitelist_disabled = false;
    
            if (err_code != NRF_SUCCESS)
            {
                NRF_LOG_DEBUG("Connection Request Failed, reason 0x%x", err_code);
            }
        }
        else
        {
            err_code = sd_ble_gap_scan_start(NULL, &m_scan_buffer);
            APP_ERROR_CHECK(err_code);
        }
    }

     

    The line:

    if (ble_advdata_uuid_find(p_adv_report->data.p_data, p_adv_report->data.len, &target_uuid) is the function that decides whether to connect to the device or not.

    The address of the advertising device is found in:

    p_adv_report->peer_addr.addr[BLE_GAP_ADDR_LEN].

    so if you know the address of the device, you can filter by this:

    if (p_adv_report->peer_addr.addr[0] = 0x12 &&
        p_adv_report->peer_addr.addr[1] = 0x34 &&
        p_adv_report->peer_addr.addr[2] = 0x56 &&
        p_adv_report->peer_addr.addr[3] = 0x78 &&
        p_adv_report->peer_addr.addr[4] = 0x9a &&
        p_adv_report->peer_addr.addr[5] = 0xbc)
    {
        // the same connection stuff from the function on_adv_report()
    }

     

    Try that, and let me know if it doesn't work.

     

    BR,

    Edvin

  • Hi Edvin,

    Thanks for your reply. Now we are able to connect the devices. But i mainly want to mac the mac IDs to the specific users. I am able to get the connection instances after starting the services. But how to bring the mac ids inside the service event handlers. After getting connected and when the services starts at any instances i want the mac addresses too along with the connection instances. i mean i need the mac address to differentiate between the values of the instances since we may not know which device has been connected. So i want the mac address too with the connection instance. Kindly help. 

    Thanks and Regards,

    Santosh Krishnan R 

Related