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

Read data from single peripheral at multilink nus central

Hi

I have done multilink with uart and getting data from multiple ble_uart peripheral. now i have to read data from only one peripheral . what will do for that.

I am using nrf52832

SDK15.0

Regards

Parents Reply Children
  • Hi,

    I connected two peripheral to central device. Both peripheral send data to central. central also print received data from both peripheral into terminal. But i want to select data from one specified peripheral and print only that data.

  • You save the connection handle of the peripheral that you want to listen in BLE_GAP_EVT_CONNECTED something like below

    case BLE_GAP_EVT_CONNECTED:
       m_whitelist_peripheral_conn_handle = p_gap_evt->conn_handle;
       
    

    and when you get the gatt event, you just compare the incoming event connection handle with this one before processing the data.

    For example, if you are listening through notifications, then you will have something like below

     static void on_hvx(ble_hrs_c_t * p_ble_hrs_c, const ble_evt_t * p_ble_evt)
    {
         if (m_whitelist_peripheral_conn_handle == p_ble_evt->evt.gattc_evt.conn_handle)
            {
                process_your_data(); // in your case, send this to UART
            }
            
         // if not, just ignore the incoming data from others.
    }
    
    
    

Related