This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Multi ble_app_uart to one ble_app_multilink_central

Dears, I would like to implement a solution for multi-nus(peripherals) to connect one ble_app_multilink_central(centrals). Is it the right way to implement multi-nus connecting to one central(blinky)? I have checked the developer zone about multi-nus with one central. Someone advises to follow this way for such kind of solution. I have tried to modify ble_app_multilink_central to connect just one nus(peripheral) at the first. I can connect the peripheral by uuid, but can't connect it by device_name. Have anyone can tell me how to get the device_name from adv. data?

  • I think central blinky can connect to multi nus but it don't discovery NUS service . You have to change central blinky to central nus .

  • Hi,

    Have anyone can tell me how to get the device_name from adv. data?

    The ble_app_multilink_central does this in the on_adv_report() function.

    Snippet:

    // For readibility.
    ble_gap_evt_t  const * p_gap_evt  = &p_ble_evt->evt.gap_evt;
    ble_gap_addr_t const * peer_addr  = &p_gap_evt->params.adv_report.peer_addr;
    
    // Prepare advertisement report for parsing.
    adv_data.p_data = (uint8_t *)p_gap_evt->params.adv_report.data;
    adv_data.size   = p_gap_evt->params.adv_report.dlen;
    
    // Search for advertising names.
    bool found_name = false;
    err_code = adv_report_parse(BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME,
                                &adv_data,
                                &dev_name);
    if (err_code != NRF_SUCCESS)
    {
        // Look for the short local name if it was not found as complete.
        err_code = adv_report_parse(BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME, &adv_data, &dev_name);
        if (err_code != NRF_SUCCESS)
        {
            // If we can't parse the data, then exit.
            return;
        }
        else
        {
            found_name = true;
        }
    }
    else
    {
        found_name = true;
    }
    
    if (found_name)
    {
        if (strlen(m_target_periph_name) != 0)
        {
            if (memcmp(m_target_periph_name, dev_name.p_data, dev_name.size) == 0)
            {
                do_connect = true;
            }
        }
    }
    
  • Thanks. This is the original process to check the device name from adv. data. But it cannot work for nus connecting process. There is different in adv. data checking process, but same way to get the comparing data.

    [nus] err_code = sd_ble_uuid_decode(UUID128_SIZE, &p_data[index + 2], &extracted_uuid); <== to get uuid

    [multiblinky] p_typedata->p_data = &p_data[index + 2]; <== to get device name

  • I can connect NUS service by uuid, but I cannot connect NUS service by device name at central blinky SDK.

  • Thanks for everyone who answered me. I have found the way to fix this problem, and NUS function works well.

Related