Bluetooth communication method, electronic equipment, readable storage medium and chip
By using passive scanning mode to receive BLE broadcast packets in Bluetooth devices and switching to active scanning mode under certain conditions, the problem of increased power consumption due to active scanning in Bluetooth devices is solved, achieving a balance between low power consumption and functionality, and improving the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HUAWEI DEVICE CO LTD
- Filing Date
- 2024-11-12
- Publication Date
- 2026-05-12
AI Technical Summary
The process by which existing Bluetooth Low Energy devices actively scan to discover other Bluetooth devices in the vicinity increases device power consumption and affects the user experience.
The system receives the first BLE broadcast packet using a passive scanning mode. When preset conditions are met, it switches to an active scanning mode. By combining low-power radio frequency and main radio frequency, the system determines whether to switch scanning modes based on the type and data content of the BLE broadcast packet.
While maintaining the advantage of low power consumption, a balance between device power consumption and function is achieved, avoiding the impact of frequent switching on communication performance and saving device power consumption.
Smart Images

Figure CN122028016A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Bluetooth communication technology, and in particular to a Bluetooth communication method, electronic device, readable storage medium, and chip. Background Technology
[0002] Currently, Bluetooth Low Energy (BLE) devices (scanning devices) typically discover other nearby Bluetooth devices (broadcasting devices) through active scanning. For example, after receiving a broadcast packet message from another nearby device, a BLE device actively initiates a scan request and waits for a response from the surrounding Bluetooth devices. Upon receiving the scan request, the surrounding Bluetooth devices reply with a response message. After collecting these response messages, the BLE device can decide whether to proceed with further interaction with these Bluetooth devices, such as establishing a connection. This method allows for faster discovery of other nearby Bluetooth devices, but the active scanning process significantly increases device power consumption, impacting the user experience. Summary of the Invention
[0003] This application provides a Bluetooth communication method, an electronic device, a readable storage medium, and a chip, which solves the problem in the prior art that the process of actively scanning to discover other Bluetooth devices in the vicinity increases device power consumption and affects the user experience.
[0004] To achieve the above objectives, this application adopts the following technical solution:
[0005] In a first aspect, a Bluetooth communication method is provided for use in an electronic device that supports Bluetooth communication using low-power radio frequency (LRF) and main radio frequency (MRF). The method includes: receiving a first BLE broadcast packet in a passive scanning mode, wherein the electronic device operates in LRF in the passive scanning mode; and switching from passive scanning mode to active scanning mode when the first BLE broadcast packet meets a first preset condition, wherein the electronic device operates in MRF in the active scanning mode.
[0006] The method provided in this application embodiment allows the electronic device to switch scanning modes when the first BLE broadcast packet meets the first preset condition. This enables the electronic device to switch scanning modes as needed, and to operate in low-power radio frequency (RF) mode in passive scanning mode and in main RF mode in active scanning mode. This achieves a balance between device power consumption and functionality while leveraging the low-power advantages of RF.
[0007] In some embodiments, the first preset condition includes at least one of the following: the first BLE broadcast packet is of a specified type; the first BLE broadcast packet carries instruction information indicating that the scanning device should receive the second BLE broadcast packet; the data information carried by the first BLE broadcast packet lacks target information required to perform the service; the data information carried by the first BLE broadcast packet includes information on a specified data format and data type; and the service corresponding to the data information carried by the first BLE broadcast packet is a specified service type.
[0008] Optionally, the first preset condition may also be that the first BLE broadcast packet is of a specified type, and the data information carried by the first BLE broadcast packet satisfies the following: the data information includes instruction information instructing the scanning device to receive the second BLE broadcast packet; and / or, the data information lacks target information required to perform the service; and / or, the data information includes information specifying the data format and data type; and / or, the service corresponding to the data information is a specified service type.
[0009] In this embodiment, the type of BLE broadcast packet and / or the content of the data information it carries are used to indicate whether the electronic device needs to switch scanning modes, thereby enabling the electronic device to switch as needed and avoiding frequent switching that could affect the communication effect.
[0010] In some embodiments, the specified types include ADV_IND and ADV_SCAN_IND.
[0011] In one implementation, the electronic device can determine the type of the first BLE broadcast packet based on the broadcast data field in the broadcast data type field of the data structure of the first BLE broadcast packet.
[0012] In some embodiments, when the first BLE broadcast packet meets the first preset condition, switching from passive scanning mode to active scanning mode includes: when the first BLE broadcast packet meets the first preset condition, sending a scanning request, the scanning request indicating the return of request information corresponding to the scanning request; and receiving a scanning response, the scanning response carrying the request information.
[0013] In this embodiment, the electronic device switches from passive scanning mode to active scanning mode simultaneously with switching from the current low-power radio frequency state to the main radio frequency state, and completes further reception of broadcast packets in active scanning mode. This method not only avoids affecting the normal reception of broadcast packets and saves device power consumption, but also enables on-demand switching without disrupting normal service operations.
[0014] In some embodiments, the method further includes: if the first BLE broadcast packet does not meet the first preset condition, continuously receiving a third BLE broadcast packet in a passive scanning mode, wherein the third BLE broadcast packet is the same as or different from the first BLE broadcast packet.
[0015] In this embodiment, if the first broadcast packet does not meet the first preset condition, the electronic device indicates that it does not need to request the next broadcast packet associated with the first BLE broadcast packet from the broadcast device. Therefore, the electronic device continues to receive broadcast packets in passive scanning mode, without switching scanning mode or radio frequency state, thus avoiding frequent switching and affecting the communication experience.
[0016] In some embodiments, the method further includes: switching from active scanning mode to passive scanning mode when a second preset condition is met.
[0017] In this embodiment, when the second preset condition is met, the electronic device switches from the current active scanning mode to the passive scanning mode, thereby enabling the electronic device to operate in low-power radio frequency to save device power consumption.
[0018] In some embodiments, the second preset condition includes at least one of the following: no broadcast packet of a specified type is received within a preset time period; the number of consecutive times no broadcast packet of the specified type is received meets a preset number; and it is determined that the reception of BLE broadcast packets in active scanning mode has been completed.
[0019] In this embodiment, if the electronic device does not receive a broadcast packet of a specified type within a preset time; and / or if the number of consecutive failures to receive a broadcast packet of a specified type meets a preset number, it indicates that no more data needs to be acquired at present, or that the reception of BLE broadcast packets in active scanning mode has been completed. At this time, the electronic device switches from the current active scanning mode to passive scanning mode so that it can work in a low-power radio frequency state, thereby saving device power consumption.
[0020] Secondly, a Bluetooth communication device is provided for use in an electronic device that supports Bluetooth communication using low-power radio frequency and main radio frequency. The device includes: a receiving module for receiving a first BLE broadcast packet in a passive scanning mode, wherein the electronic device operates in low-power radio frequency in the passive scanning mode; and a switching module for switching from passive scanning mode to active scanning mode when the first BLE broadcast packet meets a first preset condition, wherein the electronic device operates in main radio frequency in the active scanning mode.
[0021] Thirdly, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the method shown in the first aspect.
[0022] Fourthly, a computer-readable storage medium is provided that stores a computer program, which, when executed by a processor, implements the method shown in the first aspect.
[0023] Fifthly, a chip is provided, the chip including a processor and a memory, the memory storing a computer program that, when executed by the processor, implements the method shown in the first aspect.
[0024] In a sixth aspect, a computer program product is provided, comprising a computer program / instructions that, when executed by a processor / electronic device, implement the method shown in the first aspect.
[0025] It is understood that the beneficial effects of the second to sixth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here. Attached Figure Description
[0026] Figure 1 An architecture diagram of a Bluetooth communication system provided in this application embodiment;
[0027] Figure 2 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application;
[0028] Figure 3A This is a schematic diagram of the structure of a Bluetooth communication module provided in an embodiment of this application;
[0029] Figure 3B A schematic diagram of a radio frequency structure provided in an embodiment of this application;
[0030] Figure 3C A software structure block diagram of the Bluetooth communication module provided in the embodiments of this application;
[0031] Figure 4A A schematic diagram of the architecture of broadcast and scanning services supported by electronic devices provided in embodiments of this application;
[0032] Figure 4B This application provides a schematic diagram of the structure of a BLE broadcast packet according to an embodiment of the present application.
[0033] Figure 5 A schematic diagram of the interaction process of a Bluetooth communication method provided in an embodiment of this application;
[0034] Figure 6 A schematic diagram of the interaction flow of another Bluetooth communication method provided in an embodiment of this application;
[0035] Figure 7 This is a schematic diagram of the structure of the Bluetooth communication device provided in the embodiments of this application;
[0036] Figure 8 This is a schematic diagram of the chip structure provided in an embodiment of this application. Detailed Implementation
[0037] The technical solutions provided in the embodiments of this application will be described below with reference to the accompanying drawings.
[0038] It should be understood that in the description of the embodiments of this application, unless otherwise stated, " / " means "or". For example, A / B can mean A or B. The "and / or" in this document is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist simultaneously, and B exists alone.
[0039] In this embodiment, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this embodiment, unless otherwise stated, "a plurality of" means two or more.
[0040] Figure 1 This is an architecture diagram of a Bluetooth communication system provided in an embodiment of this application. Figure 1 As shown, the system may include multiple electronic devices. Each electronic device can communicate with other electronic devices in the BLE and Bluetooth communication system. This application does not specifically limit the type of electronic device; for example, the electronic device can be a portable electronic device such as a mobile phone, tablet computer, personal digital assistant (PDA), wearable device (e.g., Bluetooth headset, smartwatch, etc.), or a laptop computer, or a non-portable electronic device such as a desktop computer. Examples of electronic devices include, but are not limited to, devices equipped with… Or electronic devices with other operating systems.
[0041] The electronic device in the embodiments of this application can also be called a terminal device, which can be a device with wireless transceiver function. Specifically, it can refer to user equipment (UE), access terminal, user unit (subscriber unit), user station, mobile station, customer premises equipment (CPE), remote station, remote terminal, mobile device, user terminal, wireless communication equipment, user agent or user device. Terminal devices can also be satellite phones, cellular phones, smartphones, wireless data cards, wireless modems, machine-type communication devices, cordless phones, session initiation protocol (SIP) phones, wireless local loop (WLL) stations, personal digital assistants (PDAs), handheld devices with wireless communication capabilities, computing devices or other processing devices connected to a wireless modem, in-vehicle devices, communication devices mounted on high-altitude aircraft, wearable devices, drones, robots, point-of-sale (POS) machines, terminals in device-to-device (D2D) communication, terminals in vehicle-to-everything (V2X) communication, virtual reality (VR) terminal devices, augmented reality (AR) terminal devices, wireless terminals in industrial control, wireless terminals in self-driving, wireless terminals in remote medical care, wireless terminals in smart grids, and wireless terminals in transportation security. This application does not limit the scope of wireless terminals, such as those used in smart cities, smart homes, or future communication networks.
[0042] In this embodiment, the device for implementing the functions of the terminal device can be the terminal device itself; or it can be a device capable of supporting the terminal device in implementing the functions, such as a chip system. This device can be installed in the terminal device or used in conjunction with the terminal device. In this embodiment, the chip system can be composed of chips, or it can include chips and other discrete components.
[0043] The structure of the electronic device involved in the embodiments of this application is described below.
[0044] Figure 2 This is a schematic diagram of the hardware structure of the electronic device provided in an embodiment of this application. See also... Figure 2 As shown, the electronic device includes a processor 210, an external memory interface 220, an internal memory 221, a universal serial bus (USB) interface 230, a charging management module 240, a power management module 241, a battery 242, an antenna 1, an antenna 2, a mobile communication module 250, a wireless communication module 260, an audio module 270, a speaker 270A, a receiver 270B, a microphone 270C, a headphone jack 270D, a sensor module 280, buttons 290, a motor 291, an indicator 292, a camera 293, a display screen 294, and a subscriber identification module (SIM) card interface 295, etc.
[0045] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device. In other embodiments of this application, the electronic device may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0046] Processor 210 may include one or more processing units, such as application processors (APs), modem processors, graphics processing units (GPUs), image signal processors (ISPs), controllers, memory, video codecs, digital signal processors (DSPs), baseband processors, and / or neural network processing units (NPUs). Different processing units may be independent devices or integrated into one or more processors. The controller may serve as the nerve center and command center of the electronic device. The controller can generate operation control signals based on instruction opcodes and timing signals to control instruction fetching and execution.
[0047] The processor 210 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 210 is a cache memory. This memory can store instructions or data that the processor 210 has just used or that are used repeatedly. If the processor 210 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 210, and thus improves the efficiency of the system.
[0048] The charging management module 240 receives charging input from a charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 240 receives charging input from the wired charger via a USB interface 230. In some wireless charging embodiments, the charging management module 240 receives wireless charging input via the wireless charging coil of the electronic device. While charging the battery 242, the charging management module 240 can also supply power to the electronic device via the power management module 241.
[0049] The power management module 241 connects the battery 242, the charging management module 240, and the processor 210. The power management module 241 receives input from the battery 242 and / or the charging management module 240, providing power to the processor 210, internal memory 221, external memory, display 294, camera 293, and wireless communication module 260, etc. The power management module 241 can also monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage current, impedance).
[0050] The wireless communication function of electronic devices can be realized through antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, modem processor and baseband processor, etc.
[0051] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device can be used to cover one or more communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with a tuning switch.
[0052] The mobile communication module 250 can provide solutions for wireless communication applications in electronic devices, including 2G / 3G / 4G / 5G. The mobile communication module 250 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 250 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 250 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1.
[0053] In some embodiments, at least some functional modules of the mobile communication module 250 may be disposed in the processor 210. In some embodiments, at least some functional modules of the mobile communication module 250 and at least some modules of the processor 210 may be disposed in the same device.
[0054] The modem processor may include a modulator and a demodulator. The modulator modulates the low-frequency baseband signal to be transmitted into a mid-to-high frequency signal. The demodulator demodulates the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After processing by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs sound signals through an audio playback device (not limited to speaker 270A, receiver 270B, etc.) or displays images or videos through the display screen 294. In some embodiments, the modem processor may be a separate device. In other embodiments, the modem processor may be independent of the processor 210 and may be housed in the same device as the mobile communication module 250 or other functional modules.
[0055] The wireless communication module 260 can provide solutions for wireless communication applications in electronic devices, including wireless local area networks (WLAN) (e.g., Wi-Fi), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR). The wireless communication module 260 can be one or more devices integrating at least one communication processing module. The wireless communication module 260 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signal, and sends the processed signal to processor 210. The wireless communication module 260 can also receive signals to be transmitted from processor 210, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2. For example, the wireless communication module 260 can be a Wi-Fi communication module, a Bluetooth communication module, a ZigBee communication module, etc.
[0056] The BLE scanning function in the wireless communication module 260 can be provided by... Figure 3A The Bluetooth communication module shown is implemented as follows. Figure 3AAs shown, the Bluetooth communication module may include, but is not limited to, a Bluetooth host 260A and a Bluetooth module 260B. The Bluetooth host 260A can be a Bluetooth chip. The Bluetooth host 260A can receive instructions from an application 2601 running in the electronic device; or preset a higher layer protocol 2602; or call the host controller interface (HCI) 2603. The Bluetooth module 260B may include, but is not limited to, a Bluetooth controller 2611, a link manager 2612, a baseband and link controller 2613, a radio frequency (TX / RX) unit 2614, and an antenna 2615. When the Bluetooth communication module implements the BLE scanning function, the application 2601 first issues a command to start a BLE scan. The Bluetooth host 260A configures the scan request parameters, forming a scan request message. Then, it calls the host controller interface 2603 to send the scan request message to the host controller 2611 in the Bluetooth module 260B. It is then transmitted to the Bluetooth communication module of the broadcasting device via link management 2612, baseband and link controller 2613, radio frequency 2614, and antenna 2615.
[0057] Electronic devices need to enable the software modules related to the BLE broadcast signal scanning function on the BLE communication module to scan BLE broadcast channels and receive broadcast packets. In this embodiment, the BLE scanning function can be started if the application in the scanning device issues a start command.
[0058] In this embodiment, see Figure 3B As shown, the radio frequency (radio TX / RX) 1614 of the Bluetooth module 260B includes low-power radio (also known as ultra-low-power radio) and main radio. In scenarios where electronic devices use low-power radio, in order to take advantage of the power consumption of low-power radio, the Bluetooth communication module is in a passive scanning state, that is, the Bluetooth communication module only receives broadcast packets and does not send broadcast packets, thereby saving device power consumption.
[0059] See Figure 3C The diagram shown is a software structure block diagram of a Bluetooth communication module provided in an embodiment of this application. Figure 3CAs shown, the software architecture of the Bluetooth communication module comprises three layers, from top to bottom: the application layer, the host layer, and the control layer. The application layer corresponds to the application layer in the software architecture of an electronic device, and will not be elaborated upon here. The host layer includes, but is not limited to, the BLE protocol stack, higher-level protocols, and the Host Control Interface (HCI). The BLE protocol stack pre-stores the code implementing the BLE protocol; the higher-level protocols define the higher-level signaling for wireless communication; and the HCI is used for data interaction between the host layer and the control layer. The control layer includes, but is not limited to, the host controller, the link layer, and the physical layer. The host controller is connected to the HCI and enables data interaction between the host layer and the control layer; the link layer and the physical layer are primarily used for signal transmission.
[0060] Camera 293 is used to capture still images or videos. In some embodiments, the electronic device may include one or N cameras 293, where N is a positive integer greater than 1.
[0061] Display screen 294 is used to display images, videos, etc. Display screen 294 includes a display panel. The display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a miniature LED, a microLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device may include one or N displays 294, where N is a positive integer greater than 1.
[0062] The external storage interface 220 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device. The external memory card communicates with the processor 210 through the external storage interface 220 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.
[0063] Internal memory 221 can be used to store executable program code, including instructions. Processor 210 executes various functional applications and data processing of the electronic device by running the instructions stored in internal memory 221. Internal memory 221 may include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a function (such as sound playback, image playback, etc.). The data storage area may store data created during the use of the electronic device (such as audio data, phonebook, etc.).
[0064] In addition, the internal memory 221 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
[0065] Electronic devices can implement audio functions through audio modules 270, speakers 270A, receivers 270B, microphones 270C, headphone jacks 270D, and application processors.
[0066] The audio module 270 is used to convert digital audio signals into analog audio signals for output, and also to convert analog audio inputs into digital audio signals. The audio module 270 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 270 may be located in the processor 210, or some functional modules of the audio module 270 may be located in the processor 210.
[0067] The speaker 270A, also known as a "loudspeaker," is used to convert audio electrical signals into sound signals. Electronic devices can listen to music or make hands-free calls through the speaker 270A; for example, the speaker can play the comparison analysis results provided in the embodiments of this application.
[0068] The receiver 270B, also known as the "earpiece," is used to convert audio electrical signals into sound signals. When an electronic device answers a phone call or voice message, the receiver 270B can be brought close to the ear to hear the voice.
[0069] Microphone 270C, also known as a "microphone" or "voice transducer," is used to convert sound signals into electrical signals. When making a phone call or sending a voice message, the user can speak by bringing their mouth close to microphone 270C, inputting the sound signal into microphone 270C. An electronic device can have at least one microphone 270C. In some embodiments, the electronic device can have two microphones 270C, which, in addition to collecting sound signals, can also perform noise reduction. In other embodiments, the electronic device can also have three, four, or more microphones 270C, enabling sound signal collection, noise reduction, sound source identification, and directional recording, among other functions.
[0070] In some embodiments, the electronic device can receive ultrasonic signals sent by other electronic devices via microphone 270C, and identify the frequency and received intensity of the ultrasonic signals via processor 210.
[0071] The headphone jack 270D is used to connect wired headphones. The headphone jack 270D can be a USB 230 interface or a 2.5mm Open Mobile Terminal Platform (OMTP) standard interface, a CTIA (Cellular Telecommunications Industry Association of the USA) standard interface.
[0072] The sensor module 280 may include a pressure sensor 280A, a gyroscope sensor 280B, a barometric pressure sensor 280C, a magnetic sensor 280D, an accelerometer sensor 280E, a distance sensor 280F, a proximity sensor 280G, a fingerprint sensor 280H, a temperature sensor 280J, a touch sensor 280K, an ambient light sensor 280L, a bone conduction sensor 280M, etc.
[0073] Buttons 290 include a power button, volume buttons, etc. Buttons 290 can be mechanical buttons or touch-sensitive buttons. The electronic device can receive button input and generate key signal inputs related to user settings and function control of the electronic device.
[0074] Motor 291 can generate vibration alerts. Motor 291 can be used for incoming call vibration alerts or for touch vibration feedback. For example, different vibration feedback effects can be corresponding to touch operations applied to different applications (such as taking photos, playing audio, etc.). Motor 291 can also provide different vibration feedback effects for touch operations applied to different areas of the display screen 294.
[0075] Indicator 292 can be an indicator light, which can be used to indicate the charging status and power changes of electronic devices, or to indicate messages, missed calls, notifications, etc.
[0076] The SIM card interface 295 is used to connect SIM cards. The SIM card can be inserted into or removed from the SIM card interface 295 to achieve contact and separation with the electronic device. The electronic device can support one or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 295 supports Nano SIM cards, Micro SIM cards, and other SIM cards. Multiple cards can be inserted into the same SIM card interface 295 simultaneously. The multiple cards can be of the same or different types.
[0077] The following embodiments of this application will be used to illustrate having Figure 2 The electronic device with the structure shown, and Figure 1 Taking the Bluetooth communication system shown as an example, and in conjunction with the accompanying drawings and application scenarios, the Bluetooth communication method provided in this application embodiment will be specifically described.
[0078] In the embodiments of this application, Figure 1 The Bluetooth communication system shown is a Bluetooth system based on the Bluetooth Low Energy (BLE) communication protocol. Electronic devices can communicate based on BLE's broadcast mechanism. See also Figure 4A As shown, the electronic device in this application embodiment can provide two services based on BLE: advertising and scanning.
[0079] Based on the BLE broadcast service, electronic devices can send BLE broadcast packets (also known as BLE broadcast signals or simply broadcast packets) on the BLE broadcast channel. Based on the BLE scanning service, electronic devices can scan for BLE broadcast packets sent by other electronic devices on the BLE broadcast channel.
[0080] In this application embodiment, the electronic device that sends BLE broadcast packets can be referred to as the advertiser, broadcast device, or slave device; the electronic device that scans BLE broadcast packets can be referred to as the scanner, scanning device, or master device. Any electronic device that performs sensing and communication based on BLE can be called a BLE device. It should be noted that the BLE device involved in this application embodiment can be either a scanning device (i.e., when the BLE device is in Scanning state) or a broadcast device (i.e., when the BLE device is in Advertising state).
[0081] In this embodiment, both the broadcasting device and the scanning device can support BLE broadcast communication functions. Specifically, the broadcasting device can broadcast BLE broadcast signals on the BLE broadcast channel, and the scanning device can scan the BLE broadcast channel and receive BLE broadcast signals.
[0082] For example, a broadcast device can periodically send BLE broadcast packets of type ADV_IND on three broadcast channels (idx = 37, 38, 39) in sequence. Once successfully sent, it will listen for scan request (SCAN_REQ) packets sent by scanning devices. If a SCAN_REQ packet is detected from a scanning device, the broadcast device will respond with a scan response (SCAN_RSP) packet. The SCAN_RSP is sent undirected and can be scanned by all scanning devices within a certain area, regardless of whether the scanning devices have sent SCAN_REQ packets to the broadcast device. The scanning device can periodically scan each broadcast channel (e.g., idx = 37, 38, 39). If the scanning device receives a scannable event sent by the broadcast device on a certain channel (if the broadcast packet type is ADV_IND or ADV_SCAN_IND, it is determined that a scannable event has been received), the scanning device will immediately send a SCAN_REQ data packet to the broadcast device that sent the scannable event on the same channel, thereby requesting the broadcast device to send the corresponding SCAN_RSP data packet.
[0083] In this embodiment, the broadcasting device can be a power-sensitive device that is not constantly charging and has BLE broadcasting functionality; for example, it can be a smart wearable terminal device such as a smartwatch or smart glasses, or a terminal device with a small battery capacity. The number of broadcasting devices in the Bluetooth communication system is not limited and can be multiple, such as... Figure 1 The image shows Bluetooth headsets and smartwatches. Scanning devices can be mobile terminals, tablets, laptops, personal computers, and other electronic devices with BLE scanning capabilities. There is no limit to the number of scanning devices in the Bluetooth communication system; multiple devices can be used, such as... Figure 1 The image shows a mobile phone and a laptop. Broadcasting and scanning devices can sense and communicate via BLE; therefore, both broadcasting and scanning devices can be referred to as BLE devices.
[0084] At any given moment, a BLE device participating in broadcast communication can be in one of the following three states:
[0085] Advertising: In this state, the BLE device acts as a data sender and periodically transmits broadcast data.
[0086] Scanning: In this state, the BLE device acts as a data receiver, scanning and receiving broadcast data.
[0087] Initiating connection state: In this state, the BLE device acts as the connection initiator. If it scans broadcast data with the "connectable" flag, it will initiate a connection request.
[0088] BLE devices participating in broadcast communication can send different types of BLE broadcast packets under different states. Among them, BLE broadcast is divided into legacy advertising and extended advertising. This embodiment mainly uses legacy advertising as an example for specific explanation.
[0089] BLE devices in Advertising mode can send four types of BLE broadcast packets: connectable undirected event type ADV_IND; scannable undirected event type ADV_SCAN_IND; connectable directed event type ADV_DIRECT_IND; and non-connectable undirected event type ADV_NONCONN_IND.
[0090] ADV_IND: This is the most widely used and common broadcast type, carrying no more than 31 bytes of broadcast data. It indicates that the broadcasting device sending the ADV_IND type broadcast packet is open to connection requests from any device. A broadcasting device that sends this type of broadcast packet can be detected by a scanning device, or it can enter into a connection as a slave device upon receiving a connection request. This type of broadcast can be sent even without a connection being established.
[0091] ADV_SCAN_IND: Similar to ADV_IND, it can carry broadcast data but cannot be linked; it can be scanned. In some scenarios, when the broadcasting device and the scanning device need to transmit additional data besides the broadcast data, but due to various reasons such as broadcast data length limitations or privacy requirements, ADV_IND type broadcast packets cannot meet the transmission requirements, ADV_SCAN_IND type broadcast packets can be used. While broadcasting periodically, the broadcasting device listens for SCAN_REQ packets from the scanning device. After receiving the broadcast packet, the scanning device can request more data through the SCAN_REQ packet.
[0092] ADV_DIRECT_IND: This is a broadcast type specifically used for point-to-point connections, where the Bluetooth addresses of both parties are already known. It cannot carry broadcast data, can be connected to by specified devices, and cannot be scanned.
[0093] ADV_NONCONN_IND: Similar to ADV_IND, it can carry broadcast data, but it cannot be connected to or scanned. Broadcast devices only need to periodically transmit simple data (e.g., temperature information of a specific temperature node), and do not require further interaction with scanning devices. Therefore, they can send broadcast packets of type ADV_NONCONN_IND. Broadcast devices only need to periodically broadcast this type of packet; scanning devices scan and receive according to their own strategies, and no additional data exchange is required between the two.
[0094] The BLE broadcast packet types that a BLE device can send in Scanning mode are: SCAN_REQ and SCAN_RSP.
[0095] Among them, SCAN_REQ: Scan Request. When the scanning device receives a broadcast packet of type ADV_IND or ADV_SCAN_IND sent by the broadcasting device, it can request the broadcasting device to broadcast more information through a broadcast packet of type SCAN_REQ, such as device information, or a universally unique identifier (UUID), and other information such as manufacturer-specific format information (such as hardware version, software version number, device serial number, etc.).
[0096] SCAN_RSP: The broadcast device's response to a SCAN_REQ initiated by a scanning device. As a supplement to the broadcast packet, the broadcast device can send more broadcast data to the scanning device so that the scanning device can obtain more information about the broadcast device. This helps to provide richer broadcast data and enables the scanning device to better understand the surrounding BLE devices. For example, if the BLE broadcast packet sent by the broadcast device does not contain the device name, the broadcast device can encapsulate the device name in a SCAN_RSP after receiving the SCAN_REQ and send it to the scanning device.
[0097] The BLE broadcast packet type that a BLE device can send in the Initiating state is: CONNECT_REQ.
[0098] CONNECT_REQ: When a scanning device receives broadcast data of type ADV_IND or ADV_DIRECT_IND, it can use this BLE broadcast packet to request a connection with the other party. The scanning device sends this connection request to the broadcast device, and the connection is then established.
[0099] As mentioned above, BLE devices participating in broadcast communication can send different types of BLE broadcast packets. Therefore, the state of a BLE device in broadcast communication can be determined based on the different types of BLE broadcast packets sent.
[0100] In BLE broadcast communication, the BLE broadcast packets transmitted by broadcasting and scanning devices have a specific format.
[0101] For example, see Figure 4B This illustrates the structure of a BLE broadcast packet according to an embodiment of this application. Figure 4B As shown, a BLE broadcast packet includes a significant data part and a non-significant data part. The significant data part includes one or more broadcast data units (AD structures). Each broadcast data unit includes a length part and a data part. The length part indicates the length of the data part, and the data part includes a broadcast data field (AD data) and a broadcast data type field (AD type). The broadcast data field carries the broadcast data, and the broadcast data type field indicates the type of the broadcast data. Understandably, BLE broadcast packets are 31 bytes long. If the significant data part is less than 31 bytes, it is padded with zeros; this padded data is considered invalid.
[0102] It should be noted that the Bluetooth communication method provided in this application mainly involves the transmission of BLE broadcast packets by a broadcasting device in Advertising state and the reception of BLE broadcast packets by a scanning device in Scanning state.
[0103] Currently, scanning devices can discover other Bluetooth devices, i.e. broadcasting devices, in the vicinity through active or passive scanning modes.
[0104] Active scanning: Active scanning involves the scanning device, upon receiving a broadcast packet message from other nearby devices, proactively sending a SCAN_REQ request packet to inquire whether further interaction is possible with the broadcasting device (i.e., nearby Bluetooth devices). Upon receiving a SCAN_RSP response message from the broadcasting device, the scanning device then initiates further interaction. For example, the scanning device sends a SCAN_REQ request message to request a response from the broadcasting device. Upon receiving this SCAN_REQ request message, the broadcasting device replies with a SCAN_RSP response message. After collecting this response information, the scanning device can decide whether to proceed with further interaction with the broadcasting device, such as establishing a connection.
[0105] Passive Scanning: The scanning device passively listens for BLE broadcast packets from the broadcasting device but does not actively send messages to inquire. The BLE broadcast packets sent by the broadcasting device can be any type of BLE broadcast packet shown in the above embodiments, such as scannable broadcast packets ADV_IND or ADV_SCAN_IND, or unscannable broadcast packets ADV_DIRECT_IND or ADV_NONCONN_IND. In passive scanning mode, after starting the scanning window, the scanning device only passively listens for and receives BLE broadcast packets sent by the broadcasting device. These BLE broadcast packets may include basic information about the broadcasting device and broadcast data. Based on the received broadcast information, the scanning device decides whether to proceed with further interaction with the broadcasting device, such as establishing a connection.
[0106] As shown above, when a scanning device is in active scanning mode, it can discover nearby Bluetooth devices faster, but this increases device power consumption. When a scanning device is in passive scanning mode, its power consumption is lower, but it may take longer to acquire sufficient broadcast information from the broadcasting device. Currently, scanning devices typically discover other nearby Bluetooth devices through active scanning. While this method can discover other nearby Bluetooth devices faster, the active scanning process significantly increases device power consumption, impacting the user experience.
[0107] Therefore, this application provides a Bluetooth communication method in which the Bluetooth device can switch the scanning mode as needed, i.e., passive scanning mode and active scanning mode, which is triggered by the received BLE broadcast packet. This method leverages the low power consumption advantage of low power radio frequency while achieving a balance between device power consumption and functionality.
[0108] Figure 5 This is a schematic diagram of the interaction flow of a Bluetooth communication method provided in an embodiment of this application. The execution entities of this method include a broadcasting device and a scanning device, wherein the scanning device supports Bluetooth communication using both low-power radio frequency and main radio frequency. See also Figure 5 As shown, the method includes the following steps S501 to S503.
[0109] S501, the broadcasting device sends the first BLE broadcast packet.
[0110] The first BLE broadcast packet can be sent by the broadcasting device after it starts BLE broadcasting.
[0111] In this embodiment, the first BLE broadcast packet may be a connectable non-directional broadcast ADV_IND or a scannable non-directional broadcast ADV_SCAN_IND; it may also be a connectable directional broadcast ADV_DIRECT_IND or a non-connectable non-directional broadcast ADV_NONCONN_IND.
[0112] In some embodiments, after sending a first BLE broadcast packet of a specified type, the broadcasting device expects to receive a scan request sent by the scanning device in active scanning mode. Upon receiving the scan request, the broadcasting device responds to the scan request and sends the next BLE broadcast packet to the scanning device. If the broadcasting device does not receive a scan request from the scanning device within a preset time after sending the first BLE broadcast packet of the specified type, it retransmits the first BLE broadcast packet until a preset maximum communication time or number of retransmissions is exceeded.
[0113] S502, the scanning device uses passive scanning mode to receive the first BLE broadcast packet sent by the broadcasting device. In passive scanning mode, the scanning device operates in low power radio frequency.
[0114] As can be seen from the foregoing embodiments, the Bluetooth communication module in the scanning device provided in this application supports low-power radio frequency technology. Therefore, the scanning device can receive the first BLE broadcast packet sent by the broadcast device in passive scanning mode based on low-power radio frequency.
[0115] In some embodiments, when the display device displays a non-settings interface, the scanning device adopts a passive scanning mode to receive a first BLE broadcast packet sent by the broadcast device. The non-settings interface is an interface other than the settings interface, and the settings interface is the interface related to the BLE scan performed when the settings application is running in the foreground in response to the operation of the application icon of the settings application.
[0116] S503, when the first BLE broadcast packet meets the first preset condition, the scanning device switches from passive scanning mode to active scanning mode. In active scanning mode, the scanning device operates on the main radio frequency.
[0117] In some embodiments, the first preset condition includes the first BLE broadcast packet being of a specified type. The specified type includes ADV_IND and ADV_SCAN_IND, meaning the specified type can be either ADV_IND or ADV_SCAN_IND.
[0118] As mentioned above, the first BLE broadcast packet may be any of the four types of BLE broadcast packets that the broadcasting device can send in the Advertising state. After receiving the first BLE broadcast packet sent by the broadcasting device, the scanning device determines the type of the first BLE broadcast packet. If the type of the first BLE broadcast packet is a specified type, it determines that the first BLE broadcast packet meets the first preset condition.
[0119] In other embodiments, the first preset condition includes: the first BLE broadcast packet carrying instruction information indicating that the scanning device should receive the second BLE broadcast packet; or, the data information carried by the first BLE broadcast packet lacks target information required to perform the service; or, the data information carried by the first BLE broadcast packet is information of a specified data format and data type; or, the service corresponding to the data information carried by the first BLE broadcast packet is a specified service type.
[0120] The specific details corresponding to the different first preset conditions will be described in detail in the following embodiments, and will not be repeated in this section.
[0121] Optionally, the scanning device may determine that the first BLE broadcast packet meets the first preset condition if the first BLE broadcast packet is of a specified type and the data information it carries meets the above requirements. In a specific implementation, the scanning device may determine the type of the first BLE broadcast packet based on the broadcast data in the broadcast data type field of the data structure of the first BLE broadcast packet, and when it is determined to be of the specified type, parse the first BLE broadcast packet to obtain the data information carried by the first BLE broadcast packet, and then determine that the first BLE broadcast packet meets the first preset condition if the data information meets the above requirements.
[0122] When the first BLE broadcast packet meets the first preset condition, the scanning device switches from the passive scanning mode operating in low-power radio frequency to the active scanning mode. In the active scanning mode, the scanning device operates in the main radio frequency.
[0123] In some embodiments, if the first BLE broadcast packet does not meet the first preset condition, the scanning device maintains the current passive scanning mode, that is, continues to receive the third BLE broadcast packet using the passive scanning mode. The third BLE broadcast packet may be the same as or different from the first BLE broadcast packet. In this case, the scanning device neither switches the scanning mode nor the radio frequency mode.
[0124] In this embodiment, the scanning device first operates in passive scanning mode using low-power radio frequency (RF) to receive the first BLE broadcast packet sent by the broadcasting device. In passive scanning mode, the scanning device only receives the BLE broadcast packet and does not need to send a scan request, thus leveraging the advantages of RF and saving device power consumption. When the first BLE broadcast packet meets a first preset condition, the scanning device determines that it needs to obtain more data information from the broadcasting device. At this time, the scanning device switches from the current passive scanning mode to active scanning mode and operates in the main radio frequency communication state, thereby achieving the goal of switching scanning modes on demand. This approach expands the application scenarios of RF technology, leverages its low-power advantages, and achieves a balance between device power consumption and functionality.
[0125] The Bluetooth communication method provided in this application will be further explained below with reference to specific embodiments.
[0126] Figure 6 This is a schematic diagram of the interaction flow of a Bluetooth communication method provided in an embodiment of this application, involving scanning devices and broadcasting devices as the executing entities. See also Figure 6 As shown, the method includes the following steps S601 to S606.
[0127] S601, the broadcasting equipment sends the first BLE broadcast packet.
[0128] In some embodiments, the broadcasting device broadcasts a first BLE broadcast packet using the BLE communication protocol during a first broadcast period.
[0129] The first broadcast period can be any value between 0 and 2 seconds, or a time interval in milliseconds. For example, the first broadcast period can be 1 second or 20 milliseconds.
[0130] In a specific implementation, application A in the broadcasting device can issue a first start command to initiate BLE broadcasting. Optionally, this first start command can be issued to BLE protocol stack A and link control A, etc. After receiving the first start command, BLE protocol stack A in the broadcasting device sets the broadcast parameters and then sends the broadcast parameters to link control A. Link control A generates a first BLE broadcast packet based on the broadcast parameters, then initiates the broadcast and broadcasts it through antenna A in the broadcasting device. Figure 6 (Not shown in the image) This first BLE broadcast packet is broadcast.
[0131] S602, the scanning device uses passive scanning mode to receive the first BLE broadcast packet.
[0132] In a specific implementation, the application B in the scanning device may issue a second start command to initiate BLE scanning. Optionally, this second start command may be issued to the BLE protocol stack B and the link control B, etc. The BLE protocol stack B in the scanning device sets the scanning parameters and, after setting, sends the scanning parameters to the link control B. These scanning parameters include the radio frequency (RF) and scanning mode used in the scanning process; in this step, the RF is low-power RF, and the scanning mode is passive scanning mode, etc. After receiving the scanning parameters, the link control B initiates scanning, that is, it receives the first BLE broadcast packet sent by the broadcast device in passive scanning mode. Specifically, the antenna B in the scanning device may receive the first BLE broadcast packet and then report it to the link control B.
[0133] After receiving the first BLE broadcast packet sent by antenna B, link control B sends it to BLE protocol stack B.
[0134] In some embodiments, the scanning device receives a first BLE broadcast packet sent by the broadcasting device in a passive scanning mode during a first scan cycle. Based on this embodiment, the scanning device uses low-power radio frequency (RF) operating in passive scanning mode to receive the BLE broadcast packet, allowing the scanning process to leverage the low-power advantages of RF. Therefore, within a reasonable power consumption range, the scan cycle can be appropriately increased or the scan duty cycle can be increased. For example, the scan cycle can be set to 60 milliseconds, or the duty cycle can be increased from the previous 3% to 7%–10%, thereby further improving the performance of the scanning device within a reasonable power consumption range.
[0135] S603, when the first BLE broadcast packet meets the first preset condition, the scanning device switches from passive scanning mode to active scanning mode.
[0136] In a specific implementation, after receiving the first BLE broadcast packet, protocol stack B determines the type of the first BLE broadcast packet based on the broadcast data in the broadcast data type field of the first BLE broadcast packet's data structure. If it is a broadcast packet of the specified type, it parses the first BLE broadcast packet to obtain the data information carried by the first BLE broadcast packet, and then sends this data information to application B through the host control interface. When application B determines that the first BLE broadcast packet meets the first preset condition based on its type and / or the data information it carries, it instructs the switch from passive scanning mode to active scanning mode.
[0137] For example, when protocol stack B receives the first BLE broadcast packet, if the broadcast data in the broadcast data type field of the first BLE broadcast packet determines that the first BLE broadcast packet is ADV_IND, the first BLE broadcast packet is parsed to obtain the data information carried by the first BLE broadcast packet. Then, BLE protocol stack B sends this data information to application B. Application B determines that the first BLE broadcast packet meets the first preset condition based on the type of the first BLE broadcast packet and / or the data information it carries, and then issues a first scan mode switching instruction to BLE protocol stack B to switch from passive scan mode to active scan mode. BLE protocol stack B sets the scan parameters according to the first scan mode switching instruction, and after setting, sends the scan parameters to link control B, so that link control switches from passive scan mode to active scan mode and completes the reception of subsequent BLE broadcast packets in active scan mode. The scanning parameters include the radio frequency (RF) used during the scanning process, the scanning mode, and the scan request information. In this step, the RF is the main RF, the scanning mode is the active scanning mode, and the scan request information may include a scan address field, an adv address field, and a scan request data field. The scan address field contains the public or random address of the scanning device, the adv address field contains the public or random address of the broadcasting device, and the scan request data field contains request information that instructs the broadcasting device to send the next BLE broadcast packet, such as the second BLE broadcast packet shown below.
[0138] Optionally, when application B receives the first BLE broadcast packet, if the broadcast data in the broadcast data type field of the first BLE broadcast packet structure determines that the first BLE broadcast packet is ADV_DIRECT_IND or ADV_NONCONN_IND, it means that it does not need to receive the next packet. Application B does not need to instruct to switch the scanning mode, and link control B maintains the current passive scanning mode and continues to receive other BLE broadcast packets broadcast by the broadcasting device.
[0139] In some embodiments, if during the process of setting broadcast parameters in the BLE protocol stack A of the broadcasting device, after the basic broadcast parameters are set, the broadcast parameters are sent to link control A, and at the same time, Scan_Request_Notification_Enable = Enable is set in LESet Extended Advertising Parameters in the Bluetooth standard protocol to enable receiving scan requests, then after the scanning device receives the first BLE broadcast packet sent by the broadcasting device, it will automatically switch from the current passive scanning mode to active scanning mode.
[0140] In this embodiment, the first preset condition includes at least one of the following:
[0141] 1) The first BLE broadcast packet is of the specified type.
[0142] For example, the specified type can be ADV_IND or ADV_SCAN_IND.
[0143] 2) The first BLE broadcast packet carries an instruction to the scanning device to receive the second BLE broadcast packet.
[0144] It should be understood that the effective field length of BLE broadcast packets sent by broadcast devices is relatively short, not exceeding 31 bytes. A single BLE broadcast packet can contain limited information. For example, when carrying device information in a BLE broadcast packet, there may be situations where the broadcast device cannot carry complete device information in a single packet. In practical applications, to ensure the accuracy of device identification and pairing, the scanning device also needs to obtain complete device information. Therefore, the broadcast device may send the device information in two or more BLE broadcast packets. In other words, when the number of bytes of data information to be carried in a BLE broadcast packet exceeds 31 bytes, the broadcast device can encapsulate the indication information along with the required data information in the BLE broadcast packet.
[0145] Based on this, the broadcasting device can include an instruction in the first BLE broadcast packet to the scanning device to receive the second BLE broadcast packet. This allows the scanning device to parse the first BLE broadcast packet upon receipt and, based on the obtained instruction, switch from passive scanning mode to active scanning mode. In active scanning mode, the scanning device can send a scan request to request the broadcasting device to send more device information. The second BLE broadcast packet can be the next data packet after the first BLE broadcast packet; for example, the first and second BLE broadcast packets can form relatively complete device information for the broadcasting device.
[0146] For example, the indication information could be "send scan request". When the scanning device confirms that the data information carries the indication information of "send scan request", it switches from the current passive scanning mode to active scanning mode to send the scan request in active scanning mode.
[0147] 3) The data information carried in the first BLE broadcast packet lacks the target information required to perform the service.
[0148] Based on the data information carried in the first BLE broadcast packet, the scanning device determines that some target information is missing from the data information. This target information is the target information that the scanning device needs when performing its business. For example, if the BLE broadcast packet sent by the broadcast device does not contain the device name, the scanning device switches from passive scanning mode to active scanning mode to request more information from the broadcast device.
[0149] 4) The data information carried by the first BLE broadcast packet includes information on the specified data format and data type.
[0150] The scanning device and the broadcasting device can pre-negotiate the data format or data type required to receive the next BLE broadcast packet from the broadcasting device. At this point, the scanning device can determine whether to switch the current scanning mode based on the data information carried in the first BLE broadcast packet.
[0151] In some embodiments, the scanning device determines whether it is the recipient of the first BLE broadcast packet based on the data information carried in the first BLE broadcast packet. Optionally, the scanning device can determine this based on the recipient's MAC address in the data information or other pre-negotiated or pre-defined rules. If the first BLE broadcast packet data is transmitted in encrypted form, decryption is required before the determination. If decryption is successful, the device is determined to be the designated recipient, and in this case, the scanning device needs to switch scanning modes. If decryption fails, or the ID does not match, or other rules are not met, the device is considered not to be the designated recipient. In this case, the scanning device does not need to switch scanning modes.
[0152] 5) The service corresponding to the data information carried by the first BLE broadcast packet is a specified service type.
[0153] In some embodiments, if the scanning device determines that the service corresponding to the data information carried in the first BLE broadcast packet is a specified service type, the scanning device needs to switch scanning modes. For example, if the scanning device determines that the service type corresponding to the data information is data sharing, and since data sharing typically requires the transmission of a large amount of data, the scanning device switches from passive scanning mode to active scanning mode to request more information from the broadcast device in active scanning mode.
[0154] S604, In active scanning mode, the scanning device sends a scanning request to the broadcasting device, instructing the broadcasting device to return the corresponding request information.
[0155] Since broadcasting devices broadcast BLE broadcast packets according to a fixed broadcast period, if the scanning device's processing speed is fast enough or its scanning period is low, it can determine the need to switch scanning modes before receiving the next first BLE broadcast packet from the broadcasting device, and complete the switch, then immediately send a scan request to the broadcasting device. If, due to processing power limitations or other constraints, the scanning device cannot complete the scan mode switch before receiving the next first BLE broadcast packet from the broadcasting device, it can issue a scan request upon receiving the next first BLE broadcast packet from the broadcasting device.
[0156] In a specific implementation, the link control B of the scanning device can send a scan request SCAN_REQ to the broadcasting device through antenna B. This scan request is used to instruct the broadcasting device to send the corresponding request information for the scan.
[0157] S605, after receiving a scan request, the broadcasting device returns a scan response to the scanning device, which carries the request information.
[0158] S606, When the second preset condition is met, the scanning device switches from active scanning mode to passive scanning mode.
[0159] The second preset condition includes at least one of the following:
[0160] 1) The scanning device did not receive the specified type of broadcast packet within the preset time.
[0161] For example, after the scanning device switches from passive scanning mode to active scanning mode, a timeout period is set, and if no broadcast packet of a specified type is received within the preset time, it switches from active scanning mode back to passive scanning mode.
[0162] 2) The number of times the scanning device fails to receive a broadcast packet of the specified type meets the preset number.
[0163] 3) Confirm that the reception of BLE broadcast packets in active scanning mode has been completed.
[0164] The scanning device, through the method provided in this application embodiment, can switch the current scanning mode from passive scanning mode to active scanning mode under preset conditions, i.e. when more data information needs to be acquired, thereby enabling the reception of more data information.
[0165] In summary, the embodiments of this application provide a method for switching scanning modes on demand, namely, passive scanning and active scanning are switched according to service triggers, and the scanning device operates in low-power radio frequency in passive scanning mode and in main radio frequency in active scanning mode. In this way, the low power consumption advantage of low-power radio frequency is utilized, while the balance between device power consumption and function is achieved.
[0166] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0167] This application also provides a Bluetooth communication device for use in an electronic device, which supports Bluetooth communication using both low-power radio frequency and main radio frequency. See also Figure 7 As shown, the device includes a receiving module 701 and a switching module 702.
[0168] The receiving module 701 is used to receive the first BLE broadcast packet in passive scanning mode. In passive scanning mode, the electronic device operates in low-power radio frequency.
[0169] The switching module 702 is used to switch from passive scanning mode to active scanning mode when the first BLE broadcast packet meets the first preset condition. In the active scanning mode, the electronic device operates on the main radio frequency.
[0170] This application also provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it is configured to perform the Bluetooth communication method shown in the above embodiments.
[0171] This application also provides a chip, see [link to relevant documentation] Figure 8 As shown, the chip includes a processor and a memory, in which a computer program is stored. When the computer program is executed by the processor, it implements the Bluetooth communication method in the above embodiments.
[0172] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the Bluetooth communication methods provided in the above embodiments.
[0173] This application also provides a computer program product, which includes a computer program that, when run by an electronic device, enables the electronic device to implement the Bluetooth communication method provided in the above embodiments.
[0174] It should be understood that the processor mentioned in the embodiments of this application can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0175] It should also be understood that the memory mentioned in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM).
[0176] In the embodiments provided in this application, the division of each framework or module is only a logical functional division. In actual implementation, there may be other division methods. For example, multiple frameworks or modules may be combined or integrated into another system, or some features may be ignored or not executed.
[0177] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.
[0178] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0179] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0180] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A Bluetooth communication method, characterized in that, Applied to an electronic device that supports Bluetooth communication using low-power radio frequency and main radio frequency, the method includes: The first BLE broadcast packet is received using a passive scanning mode, wherein the electronic device operates on the low-power radio frequency in the passive scanning mode; When the first BLE broadcast packet meets the first preset condition, the passive scanning mode is switched to the active scanning mode. In the active scanning mode, the electronic device operates on the main radio frequency.
2. The method according to claim 1, characterized in that, The first preset condition includes at least one of the following: The first BLE broadcast packet is of a specified type; The first BLE broadcast packet carries instruction information instructing the scanning device to receive the second BLE broadcast packet; The data information carried by the first BLE broadcast packet lacks the target information required to perform the service; The data information carried by the first BLE broadcast packet includes information on the specified data format and data type; The data information carried by the first BLE broadcast packet corresponds to a specified service type.
3. The method according to claim 2, characterized in that, The specified types include ADV_IND and ADV_SCAN_IND.
4. The method according to any one of claims 1 to 3, characterized in that, The step of switching from passive scanning mode to active scanning mode when the first BLE broadcast packet meets the first preset condition includes: If the first BLE broadcast packet meets the first preset condition, a scan request is sent, and the scan request indicates the return of the request information corresponding to the scan request; Receive a scan response, which carries the request information.
5. The method according to any one of claims 1 to 4, characterized in that, The method further includes: If the first BLE broadcast packet does not meet the first preset condition, the passive scanning mode is continuously used to receive the third BLE broadcast packet, which may be the same as or different from the first BLE broadcast packet.
6. The method according to any one of claims 1 to 5, characterized in that, The method further includes: Under the condition that the second preset condition is met, the active scanning mode is switched to the passive scanning mode.
7. The method according to claim 6, characterized in that, The second preset condition includes at least one of the following: No broadcast packet of the specified type was received within the preset time; The number of consecutive times no broadcast packets of the specified type are received meets the preset limit; It has been confirmed that the reception of BLE broadcast packets in the active scanning mode has been completed.
8. An electronic device, characterized in that, The method includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the method as described in any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method as described in any one of claims 1 to 7.
10. A chip, characterized in that, The chip includes a processor and a memory, the memory storing a computer program that, when executed by the processor, implements the method as described in any one of claims 1 to 7.
11. A computer program product, characterized in that, The computer program product includes a computer program / instruction that, when executed by a processor / electronic device, implements the method as described in any one of claims 1 to 7.