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

Connect one pheripheral to two central

Hi

how to  connect  one peripheral to two central and after connection established sent the data to both central?

I am using nrf52, soft device 132 .

i am able to make connection and send data from one peripheral to one central using ble_app_uart(peripheral),ble_app_uart_c(central ) code.

Parents Reply Children
  • Can you please tell me which example code you have used for connecting one peripheral to two central.

    and what changes you have done for making connection one peripheral with two central.

    I am using ble_app_uart {ble_peripheral code} and ble_app_uart_c{ble_central code].

  • Hi.

    meghna said:
    I am using ble_app_uart {ble_peripheral code}

     

    As I wrote earlier, you should use ble_app_multiperipheral on the peripheral side. You can find it in the experimental folder under the ble_peripheral examples folder. No changes are needed. 

  • In multi peripheral example there is no implementation for sending data from peripheral to central but in ble_app_uart there is direct function for sending data..

    I am able to make connection between one peripheral and two central using ble_app_uart code(peripheral) by making below changes in code .

    ble_app_uart(main.c) - :

    static void on_connected(const ble_gap_evt_t * const p_gap_evt)
    {
        ret_code_t  err_code;
        uint32_t    periph_link_cnt = ble_conn_state_peripheral_conn_count(); // Number of peripheral links.

        NRF_LOG_INFO("Connection with link 0x%x established.", p_gap_evt->conn_handle);

        // Assign connection handle to available instance of QWR module.
        for (uint32_t i = 0; i < NRF_SDH_BLE_PERIPHERAL_LINK_COUNT; i++)
        {
            //if (m_qwrs[i].conn_handle == BLE_CONN_HANDLE_INVALID)
            {
               // err_code = nrf_ble_qwr_conn_handle_assign(&m_qwrs[i], p_gap_evt->conn_handle);
                APP_ERROR_CHECK(err_code);
                break;
            }
        }

     bsp_board_led_on(CONNECTED_LED);
       if (periph_link_cnt == NRF_SDH_BLE_PERIPHERAL_LINK_COUNT)
           {
           bsp_board_led_off(ADVERTISING_LED);
        }
        else
        {
            // Continue advertising. More connections can be established because the maximum link count has not been reached.
            advertising_start();
        }
    }

    static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
    {
        uint32_t err_code;

        switch (p_ble_evt->header.evt_id)
        {
            case BLE_GAP_EVT_CONNECTED:
                 {
                   on_connected(&p_ble_evt->evt.gap_evt);
                 }
                 break;
                //NRF_LOG_INFO("Connected");
                //err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
                //APP_ERROR_CHECK(err_code);
                //m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
                //err_code = nrf_ble_qwr_conn_handle_assign(&m_qwr, m_conn_handle);
                //APP_ERROR_CHECK(err_code);
                //break;

    }

    }

    Can you please suggest is this right way or not?After making connection i am not able sent data between peripheral to central .How to sent data?

  • Q.What i am trying to implement?

    A. i am making a ble remote(peripheral) and there is two device (central).I want, when i press button on peripheral(remote) then it should reflect on both central(camera device/speaker device like volume up/down and many more) as per requirement.

  • Hi,

    I'm not sure what the issue is. This is exactly what is done in the example I linked in my previous comment. Please try the example. 

    regards

    Jared 

Related