Bluetooth Dual Topology means that a Bluetooth device can act as a master on one connection, while acting as a slave on another connection. Silicon Labs Bluetooth stack allows connection to multiple slaves and masters simultaneously, with a maximum number of 8 connections. This document shows how to handle multiple connections in your Bluetooth application, if you are expecting to be slave on some connections and master on others.
Bluetooth Dual Topology
Establishing Multiple Connections
To create a Bluetooth connection, one of the devices has to be advertising and another one has to scan for advertisements, and send a connection request. The advertiser device will become the slave on the connection and the scanner device will become the master.
To enable both master and slave functionality, the device has to act both as an advertiser and as a scanner after initialization. A connectable advertisement can be started with gecko_cmd_le_gap_start_advertising(), while scanning can be started with gecko_cmd_le_gap_start_discovery. Silicon Labs' Bluetooth stack can handle scanning and advertising at the same time, however, because it needs time multiplexing, it is worth decreasing the duty cycle of the scanning from the default 100%. To decrease the duty cycle, set the scan_window shorter than the scan_interval with gecko_cmd_le_gap_set_discovery_timing.
After the scanner finds an advertisement, a gecko_evt_le_gap_scan_response event is generated and the scanner can decide (based on advertisement data) if it wants to connect to this device with gecko_cmd_le_gap_connect().
Flowchart for Simultaneous Scanning and Advertising
When a connection is opened, a gecko_evt_le_connection_opened is generated regardless of whether the connection was initiated by our device or by a remote device. To differentiate between these two cases, the gecko_evt_le_connection_opened event provides a master parameter which is set to 1 if our device was the initiator and hence became the master, and which is set to 0 if the connection was initiated by a remote device and hence our device became the slave.
case gecko_evt_le_connection_opened_id: printLog("connection opened (%s)\r\n", evt->data.evt_le_connection_opened.master ? "master" : "slave"); break;
To learn more about how to handle multiple connections, see these articles: Multi-Slave Topology, Multi-Master Topology
This guide has a related code example, here: Multi-Slave Multi-Master Dual Topology Example