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

How to connect multiple peers in a row

Hello

My nRF51 with S120 BLE stack is running as central. I want to connect 3 other nRF51 peripherals at the same time. So in the first step I did a scan and stored the regarding peer_addr.addr. Later on, I want to connect all the stored peripherals directly in a row. I try this with the following algorithm:

for(i=0; i<MAX_CLIENTS; i++)
{
	if(m_networkInfo.device[i].connected == 1)
	{
		dbg_printf("connecting device %d\r", m_networkInfo.device[i].systemID);
		memcpy(peer_addr.addr, m_networkInfo.device[i].bleHWaddress, 6);
		err_code = clientConnect(peer_addr, m_networkInfo.device[i].systemID);
	}
}

uint32_t clientConnect(ble_gap_addr_t peer_addr, uint8_t systemID)
{
	uint32_t err_code;
	
	waitForConnectionState();
	setConnectionProgress();
	err_code = deviceConnect(peer_addr);
	APP_ERROR_CHECK(err_code);	
	return err_code;
}

uint32_t deviceConnect(ble_gap_addr_t peer_addr)
{
	uint32_t err_code;
	
	err_code = sd_ble_gap_connect(&peer_addr, &m_scan_params, &m_connection_param);
	if(err_code != NRF_SUCCESS) dbg_printf("ConnectError %d\n", err_code);
	
	return err_code;
}

As I can see, only the first device of the list "m_networkInfo" will be connected. The connection to the other stored peripheral addresses will not be established. How can I achieve my goal to establish a connection to all stored peer addresses? Of course, all stored peers are available on air.

Regards, BTprogrammer

Parents Reply Children
No Data
Related