How to communicate with specific peripheral during multiple peripherals BLE connection with NUS

Hello all. Now I am making a BLE network with multiple peripherals and central based on NUS. How could I make data transfer between the central and specific peripherals? I followed the "ble_app_multilink_central" in the example folder. I made two peripherals which name is "m_target_peripheral_name_1" and "m_target_peripheral_name_2". But the code doesn't work at all. So how can I make connection between specific peripheral and central? Thanks.

static void scan_init(void)
{
    ret_code_t          err_code;
    nrf_ble_scan_init_t init_scan;

    memset(&init_scan, 0, sizeof(init_scan));

    init_scan.connect_if_match = true;
    init_scan.conn_cfg_tag     = APP_BLE_CONN_CFG_TAG;

    err_code = nrf_ble_scan_init(&m_scan, &init_scan, scan_evt_handler);
    APP_ERROR_CHECK(err_code);

    /* comment by Ming
    err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_UUID_FILTER, &m_nus_uuid);
    APP_ERROR_CHECK(err_code);
    end by Ming */
    
    err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_NAME_FILTER, m_target_peripheral_name_1);              // set up peripheral name
    APP_ERROR_CHECK(err_code);

    err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_NAME_FILTER, m_target_peripheral_name_2);              // set up peripheral name
    APP_ERROR_CHECK(err_code);

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

}

Parents Reply Children
No Data
Related