[In-depth analysis] Take you to understand the working mode of the BLE Bluetooth module

Bluetooth is a new wireless communication technology, which is a standard wireless communication protocol, which can realize wireless data and voice communication. Transceiver chips based on low-cost devices can be used for short-range wireless connections, a short-range wireless connection technology for fixed and mobile equipment monitoring communication environments. Among them, the BLE Bluetooth module occupies a stable position in various devices of the Internet of Things in the civilian field by virtue of its industrial grade, low power consumption, and high performance characteristics.

BLE bluetooth module

 BLE Bluetooth module: SKYLAB BLE Bluetooth module is divided into 4.0BLE Bluetooth module, 4.2BLE Bluetooth module, 5.0BLE Bluetooth module, 5.2BLE Bluetooth module according to the Bluetooth standard. At present, mature solutions based on BLE Bluetooth module include smart light control solutions and smart lock solutions. , MAC address QR code scanning and printing scheme, and indoor positioning scheme based on Bluetooth. At present, the BLE Bluetooth module has been widely used in positioning tags, asset tracking, sports and fitness sensors, medical sensors, smart watches, remote controls, toys and other products. In particular, Bluetooth 5.0 is a technical specification formulated for the Internet of Things, smart home appliances, and wearable device specifications, leading WiFi in these fields.

How the BLE Bluetooth module works

1. Bluetooth module master-slave relationship

Bluetooth technology stipulates that when Bluetooth communication is performed between each pair of devices, one Bluetooth module must be in the master role, and the other Bluetooth module must be in the slave role to communicate. When communicating, the master must search, initiate pairing, and establish a link successfully. After that, both parties can send and receive data. In theory, a Bluetooth master device can communicate with 7 Bluetooth slave devices at the same time. A device with Bluetooth communication function can switch between two roles. It usually works in slave mode and waits for other master devices to connect. When necessary, it switches to master mode and initiates calls to other devices. When a Bluetooth device initiates a call in the main mode, it needs to know the other party's Bluetooth address, pairing password and other information. After the pairing is completed, the call can be initiated directly.

2. Bluetooth module call process

When the Bluetooth master device initiates a call, it first searches to find out the Bluetooth devices that can be found around. After the master device finds the slave Bluetooth device, it will pair with the slave Bluetooth device. At this time, you need to enter the PIN code of the slave device, and some devices do not need to enter the PIN code.

After the pairing is completed, the slave Bluetooth device will record the trust information of the master device. At this time, the master can initiate a call to the slave device, and the paired device does not need to be re-paired in the next call. For paired devices, the Bluetooth headset as the slave can also initiate a link establishment request, but the Bluetooth module for data communication generally does not initiate a call.

After the link is successfully established, two-way data or voice communication can be carried out between the master and the slave. In the communication state, both the master and slave devices can initiate disconnection and disconnect the Bluetooth link.

3. Bluetooth data transmission

In the application of Bluetooth data transmission, one-to-one serial data communication is one of the most common applications. The pairing information between the two Bluetooth modules is set in advance before the Bluetooth module leaves the factory. Address, etc., when the devices at both ends are powered on, the link will be established automatically, and the transparent serial port transmission will not require the intervention of peripheral circuits.

In the 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, and will not be searched by other Bluetooth devices; the other is the development state, which can be searched by the designated master , and can also be found and established by other Bluetooth devices.

BLE Bluetooth module working mode

Bluetooth devices play different roles in various application scenarios, and Bluetooth application scenarios are closely related to their working modes. The BLE Bluetooth module has two main roles, which are the host and the slave. The Bluetooth module as the host is divided into scanners, initiators and data clients, and the Bluetooth module as the slave is divided into broadcasters. , passive connectors and data servers.

The BLE Bluetooth module has 7 main working modes, which are the host mode most familiar to engineers, slave mode, master-slave integration, broadcaster, observer, iBeacon mode, and Mesh networking mode.

1. Host mode

The device responsible for scanning and initiating establishment requests can communicate with one or more slave devices

  1. Regularly scan the broadcast information sent by the surrounding broadcast status devices, you can search the surrounding devices and select the slave device to be connected for pairing and connection;
  2. You need to know the mac address of the slave device, the pairing password and other information. After the pairing is completed, you can connect directly. After the communication link is successfully established, the master and slave can send and receive data;
  3. The master device can set the mac address of the default connection slave device;
  4. Support the whitelist function, when the module searches for a device that meets the whitelist, it will connect;
  5. After the master device finds the slave device, it will pair with the slave device. At this time, the PIN code of the slave device needs to be entered;
  6. When the master-slave transparent transmission protocol is the same, the data transparent transmission between the serial port of the master device and the serial port of the slave device can be realized only through simple parameter settings;
  7. Support disconnection and reconnection function. When the abnormal interference problem disappears and the working environment of the module returns to normal, the master device will automatically search for the slave device that has just been disconnected, minimizing data loss and improving system stability.

2. Slave mode

