- Master device working mode
The main device is a party that can search for others and actively establish a connection, transformed from the scanning state. It can connect and communicate with one or more slave devices, it will periodically scan the broadcast information sent by the surrounding broadcast status devices, it can search the surrounding devices and select the slave devices to be connected for pairing and connection, and establish a communication link After success, both master and slave can send and receive data. For example, a smart phone, a Bluetooth module that acts as a host during data transmission.
When a Bluetooth device initiates a connection in master mode, it needs to know the mac address of the slave device, pairing password and other information. After the pairing is completed, it can be connected directly. At the same time, the master device can set the mac address of the default connected slave device, so that the master device module will automatically search for the slave device with the mac address and connect when it is powered on. And it supports the whitelist function, the user only needs to write the mac of the device to be connected into the whitelist, and the module will connect when it searches for a device that meets the whitelist. When the master-slave transparent transmission protocol is the same, the user does not need to pay attention to the data conversion process between the serial port data and the wireless data packet, and only needs to set simple parameters to realize the data transparent transmission between the serial port of the master device and the serial port of the slave device.
In order to ensure the stability of the connection and prevent the disconnection between the modules due to abnormal problems such as power failure and signal, you can enable the function of disconnection reconnection. When the abnormal interference problem disappears and the working environment of the module returns to normal, the main device will automatically search The slave device can reduce data loss as much as possible and improve system stability.
- Slave device working mode
The slave device mode is transformed from the broadcaster mode. The unconnected slave device first enters the broadcast state and waits to be searched by the host. When the host scans and establishes a connection with the slave device, it can send and receive data with the host device. You can’t take the initiative to establish a connection, you can only wait for others to connect you. The difference from the broadcast mode is that the Bluetooth module in the slave mode can be connected, regularly connect and transmit data with the host, and act as a slave during data transmission. For example, Bluetooth watch bracelet, Bluetooth mouse, etc. work in slave device mode.
In one-to-one application, the slave device can be set to two types. One is the silent state, that is, it can only communicate with the designated master device and is not searched by other Bluetooth devices; the other is the development state, which can be searched by the designated master device. It can also be found by other Bluetooth devices to establish a connection.
In slave device mode, users can develop their own APP according to the agreement. This mode contains a service for sending and receiving via serial port. Users can find it through UUID. There are two channels in it, namely read and write. Users can operate these two channels for data transmission. If the master device and the slave device used by the user are bluetooth modules produced by the same manufacturer, then the master device and the slave device can be connected without paying attention to the protocol inside. The pairing information between the two bluetooth devices is preset before leaving the factory. , After the devices at both ends are powered on, the link is automatically established, without the intervention of peripheral circuits, the serial ports of the two devices can directly transmit data transparently, and establish a simple wireless transmission channel for users.
- Master-slave integrated working mode
The master-slave integrated working mode means that the Bluetooth module can act as a master device and a slave device at the same time. It can switch between two roles. When working in slave mode, it waits for other master devices to connect. When necessary, it switches to master mode and initiates connection calls to other devices. The master-slave integration provides the ability to expand the Bluetooth module. After the Bluetooth 4.1 protocol specification, the “Link Layer Topology” function is added, which allows the Bluetooth module to act as a master device and a slave device at the same time, operating in any combination of roles. Such as Bluetooth HUB terminal.
When the bluetooth module with master-slave integration works, the bluetooth module can act as a master device to collect information of other peripheral slave node devices, and at the same time, act as a slave device to report the collected information to a master control terminal such as a mobile phone. The advantage of this is that the peripheral slave node device information can not be limited to local storage, and the master-slave integrated Bluetooth module plays the role of a repeater, and after collection, it is uploaded to the cloud or centralized controller for storage or display.
The master-slave integration adds additional functions of the Bluetooth module, cost optimization and ease of use. If a Bluetooth module previously operated as a master in a closed system, it can now also be connected to a smartphone as a slave at the same time, thus enabling a new dimension of connectivity. In the master-slave mode, one Bluetooth module can play two roles, which can optimize the system architecture.