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
  • Hi,

    I use the same multilink project for connecting 5 custom peripherals to one central (52840 DK). All peripheral devices are connected to the central . 

    I want my custom peripherals to read simple commands and respond with an answer back to the central.

    I have completed the first part where I send simple ble serial commands (a hex value) from a smartphone to one peripheral and the peripheral responds back to smartphone with a hex value. Now I want to do the same thing but from the nRF52840 DK when all peripherals are connected to it.

    1. I don't know how to target a specific peripheral in order to send data to it. How can I do it?

    2. I don't know hot to receive data from a specific peripheral. Do I need to do some kind of de-multiplexing in the code or something like that?

  • Hi,

    This thread might be helpful.

    masterLee said:
    2. I don't know hot to receive data from a specific peripheral. Do I need to do some kind of de-multiplexing in the code or something like that?

    I'm not sure what you want to do here. You just have to send data from that specific peripheral.

Related