The device responsible for broadcasting and accepting connection requests cannot actively establish a connection, intelligently waiting for others to connect

  1. The 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;
  2. The bluetooth module in the slave device mode can be connected, regularly connect and transmit data with the host, and act as a slave during the data transmission process;
  3. 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;
  4. In slave device mode, users can develop their own APP according to the protocol. 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;
  5. In the communication state, both the master device and the slave device can initiate a disconnection, that is, disconnect the Bluetooth link.

3. Master-slave integrated working mode

It can be used as a master device and a slave device at the same time. After the Bluetooth 4.1 protocol specification, the function of "link topology" is added to play the role of a repeater

  1. The Bluetooth module allows simultaneous operation as a master and a slave in any combination of roles;
  2. 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 uploads it to the cloud or centralized controller for storage or display after collection;
  3. The master-slave integration adds additional functions of the Bluetooth module, cost optimization and ease of use; If the Bluetooth module previously worked as a master device in a closed system, it can now also be connected to a smartphone as a slave device at the same time, thereby achieving a new connection dimension ;

4. Broadcaster working mode

The functions that must be supported by devices above Bluetooth 4.0, one-to-many sending, periodically broadcasting fixed-length data to surrounding devices, broadcasting their own mac address, name and supported features, are mainly used to be discovered by other devices, and not sending data

  1. The module can continue to broadcast in low power consumption mode, which is suitable for applications with extremely low power consumption, small data volume, and one-way transmission. The important function of the Bluetooth broadcast channel is to discover devices, initiate connections and distribute data;
  2. Bluetooth broadcasts generally broadcast its own mac address, name and supported features to the outside world. The broadcast is mainly used to be discovered by other devices, not for data transmission;
  3. There are two types of broadcast packets: Advertising Data and Scan Response. The broadcast packet must be broadcast by each device, and the response packet is optional. The length of each packet is a fixed byte N , the length N of the data packet expands as the standard of the Bluetooth protocol increases;  
  4. The broadcast mode mainly has two usage scenarios: (1) One-way, connectionless data communication, the data sender broadcasts data on the broadcast channel, and the data receiver scans and receives the data; the broadcaster will be used as a server. (2 ) Connection-oriented establishment, such as the bluetooth slave device broadcasts a message and is searched by the master device for connection. The only difference between the broadcaster and the slave device mode is that it cannot be connected by the host device and can only broadcast data.

5. Observer working mode

One-to-many receiving, monitoring and reading broadcast data in the air cannot initiate data, and can only continuously scan slaves

  1. Observer mode, the module is not connected in this mode;
  2. Applied to the application of data collection concentrator, such as sensor concentrator collection and other functions;
  3. Bluetooth gateway, the Bluetooth module is in observer mode, no broadcasting, it can scan the surrounding broadcasting devices, but cannot request to connect with broadcasting devices.

6. iBeacon working mode

The micro-positioning technology developed on the basis of the Bluetooth 4.0 specification, the low-power Bluetooth beacon, uses BLE technology, a broadcast mode, and it is also a low-power Bluetooth device (slave device) with this protocol ), working in the broadcast mode, broadcasting to the surroundings, and all broadcast data are arranged under specific rules

  1. Working in broadcast mode, it uses the broadcast frame named "Advertising" in BLE. The notification frame is a frame sent periodically, as long as it is a device that supports BLE, it can receive it;
  2. The transmission power of the broadcast can be adjusted, and the mac address, UUID and other fixed-byte strings of the Bluetooth device are continuously broadcast, and the application software will take some measures according to the string after receiving the string;
  3. It cannot be connected with any low-power Bluetooth host, and is usually placed in a fixed position indoors, so as to broadcast continuously to the surroundings, and all broadcast data is arranged under specific rules.

7. Mesh networking working mode

Compatible with 4 and 5 series Bluetooth protocols, realize "many-to-many" device communication, large-scale networking, each network can connect a theoretical maximum of 65536 nodes, no gateway is required, each node can be used as an AP and a router

  1. Using Bluetooth devices as signal relay stations, using low-power Bluetooth broadcasting to send and receive information, Bluetooth Mesh technology expands the communication relationship of Bluetooth and breaks the previous limitation that Bluetooth devices can only communicate with one-to-one master-slave and broadcast one-to-many. Enable Bluetooth devices in the network to achieve "many-to-many" device communication;
  2. When communicating, when a node is damaged or blocked, it can automatically bypass the node and re-select the path to reach the destination, which can make the network more efficient and reliable; each node can send, receive, and forward messages. Messages can be forwarded in the Mesh network to reach a longer distance;
  3. It has application advantages in many fields such as smart homes and smart buildings. Bluetooth Mesh technology will become the optimal solution for short-distance large-scale networking of the Internet of Things.

    At present, Bluetooth technology has been widely used in all IoT smart products including smart home, consumer electronics, smart medical care, automobiles, smart wearable devices and smart building equipment, accelerating the pace of interaction between people and everything. The Bluetooth modules used in the field of Internet of Things are basically low-power Bluetooth modules. In addition to the above applications, Bluetooth modules can also be used in home Internet of Things, vehicle control, lantern control solutions, building management, supermarket product Beacon promotion and other fields .
     

Guess you like

Origin blog.csdn.net/SKYLAB01/article/details/131699132