WO2023246648A1 - 蓝牙数据的处理方法、终端设备和可读存储介质 - Google Patents

蓝牙数据的处理方法、终端设备和可读存储介质 Download PDF

Info

Publication number
WO2023246648A1
WO2023246648A1 PCT/CN2023/100748 CN2023100748W WO2023246648A1 WO 2023246648 A1 WO2023246648 A1 WO 2023246648A1 CN 2023100748 W CN2023100748 W CN 2023100748W WO 2023246648 A1 WO2023246648 A1 WO 2023246648A1
Authority
WO
WIPO (PCT)
Prior art keywords
service
bluetooth
information
target
processing unit
Prior art date
Application number
PCT/CN2023/100748
Other languages
English (en)
French (fr)
Inventor
郝良
王书峰
董福琦
王金成
张静静
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2023246648A1 publication Critical patent/WO2023246648A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/80Services using short range communication, e.g. near-field communication [NFC], radio-frequency identification [RFID] or low energy communication

Definitions

  • the embodiments of the present application relate to the field of Bluetooth technology, and in particular, to a Bluetooth data processing method, a terminal device, and a readable storage medium.
  • BT Bluetooth
  • the Bluetooth protocol stack and the open interface (Framework interface) implemented by the Bluetooth service are usually deployed on the application processor (application processor, AP) of the smart terminal device at the same time, and the AP processes the relevant Bluetooth data. .
  • the AP will always be in working state, and the working current of the AP is usually large, resulting in serious power consumption of the terminal device.
  • Embodiments of the present application provide a Bluetooth data processing method, a terminal device, and a readable storage medium, which reduce the power consumption of the terminal device.
  • a Bluetooth data processing method is provided, which is applied to a terminal device.
  • the terminal device includes a main processing unit, an auxiliary processing unit and a Bluetooth chip;
  • the Bluetooth data processing method includes: the Bluetooth chip receives the first Bluetooth data; if the Bluetooth When the chip determines that the first Bluetooth data meets the preset conditions, it sends the first Bluetooth data to the auxiliary processing unit; the auxiliary processing unit processes the first Bluetooth data.
  • the first aspect provides a method for processing Bluetooth data.
  • Some Bluetooth services are deployed on the auxiliary processing unit of the terminal device for processing.
  • the Bluetooth chip has the ability to filter Bluetooth data and sends Bluetooth data that meets the preset conditions to the auxiliary processing unit for processing.
  • the Bluetooth data that originally needs to be processed by the main processing unit of the terminal device is diverted, thereby shortening the working time of the main processing unit, thereby reducing the power consumption of the terminal device and improving the battery life of the terminal device.
  • the Bluetooth chip determines that the first Bluetooth data meets the preset conditions, including: the Bluetooth chip parses the first Bluetooth data to obtain the first device identifier and the first logical channel index; if the first device identifier and The first logical channel index is in the information list, and the Bluetooth chip determines that the first Bluetooth data meets the preset conditions; the information list is used to store the device identification of the target device and the logical channel information of the target service, and the auxiliary processing unit is used to process the Bluetooth of the target service. data.
  • an information list is stored in the Bluetooth chip, and the information list stores relevant information of the Bluetooth service deployed and processed on the auxiliary processing unit and the device identification of the target device.
  • the Bluetooth chip has the ability to parse and filter Bluetooth data. The Bluetooth chip parses the first Bluetooth data to obtain the first device identifier and the first logical channel index. If the first device identifier and the first logical channel index are in the information list, it means that the first Bluetooth data needs to be processed on the auxiliary processing unit.
  • the Bluetooth data processing method also includes: if the first device identifier or the first logical channel index is not in the information list, the Bluetooth chip sends the first Bluetooth data to the main processing unit; the main processing unit processes the first Bluetooth data.
  • the Bluetooth data processing method also includes: if the first device identifier or the first logical channel index is not in the information list, the Bluetooth chip sends the first Bluetooth data to the main processing unit; the main processing unit processes the first Bluetooth data.
  • One Bluetooth data is not in the information list.
  • the first device identifier or the first logical channel index is not in the information list, it means that the first Bluetooth data does not need to be processed on the auxiliary processing unit, but is still processed by the main processing unit.
  • the Bluetooth data processing method also includes: the auxiliary processing unit generates the second Bluetooth data of the target service; the auxiliary processing unit sends the second Bluetooth data to the Bluetooth chip; the Bluetooth chip encapsulates the second Bluetooth data. , get the data to be sent; the Bluetooth chip sends the data to be sent to the target device.
  • the terminal device serves as a data sending end and sends data of the target service to the target device.
  • the auxiliary processing unit By processing the data of the target service through the auxiliary processing unit, the energy consumption of the terminal device is reduced and the battery life is extended.
  • the Bluetooth chip before the Bluetooth chip receives the first Bluetooth data, it also includes: the main processing unit sending the first MAC address of the target device and the first service information of the target service to the auxiliary processing unit; the target device is and the terminal device For Bluetooth communication equipment, the first service information is used to assist the processing unit in processing the Bluetooth data of the target service; the auxiliary processing unit sends the first MAC address and the second service information to the Bluetooth chip; the second service information is part of the first service information Or all the information; the Bluetooth chip adds the device identification of the target device and the logical channel information of the target service to the information list based on the first MAC address and the second service information; the device identification of the target device and the logical channel information of the target service are used for Bluetooth The chip processes Bluetooth data for the target service.
  • some Bluetooth services are moved from the main processing unit to the auxiliary processing unit for processing.
  • the main processing unit and the auxiliary processing unit synchronize the first service information of the target service with the MAC address of the target device, and transmit the second service information of the target service with the MAC address of the target device between the auxiliary processing unit and the Bluetooth chip, thereby, the auxiliary processing unit And the Bluetooth chip learns that the target service is processed on the auxiliary processing unit.
  • the auxiliary processing unit and Bluetooth chip can process the Bluetooth data of the target service, diverting the Bluetooth data that originally needs to be processed by the main processing unit of the terminal device, thus shortening the working time of the main processing unit and thus reducing the cost of the terminal device. Power consumption improves the battery life of terminal equipment.
  • the device identifier of the target device includes an ACL identifier.
  • the terminal device and the target device support the GATT protocol
  • the target service includes at least one feature
  • the first service information, the second service information, and the logical channel information of the target service including: the target feature in at least one feature.
  • the first service information also includes: UUID of the target service, and the first service information is used to assist the processing unit in processing the Bluetooth data of the target feature.
  • the target feature needs to be enabled; the first service information, the second service information and The logical channel information of the target service also includes: the logical channel index of the target feature descriptor.
  • the logical channel index of the descriptor of the target feature is used to enable the target feature, and the main processing unit and/or the auxiliary processing unit can enable the target feature.
  • the target feature is not enabled by the main processing unit.
  • the main processing unit does not enable the target features, and the auxiliary processing unit needs to complete the enabling of the target features. Therefore, the first service information, the second service information and the logical channel information of the target service need to include the logical channel index of the descriptor of the target feature, so that the auxiliary processing unit enables the target feature.
  • the Bluetooth chip before the Bluetooth chip receives the first Bluetooth data, it further includes: a main processing unit and/or an auxiliary processing unit enabling the target feature.
  • the terminal device and the target device support the RFCOMM protocol; the first service information and the second service information include: the logical channel number of the target service and the role of the target service; where the role is client or service end.
  • the first service information also includes the UUID of the target service.
  • the method further includes: the main processing unit sending the message to the Bluetooth chip.
  • Channel information the channel information includes the second MAC address of the target device and the DLCI of the target service; accordingly, the Bluetooth chip adds the device identification of the target device and the logic of the target service to the information list based on the first MAC address and the second service information.
  • the channel information includes: the Bluetooth chip adds the device identification of the target device and the logical channel information of the target service to the information list based on the first MAC address, the second service information, the second MAC address and the DLCI.
  • the Bluetooth chip adds the device identification of the target device and the logical channel information of the target service to the information list based on the first MAC address, the second service information, the second MAC address and the DLCI, including: if the first The first MAC address and the second MAC address are the same, and the Bluetooth chip determines the device identification of the target device based on the first MAC address or the second MAC address; the Bluetooth chip obtains the logical channel channel number to be compared and the role to be compared based on the DLCI; if it is to be compared If the logical channel channel number is the same as that of the target service, and the role to be compared is the same as the role of the target service, the Bluetooth chip will determine the DLCI as the logical channel information of the target service; add the device of the target device to the information list Logo and DLCI.
  • the Bluetooth data processing method further includes: the main processing unit sends first information to the auxiliary processing unit; the first information is used to instruct the main processing unit to process the Bluetooth data of the target service; the auxiliary processing unit performs the processing according to the first The information deletes the first service information; the auxiliary processing unit sends the second information to the Bluetooth chip; the second information is used to instruct the main processing unit to process the Bluetooth data of the target service; the Bluetooth chip deletes the logical channel of the target service in the information list according to the second information information.
  • the target service can be redeployed on the main processing unit. Therefore, the relevant information of the target service needs to be deleted between the main processing unit, the auxiliary processing unit and the Bluetooth chip, so that the main processing unit can process the Bluetooth data of the target service.
  • the information list includes a device list and a sinking service list; the device list includes a device identifier of the target device, and the sinking service list includes a device identifier of the target device and logical channel information of the target service.
  • the terminal device is a client of the target service
  • the target device is a client of the target service. Server.
  • a Bluetooth data processing device which can be applied to terminal equipment.
  • the Bluetooth data processing device includes: a receiving module for receiving the first Bluetooth data; a first processing module for sending the first Bluetooth data to the second processing module when it is determined that the first Bluetooth data meets the preset conditions; Two processing modules, used to process the first Bluetooth data.
  • the first processing module is configured to: parse the first Bluetooth data to obtain the first device identifier and the first logical channel index; if the first device identifier and the first logical channel index are in the information list, then It is determined that the first Bluetooth data meets the preset conditions; the information list is used to store the device identification of the target device and the logical channel information of the target service, and the second processing module is used to process the Bluetooth data of the target service.
  • the first processing module is also configured to: if the first device identification or the first logical channel index is not in the information list, send the first Bluetooth data to the third processing module; the third processing module, Used to process the first Bluetooth data.
  • the second processing module is also used to: generate second Bluetooth data of the target service, and send the second Bluetooth data to the first processing module; the first processing module is also used to: process the second Bluetooth data Encapsulation is performed to obtain the data to be sent; the Bluetooth data processing device also includes a sending module for sending the data to be sent to the target device.
  • the third processing module is also configured to: before the receiving module receives the first Bluetooth data, send the first MAC address of the target device and the first service information of the target service to the second processing module; the target device For a device that communicates with the terminal device via Bluetooth, the first service information is used by the second processing module to process the Bluetooth data of the target service; the second processing module is also used to: send the first MAC address and the second service information to the first processing module; The second service information is part or all of the information in the first service information; the first processing module is also used to: add the device identification of the target device and the logic of the target service to the information list according to the first MAC address and the second service information.
  • Channel information; the device identification of the target device and the logical channel information of the target service are used by the first processing module to process the Bluetooth data of the target service.
  • the device identifier of the target device includes an ACL identifier.
  • the terminal device and the target device support the GATT protocol
  • the target service includes at least one feature
  • the first service information, the second service information, and the logical channel information of the target service including: the target feature in at least one feature.
  • the first service information also includes: UUID of the target service, and the first service information is used by the second processing module to process the Bluetooth data of the target feature.
  • the target feature needs to be enabled; the first service information, the second service information and the logical channel information of the target service also include: the logical channel index of the descriptor of the target feature.
  • the target feature is not enabled by the third processing module.
  • the third processing module and/or the second processing module are also configured to enable the target feature before the receiving module receives the first Bluetooth data.
  • the terminal device and the target device support the RFCOMM protocol; the first service information and the second service information include: the logical channel number of the target service and the role of the target service; where the role is client or service end.
  • the first service information also includes the UUID of the target service.
  • the third processing module is also used to: send channel information to the first processing module;
  • the channel information includes the second MAC address of the target device and the DLCI of the target service;
  • the first processing module is used to: add the device of the target device to the information list according to the first MAC address, the second service information, the second MAC address and the DLCI.
  • Logical channel information identifying and targeting the service.
  • the first processing module is configured to: if the first MAC address and the second MAC address are the same, determine the device identification of the target device according to the first MAC address or the second MAC address; obtain the device identification to be compared according to the DLCI The logical channel number and the role to be compared; if the logical channel number to be compared is the same as the logical channel number of the target service, and the role to be compared is the same as the role of the target service, then the DLCI is determined as the logical channel of the target service Information; add the device identification and DLCI of the target device to the information list.
  • the third processing module is also configured to: send first information to the second processing module, where the first information is used to instruct the third processing module to process the Bluetooth data of the target service; the second processing module is also configured to: : Delete the first service information according to the first information, and send the second information to the first processing module.
  • the second information is used to instruct the third processing module to process the Bluetooth data of the target service; the first processing module is also used to: according to the second Message deletes the logical channel information of the target service from the message list.
  • the information list includes a device list and a sinking service list; the device list includes a device identifier of the target device, and the sinking service list includes a device identifier of the target device and logical channel information of the target service.
  • the terminal device is a client of the target service
  • the target device is a server of the target service.
  • a terminal device including a processor and a Bluetooth chip.
  • the processor includes a main processing unit and an auxiliary processing unit.
  • the processor is coupled to a memory.
  • the processor executes a computer program stored in the memory to implement the first aspect. provided method.
  • a fourth aspect provides a program, which when executed by a processor is used to perform the method provided in the first aspect.
  • a computer-readable storage medium is provided. Instructions are stored in the computer-readable storage medium. When the instructions are run on a computer or processor, the method provided in the first aspect is implemented.
  • a sixth aspect provides a program product, the program product comprising a computer program, the computer program being stored in a readable storage medium, and at least one processor of the device being able to read the computer program from the readable storage medium. , the at least one processor executes the computer program so that the device implements the method provided in the first aspect.
  • Figures 1A to 1C are a set of schematic diagrams of application scenarios applicable to the embodiments of this application;
  • Figure 2 is a schematic structural diagram of a terminal device provided by an embodiment of the present application.
  • FIG. 3 is a schematic structural diagram of the Bluetooth protocol stack provided by the embodiment of the present application.
  • FIG. 4 is a schematic diagram of the GATT data structure provided by the embodiment of the present application.
  • Figure 5 is a schematic diagram of the logical channel management information of the rate meter service provided by the embodiment of the present application.
  • Figure 6 is a schematic diagram of a principle of processing Bluetooth data by a terminal device according to an embodiment of the present application.
  • Figure 7 is a schematic diagram of a principle of processing Bluetooth data by a terminal device in BLE communication provided by the embodiment of the present application.
  • Figure 8 is a schematic diagram of a principle of how a terminal device processes Bluetooth data in classic Bluetooth provided by an embodiment of the present application
  • Figure 9 is another schematic diagram of the principle of processing Bluetooth data by a terminal device according to an embodiment of the present application.
  • Figure 10 is a flow chart of a Bluetooth data processing method provided by an embodiment of the present application.
  • Figure 11 is a data structure in BLE communication provided by the embodiment of the present application.
  • Figure 12 is a data structure in classic Bluetooth communication provided by the embodiment of the present application.
  • Figure 13 is another flow chart of the Bluetooth data processing method provided by the embodiment of the present application.
  • Figure 14 is another schematic diagram of another principle of processing Bluetooth data by a terminal device in BLE communication provided by the embodiment of the present application.
  • Figure 15 is another flow chart of the Bluetooth data processing method provided by the embodiment of the present application.
  • Figure 16 is another schematic diagram of another principle of how a terminal device processes Bluetooth data in classic Bluetooth provided by an embodiment of the present application.
  • Figure 17 is another flow chart of the Bluetooth data processing method provided by the embodiment of the present application.
  • Figure 18 is a schematic structural diagram of a Bluetooth data processing device provided by an embodiment of the present application.
  • the Bluetooth data processing method provided by the embodiments of this application is suitable for scenarios where multi-core terminal devices process Bluetooth data.
  • FIGS. 1A to 1C show three application scenarios, but FIGS. 1A to 1C do not limit the application scenarios of the embodiments of the present application.
  • the user uses an exercise bike to exercise and wears a smart watch.
  • Both exercise bikes and smartwatches support Bluetooth functionality.
  • An application (APP) with exercise management functions is installed on the smart watch.
  • the embodiment of this application does not limit the name of the APP, for example, sports and health APP.
  • the exercise bike and the smart watch communicate via Bluetooth, the exercise bike continuously reports relevant data to the smart watch through Bluetooth communication while the user is exercising.
  • the smart watch receives relevant data through Bluetooth communication, and displays the exercise information in the interface of the sports health APP after processing, so that users can view the details of the exercise during exercise and adjust the exercise status in time.
  • an exercise bike and a smartwatch communicate via Bluetooth low energy (BLE).
  • BLE Bluetooth low energy
  • both the mobile phone and the smart watch support Bluetooth functionality.
  • APPs with message notification functions are installed on mobile phones and smart watches.
  • the system application that comes with the device is called a message notification APP.
  • the mobile phone and the smart watch communicate via Bluetooth.
  • the mobile phone receives a prompt message, as shown in Figure 1B.
  • a prompt box 11 pops up in the current interface of the mobile phone.
  • the prompt box 11 includes a prompt message, the content of which is "Xiao Ming: What are you going to eat tonight?".
  • the mobile phone sends prompt information to the smart watch through Bluetooth communication.
  • the smart watch receives the prompt information and displays it after processing. See the display content of the smart watch in Figure 1B.
  • the phone and smartwatch communicate via classic Bluetooth.
  • both the mobile phone and the smart watch support the Bluetooth function.
  • Mobile phones and smart phones Applications with sports management functions are installed on the watch, such as sports health APP.
  • the mobile phone and the smart watch communicate via Bluetooth. After the smart watch completes the collection of sports and health data, it sends it to the mobile phone through Bluetooth communication.
  • the mobile phone receives the sports and health data through Bluetooth communication, and displays it in the relevant interface of the sports and health APP after processing. For details, see the current display content of the mobile phone in Figure 1C.
  • the display of the mobile phone makes up for the shortcomings of the poor user experience of the smart watch due to the small screen, and improves the user experience.
  • the phone and smartwatch communicate via classic Bluetooth.
  • the multi-core terminal device in the embodiment of this application means that the processor of the terminal device includes at least two processing units.
  • the embodiments of this application do not limit the number, name, and type of processing units.
  • the processor may include but is not limited to the following processing units: application processor (AP), microcontroller unit (MCU), graphics processing unit (GPU), image signal processor (image signal processor) , ISP), digital signal processor (digital signal processor, DSP), or neural network processor (neural-network processing unit, NPU), etc.
  • AP application processor
  • MCU microcontroller unit
  • GPU graphics processing unit
  • image signal processor image signal processor
  • ISP image signal processor
  • DSP digital signal processor
  • neural network processor neural-network processing unit
  • At least one processing unit may be called a main processing unit, and at least one processing unit other than the main processing unit may be called an auxiliary processing unit.
  • the embodiments of this application do not limit the number, name, and type of main processing units and auxiliary processing units.
  • the main processing unit may also be called a main processor or a main core
  • the auxiliary processing unit may also be called an auxiliary processor, a slave processing unit, a slave processor or a slave core.
  • FIG. 2 is a schematic structural diagram of a terminal device provided by an embodiment of the present application.
  • the terminal device includes: a main processing unit 21, an auxiliary processing unit 22, a Bluetooth (BT) chip 23, a memory 24, a sensor 25, a power module 26 and a display 27.
  • BT Bluetooth
  • the main processing unit 21 is used to run the operating system of the terminal device, deploy the Bluetooth protocol stack, Bluetooth services, Bluetooth open interfaces, etc.
  • the auxiliary processing unit 22 is used to communicate with the sensor 25, collect and process the data of the sensor 25. Compared with the main processing unit 21, the auxiliary processing unit 22 can also run a lightweight operating system. In this embodiment of the present application, the auxiliary processing unit 22 is also used to process the Bluetooth data of the offload service. Offload services refer to Bluetooth services deployed and processed on the auxiliary processing unit.
  • the BT chip 23 used for Bluetooth connection and data transmission with other devices.
  • the BT chip 23 can distinguish and filter the Bluetooth data for the sinking services, and send the Bluetooth data of the sinking services to the auxiliary processing unit 22 .
  • the BT chip 23 is also used to protocol-encapsulate the Bluetooth data of the downlink service sent by the auxiliary processing unit 22 and send it to the target device.
  • Memory 24 is used to store executable program codes and/or data, and the executable program codes may include instructions.
  • the memory 24 may include a program storage area and a data storage area.
  • the memory 24 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, hard disk drive (HDD), solid-state drive (SS), flash memory device, general purpose Flash memory (universal flash storage, UFS), etc., can also include volatile memory (volatile memory), such as random-access memory (random-access memory, RAM).
  • the sensor 25 may include, but is not limited to, at least one of the following: pressure sensor, gyro sensor, air pressure sensor, magnetic sensor, acceleration sensor, distance sensor, proximity light sensor, fingerprint sensor, Temperature sensor, touch sensor, ambient light sensor, or bone conduction sensor.
  • the power module 26 is used to connect a power source (such as a battery) to supply power to modules or components in the terminal equipment. It can also monitor battery capacity, battery cycle times, battery health status (leakage, impedance) and other parameters.
  • a power source such as a battery
  • FIG. 2 does not limit the structure of the terminal device.
  • the terminal device may include more or fewer components than shown in the figure, or some components may be combined, or some components may be separated, or may be arranged differently.
  • the components illustrated may be implemented in hardware, software, or a combination of software and hardware.
  • the terminal device may also include at least one of the following: a mobile communication module, an audio module, a camera, a microphone, a headphone interface, an antenna, etc.
  • a terminal device may also be called a terminal, an electronic device, a communication device, a user device, etc.
  • Some examples of terminal devices are: mobile phones, tablets, PDAs, wearable devices, mobile internet devices (MID), virtual reality (VR) devices, augmented reality (AR) devices, Or terminals in smart homes, etc.
  • the main processing unit is an AP
  • the auxiliary processing unit is an MCU
  • the terminal device is a smart watch
  • the device that communicates with the smart watch via Bluetooth is a sports bicycle. Or take a mobile phone as an example to illustrate.
  • Bluetooth communication can include the classic Bluetooth part and the BLE part.
  • Bluetooth protocol standard 4.0 and below is mainly the classic Bluetooth part
  • BLE corresponds to Bluetooth protocol standard 4.0 or higher protocol version.
  • BLE is developed based on classic Bluetooth.
  • Classic Bluetooth is usually used for transmission of relatively large amounts of data, such as voice, music, etc.
  • BLE has the characteristics of low cost, low power consumption, and high real-time requirements.
  • Classic Bluetooth also includes basic rate (BR) and enhanced data rate (EDR). Compared with BR, EDR has a higher transmission rate, for example, it can reach 8 times the BR rate.
  • BR basic rate
  • EDR enhanced data rate
  • FIG. 3 is a schematic structural diagram of a Bluetooth protocol stack provided by an embodiment of the present application.
  • the Bluetooth protocol stack includes a host (Host), a controller (Controller) and a host controller interface (HCI).
  • HCI is used to standardize the communication protocol and communication commands between the host and the controller.
  • the host is deployed on the main processing unit (such as AP), and the controller is deployed on the BT chip.
  • the main processing unit such as AP
  • the controller is deployed on the BT chip.
  • the controller can be represented as BR/EDR Controller, including: radio frequency layer (RF), baseband layer (Baseband) and link management protocol (link management protocol, LMP).
  • RF radio frequency layer
  • Baseband baseband layer
  • LMP link management protocol
  • the radio frequency layer is used to send or receive data etc.
  • the baseband layer is used for modulation and demodulation of data, etc.
  • the link management layer is used to manage and control links.
  • High-level protocols in the host include but are not limited to: logical link control and adaptation protocol (L2CAP), radio frequency communication protocol (radio frequency communication, RFCOMM), service discovery protocol (service discovery protocol, SDP), etc.
  • L2CAP logical link control and adaptation protocol
  • RFCOMM radio frequency communication protocol
  • SDP service discovery protocol
  • the controller can be represented as LE Controller or BLE Controller, including: physical layer (PHY) and link layer (LL).
  • PHY physical layer
  • LL link layer
  • the physical layer is used to select wireless frequency bands, modulation and demodulation methods, send and receive data, etc.
  • the link layer is used to manage and control links, determine the sending time of data packets, select radio frequency channels, and implement feedback and retransmission of data packets.
  • the high-level protocols in the host may include but are not limited to: L2CAP, attribute protocol (ATT), generic attribute profile (GATT), etc.
  • L2CAP attribute protocol
  • ATT attribute protocol
  • GATT generic attribute profile
  • Bluetooth services are composed of two types (or roles), including: client and server.
  • a connection needs to be established first.
  • the party that initiates the connection request is called the client, and the party that receives the connection request is called the server.
  • the server can provide data services.
  • the server Before the client initiates a connection request, the server needs to be in a listening state to listen for whether there is a client requesting to establish a connection. When the server listens to the client's connection request, the server can choose to establish the connection or reject the connection.
  • the Bluetooth services provided by the sports bicycle include a power meter, cadence meter, speed meter, etc.
  • the rate meter as an example, the two roles of the rate meter include the rate data server and the rate data reading client.
  • the smart watch acts as a rate data reading client and initiates a connection request to the sports bicycle.
  • the exercise bike accepts connection requests and establishes Bluetooth connections. The exercise bike can then send rate data to the smartwatch.
  • the smart watch displays the rate information after processing.
  • both mobile phones and smart watches support message notification services.
  • the two roles of the message notification service include the message notification server and the message notification client.
  • the smart watch acts as a message notification client and initiates a connection request to the mobile phone; accordingly, the mobile phone acts as a message notification server, accepts the connection request and establishes a Bluetooth connection. Afterwards, the mobile phone can send notification information to the smart watch; accordingly, the smart watch receives the notification information, processes it, and displays the notification information.
  • both mobile phones and smart watches are installed with sports and health APPs.
  • the two roles of sports health service include sports health server and sports health client.
  • sports health server As a sports and health client, the mobile phone initiates a connection request to the smart watch; accordingly, the smart watch, as a sports and health server, accepts the connection request and establishes a Bluetooth connection with the mobile phone.
  • a device can act only as a client, only as a server, or as both a client and a server. This is related to factors such as the software development of the Bluetooth service and the type of device.
  • the server can send data to the client as a data sender, and accordingly, the client can receive data sent by the server as a data receiver; or, the client can send data to the server as a data sender, Correspondingly, the server serves as the data receiver to receive the data sent by the client.
  • the terminal device acting as a client or server, can learn the Bluetooth services it supports.
  • the terminal device can learn the Bluetooth services provided by the server through processes such as service discovery, service query or device query. Processes such as service discovery, service query or device query can be found in the Bluetooth protocol.
  • Bluetooth services have logical channel management information to distinguish different Bluetooth services.
  • Bluetooth communication methods are different, the Bluetooth protocols used are different, and the logical channel management information of the Bluetooth service is also different.
  • BluetoothSocket In classic Bluetooth, a Socket (socket) connection is used between the client and the server of the Bluetooth service, also called a BluetoothSocket connection.
  • the connection process of BluetoothSocket is implemented through the RFCOMM protocol.
  • the logical channel channel (channel) number of the logical channel corresponding to the Bluetooth service is involved.
  • the RFCOMM channel has a data link connection identifier (DLCI).
  • the logical channel management information of the Bluetooth service can include but is not limited to: the universal unique identifier (UUID) of the Bluetooth service, the logical channel channel number of the Bluetooth service, the role of the Bluetooth service, and, DLCI for Bluetooth services.
  • UUID universal unique identifier
  • the roles include client and server.
  • DLCI has a conversion relationship with logical channel channel numbers and roles. Based on this conversion relationship, the DLCI can be calculated based on the logical channel number and role. Correspondingly, the logical channel number and role corresponding to the DLCI can be obtained through the DLCI.
  • DLCI can refer to Bluetooth related protocols.
  • DLCI can be used by the Bluetooth chip to filter and distinguish different Bluetooth services, so that the data of different Bluetooth services can be sent to the main processing unit or the auxiliary processing unit for processing.
  • the terminal device can obtain the logical channel number of the Bluetooth service from the server of the Bluetooth service. If the terminal device serves as the server of the Bluetooth service, the terminal device can directly obtain the logical channel number of the Bluetooth service.
  • the Bluetooth service is a message notification service.
  • the smart watch is the client of the message notification service
  • the mobile phone is the server of the message notification service.
  • the smart watch receives the logical channel channel number of the message notification service sent by the mobile phone.
  • the role is the client, and the DLCI can be calculated based on the logical channel number of the message notification service and the role (client).
  • the logical channel management information of the message notification service includes: the logical channel number of the message notification service, the role of the smart watch in the message notification service (client), and the DLCI.
  • BLE supports the GATT protocol, and the GATT connection is used between the client and the server of the Bluetooth service.
  • GATT protocol Bluetooth services are described through a data hierarchy.
  • FIG. 4 is a schematic diagram of the GATT data structure provided by the embodiment of the present application.
  • each service includes at least one character.
  • Character may include at least one descriptor (descriptor or description information); alternatively, character (characteristic) may not include a descriptor (descriptor).
  • Character has characteristic attributes (properties), such as broadcast, read, Write, notify, indicate, etc. Assume that device A and device B communicate via Bluetooth. For device B, through reading (read) and writing (write), device A can be notified to request data from device B. Device B can send data to device A by notifying, and accordingly, device A receives the data reported by device B by notifying.
  • characteristic attributes such as broadcast, read, Write, notify, indicate, etc. Assume that device A and device B communicate via Bluetooth. For device B, through reading (read) and writing (write), device A can be notified to request data from device B. Device B can send data to device A by notifying, and accordingly, device A receives the data reported by device B by notifying.
  • feature attributes need to be enabled to take effect, such as notification (notify) and indication (indicate). At this time, it can be described as a character (feature) needs to be enabled. Therefore, if the characteristic attribute of character needs to be enabled, or in other words, character needs to be enabled, then character must include descriptor, which is used by the client to enable or disable character. (feature).
  • the logical channel management information of the Bluetooth service includes but is not limited to: the UUID of the Bluetooth service, the logical channel index and the characteristic attribute (property) of the character (feature) included in the Bluetooth service. If the character (characteristic) includes a descriptor (descriptor), the logical channel management information of the Bluetooth service also includes: the logical channel index of the character (characteristic) descriptor (descriptor). Among them, in some implementations, the logical channel index is also represented as value handle (value index, value handle, etc.) or instance id (instance identification).
  • the logical channel management information of the Bluetooth service will be exemplified below with reference to the scenario shown in Figure 1A and Figure 5 , but this does not form a limitation.
  • a sports health APP is installed on the smart watch.
  • the sports health APP has the ability to process data from three types of services: speed meter service (service 1, service 1), power meter service (service 2, service 2) and cadence meter service (service). 3. service3).
  • FIG. 5 is a schematic diagram of the logical channel management information of the rate meter service provided by an embodiment of the present application.
  • the rate meter service includes two features, identified as feature 1 and feature 2.
  • Feature 1 does not include descriptors
  • feature 2 includes descriptors.
  • Service, character, and descriptor all have attribute indexes (attribute handle) with different values, which can uniquely distinguish different services, characteristics, or descriptors.
  • the attribute index value of the rate meter service is 22, the attribute index value of feature 1 in the rate meter service is 23, the attribute index value of feature 2 in the rate meter service is 25, and the descriptor of feature 2 in the rate meter service
  • the attribute index value of is 27.
  • Character (feature) has a value handle (value index), which refers to the index value corresponding to the value of the feature.
  • a feature of the rate meter can be matched through the attribute index (attribute handle), and the value of the rate meter feature can be matched through the value handle (value index). for example. Assume that feature 1 represents the speed value of the rate meter service.
  • the descriptor has a value handle (value index), and the value handle (value index) of the descriptor (descriptor) is the same as the attribute index (attribute handle).
  • the attribute index of the rate meter service has a value of 22.
  • the rate meter service includes 2 features.
  • the attribute index of feature 1 takes the value 23, and the value index takes the value 24.
  • the attribute index of feature 2 takes the value 25, and the value index takes the value 26.
  • the characteristic attributes of characteristic 2 include notification and have descriptors.
  • the attribute index (or value index) of the descriptor of feature 2 takes the value 27.
  • the logical channel management information of the rate meter service may include: the UUID of the rate meter service, the logical channel index (value 24) and feature attributes of feature 1, the logical channel index (value 26) and feature attributes of feature 2, and, features The logical channel index of the descriptor of 2 (value 27).
  • the Bluetooth service is deployed on the main processing unit (such as AP) of the terminal device.
  • the AP processes the Bluetooth data of the Bluetooth service.
  • FIG. 6 is a schematic diagram of a principle of processing Bluetooth data by a terminal device according to an embodiment of the present application. Referring to the thick solid line in Figure 6, when the terminal device serves as the data receiver, the BT chip receives the Bluetooth data and sends it to the AP for processing; when the terminal device serves as the data sender, the AP encapsulates the Bluetooth data with the protocol and sends it to the BT chip. The BT chip sends the received data. It can be seen that the AP is always working.
  • the working current of AP is relatively large, which will increase the power consumption of terminal equipment.
  • the terminal device remains in a high power consumption state for a long time, and the battery capacity of the terminal device is limited, resulting in a significant decrease in the battery life of the terminal device.
  • Figure 7 is a schematic diagram of a principle of processing Bluetooth data by a terminal device in BLE communication provided by an embodiment of the present application. It should be noted that Figure 7 does not limit the structures of sports bicycles and smart watches.
  • the sports bicycle includes: BT chip, Bluetooth protocol stack, transmission module, Bluetooth service, sensors and display.
  • the sensor shows a rate meter sensor and a power meter sensor.
  • Bluetooth services are deployed at the application layer, including rate meter services and power meter services.
  • the sports bicycle serves as the server of the Bluetooth service.
  • the Bluetooth service includes: rate data server and power data server.
  • the transmission module is used to transmit data and can include but is not limited to: Commu module, universal asynchronous receiver/transmitter (UART), serial peripheral interface (Serial Peripheral Interface, SPI), etc.
  • the Commu module can realize the distribution of business data.
  • UART is a universal serial data bus used for asynchronous communication.
  • SPI is a high-speed, full-duplex, synchronous communication bus.
  • the Bluetooth protocol stack shows part of the Bluetooth protocol and logical channel management information.
  • Bluetooth protocols include but are not limited to GATT, ATT, L2CAP and HCI.
  • the logical channel management information the logical channel management information corresponding to the rate meter service is identified as UINT1
  • the logical channel management information corresponding to the power meter service is identified as UINT2.
  • the smart watch includes: BT chip, MCU, AP and display.
  • the BT chip includes the RF module and the baseband layer/LL module. "/" represents the relationship of or. Please refer to the relevant description of the Bluetooth protocol stack above.
  • the MCU includes: transmission module, sensor, positioning module and other modules.
  • the transmission module is used to transmit data and can include but is not limited to: Commu module, UART, SPI, etc.
  • AP includes: Bluetooth protocol stack, BT Framework (interface), Bluetooth service and sports health APP.
  • the sports health APP is located at the application layer, that is, a third-party application, which can provide a variety of Bluetooth services, such as rate meter service and power meter service.
  • the smart watch acts as a client of the Bluetooth service, including: rate data reading client and power data reading client.
  • BT Framework is used to provide APIs for upper-layer applications to call to achieve Bluetooth capabilities.
  • provided APIs include BluetoothGATT.
  • the Bluetooth protocol stack shows part of the Bluetooth protocol and logical channel management information.
  • Bluetooth protocols include but are not limited to GATT, ATT, L2CAP and HCI.
  • the logical channel management information corresponding to the rate meter service is identified as UINT1
  • the logical channel management information corresponding to the power meter service is identified as UINT2.
  • the exercise bike After the exercise bike is turned on, it first registers the BLE GATT SERVER server to monitor the client's connection. Subsequently, the exercise bike initiates a BLE connectable broadcast. Smart watch runs sports and health After the APP, the sports health APP starts scanning the surrounding BLE devices by calling the BLE scanning interface provided by BT Framework. The BT chip starts scanning, obtains the scanning results, and sends the scanning results to the AP. The Bluetooth protocol stack parses the scan results and notifies the sports health APP through callbacks. The sports health APP obtains the scan results and obtains information such as the equipment broadcast name of the exercise bicycle and the media access control (MAC) address of the equipment.
  • MAC media access control
  • the sports health APP calls connectGATT provided by BT Framework to initiate the connection of the logical channel.
  • the sports health APP queries the Bluetooth service provided by the exercise bike through the discovery service provided by the BT Framework, and obtains the logical channel management information of the Bluetooth service.
  • the sports health APP enables the data reporting service of exercise bikes, exercise bikes can report relevant data to smart watches.
  • the BT chip of the smart watch receives the Bluetooth data sent by the exercise bike and sends it directly to the AP for processing. After the AP processes the Bluetooth data, it can send it to the display screen to achieve screen display.
  • the AP processes the Bluetooth data and sends it to the BT chip, and the BT chip sends the data received from the AP to the exercise bike.
  • FIG. 8 is a schematic diagram of a principle for processing Bluetooth data by a terminal device in classic Bluetooth provided by an embodiment of the present application. It should be noted that Figure 8 does not limit the structure of mobile phones and smart watches.
  • the mobile phone includes: BT chip, Bluetooth protocol stack, BT Framework, Bluetooth service and display.
  • the Bluetooth service is deployed at the application layer, showing message notification service and sports health service.
  • the mobile phone serves as the server of the message notification service, including: the message notification server.
  • Mobile phones can also be used as clients or servers of sports and health services, including: sports and health clients/servers.
  • BT Framework is used to provide APIs for upper-layer applications to call to achieve Bluetooth communication capabilities.
  • the provided API includes BluetoothSocket.
  • the Bluetooth protocol stack shows part of the Bluetooth protocol and logical channel management information.
  • Bluetooth protocols include but are not limited to RFCOMM, L2CAP and HCI.
  • the logical channel management information corresponding to the message notification service is identified as UINT1
  • the logical channel management information corresponding to the sports health service is identified as UINT2.
  • Bluetooth communication methods different Bluetooth protocols used, different APIs provided by BT Framework, and different implemented Bluetooth services.
  • classic Bluetooth communication is supported.
  • Bluetooth protocols include RFCOMM, L2CAP and HCI.
  • APIs provided by BT Framework include BluetoothSocket, etc.
  • Bluetooth services include message notification services and sports health services.
  • the smart watch serves as the client of the message notification service, including: message notification client.
  • Smart watches can also serve as a server or client for sports health services, including: sports health server/client.
  • the message on the mobile phone notifies the server, uses BluetoothServerSocket to create a listening server socket, and monitors the client's connection request.
  • a BluetoothSocket is returned to manage the connection.
  • Messages on the smartwatch notify the client, using a single BluetoothSocket to initiate and manage the connection.
  • the message notifies the client to initiate the establishment of the Bluetooth RFCOMM channel by calling the bluetooth socket connect interface provided by BT Framework.
  • the mobile phone when there is a notification message on the mobile phone, the mobile phone sends the notification message to the smart watch, causing the smart watch to display the notification message.
  • the smart watch serves as the data receiver.
  • the BT chip of the smart watch receives the notification message sent by the mobile phone and sends it directly to the AP for processing. After the AP processes the notification message, it can send it to the display screen to achieve screen display.
  • notification messages will be received on the mobile phone from time to time.
  • the mobile phone constantly reports notification messages to the smart watch, causing the AP of the smart watch to be in working state all the time, consuming a lot of power and reducing the battery life of the smart watch.
  • the embodiment of the present application provides a method for processing Bluetooth data.
  • the main processing unit (such as AP) on the terminal device can sink part of the Bluetooth service to the auxiliary processing unit (such as MCU) for management.
  • This part of the Bluetooth service can be called Offload business.
  • the main processing unit, auxiliary processing unit and BT chip need to synchronize the necessary data of sinking services.
  • the Bluetooth chip has the ability to parse, encapsulate and filter the Bluetooth data of sinking services. In this way, when the terminal device serves as the data receiver, after receiving the Bluetooth data, the BT chip analyzes the Bluetooth data.
  • the auxiliary processing unit When it is determined that the data is for the sinking service, it is sent to the auxiliary processing unit for processing; when it is determined that the data is not for the sinking service, it is sent to Main processing unit processing.
  • the terminal device serves as the data sender, for the downlink service, the auxiliary processing unit can send the downlink service data to the BT chip, and the BT chip encapsulates the data and sends it out.
  • the Bluetooth data processing method uses the auxiliary processing unit to process part of the Bluetooth data, thereby diverting the Bluetooth data that originally needs to be processed by the main processing unit, shortening the working time of the main processing unit, and reducing the terminal cost.
  • the power consumption of the device increases the battery life of the terminal device.
  • FIG. 9 is another schematic diagram of the principle of processing Bluetooth data by a terminal device according to an embodiment of the present application.
  • the terminal equipment includes AP91, MCU92 and BT chip 93.
  • the MCU 92 includes: a downlink management service module 921 and a Bluetooth service module 922.
  • the BT chip 93 includes: an interface module 931, an information list 932, and a protocol data parsing/encapsulation module 933.
  • the sinking management business module 921 is used to communicate with AP91 and provide API interfaces for upper-layer applications to call.
  • the API interface may include a data synchronization interface, a data desynchronization interface, etc.
  • the data synchronization interface is used to synchronize the first service information of the sinking service between AP91 and MCU92.
  • the data desynchronization interface is used to desynchronize the first service information of the sinking service between AP91 and MCU92.
  • the sinking management service module 921 is also used to communicate with the Bluetooth service module 922, and can call the API provided by the Bluetooth service module 922.
  • the Bluetooth business module 922 is used to communicate with the downlink management business module 921 and the BT chip 93 to realize communication between the MCU 92 and the BT chip 93 .
  • the Bluetooth service module 922 can provide an API interface for the downlink management service module 921 to call.
  • the API interface includes but is not limited to at least one of the following: virtual connection interface, registration interface, enabled service interface, read interface, write interface, or callback interface.
  • Bluetooth communication methods are different, such as classic Bluetooth and BLE, the API interfaces provided by the Bluetooth service module 922 are different. For details, please refer to the description of the embodiments shown in FIG. 15 and FIG. 17 .
  • the interface module 931 is used to communicate with the Bluetooth service module 922 to realize communication between the MCU 92 and the BT chip 93 .
  • the interface module 931 can provide an API interface.
  • API interfaces include but are not limited to at least one of the following: virtual connection interface, registration interface, enabled service interface, read interface, write interface, or callback interface.
  • the API interface provided by the interface module 931 is different. For details, see Figure 15 and description of the embodiment shown in Figure 17.
  • the information list 932 is used to store the device identification of the target device for Bluetooth communication with the terminal device, and to store the logical channel information of the sinking service.
  • the protocol data analysis/encapsulation module 933 is used to analyze the Bluetooth data received by the BT chip 93, and determine whether the received Bluetooth data belongs to the sinking service according to the device identification and logical channel information stored in the information list 932; if it belongs to the sinking service , then send it to MCU92 for processing; if it does not belong to the sinking service, then send it to AP91 for processing.
  • the protocol data parsing/encapsulation module 933 is also used to encapsulate the data of the downlink service received from the MCU 92, and then sends it to the target device.
  • AP91, MCU92 and BT chip 93 there is an inter-core communication interface between AP91, MCU92 and BT chip 93.
  • the communication between AP91 and BT chip 93 can be realized directly through the communication interface between AP91 and BT chip 93, or through MCU92.
  • Bluetooth service and service have the same meaning.
  • FIG 10 is a flow chart of a Bluetooth data processing method provided by an embodiment of the present application.
  • the execution subject of the Bluetooth data processing method provided in this embodiment may be a terminal device.
  • the terminal device includes a main processing unit, an auxiliary processing unit and a Bluetooth chip.
  • the terminal device and the target device have established a Bluetooth connection.
  • This embodiment does not limit the name and type of the target device.
  • the terminal device is a smart watch and the target device is a sports bicycle.
  • the terminal device is a smart watch and the target device is a mobile phone.
  • the terminal device is a mobile phone and the target device is a smart watch.
  • connection information includes but is not limited to: asynchronous connection-oriented link (ACL) identification and the MAC address of the target device.
  • ACL asynchronous connection-oriented link
  • the end device can also learn the Bluetooth services supported by the end device and the target device.
  • the Bluetooth data processing method provided by this embodiment may include:
  • the main processing unit sends the first MAC address of the target device and the first service information of the target service to the auxiliary processing unit.
  • the auxiliary processing unit receives the first MAC address and the first service information sent by the main processing unit.
  • the first service information is used to assist the processing unit in processing Bluetooth data of the target service.
  • the data transmitted between the main processing unit, the auxiliary processing unit and the Bluetooth chip all include the MAC address of the target device.
  • the MAC address of the target device sent by the main processing unit to the auxiliary processing unit is called the first MAC address.
  • the terminal device or target device can support multiple Bluetooth services.
  • the Bluetooth service deployed and processed on the auxiliary processing unit of the terminal device is called a target service, which can also be called an offload service.
  • the target service is the service provided by the server.
  • the terminal device can perform service discovery, service query or device query, etc. The process learns the Bluetooth service supported by the target device, and the target service is the Bluetooth service supported by the target device.
  • the target service is the Bluetooth service supported by the terminal device.
  • the Bluetooth service includes at least one character. All characters (features) included in the Bluetooth service can be deployed on the auxiliary processing unit; or some characters (features) in the Bluetooth service can be deployed on the auxiliary processing unit.
  • the Bluetooth protocols used are different, and the first service information is also different.
  • the target service includes at least one characteristic.
  • the first service information includes: the UUID of the target service, the logical channel index of the target feature in at least one feature, and the feature attribute. Reference may be made to the relevant description of the logical channel management information of the Bluetooth service mentioned above in this application.
  • the first service information is used to assist the processing unit in processing the Bluetooth data of the target feature. That is to say, the target feature in the target service is deployed on the auxiliary processing unit of the terminal device for processing. This embodiment does not limit the number of target features.
  • the first service information further includes: a logical channel index of the descriptor of the target feature.
  • the logical channel index of the target feature's descriptor is used to enable the target feature.
  • the target feature needs to be enabled, and either the main processing unit or the auxiliary processing unit can enable the target feature. If the target feature is not enabled by the main processing unit, then it needs to be enabled by the auxiliary processing unit.
  • the first service information needs to include the logical channel index of the descriptor of the target feature, so that the auxiliary processing unit enables the target feature. If the target feature has been enabled by the main processing unit, then the first service information does not need to include the logical channel index of the descriptor of the target feature, thereby avoiding repeated enabling of the target feature by the main processing unit and the auxiliary processing unit.
  • the first service information further includes: a logical channel index of the descriptor of the target feature.
  • the target feature needs to be enabled.
  • the first service information may include a logical channel index of the descriptor of the target feature.
  • the auxiliary processing unit may enable the target feature according to the logical channel index of the descriptor of the target feature.
  • the main processing unit and the auxiliary processing unit may repeatedly enable the target feature.
  • the main processing unit can send enabling information to the auxiliary processing unit, indicating whether the main processing unit enables the target feature.
  • enabling information By enabling information, repeated enabling of target features by the main processing unit and the auxiliary processing unit is avoided.
  • the enabling information may be included in the first service information.
  • the number of data transfers between the main processing unit and the auxiliary processing unit is reduced.
  • the first service information includes: the logical channel number of the target service and the role of the target service.
  • the role is client or server. Reference may be made to the relevant description of the logical channel management information of the Bluetooth service mentioned above in this application.
  • the first service information may also include the UUID of the target service.
  • the terminal device can serve as a client of the target service or as a server of the target service; accordingly, the target device can serve as a server of the target service or as a client of the target service.
  • a The application scenario can be: the terminal device serves as the client of the target service, the target device serves as the server of the target service, and the target service is the Bluetooth service supported by the target device.
  • the target device can send data of the target service to the terminal device.
  • the terminal device can also send data of the target service to the target device.
  • an application scenario can be: the terminal device serves as the server of the target service, the target device serves as the client of the target service, and the target service is the Bluetooth service supported by the terminal device.
  • the terminal device can send data of the target service to the target device.
  • the target device can also send data of the target service to the end device.
  • the downlink management service module 921 can enable the main processing unit to send the first MAC address and the first service information to the auxiliary processing unit by calling an API interface, such as a data synchronization interface.
  • the auxiliary processing unit sends the first MAC address and the second service information to the Bluetooth chip.
  • the second service information is part or all of the first service information.
  • the Bluetooth chip receives the first MAC address and the second service information sent by the auxiliary processing unit.
  • the second service information includes: the logical channel index and feature attributes of the target feature in at least one feature included in the target service.
  • the second service information may also include: the logical channel index of the descriptor of the target feature. Please refer to the description in S1001 and will not go into details here.
  • the second service information may also include: UUID of the target service.
  • the second service information includes: the logical channel number of the target service and the role of the target service; where the role is a client or a server.
  • the second service information may also include: UUID of the target service. It should be noted that if the first service information does not include the UUID of the target service, the second service information does not include the UUID of the target service. If the first service information includes the UUID of the target service, then the second service information may include the UUID of the target service, or may not include the UUID of the target service.
  • the downlink management business module 921, the Bluetooth business module 922 and the interface module 931 can realize that the auxiliary processing unit sends the first MAC address and the second service information to the Bluetooth chip by calling the relevant API interface.
  • the Bluetooth chip adds the device identification of the target device and the logical channel information of the target service to the information list based on the first MAC address and the second service information.
  • the device identification of the target device and the logical channel information of the target service are used by the Bluetooth chip to process the Bluetooth data of the target service.
  • the Bluetooth chip and auxiliary processing unit can then process the Bluetooth data for the target service.
  • the device identifier is used by the Bluetooth chip to uniquely distinguish different devices.
  • the device identification of the target device includes: the identification of the ACL link of the Bluetooth connection between the target device and the terminal device.
  • the ACL link identifier can be expressed as an ACL handle.
  • the logical channel information of the service can uniquely distinguish different Bluetooth services among all the Bluetooth services supported by a device.
  • the target service if the target service is a Bluetooth service supported by the target device, the target service can be uniquely identified among all Bluetooth services supported by the target device through the logical channel information of the target service; if the target service is a Bluetooth service supported by the terminal device, Bluetooth service, through the logical channel information of the target service, the target service can be uniquely identified among all Bluetooth services supported by the terminal device.
  • the logical channel information of the target service and the device identification of the target device are associated.
  • Bluetooth services are described using the hierarchical structure of "application-service-feature-descriptor". See Figure 4 and Figure 5.
  • the attribute handles of services, characteristics, and descriptors are ordered internally, which may result in the same logical channel information for different services supported by different devices.
  • the attribute index (attribute handle) range of the rate meter service supported by device 1 is 21-30
  • the attribute index (attribute handle) range of the power meter service is 31-40
  • the value handle (value index) of feature 1 in the rate meter service is ) takes a value of 25.
  • the attribute index (attribute handle) range of the power meter service supported by device 2 is 21-30, and the value handle (value index) of feature 1 in the power meter service is 25. It can be seen that for the value handle (value index) value 25, the corresponding services and features in device 1 and device 2 are different.
  • Device 1 corresponds to feature 1 of the rate meter service
  • device 2 corresponds to feature 1 of the power meter service. Therefore, the logical channel information of the target service and the device identification of the target device may have an associated relationship, and different services of different devices can be uniquely distinguished through the device identification of the target device and the logical channel information of the target service.
  • the Bluetooth protocols used are different, and the logical channel information of the target service is different.
  • the logical channel information of the target service includes: the logical channel index and feature attributes of the target feature in at least one feature included in the target service.
  • the logical channel information of the target service may also include: the logical channel index of the descriptor of the target feature. Please refer to the description in S1001 and will not go into details here.
  • the logical channel information of the target service includes the DLCI of the target service.
  • the DLCI of the target service may also be called the logical channel index of the target service.
  • the information list is used to store the device identification of the target device and the logical channel information of the target service.
  • This embodiment does not limit the implementation method of the information list. It may be a data list or a file in a preset format, it may be one data list or multiple data lists, or one file or multiple files.
  • the information list includes a device list and a sinking service list.
  • the device list includes the device ID of the target device.
  • the sinking service list includes the logical channel information of the target service.
  • the dropped service list may also include the device identifier of the target device, which may indicate the association between the device identifier of the target device and the logical channel information of the target service.
  • the Bluetooth chip adds the device identification of the target device and the logical channel information of the target service to the information list based on the first MAC address and the second service information, which may include:
  • the Bluetooth chip determines the device identification of the target device based on the first MAC address.
  • the Bluetooth chip determines the logical channel information of the target service based on the second service information.
  • the main processing unit sends the first MAC address and the first service information to the auxiliary processing unit, and the auxiliary processing unit sends the first MAC address and the second service information to the Bluetooth chip.
  • the Bluetooth chip can obtain the ACL handle of the target device based on the first MAC address, and determine the logical channel information of the target service based on the second service information.
  • the Bluetooth chip also includes: before adding the device identification of the target device and the logical channel information of the target service to the information list based on the first MAC address and the second service information:
  • the main processing unit sends channel information to the Bluetooth chip.
  • the channel information includes the target device's secondary MAC address and the DLCI of the target service.
  • the Bluetooth chip adds the target to the information list based on the first MAC address and the second service information.
  • the device identification of the device and the logical channel information of the target service including:
  • the Bluetooth chip adds the device identification of the target device and the logical channel information of the target service to the information list based on the first MAC address, the second service information, the second MAC address and the DLCI.
  • the Bluetooth chip adds the device identification of the target device and the logical channel information of the target service to the information list based on the first MAC address, the second service information, the second MAC address and the DLCI, including:
  • the Bluetooth chip determines the device identification of the target device based on the first MAC address or the second MAC address.
  • the Bluetooth chip obtains the logical channel number and role to be compared based on the DLCI.
  • the Bluetooth chip determines the DLCI as the logical channel information of the target service.
  • the channel information may also include the UUID of the target service.
  • the Bluetooth protocol stack at least calculates the DLCI of the service based on the logical channel number and role of the service. That is to say, other information is needed when calculating DLCI. When other information is different, the same logical channel channel The DLCI corresponding to the number and role may be different.
  • the main processing unit sends the second MAC address of the target device and the DLCI of the target service to the Bluetooth chip.
  • the main processing unit sends the first MAC address of the target device and the first service information of the target service to the auxiliary processing unit, and the auxiliary processing unit sends the first MAC address and the second service information to the Bluetooth chip.
  • the MAC address of the target device sent by the main processing unit to the auxiliary processing unit is called the first MAC address
  • the MAC address of the target device sent by the main processing unit to the Bluetooth chip is called the second MAC address.
  • the Bluetooth chip can determine the ACL handle of the target device based on the first MAC address or the second MAC address.
  • the Bluetooth chip calculates the channel number of the logical channel to be compared and the role to be compared based on the DLCI received from the main processing unit.
  • the Bluetooth chip will The DLCI received from the main processing unit determines the logical channel information serving the target.
  • the main processing unit of the terminal device can sink some Bluetooth services to the auxiliary processing unit for processing.
  • the main processing unit and the auxiliary processing unit synchronize the first service information of the target service with the MAC address of the target device, and transmit the second service information of the target service with the MAC address of the target device between the auxiliary processing unit and the Bluetooth chip, thereby, the auxiliary processing unit And the Bluetooth chip learns that the target service is processed on the auxiliary processing unit. Subsequently, the auxiliary processing unit and Bluetooth chip can process the Bluetooth data of the target service.
  • the Bluetooth data processing method provided in this embodiment transfers part or all of the Bluetooth data of the Bluetooth service processed by the main processing unit to the auxiliary processing unit for processing, forming a data offload and shortening the working time of the main processing unit. Since the power consumption of the auxiliary processing unit is smaller than that of the main processing unit, the power consumption of the terminal device is reduced and the battery life of the terminal device is extended.
  • the Bluetooth data processing method provided in this embodiment may also include:
  • the Bluetooth chip receives the first Bluetooth data.
  • the Bluetooth chip parses the first Bluetooth data and obtains the first device identifier and the first logical channel index. Determine whether the first device identification and the first logical channel index are in the information list.
  • the first device identifier and the first logical channel index are in the information list, it indicates that the first Bluetooth data is Bluetooth data of the target service and needs to be processed by the auxiliary processing unit, then execute S1006 and S1007.
  • the first device identifier or the first logical channel index is not in the information list, it means that the first Bluetooth data is not the Bluetooth data of the target service and needs to be processed by the main processing unit, then execute S1008 and S1009.
  • the Bluetooth chip sends the first Bluetooth data to the auxiliary processing unit.
  • the auxiliary processing unit processes the first Bluetooth data.
  • the Bluetooth chip sends the first Bluetooth data to the main processing unit.
  • the main processing unit processes the first Bluetooth data.
  • the terminal device serves as a data receiving end and receives and processes Bluetooth data sent by the target device.
  • the Bluetooth chip of the terminal device has protocol data parsing capability.
  • the protocol data parsing/encapsulation module 933 shown in Figure 9 parses the first device identifier and the first logical channel index from the first Bluetooth data. According to The information list determines whether the first Bluetooth data belongs to the target service. If it is the data of the target service, it is processed by the auxiliary processing unit, which reduces the energy consumption of the terminal device and extends the battery life.
  • Protocol data parsing/encapsulation will be exemplarily described with reference to Figures 11 and 12, but Figures 11 and 12 do not limit the data structure.
  • Figure 11 shows a data structure in BLE communication provided by the embodiment of the present application.
  • GATT data includes: type (TYPE), ACL handle (ACL HANDLE), ACL data length (ACL DATA LENGTH), L2CAP data length (L2CAP DATA LENGTH), L2CAP CID (communication identifier, communication identifier) , ATT operation code (ATT OPCODE), ATT handle (ATT Handle), ATT data (ATT DATA).
  • the type is specifically ACL.
  • the locations indicated by the four arrows in Figure 11 are, in order: the location where data parsing starts/the data encapsulation ends, the location of the device identification, the location of the logical channel information, and the location where the data parsing ends/the data encapsulation starts.
  • Figure 12 is a data structure in classic Bluetooth communication provided by the embodiment of the present application.
  • RFCOMM data includes: type (TYPE), ACL handle (ACL HANDLE), ACL data length (ACL DATA LENGTH), L2CAP data length (L2CAP DATA LENGTH), L2CAP CID, RFCOMM DLCI, RFCOMM control (RFCOMM CONTROL), RFCOMM data (RFCOMM DATA).
  • the type is specifically ACL.
  • the locations indicated by the four arrows in Figure 12 are: the location where data parsing starts/the data encapsulation ends, the location of the device identification, the location of the logical channel information, and the location where the data parsing ends/the data encapsulation starts.
  • the Bluetooth data processing method provided in this embodiment may also include:
  • the auxiliary processing unit generates second Bluetooth data of the target service.
  • the auxiliary processing unit sends the second Bluetooth data to the Bluetooth chip.
  • the Bluetooth chip encapsulates the second Bluetooth data according to the device identification of the target device and the logical channel information of the target service to obtain the data to be sent.
  • the Bluetooth chip sends the data to be sent to the target device.
  • the terminal device serves as a data sending end and sends data of the target service to the target device.
  • the auxiliary processing unit processes the data of the target service, it sends the second Bluetooth data to the Bluetooth chip.
  • the Bluetooth chip has protocol data encapsulation capability.
  • the protocol data parsing/encapsulation module 933 shown in Figure 9 encapsulates the second Bluetooth data according to the information list and sends it to the target device. Processing of target services by auxiliary processing units data, reducing the energy consumption of terminal equipment and extending battery life.
  • FIG. 13 is another flow chart of a Bluetooth data processing method provided by an embodiment of the present application.
  • the Bluetooth data processing method provided by this embodiment may also include:
  • the main processing unit sends the first information to the auxiliary processing unit.
  • the first information is used to instruct the main processing unit to process Bluetooth data of the target service.
  • the first information may include the first MAC address of the target device and the first service information of the target service.
  • the downlink management business module 921 can enable the main processing unit to send the first information to the auxiliary processing unit by calling an API interface, such as a data cancellation synchronization interface.
  • the auxiliary processing unit deletes the first service information according to the first information.
  • the auxiliary processing unit also deletes the first MAC address based on the first information.
  • the auxiliary processing unit sends the second information to the Bluetooth chip.
  • the second information is used to instruct the main processing unit to process Bluetooth data of the target service.
  • the second information may include the first MAC address of the target device and the second service information of the target service.
  • the downlink management business module 921, the Bluetooth business module 922 and the interface module 931 can enable the auxiliary processing unit to send the second information to the Bluetooth chip by calling the relevant API interface.
  • the Bluetooth chip deletes the logical channel information of the target service from the information list according to the second information.
  • the Bluetooth chip also deletes the device identification of the target device based on the second information.
  • the target service can be redeployed on the main processing unit. Therefore, the relevant information of the target service needs to be deleted between the main processing unit, the auxiliary processing unit and the Bluetooth chip, so that the main processing unit can process the Bluetooth data of the target service.
  • the Bluetooth services that need to be processed can be flexibly arranged on the main processing unit and the auxiliary processing unit.
  • FIG. 14 is another schematic diagram of the principle of processing Bluetooth data by a terminal device in BLE communication according to an embodiment of the present application.
  • Figure 15 is another flow chart of the Bluetooth data processing method provided by the embodiment of the present application.
  • the downlink management service module 921 corresponds to the downlink management service module in Figure 14
  • the Bluetooth service module 922 corresponds to the GATT Bluetooth service module in Figure 14
  • the interface module 931 corresponds to the In the GATT interface module in Figure 14
  • the information list 932 corresponds to the device list and sinking service list in Figure 14
  • the protocol data parsing/encapsulation module 933 corresponds to the protocol data parsing/encapsulation module in Figure 14.
  • the API provided by the sinking management business module, GATT Bluetooth business module, and GATT interface module implements the GATT protocol.
  • the thick solid lines and thick dashed lines in Figure 14 show the data flow during Bluetooth data processing.
  • the AP processes the data of the Bluetooth service, and the BT chip does not parse/encapsulate the data.
  • the target service is deployed on the MCU.
  • the BT chip of the smart watch receives the Bluetooth data sent by the sports bicycle and analyzes the data to determine whether it belongs to the target service.
  • the data belongs to the target service, it is sent to the MCU for processing, and the MCU implements the screen display of the target service data; if the data does not belong to the target service, it is sent to AP processing, the AP realizes the screen display.
  • the MCU processes the Bluetooth data of the target service and sends it to the BT chip.
  • the BT chip encapsulates the data and sends it to the exercise bike.
  • the terminal device is a smart watch and the target device is a sports bicycle.
  • the target service is the rate meter service.
  • the rate meter service includes feature 1 and feature 2.
  • Feature 1 (character1) does not need to be enabled, and feature 2 (character2) needs to be enabled.
  • the logical channel index of character1 is handle value 24.
  • the logical channel index of character2 is handle value 26, and the logical channel index of character2 descriptor is handle value 27.
  • the target characteristic is character1 served by the rate meter and does not need to be enabled.
  • Bluetooth data processing methods include:
  • the AP sends the first MAC address of the sports bicycle and the first service information of the rate meter service to the MCU.
  • the first service information includes: the UUID of the rate meter service, the logical channel index of character1 (handle value 24) and the characteristic attribute (property).
  • the MCU sends the first MAC address and the second service information to the BT chip.
  • the second service information includes: the logical channel index of character1 (handle value 24) and the characteristic attribute (property).
  • the second service information may also include: UUID of the rate meter service.
  • the BT chip adds the device identification of the sports bicycle and the logical channel information of the rate meter service to the information list based on the first MAC address and the second service information.
  • the logical channel information of the rate meter service includes: the logical channel index of character1 (handle value 24) and the characteristic attribute (property).
  • the target characteristic is character2 served by the rate meter, which needs to be enabled.
  • the AP has enabled character2, and the MCU does not need to enable it.
  • Bluetooth data processing methods include:
  • the AP sends the first MAC address of the sports bicycle and the first service information of the rate meter service to the MCU.
  • the first service information includes: the UUID of the rate meter service, the logical channel index of character2 (handle value 26) and the characteristic attribute (property).
  • the MCU sends the first MAC address and the second service information to the BT chip.
  • the second service information includes: the logical channel index of character2 (handle value 26) and the characteristic attribute (property).
  • the second service information may also include: UUID of the rate meter service.
  • the AP notifies the BT chip to enable feature 2 of the rate meter service.
  • the BT chip adds the device identification of the sports bicycle and the logical channel information of the rate meter service to the information list based on the first MAC address and the second service information.
  • the logical channel information of the rate meter service includes: the logical channel index of character2 (handle value 26) and the characteristic attribute (property).
  • this embodiment does not limit the execution order between S1503 and S1505 and S1501, S1502 and S1506.
  • the target characteristic is character2 served by the rate meter, which needs to be enabled.
  • the AP does not enable character2 and needs to be enabled by the MCU.
  • Bluetooth data processing methods include:
  • the AP sends the first MAC address of the sports bicycle and the first service information of the rate meter service to the MCU.
  • the first service information includes: the UUID of the rate meter service, the logical channel index of character2 (handle value 26) and characteristic attribute (property), and the logical channel index of the descriptor of character2 (handle value 27).
  • the MCU sends the first MAC address and the second service information to the BT chip.
  • the second service information includes: the logical channel index of character2 (handle value 26) and the characteristic attribute (property), and the logical channel index of the descriptor of character2 (handle value 27).
  • the second service information may also include: UUID of the rate meter service.
  • the MCU notifies the BT chip to enable feature 2 of the rate meter service.
  • the BT chip adds the device identification of the sports bicycle and the logical channel information of the rate meter service to the information list based on the first MAC address and the second service information.
  • the logical channel information of the rate meter service includes: the logical channel index of character2 (handle value 26) and characteristic attribute (property), and the logical channel index of character2 descriptor (handle value 27).
  • this embodiment does not limit the execution order between S1504, S1505 and S1506.
  • the API provided by the GATT Bluetooth service module may include but is not limited to at least one of the following: GATT virtual connection interface, write character&descripter interface, read characteristic interface, offload service information registration interface (requires offload Characteristic information of the business), GATT callback interface (including connection events, characteristic change events, read characterisc callback events, etc.), or enable the service interface.
  • GATT virtual connection interface write character&descripter interface
  • read characteristic interface read characteristic interface
  • offload service information registration interface requires offload Characteristic information of the business
  • GATT callback interface including connection events, characteristic change events, read characterisc callback events, etc.
  • enable the service interface may include but is not limited to at least one of the following: GATT virtual connection interface, write character&descripter interface, read characteristic interface, offload service information registration interface (requires offload Characteristic information of the business), GATT callback interface (including connection events, characteristic change events, read characterisc callback events, etc.), or enable the service interface.
  • the MCU sends the first MAC address and the second service information to the BT chip.
  • An implementation method may include: the sinking management service module calls the GATT virtual connection interface provided by the GATT Bluetooth service module to initiate a virtual connection. , inform the BT chip of the sports bicycle's MAC address through inter-core communication, instructing the MCU to prepare to receive the data of the sports bicycle's offload business. It should be noted that since the sports health APP on the AP side has completed the connection to the actual physical channel of the exercise bicycle, the connection initiated here is to notify the BT chip to add the equipment identification of the exercise bicycle to the device list, so as to facilitate the subsequent BT chip It can filter and identify sports bicycle data, so it is called a virtual connection.
  • the sinking management business module After the MCU obtains the result of the callback virtual connection (for example, it can indicate whether the device identification of the sports bicycle is successfully added to the device list), the sinking management business module calls the offload service information registration interface provided by the GATT Bluetooth business module and adds the characteristic of the rate meter service. And the descriptor's handle, property and other information (second service information) are notified to the BT chip.
  • the BT chip obtains the second service information, it can add the second service information to the sinking business list.
  • the MCU notifies the BT chip to enable feature 2 of the rate meter service.
  • An implementation method may include: the sinking management service module calls the enabling service interface provided by the GATT Bluetooth business module to notify the BT chip of the rate meter service. Enable the character of the accounting service.
  • FIG. 16 is a schematic diagram of another principle of how a terminal device processes Bluetooth data in classic Bluetooth provided by an embodiment of the present application.
  • Figure 17 is another flow chart of the Bluetooth data processing method provided by the embodiment of the present application.
  • the downlink management service module 921 corresponds to the downlink management business module in Figure 16
  • the Bluetooth service module 922 corresponds to the Socket Bluetooth service module in Figure 16
  • the interface module 931 corresponds to In the Socket interface module in Figure 16
  • the information list 932 corresponds to the device list and sinking service list in Figure 16
  • the protocol data parsing/encapsulation module 933 corresponds to the protocol data parsing/encapsulation module in Figure 14.
  • the API provided by the sinking management business module, Socket Bluetooth business module, and Socket interface module implements the RFCOMM protocol.
  • the BT chip can also include a status management module for maintaining the status of the BT chip, such as chip sniff status, RFCOMM channel flow control, etc.
  • a status management module for maintaining the status of the BT chip, such as chip sniff status, RFCOMM channel flow control, etc.
  • the terminal device is a smart watch and the target device is a mobile phone.
  • the target service is the message notification service.
  • the mobile phone is the server of the message notification service.
  • the smart watch is the client of the message notification service, that is, the role is the client.
  • the Bluetooth data processing method may include:
  • the AP sends channel information to the BT chip.
  • the channel information includes the second MAC address of the mobile phone and the DLCI of the message notification service.
  • the channel information may also include the UUID of the message notification service.
  • the UUID of the message notification service For example, as shown in Figure 16, when the AP sends channel information to the BT chip through the MCU, it needs to carry the UUID of the message notification service.
  • the AP sends the first MAC address of the mobile phone and the first service information of the message notification service to the MCU.
  • the first service information includes: the logical channel number of the message notification service and the role of the message notification service (specifically, the client).
  • the first service information may also include: UUID of the message notification service.
  • the MCU sends the first MAC address and the second service information to the BT chip.
  • the second service information includes: the logical channel number of the message notification service and the role of the message notification service (specifically, the client).
  • the second service information may also include: UUID of the message notification service.
  • the BT chip adds the device identification of the mobile phone and the logical channel information of the message notification service to the information list based on the first MAC address, the second MAC address, the second service information and the DLCI.
  • the terminal device includes hardware and/or software modules corresponding to each function.
  • the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is performed by hardware or computer software driving the hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions in conjunction with the embodiments for each specific application, but such implementations should not be considered to be beyond the scope of this application.
  • Embodiments of the present application can divide the functional modules of the terminal device according to the above method examples. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one module. middle. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical function division. In actual implementation, there may be other division methods. It should be noted that the names of the modules in the embodiments of this application are schematic, and there are no restrictions on the names of the modules during actual implementation.
  • FIG. 18 is a schematic structural diagram of a Bluetooth data processing device provided by an embodiment of the present application.
  • the Bluetooth data processing device is applied to terminal equipment.
  • the Bluetooth data processing device may include:
  • the first processing module 1802 is configured to send the first Bluetooth data to the second processing module 1803 when it is determined that the first Bluetooth data meets the preset conditions;
  • the second processing module 1803 is used to process the first Bluetooth data.
  • the first processing module 1802 is used for:
  • the information list is used to store the device identification and target service of the target device.
  • the second processing module 1803 is used to process the Bluetooth data of the target service.
  • the first processing module 1802 is also used to:
  • the first device identifier or the first logical channel index is not in the information list, send the first Bluetooth data to the third processing module 1804;
  • the third processing module 1804 is used to process the first Bluetooth data.
  • the second processing module 1803 is also used to:
  • the first processing module 1802 is also used to:
  • the third processing module 1804 is also used to:
  • the first MAC address of the target device and the first service information of the target service are sent to the second processing module 1803; the target device is in Bluetooth communication with the terminal device.
  • the device, the first service information is used by the second processing module 1803 to process the Bluetooth data of the target service;
  • the second processing module 1803 is also configured to: send the first MAC address and second service information to the first processing module 1802; the second service information is part of the first service information or All information;
  • the first processing module 1802 is further configured to: add the device identification of the target device and the logical channel information of the target service to the information list according to the first MAC address and the second service information; The device identification of the target device and the logical channel information of the target service are used by the first processing module 1802 to process the Bluetooth data of the target service.
  • the device identification of the target device includes an ACL identification.
  • the terminal device and the target device support the GATT protocol, and the target service includes at least one feature;
  • the first service information, the second service information and the logical channel information of the target service include: The logical channel index and feature attributes of the target feature in the at least one feature;
  • the first service information also includes: the UUID of the target service, and the first service information is used by the second processing module 1803 to process the Bluetooth data of the target feature.
  • the target feature needs to be enabled
  • the first service information, the second service information and the logical channel information of the target service also include: a logical channel index of the descriptor of the target feature.
  • the target feature is not enabled by the third processing module 1804.
  • the third processing module 1804 and/or the second processing module 1803 are also used to:
  • the target feature is enabled.
  • the terminal device and the target device support the RFCOMM protocol
  • the first service information and the second service information include: a logical channel number of the target service and a role of the target service; wherein the role is a client or a server.
  • the first service information also includes the UUID of the target service.
  • the third processing module 1804 is also used to:
  • the channel information includes the second MAC address of the target device and the DLCI of the target service;
  • the first processing module 1802 is used for:
  • the second service information, the second MAC address and the DLCI, the device identification of the target device and the logical channel information of the target service are added to the information list.
  • the first processing module 1802 is used for:
  • first MAC address and the second MAC address are the same, determine the device identification of the target device according to the first MAC address or the second MAC address;
  • the DLCI is determined to be the target service.
  • the third processing module 1804 is also used to:
  • the first information is used to instruct the third processing module 1804 to process the Bluetooth data of the target service;
  • the second processing module 1803 is also used to:
  • the first processing module 1802 is also used to:
  • the information list includes a device list and a sinking service list; the device list includes a device identifier of the target device, and the sinking service list includes a device identifier of the target device and a service name of the target service.
  • Logical channel information includes a device identifier of the target device, and a sinking service list includes a device identifier of the target device and a service name of the target service.
  • the terminal device is a client of the target service, and the target device serves the target of the server.
  • the Bluetooth data processing device provided in this embodiment is used to execute the Bluetooth data processing method provided in the embodiment of this application.
  • the technical principles and technical effects are similar and will not be described again here.
  • the first processing module may include an interface module 931, an information list 932 and a protocol data parsing/encapsulation module 933; the second processing module may include sinking Management service module 921 and Bluetooth service module 922.
  • Embodiments of the present application also provide a computer program product.
  • the computer program product When the computer program product is run on a device, it causes the device to execute the technical solutions in the above embodiments. Its implementation principles and technical effects are similar to those in the above related embodiments. No further details will be given.
  • Embodiments of the present application provide a computer-readable storage medium on which program instructions are stored.
  • program instructions When the program instructions are executed by a device, they cause the device to execute the technical solutions of the above embodiments.
  • the implementation principles and technical effects are similar to the above-mentioned related embodiments and will not be described again here.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

本申请实施例涉及蓝牙技术领域,提供一种蓝牙数据的处理方法、终端设备和可读存储介质。终端设备包括主处理单元、辅助处理单元和蓝牙芯片。蓝牙数据的处理方法应用于终端设备,包括:蓝牙芯片接收第一蓝牙数据;若蓝牙芯片确定第一蓝牙数据满足预设条件,则将第一蓝牙数据发送至辅助处理单元;辅助处理单元处理第一蓝牙数据。在本申请实施例中,部分蓝牙服务部署在辅助处理单元上处理,蓝牙芯片具有过滤蓝牙数据的能力,将满足预设条件的蓝牙数据发送给辅助处理单元处理,缩短了主处理单元的工作时间,从而降低了终端设备的耗电。

Description

蓝牙数据的处理方法、终端设备和可读存储介质
本申请要求于2022年06月23日提交国家知识产权局、申请号为202210718449.6、申请名称为“蓝牙数据的处理方法、终端设备和可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请实施例涉及蓝牙技术领域,尤其涉及一种蓝牙数据的处理方法、终端设备和可读存储介质。
背景技术
随着终端技术的发展,智能终端设备越来越趋于多样化,数据处理能力越来越强。比如,从初期的手机、平板电脑等形态,逐步演进到手表、音箱、智慧屏等各类形态。以智能手机为例,智能手机包括有2核手机、4核手机、8核手机等等。而且,随着通信技术的发展,智能终端设备的通信能力也越来越强。这其中,蓝牙(bluetooth,BT)通信已经成为智能终端设备支持的一种基本通信方式。
目前,在蓝牙通信的实现上,通常将蓝牙协议栈和蓝牙服务实现的开放接口(Framework接口)同时部署在智能终端设备的应用处理器(application processor,AP)上,由AP处理相关的蓝牙数据。这样,当两个进行蓝牙通信的终端设备之间需要频繁的传输数据时,AP将一直处于工作状态,而AP的工作电流通常较大,导致终端设备耗电严重。
发明内容
本申请实施例提供一种蓝牙数据的处理方法、终端设备和可读存储介质,降低了终端设备的耗电。
第一方面,提供了一种蓝牙数据的处理方法,应用于终端设备,终端设备包括主处理单元、辅助处理单元和蓝牙芯片;蓝牙数据的处理方法包括:蓝牙芯片接收第一蓝牙数据;若蓝牙芯片确定第一蓝牙数据满足预设条件,则将第一蓝牙数据发送至辅助处理单元;辅助处理单元处理第一蓝牙数据。
第一方面提供的蓝牙数据的处理方法,部分蓝牙服务部署在终端设备的辅助处理单元上处理,蓝牙芯片具有过滤蓝牙数据的能力,将满足预设条件的蓝牙数据发送给辅助处理单元处理,对原本需要由终端设备的主处理单元处理的蓝牙数据形成了分流,从而缩短了主处理单元的工作时间,从而降低了终端设备的耗电,提高了终端设备的续航时间。
一种可能的实现方式中,蓝牙芯片确定第一蓝牙数据满足预设条件,包括:蓝牙芯片解析第一蓝牙数据,得到第一设备标识和第一逻辑通道索引;若第一设备标识和 第一逻辑通道索引在信息列表中,蓝牙芯片确定第一蓝牙数据满足预设条件;信息列表用于存储目标设备的设备标识和目标服务的逻辑通道信息,辅助处理单元用于处理目标服务的蓝牙数据。
在该实现方式中,蓝牙芯片中存储有信息列表,信息列表中存储有部署在辅助处理单元上处理的蓝牙服务的相关信息和目标设备的设备标识。蓝牙芯片具有解析、过滤蓝牙数据的能力。蓝牙芯片解析第一蓝牙数据得到第一设备标识和第一逻辑通道索引。如果第一设备标识和第一逻辑通道索引在信息列表中,说明第一蓝牙数据需要在辅助处理单元上处理。通过将部分蓝牙服务部署在终端设备的辅助处理单元上处理,缩短了主处理单元的工作时间,降低了终端设备的耗电。
一种可能的实现方式中,蓝牙数据的处理方法还包括:若第一设备标识或第一逻辑通道索引不在信息列表中,蓝牙芯片将第一蓝牙数据发送至主处理单元;主处理单元处理第一蓝牙数据。
在该实现方式中,如果第一设备标识或者第一逻辑通道索引不在信息列表中,说明第一蓝牙数据不需要在辅助处理单元上处理,还是由主处理单元处理。
一种可能的实现方式中,蓝牙数据的处理方法还包括:辅助处理单元生成目标服务的第二蓝牙数据;辅助处理单元将第二蓝牙数据发送至蓝牙芯片;蓝牙芯片对第二蓝牙数据进行封装,得到待发送数据;蓝牙芯片向目标设备发送待发送数据。
在该实现方式中,终端设备作为数据发送端,向目标设备发送目标服务的数据。通过辅助处理单元处理目标服务的数据,降低了终端设备的能耗,延长了续航时间。
一种可能的实现方式中,蓝牙芯片接收第一蓝牙数据之前,还包括:主处理单元向辅助处理单元发送目标设备的第一MAC地址和目标服务的第一服务信息;目标设备为和终端设备蓝牙通信的设备,第一服务信息用于辅助处理单元处理目标服务的蓝牙数据;辅助处理单元向蓝牙芯片发送第一MAC地址和第二服务信息;第二服务信息为第一服务信息中的部分或全部信息;蓝牙芯片根据第一MAC地址和第二服务信息,在信息列表中增加目标设备的设备标识和目标服务的逻辑通道信息;目标设备的设备标识和目标服务的逻辑通道信息用于蓝牙芯片处理目标服务的蓝牙数据。
在该实现方式中,将部分蓝牙服务从主处理单元下沉到辅助处理单元上处理。主处理单元和辅助处理单元之间同步目标设备的MAC地址目标服务的第一服务信息,辅助处理单元和蓝牙芯片之间传输目标设备的MAC地址目标服务的第二服务信息,从而,辅助处理单元和蓝牙芯片获知目标服务是在辅助处理单元上处理。后续,辅助处理单元和蓝牙芯片可以处理目标服务的蓝牙数据,对原本需要由终端设备的主处理单元处理的蓝牙数据形成了分流,从而缩短了主处理单元的工作时间,从而降低了终端设备的耗电,提高了终端设备的续航时间。
一种可能的实现方式中,目标设备的设备标识包括ACL标识。
一种可能的实现方式中,终端设备和目标设备支持GATT协议,目标服务包括至少一个特征;第一服务信息、第二服务信息和目标服务的逻辑通道信息,包括:至少一个特征中目标特征的逻辑通道索引和特征属性;第一服务信息还包括:目标服务的UUID,第一服务信息用于辅助处理单元处理目标特征的蓝牙数据。
一种可能的实现方式中,目标特征需要被使能;第一服务信息、第二服务信息和 目标服务的逻辑通道信息,还包括:目标特征的描述符的逻辑通道索引。
在该实现方式中,目标特征的描述符的逻辑通道索引用于目标特征的使能,主处理单元和/或辅助处理单元可以使能目标特征。
一种可能的实现方式中,目标特征没有被主处理单元使能。
在该实现方式中,主处理单元没有使能目标特征,需要由辅助处理单元完成目标特征的使能。所以,第一服务信息、第二服务信息和目标服务的逻辑通道信息中需要包括目标特征的描述符的逻辑通道索引,从而使得辅助处理单元使能目标特征。
一种可能的实现方式中,蓝牙芯片接收第一蓝牙数据之前,还包括:主处理单元和/或辅助处理单元使能目标特征。
一种可能的实现方式中,终端设备和目标设备支持RFCOMM协议;第一服务信息和第二服务信息,包括:目标服务的逻辑通道信道号和目标服务的角色;其中,角色为客户端或服务端。
一种可能的实现方式中,第一服务信息还包括目标服务的UUID。
一种可能的实现方式中,蓝牙芯片根据第一MAC地址和第二服务信息,在信息列表中增加目标设备的设备标识和目标服务的逻辑通道信息之前,还包括:主处理单元向蓝牙芯片发送通道信息;通道信息包括目标设备的第二MAC地址和目标服务的DLCI;相应的,蓝牙芯片根据第一MAC地址和第二服务信息,在信息列表中增加目标设备的设备标识和目标服务的逻辑通道信息,包括:蓝牙芯片根据第一MAC地址、第二服务信息、第二MAC地址和DLCI,在信息列表中增加目标设备的设备标识和目标服务的逻辑通道信息。
一种可能的实现方式中,蓝牙芯片根据第一MAC地址、第二服务信息、第二MAC地址和DLCI,在信息列表中增加目标设备的设备标识和目标服务的逻辑通道信息,包括:若第一MAC地址和第二MAC地址相同,蓝牙芯片根据第一MAC地址或第二MAC地址确定目标设备的设备标识;蓝牙芯片根据DLCI得到待比对逻辑通道信道号和待比对角色;若待比对逻辑通道信道号和目标服务的逻辑通道信道号相同,且待比对角色和目标服务的角色相同,则蓝牙芯片将DLCI确定为目标服务的逻辑通道信息;在信息列表中增加目标设备的设备标识和DLCI。
一种可能的实现方式中,蓝牙数据的处理方法还包括:主处理单元向辅助处理单元发送第一信息;第一信息用于指示主处理单元处理目标服务的蓝牙数据;辅助处理单元根据第一信息删除第一服务信息;辅助处理单元向蓝牙芯片发送第二信息;第二信息用于指示主处理单元处理目标服务的蓝牙数据;蓝牙芯片根据第二信息在信息列表中删除目标服务的逻辑通道信息。
在该实现方式中,目标服务可以重新部署在主处理单元上。因此,主处理单元、辅助处理单元和蓝牙芯片之间需要删除目标服务的相关信息,从而使得主处理单元可以处理目标服务的蓝牙数据。
一种可能的实现方式中,信息列表包括设备列表和下沉业务列表;设备列表包括目标设备的设备标识,下沉业务列表包括目标设备的设备标识和目标服务的逻辑通道信息。
一种可能的实现方式中,终端设备为目标服务的客户端,目标设备为目标服务的 服务端。
第二方面,提供了一种蓝牙数据的处理装置,可以应用于终端设备。蓝牙数据的处理装置包括:接收模块,用于接收第一蓝牙数据;第一处理模块,用于在确定第一蓝牙数据满足预设条件时,将第一蓝牙数据发送至第二处理模块;第二处理模块,用于处理第一蓝牙数据。
一种可能的实现方式中,第一处理模块用于:解析第一蓝牙数据,得到第一设备标识和第一逻辑通道索引;若第一设备标识和第一逻辑通道索引在信息列表中,则确定第一蓝牙数据满足预设条件;信息列表用于存储目标设备的设备标识和目标服务的逻辑通道信息,第二处理模块用于处理目标服务的蓝牙数据。
一种可能的实现方式中,第一处理模块还用于:若第一设备标识或第一逻辑通道索引不在信息列表中,则将第一蓝牙数据发送至第三处理模块;第三处理模块,用于处理第一蓝牙数据。
一种可能的实现方式中,第二处理模块还用于:生成目标服务的第二蓝牙数据,将第二蓝牙数据发送至第一处理模块;第一处理模块还用于:对第二蓝牙数据进行封装,得到待发送数据;蓝牙数据的处理装置还包括发送模块,用于向目标设备发送待发送数据。
一种可能的实现方式中,第三处理模块还用于:在接收模块接收第一蓝牙数据之前,向第二处理模块发送目标设备的第一MAC地址和目标服务的第一服务信息;目标设备为和终端设备蓝牙通信的设备,第一服务信息用于第二处理模块处理目标服务的蓝牙数据;第二处理模块还用于:向第一处理模块发送第一MAC地址和第二服务信息;第二服务信息为第一服务信息中的部分或全部信息;第一处理模块还用于:根据第一MAC地址和第二服务信息,在信息列表中增加目标设备的设备标识和目标服务的逻辑通道信息;目标设备的设备标识和目标服务的逻辑通道信息用于第一处理模块处理目标服务的蓝牙数据。
一种可能的实现方式中,目标设备的设备标识包括ACL标识。
一种可能的实现方式中,终端设备和目标设备支持GATT协议,目标服务包括至少一个特征;第一服务信息、第二服务信息和目标服务的逻辑通道信息,包括:至少一个特征中目标特征的逻辑通道索引和特征属性;第一服务信息还包括:目标服务的UUID,第一服务信息用于第二处理模块处理目标特征的蓝牙数据。
一种可能的实现方式中,目标特征需要被使能;第一服务信息、第二服务信息和目标服务的逻辑通道信息,还包括:目标特征的描述符的逻辑通道索引。
一种可能的实现方式中,目标特征没有被第三处理模块使能。
一种可能的实现方式中,第三处理模块和/或第二处理模块,还用于:在接收模块接收第一蓝牙数据之前,使能目标特征。
一种可能的实现方式中,终端设备和目标设备支持RFCOMM协议;第一服务信息和第二服务信息,包括:目标服务的逻辑通道信道号和目标服务的角色;其中,角色为客户端或服务端。
一种可能的实现方式中,第一服务信息还包括目标服务的UUID。
一种可能的实现方式中,第三处理模块还用于:向第一处理模块发送通道信息; 通道信息包括目标设备的第二MAC地址和目标服务的DLCI;第一处理模块用于:根据第一MAC地址、第二服务信息、第二MAC地址和DLCI,在信息列表中增加目标设备的设备标识和目标服务的逻辑通道信息。
一种可能的实现方式中,第一处理模块用于:若第一MAC地址和第二MAC地址相同,根据第一MAC地址或第二MAC地址确定目标设备的设备标识;根据DLCI得到待比对逻辑通道信道号和待比对角色;若待比对逻辑通道信道号和目标服务的逻辑通道信道号相同,且待比对角色和目标服务的角色相同,则将DLCI确定为目标服务的逻辑通道信息;在信息列表中增加目标设备的设备标识和DLCI。
一种可能的实现方式中,第三处理模块还用于:向第二处理模块发送第一信息,第一信息用于指示第三处理模块处理目标服务的蓝牙数据;第二处理模块还用于:根据第一信息删除第一服务信息,并向第一处理模块发送第二信息,第二信息用于指示第三处理模块处理目标服务的蓝牙数据;第一处理模块还用于:根据第二信息在信息列表中删除目标服务的逻辑通道信息。
一种可能的实现方式中,信息列表包括设备列表和下沉业务列表;设备列表包括目标设备的设备标识,下沉业务列表包括目标设备的设备标识和目标服务的逻辑通道信息。
一种可能的实现方式中,终端设备为目标服务的客户端,目标设备为目标服务的服务端。
第三方面,提供了一种终端设备,包括处理器和蓝牙芯片,处理器包括主处理单元和辅助处理单元,处理器与存储器耦合,处理器执行存储器中存储的计算机程序,以实现第一方面提供的方法。
第四方面,提供一种程序,该程序在被处理器执行时用于执行第一方面提供的方法。
第五方面,提供一种计算机可读存储介质,计算机可读存储介质中存储有指令,当指令在计算机或处理器上运行时,实现第一方面提供的方法。
第六方面,提供一种程序产品,所述程序产品包括计算机程序,所述计算机程序存储在可读存储介质中,设备的至少一个处理器可以从所述可读存储介质读取所述计算机程序,所述至少一个处理器执行所述计算机程序使得该设备实施第一方面提供的方法。
附图说明
图1A~图1C为本申请实施例适用的应用场景的一组示意图;
图2为本申请实施例提供的终端设备的一种结构示意图;
图3为本申请实施例提供的蓝牙协议栈的一种结构示意图;
图4为本申请实施例提供的GATT数据结构的一种示意图;
图5为本申请实施例提供的速率计服务的逻辑通道管理信息的一种示意图;
图6为本申请实施例提供的终端设备处理蓝牙数据的一种原理示意图;
图7为本申请实施例提供的BLE通信中终端设备处理蓝牙数据的一种原理示意图;
图8为本申请实施例提供的经典蓝牙中终端设备处理蓝牙数据的一种原理示意图;
图9为本申请实施例提供的终端设备处理蓝牙数据的另一种原理示意图;
图10为本申请实施例提供的蓝牙数据的处理方法的一种流程图;
图11为本申请实施例提供的BLE通信中的一种数据结构;
图12为本申请实施例提供的经典蓝牙通信中的一种数据结构;
图13为本申请实施例提供的蓝牙数据的处理方法的另一种流程图;
图14为本申请实施例提供的BLE通信中终端设备处理蓝牙数据的另一种原理示意图;
图15为本申请实施例提供的蓝牙数据的处理方法的又一种流程图;
图16为本申请实施例提供的经典蓝牙中终端设备处理蓝牙数据的另一种原理示意图;
图17为本申请实施例提供的蓝牙数据的处理方法的又一种流程图;
图18为本申请实施例提供的蓝牙数据的处理装置的一种结构示意图。
具体实施方式
下面结合附图描述本申请实施例。
本申请实施例提供的蓝牙数据的处理方法,适用于多核终端设备处理蓝牙数据的场景。
示例性的,图1A~图1C示出了三种应用场景,但图1A~图1C并不对本申请实施例的应用场景形成限定。
在一个场景中,如图1A所示,用户使用运动单车健身,并且佩戴智能手表。运动单车和智能手表均支持蓝牙功能。智能手表上安装了具有运动管理功能的应用程序(application,APP)。本申请实施例对APP的名称不做限定,例如,运动健康APP。运动单车和智能手表进行蓝牙通信后,在用户运动的过程中,运动单车通过蓝牙通信将相关数据持续的上报给智能手表。相应的,智能手表通过蓝牙通信接收相关数据,处理后在运动健康APP的界面中显示运动信息,以便于用户查看运动过程中的运动详情,及时调整运动状态。例如,如图1A所示,通过智能手表的显示,用户当前已经运动10分32秒,心率为102次/分钟(bpm),消耗热量100千卡(kcal),运动单车的配速为27千米/小时(km/h)。在该示例中,运动单车和智能手表进行蓝牙低功耗(bluetooth low energy,BLE)通信。
在另一个场景中,如图1B所示,手机和智能手表均支持蓝牙功能。手机和智能手表上安装有具有消息通知功能的APP,例如为设备自带的系统应用程序,称为消息通知APP。手机和智能手表进行蓝牙通信。手机收到一条提示信息,如图1B所示,手机当前界面中弹出提示框11,提示框11中包括提示信息,内容为“小明:今天晚上吃什么?”。手机通过蓝牙通信将提示信息发送给智能手表。相应的,智能手表接收提示信息,处理后进行显示,参见图1B中智能手表的显示内容。用户看到后,知道小明在询问,今天晚上吃什么。用户通过佩戴的智能手表可以方便的查看手机上的实时提示信息,避免了用户必须随时携带手机,解放了用户双手。在该示例中,手机和智能手表进行经典蓝牙通信。
在又一个场景中,如图1C所示,手机和智能手表均支持蓝牙功能。手机和智能 手表上安装有具有运动管理功能的应用程序,例如,运动健康APP。手机和智能手表进行蓝牙通信。智能手表完成运动健康数据的采集后,通过蓝牙通信发送给手机。相应的,手机通过蓝牙通信接收运动健康数据,处理后在运动健康APP的相关界面中进行显示,具体参见图1C中手机的当前显示内容。通过手机的显示,弥补了智能手表因为屏幕狭小导致的用户观感差的缺点,提升了用户感受。在该示例中,手机和智能手表进行经典蓝牙通信。
本申请实施例中的多核终端设备,是指终端设备的处理器包括至少2个处理单元。本申请实施例对处理单元的数量、名称和类型不做限定。例如,处理器可以包括但不限于下列的处理单元:应用处理器(AP),微控制单元(microcontroller unit,MCU),图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),数字信号处理器(digital signal processor,DSP),或神经网络处理器(neural-network processing unit,NPU)等。不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。
其中,至少1个处理单元可以称为主处理单元,除主处理单元之外的至少1个处理单元可以称为辅助处理单元。本申请实施例对主处理单元和辅助处理单元的数量、名称和类型不做限定。例如,主处理单元也可以称为主处理器或主核,辅助处理单元也可以称为辅助处理器、从处理单元、从处理器或者从核。
示例性的,图2为本申请实施例提供的终端设备的一种结构示意图。如图2所示,终端设备包括:主处理单元21、辅助处理单元22、蓝牙(BT)芯片23、存储器24、传感器25、电源模块26和显示器27。
主处理单元21,用于运行终端设备的操作系统,部署蓝牙协议栈、蓝牙服务以及蓝牙开放接口等。
辅助处理单元22,用于与传感器25通信,采集传感器25的数据并处理。相比于主处理单元21,辅助处理单元22还可以运行轻量级的操作系统。在本申请实施例中,辅助处理单元22还用于处理下沉(offload)业务的蓝牙数据。下沉(offload)业务是指部署在辅助处理单元上处理的蓝牙服务。
BT芯片23,用于与其他设备进行蓝牙连接和数据传输。在本申请实施例中,BT芯片23接收蓝牙数据后,可以针对下沉业务对蓝牙数据进行区分并加以过滤,将下沉业务的蓝牙数据发送给辅助处理单元22。BT芯片23还用于对辅助处理单元22发送的下沉业务的蓝牙数据进行协议封装,发送给目标设备。
存储器24,用于存储可执行的程序代码和/或数据,可执行的程序代码可以包括指令。存储器24可以包括存储程序区和存储数据区。存储器24可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件,硬盘(hard disk drive,HDD),固态硬盘(solid-state drive,SS),闪存器件,通用闪存存储器(universal flash storage,UFS)等,还可以包括易失性存储器(volatile memory),例如随机存取存储器(random-access memory,RAM)。
传感器25,可以包括但不限于下列中的至少一项:压力传感器,陀螺仪传感器,气压传感器,磁传感器,加速度传感器,距离传感器,接近光传感器,指纹传感器, 温度传感器,触摸传感器,环境光传感器,或者,骨传导传感器。
电源模块26,用于连接电源(例如电池)为终端设备中的模块或元器件供电,还可以监测电池容量,电池循环次数,电池健康状态(漏电,阻抗)等参数。
需要说明的是,图2并不对终端设备的结构形成限定,终端设备可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件、软件或软件和硬件的组合实现。例如,终端设备还可以包括下列中的至少一项:移动通信模块、音频模块、摄像头、麦克风、耳机接口、天线等。
需要说明的是,本申请实施例对终端设备的名称和类型不做限定。例如,终端设备也可以称为终端、电子设备、通信设备或用户设备等。一些终端设备的举例为:手机、平板电脑、掌上电脑、可穿戴设备、移动互联网设备(mobile internet device,MID)、虚拟现实(virtual reality,VR)设备、增强现实(augmented reality,AR)设备,或智慧家庭(smart home)中的终端等。
为了方便说明,本申请实施例以主处理单元和辅助处理单元均为1个,主处理单元为AP,辅助处理单元为MCU,终端设备为智能手表,与智能手表进行蓝牙通信的设备为运动单车或手机为例进行说明。
下面,为了方便理解本申请实施例提供的技术方案,对蓝牙通信的相关概念进行说明。
1、经典蓝牙、BR&EDR、BLE
根据蓝牙通信的发展,蓝牙通信可以包括经典蓝牙部分和BLE部分。通常,蓝牙协议标准4.0以下主要是经典蓝牙部分,BLE对应蓝牙协议标准4.0或更高协议版本。BLE是建立在经典蓝牙基础上而发展的。经典蓝牙通常用于数据量比较大的传输,例如,语音、音乐等。BLE相比于经典蓝牙,具有成本低、功耗低、实时性要求高的特点。
经典蓝牙又包括基础速率(basic rate,BR)和增强速率(enhanced data rate,EDR)。EDR相比于BR,具有更高的传输速率,比如,可以达到BR速率的8倍。
2、蓝牙协议栈
示例性的,图3为本申请实施例提供的蓝牙协议栈的一种结构示意图。如图3所示,蓝牙协议栈包括主机(Host)、控制器(Controller)和主机控制器接口(host controller interface,HCI)。HCI用于规范主机与控制器之间的通信协议和通信命令等。
通常,主机部署在主处理单元(例如AP)上,控制器部署在BT芯片上。
对于经典蓝牙和BLE,涉及的具体协议有所不同。
(1)经典蓝牙的蓝牙协议栈
在经典蓝牙中,控制器可以表示为BR/EDR Controller,包括:射频层(RF)、基带层(Baseband)和链路管理层(link management protocol,LMP)。射频层用于发送或接收数据等。基带层用于对数据进行调制解调等。链路管理层用于对链路进行管理和控制等。
主机中的高层协议包括但不限于:逻辑链路控制与适配协议(logic link control and adaptation protocol,L2CAP)、无线电频率通信协议(radio frequency communication, RFCOMM)、服务发现协议(service discovery protocol,SDP)等,具体参见蓝牙协议中的相关说明。
(2)BLE的蓝牙协议栈
在BLE中,控制器可以表示为LE Controller或BLE Controller,包括:物理层(physical layer,PHY)和链路层(link layer,LL)。物理层用于选择无线频段、调制解调方式、收发数据等。链路层用于对链路进行管理和控制、确定数据包的发送时间、选择射频通道、实现数据包的反馈和重传等。
主机中的高层协议可以包括但不限于:L2CAP、属性协议(attribute protocol,ATT)、通用属性协议(generic attribute profile,GATT)等,具体参见蓝牙协议中的相关说明。
还可以将BR/EDR Controller和LE Controller合并到一个Controller中,也就是通常所说的双模蓝牙。
3、角色、客户端、服务端
在蓝牙通信中,蓝牙服务由两种类型(或者角色)构成,包括:客户端(client)和服务端(server)。
客户端和服务端通信时,需要首先建立连接。通常,发起连接请求的一方称为客户端,接收连接请求的一方称为服务端。建立连接后,服务端可以提供数据服务。在客户端发起连接请求之前,服务端需要处于侦听状态,侦听是否有客户端要求建立连接。当服务端侦听到客户端的连接请求时,服务端可以选择建立连接或者拒绝连接。
举例说明。比如,在图1A所示的场景中,运动单车提供的蓝牙服务包括功率计、踏频计、速率计等。以速率计为例,速率计的两种角色包括速率数据服务端和速率数据读取客户端。运动单车和智能手表进行蓝牙通信时,智能手表作为速率数据读取客户端,向运动单车发起连接请求。运动单车作为速率数据服务端,接受连接请求,建立蓝牙连接。之后,运动单车可以向智能手表发送速率数据。相应的,智能手表处理后进行速率信息的显示。
再比如,在图1B所示的场景中,手机和智能手表均支持消息通知服务。消息通知服务的两种角色包括消息通知服务端和消息通知客户端。智能手表作为消息通知客户端,向手机发起连接请求;相应的,手机作为消息通知服务端,接受连接请求,建立蓝牙连接。之后,手机可以向智能手表发送通知信息;相应的,智能手表接收通知信息并处理,进行通知信息的显示。
又比如,在图1C所示的场景中,手机和智能手表均安装有运动健康APP。运动健康服务的两种角色包括运动健康服务端和运动健康客户端。手机作为运动健康客户端,向智能手表发起连接请求;相应的,智能手表作为运动健康服务端,接受连接请求,和手机建立蓝牙连接。
需要说明的是,在蓝牙通信中,一个设备可以仅作为客户端,或者仅作为服务端,或者作为客户端和服务端,这与蓝牙服务的软件开发、设备的类型等因素相关。
客户端和服务端建立连接后,服务端可以作为数据发送方向客户端发送数据,相应的,客户端作为数据接收方接收服务端发送的数据;或者,客户端作为数据发送方向服务端发送数据,相应的,服务端作为数据接收方接收客户端发送的数据。
4、蓝牙服务的逻辑通道管理信息
客户端和服务端建立连接后,终端设备作为客户端或者服务端,可以获知自身支持的蓝牙服务。终端设备作为客户端,可以通过服务发现、服务查询或设备查询等流程获知服务端提供的蓝牙服务。服务发现、服务查询或设备查询等流程可以参见蓝牙协议。
蓝牙服务具有逻辑通道管理信息,用于区分不同的蓝牙服务。
蓝牙通信方式不同时,采用的蓝牙协议有所不同,蓝牙服务的逻辑通道管理信息也有所不同。
(1)经典蓝牙中,蓝牙服务的逻辑通道管理信息
在经典蓝牙中,蓝牙服务的客户端和服务端之间采用Socket(套接字)连接,也称为BluetoothSocket连接。BluetoothSocket的连接过程是通过RFCOMM协议实现的。在客户端和服务端建立连接的过程中,涉及蓝牙服务对应的逻辑通道的逻辑通道信道(channel)号。RFCOMM通道具有数据链路连接标识(data link connection identifier,DLCI)。
经典蓝牙中,蓝牙服务的逻辑通道管理信息可以包括但不限于:蓝牙服务的通用唯一标识符(universally unique identifier,UUID)、蓝牙服务的逻辑通道信道(channel)号、蓝牙服务的角色,以及,蓝牙服务的DLCI。
其中,角色包括客户端和服务端。
DLCI与逻辑通道信道号和角色具有转换关系。基于该转换关系,根据逻辑通道信道号和角色可以计算得到DLCI,相应的,通过DLCI可以得到该DLCI对应的逻辑通道信道号和角色。DLCI可以参见蓝牙相关协议。
在本申请实施例中,DLCI可以被蓝牙芯片使用,用于过滤、区分不同的蓝牙服务,从而可以将不同的蓝牙服务的数据发送至主处理单元或者辅助处理单元处理。
可选的,若终端设备作为蓝牙服务的客户端,终端设备可以从蓝牙服务的服务端获取蓝牙服务的逻辑通道信道号。若终端设备作为蓝牙服务的服务端,终端设备可以直接获取蓝牙服务的逻辑通道信道号。
举例说明。在图1B所示的场景中,蓝牙服务为消息通知服务。智能手表为消息通知服务的客户端,手机为消息通知服务的服务端。智能手表接收手机发送的消息通知服务的逻辑通道信道号。对于智能手表来说,角色为客户端,根据消息通知服务的逻辑通道信道号和角色(客户端)可以计算得到DLCI。消息通知服务的逻辑通道管理信息包括:消息通知服务的逻辑通道信道号,智能手表在消息通知服务中的角色(客户端),和DLCI。
(2)BLE中,蓝牙服务的逻辑通道管理信息
BLE支持GATT协议,蓝牙服务的客户端和服务端之间采用GATT连接。在GATT协议中,蓝牙服务通过数据分层结构进行描述。
示例性的,图4为本申请实施例提供的GATT数据结构的一种示意图。如图4所示,service(服务)为至少一个,每个service(服务)包括至少一个character(特征)。character(特征)可以包括至少一个descriptor(描述符或描述信息);或者,character(特征)不包括descriptor(描述符)。
character(特征)具有特征属性(property),例如,广播(broadcast)、读(read)、 写(write)、通知(notify)、指示(indicate),等等。假设,设备A和设备B进行蓝牙通信。对于设备B来说,通过读(read)和写(write),可以通知设备A向设备B请求数据。设备B可以通过通知(notify)的方式向设备A发送数据,相应的,设备A接收设备B通过通知(notify)的方式上报的数据。
一些特征属性(property)需要使能后才能生效,例如,通知(notify)和指示(indicate),此时,可以描述为character(特征)需要被使能。因此,如果character(特征)的特征属性需要被使能,或者说,character(特征)需要被使能,那么,character(特征)一定包括descriptor(描述符),用于客户端使能或者禁止character(特征)。
BLE中,蓝牙服务的逻辑通道管理信息包括但不限于:蓝牙服务的UUID、蓝牙服务包括的character(特征)的逻辑通道索引和特征属性(property)。如果character(特征)包括descriptor(描述符),蓝牙服务的逻辑通道管理信息还包括:character(特征)的descriptor(描述符)的逻辑通道索引。其中,在一些实施方式中,逻辑通道索引也表示为value handle(值索引、值句柄等)或者instance id(实例标识)。
下面结合图1A所示场景和图5,对蓝牙服务的逻辑通道管理信息进行示例性说明,但并不形成限定。
在图1A所示的场景中,智能手表上安装有运动健康APP。运动健康APP具备处理3种service(服务)数据的能力,3种service(服务)分别为:速率计服务(服务1、service1)、功率计服务(服务2、service2)和踏频计服务(服务3、service3)。
以速率计服务为例,图5为本申请实施例提供的速率计服务的逻辑通道管理信息的一种示意图。速率计服务包括2个特征,标识为特征1和特征2,特征1不包括描述符,特征2包括描述符。在图5中,包括两种索引值,分别为:属性索引(attribute handle)和value handle(值索引)。service(服务)、character(特征)、descriptor(描述符)均具有属性索引(attribute handle),取值不同,可以唯一区分不同的服务、特征或描述符。例如,速率计服务的属性索引取值为22、速率计服务中特征1的属性索引取值为23、速率计服务中特征2的属性索引取值为25、速率计服务中特征2的描述符的属性索引取值为27。character(特征)具有value handle(值索引),是指特征的取值对应的索引值。通过属性索引(attribute handle)可以匹配到是速率计的一个特征,通过value handle(值索引)可以匹配到速率计特征的取值。举例说明。假设,特征1表示速率计服务的速度数值。速率计上报数据时,如果携带的value handle值为24,通过解析数据可以得知速率计的速度数值的具体取值,例如为27km/h。可选的,在一些实施方式中,descriptor(描述符)具有value handle(值索引),descriptor(描述符)的value handle(值索引)和属性索引(attribute handle)相同。
如图5所示,速率计服务的属性索引取值22。速率计服务包括2个特征。特征1的属性索引取值23,值索引取值24。特征2的属性索引取值25,值索引取值26。特征2的特征属性包括通知(notify),具有描述符。特征2的描述符的属性索引(或值索引)取值27。
速率计服务的逻辑通道管理信息可以包括:速率计服务的UUID、特征1的逻辑通道索引(取值24)和特征属性、特征2的逻辑通道索引(取值26)和特征属性,以及,特征2的描述符的逻辑通道索引(取值27)。
相关技术中,蓝牙服务部署在终端设备的主处理单元(例如AP)上。终端设备和其他设备进行蓝牙通信时,由AP处理蓝牙服务的蓝牙数据。示例性的,图6为本申请实施例提供的终端设备处理蓝牙数据的一种原理示意图。参见图6中的粗实线,终端设备作为数据接收方时,BT芯片接收蓝牙数据后,发送给AP处理;终端设备作为数据发送方时,AP对蓝牙数据进行协议封装后发送给BT芯片,BT芯片将接收到的数据发送出去。可见,AP一直处于工作状态。而AP的工作电流较大,会加剧终端设备的耗电。尤其对于蓝牙数据频繁传输的场景,终端设备长时间维持在高耗电的状态,终端设备的电池容量有限,造成终端设备的续航时间明显下降。
下面,结合图1A~图1B所示的应用场景,针对BLE和经典蓝牙的不同蓝牙通信方式,对终端设备处理蓝牙数据进行详细说明。
在一种实现方式中,结合图1A,为BLE通信。图7为本申请实施例提供的BLE通信中终端设备处理蓝牙数据的一种原理示意图。需要说明,图7并不对运动单车和智能手表的结构形成限定。
如图7所示,运动单车包括:BT芯片、蓝牙协议栈、传输模块、蓝牙服务、传感器和显示屏。其中,传感器示出了速率计传感器和功率计传感器。蓝牙服务部署在应用层,包括速率计服务和功率计服务。具体的,运动单车作为蓝牙服务的服务端,蓝牙服务包括:速率数据服务端和功率数据服务端。传输模块用于传输数据,可以包括但不限于:Commu模块、通用异步收/发器(universal asynchronous receiver/transmitter,UART)、串行外设接口(Serial Peripheral Interface,SPI)等。Commu模块可以实现业务数据的分发。UART是一种通用的串行数据总线,用于异步通信,可以双向通信,实现全双工传输和接收。SPI是一种高速的、全双工的、同步的通信总线。蓝牙协议栈示出了部分蓝牙协议和逻辑通道管理信息。在BLE中,蓝牙协议包括但不限于GATT、ATT、L2CAP和HCI。在逻辑通道管理信息中,速率计服务对应的逻辑通道管理信息标识为UINT1,功率计服务对应的逻辑通道管理信息标识为UINT2。
如图7所示,智能手表包括:BT芯片、MCU、AP和显示屏。BT芯片中包括RF模块和基带层/LL模块,“/”表示或者的关系,可以参见上述蓝牙协议栈的相关说明。MCU中包括:传输模块、传感器、定位模块和其他模块。传输模块用于传输数据,可以包括但不限于:Commu模块、UART、SPI等。AP中包括:蓝牙协议栈、BT Framework(接口)、蓝牙服务和运动健康APP。其中,运动健康APP位于应用层,即第三方应用,可以提供多种蓝牙服务,例如,速率计服务、功率计服务。在本示例中,智能手表作为蓝牙服务的客户端,包括:速率数据读取客户端和功率数据读取客户端。BT Framework用于提供API,供上层应用调用,从而实现蓝牙能力。例如,提供的API包括BluetoothGATT。蓝牙协议栈示出了部分蓝牙协议和逻辑通道管理信息。在BLE中,蓝牙协议包括但不限于GATT、ATT、L2CAP和HCI。在逻辑通道管理信息中,速率计服务对应的逻辑通道管理信息标识为UINT1,功率计服务对应的逻辑通道管理信息标识为UINT2。
在该实现方式中,运动单车开机后,先注册BLE GATT SERVER服务端,用于监听客户端的连接。随后,运动单车发起BLE的可连接广播。智能手表运行运动健康 APP后,运动健康APP通过调用BT Framework提供的BLE扫描接口,开始扫描周围的BLE设备。BT芯片启动扫描,获得扫描结果,将扫描结果发送给AP。蓝牙协议栈解析扫描结果,通过回调通知到运动健康APP。运动健康APP获得扫描结果,得到运动单车的设备广播名称和设备的媒体访问控制(media access control,MAC)地址等信息。用户可以在运动健康APP的相关界面中操作,发起对运动单车的连接。相应的,运动健康APP调用BT Framework提供的connectGATT,发起逻辑通道的连接。运动健康APP等到连接的状态回调之后,通过BT Framework提供的discovery service,查询运动单车提供的蓝牙服务,获得蓝牙服务的逻辑通道管理信息。运动健康APP使能运动单车的数据上报服务后,运动单车可以向智能手表上报相关的数据。
如图7中的粗实线所示,智能手表作为数据接收方时,智能手表的BT芯片接收到运动单车发送的蓝牙数据后,直接发送给AP处理。AP对蓝牙数据处理后,可以发送给显示屏,实现屏幕送显。智能手表作为数据发送方时,AP对蓝牙数据进行处理后发送给BT芯片,BT芯片将从AP接收到的数据发送给运动单车。
在实际的应用场景中,用户使用运动单车锻炼时,运动单车会不停的生成运动数据并上报给智能手表,导致智能手表的AP一直处于工作状态,耗电较大,降低了智能手表的续航时间。
在另一种实现方式中,结合图1B,为经典蓝牙通信。图8为本申请实施例提供的经典蓝牙中终端设备处理蓝牙数据的一种原理示意图。需要说明,图8并不对手机和智能手表的结构形成限定。
如图8所示,手机包括:BT芯片、蓝牙协议栈、BT Framework、蓝牙服务和显示屏。其中,蓝牙服务部署在应用层,示出了消息通知服务和运动健康服务。手机作为消息通知服务的服务端,包括:消息通知服务端。手机还可以作为运动健康服务的客户端或者服务端,包括:运动健康客户端/服务端。BT Framework用于提供API,供上层应用调用,从而实现蓝牙通信能力。例如,提供的API包括BluetoothSocket。蓝牙协议栈示出了部分蓝牙协议和逻辑通道管理信息。在经典蓝牙中,蓝牙协议包括但不限于RFCOMM、L2CAP和HCI。在逻辑通道管理信息中,消息通知服务对应的逻辑通道管理信息标识为UINT1,运动健康服务对应的逻辑通道管理信息标识为UINT2。
图8和图7提供的智能手表的结构相似,此处不再赘述,区别在于:蓝牙通信方式不同、使用的蓝牙协议不同,BT Framework提供的API不同,实现的蓝牙服务不同。在图8中,支持经典蓝牙通信,蓝牙协议包括RFCOMM、L2CAP和HCI,BT Framework提供的API包括BluetoothSocket等,蓝牙服务包括消息通知服务和运动健康服务。智能手表作为消息通知服务的客户端,包括:消息通知客户端。智能手表还可以作为运动健康服务的服务端或者客户端,包括:运动健康服务端/客户端。
在该实现方式中,手机上的消息通知服务端,使用BluetoothServerSocket创建侦听服务器socket,监听客户端的连接请求。当监听到客户端的连接请求并接受时,返回一个BluetoothSocket来管理连接。智能手表上的消息通知客户端,使用单个BluetoothSocket发起和管理连接。具体的,消息通知客户端通过调用BT Framework提供的bluetooth socket connect接口,发起蓝牙RFCOMM通道的建立。手机上的消息通知服务端和智能手表上的消息通知客户端创建连接后,通过Bluetoothsocket收发消 息和数据。
如图8中的粗实线所示,当手机上有通知消息时,手机将通知消息发送给智能手表,使得智能手表显示该通知消息。智能手表作为数据接收方,智能手表的BT芯片接收到手机发送的通知消息,直接发送给AP处理。AP对通知消息处理后,可以发送给显示屏,实现屏幕送显。
在实际的应用场景中,手机上会不定期的收到通知消息。手机不停的将通知消息上报给智能手表,导致智能手表的AP一直处于工作状态,耗电较大,降低了智能手表的续航时间。
本申请实施例提供一种蓝牙数据的处理方法,终端设备上的主处理单元(例如AP)可以将部分蓝牙服务下沉到辅助处理单元(例如MCU)上进行管理,该部分蓝牙服务可以称为下沉(offload)业务。主处理单元、辅助处理单元和BT芯片之间需要同步下沉业务的必要数据,蓝牙芯片具有解析、封装、过滤下沉业务的蓝牙数据的能力。这样,终端设备作为数据接收方时,BT芯片接收蓝牙数据后,对蓝牙数据进行解析,确定是下沉业务的数据时,发送给辅助处理单元处理;确定不是下沉业务的数据时,发送给主处理单元处理。终端设备作为数据发送方时,对于下沉业务,辅助处理单元可以将下沉业务的数据发送给BT芯片,BT芯片将数据封装后发送出去。可见,本申请实施例提供的蓝牙数据的处理方法,通过辅助处理单元处理部分蓝牙数据,对原本需要由主处理单元处理的蓝牙数据形成了分流,缩短了主处理单元的工作时间,降低了终端设备的耗电,提高了终端设备的续航时间。
示例性的,图9为本申请实施例提供的终端设备处理蓝牙数据的另一种原理示意图。如图9所示,终端设备包括AP91、MCU92和BT芯片93。其中,MCU92包括:下沉管理业务模块921和蓝牙业务模块922。BT芯片93包括:接口模块931、信息列表932和协议数据解析/封装模块933。
下沉管理业务模块921,用于和AP91通信,提供API接口供上层应用调用。比如,API接口可以包括数据同步接口、数据取消同步接口等。数据同步接口用于AP91和MCU92之间同步下沉业务的第一服务信息。数据取消同步接口用于AP91和MCU92之间取消同步下沉业务的第一服务信息。下沉管理业务模块921还用于和蓝牙业务模块922通信,可以调用蓝牙业务模块922提供的API。
蓝牙业务模块922,用于和下沉管理业务模块921、BT芯片93通信,从而实现MCU92和BT芯片93之间的通信。蓝牙业务模块922可以提供API接口供下沉管理业务模块921调用。比如,API接口包括但不限于下列中的至少一项:虚拟连接接口、注册接口、使能服务接口、读接口、写接口,或者,回调接口。当蓝牙通信方式不同时,比如经典蓝牙和BLE,蓝牙业务模块922提供的API接口有所不同,具体可以参见图15和图17所示实施例的说明。
接口模块931,用于和蓝牙业务模块922通信,从而实现MCU92和BT芯片93之间的通信。接口模块931可以提供API接口。API接口包括但不限于下列中的至少一项:虚拟连接接口、注册接口、使能服务接口、读接口、写接口,或者,回调接口。当蓝牙通信方式不同时,接口模块931提供的API接口有所不同,具体可以参见图15 和图17所示实施例的说明。
信息列表932,用于存储与终端设备进行蓝牙通信的目标设备的设备标识,以及存储下沉业务的逻辑通道信息。
协议数据解析/封装模块933,用于对BT芯片93接收的蓝牙数据进行解析,根据信息列表932中存储的设备标识和逻辑通道信息确定接收的蓝牙数据是否属于下沉业务;如果属于下沉业务,则发送给MCU92处理;如果不属于下沉业务,则发送给AP91处理。协议数据解析/封装模块933还用于对从MCU92接收的下沉业务的数据进行封装,之后发送给目标设备。
其中,AP91、MCU92和BT芯片93之间具有核间通信接口。AP91和BT芯片93之间的通信,可以通过AP91和BT芯片93之间的通信接口直接通信,或者,通过MCU92实现通信。
下面通过具体的实施例对本申请的技术方案进行详细说明。下面的实施例可以相互结合,对于相同或相似的概念或过程可能在某些实施例中不再赘述。
本申请实施例中的术语“第一”、“第二”、“第三”、“第四”等(如果存在)是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。
需要说明,在本申请实施例中,蓝牙服务和服务表示相同含义。
图10为本申请实施例提供的蓝牙数据的处理方法的一种流程图。本实施例提供的蓝牙数据的处理方法,执行主体可以为终端设备。终端设备包括主处理单元、辅助处理单元和蓝牙芯片。终端设备和目标设备已经建立蓝牙连接。本实施例对目标设备的名称和类型不做限定。示例性的,在图1A所示的场景中,终端设备为智能手表,目标设备为运动单车。在图1B所示的场景中,终端设备为智能手表,目标设备为手机。在图1C所示的场景中,终端设备为手机,目标设备为智能手表。终端设备和目标设备建立蓝牙连接后,蓝牙芯片记录有连接信息。连接信息包括但不限于:面向连接的异步链路(asynchronous connection-oriented link,ACL)标识和目标设备的MAC地址。终端设备还可以获知终端设备和目标设备支持的蓝牙服务。
如图10和图9所示,本实施例提供的蓝牙数据的处理方法,可以包括:
S1001、主处理单元向辅助处理单元发送目标设备的第一MAC地址和目标服务的第一服务信息。
相应的,辅助处理单元接收主处理单元发送的第一MAC地址和第一服务信息。
其中,第一服务信息用于辅助处理单元处理目标服务的蓝牙数据。
其中,本申请实施例提供的蓝牙数据的处理方法,主处理单元、辅助处理单元和蓝牙芯片之间传输的数据均包括目标设备的MAC地址。为了方便区分,主处理单元向辅助处理单元发送的目标设备的MAC地址,称为第一MAC地址。
具体的,终端设备或目标设备可以支持多种蓝牙服务。在多种蓝牙服务中,将部署在终端设备的辅助处理单元上处理的蓝牙服务称为目标服务,也可以称为下沉(offload)业务。可选的,目标服务为服务端提供的服务。可选的,终端设备作为客户端、目标设备作为服务端时,终端设备可以通过服务发现、服务查询或设备查询等 流程获知目标设备支持的蓝牙服务,目标服务为目标设备支持的蓝牙服务。可选的,终端设备作为服务端时,目标服务为终端设备支持的蓝牙服务。
可选的,目标服务的全部蓝牙数据或者部分蓝牙数据可以部署在辅助处理单元上处理。比如,在BLE通信中,蓝牙服务包括至少一个character(特征)。可以将蓝牙服务包括的全部character(特征)都部署在辅助处理单元上;或者,可以将蓝牙服务中的部分character(特征)部署在辅助处理单元上。
终端设备和目标设备进行蓝牙通信的方式不同时,使用的蓝牙协议不同,第一服务信息也有所不同。
可选的,在BLE中,目标服务包括至少一个特征。第一服务信息包括:目标服务的UUID、至少一个特征中目标特征的逻辑通道索引和特征属性。可以参考本申请上述关于蓝牙服务的逻辑通道管理信息的相关说明。其中,第一服务信息用于辅助处理单元处理目标特征的蓝牙数据,也就是说,将目标服务中的目标特征部署在终端设备的辅助处理单元上进行处理。本实施例对目标特征的数量不做限定。
可选的,如果目标特征需要被使能。在一种实现方式中,如果目标特征没有被主处理单元使能,则第一服务信息还包括:目标特征的描述符的逻辑通道索引。目标特征的描述符的逻辑通道索引用于对目标特征进行使能。
在该实现方式中,目标特征需要被使能,主处理单元或者辅助处理单元均可以对目标特征使能。如果目标特征没有被主处理单元使能,那么,需要由辅助处理单元进行使能。第一服务信息需要包括目标特征的描述符的逻辑通道索引,使得辅助处理单元对目标特征使能。如果目标特征已经被主处理单元使能,那么,第一服务信息不需要包括目标特征的描述符的逻辑通道索引,从而避免了主处理单元和辅助处理单元对目标特征的重复使能。
可选的,如果目标特征需要被使能。在另一种实现方式中,第一服务信息还包括:目标特征的描述符的逻辑通道索引。
在该实现方式中,目标特征需要被使能。无论主处理单元是否已经对目标特征使能,第一服务信息都可以包括目标特征的描述符的逻辑通道索引。辅助处理单元可以根据目标特征的描述符的逻辑通道索引对目标特征使能。在该实现方式中,主处理单元和辅助处理单元可能对目标特征重复使能。
可选的,主处理单元可以向辅助处理单元发送使能信息,指示主处理单元是否对目标特征使能。通过使能信息,避免了主处理单元和辅助处理单元对目标特征的重复使能。
可选的,使能信息可以包含在第一服务信息中。减少了主处理单元和辅助处理单元之间传输数据的次数。
可选的,在经典蓝牙中,第一服务信息包括:目标服务的逻辑通道信道号和目标服务的角色。其中,角色为客户端或服务端。可以参考本申请上述关于蓝牙服务的逻辑通道管理信息的相关说明。
可选的,在经典蓝牙中,第一服务信息还可以包括目标服务的UUID。
需要说明,终端设备可以作为目标服务的客户端,也可以作为目标服务的服务端;相应的,目标设备作为目标服务的服务端,或者作为目标服务的客户端。比如,一种 应用场景可以为:终端设备作为目标服务的客户端,目标设备作为目标服务的服务端,目标服务为目标设备支持的蓝牙服务。目标设备可以向终端设备发送目标服务的数据。终端设备也可以向目标设备发送目标服务的数据。又比如,一种应用场景可以为:终端设备作为目标服务的服务端,目标设备作为目标服务的客户端,目标服务为终端设备支持的蓝牙服务。终端设备可以向目标设备发送目标服务的数据。目标设备也可以向终端设备发送目标服务的数据。
可选的,结合图9,下沉管理业务模块921可以通过调用API接口,例如数据同步接口,实现主处理单元向辅助处理单元发送第一MAC地址和第一服务信息。
S1002、辅助处理单元向蓝牙芯片发送第一MAC地址和第二服务信息。
其中,第二服务信息为第一服务信息中的部分或全部信息。
相应的,蓝牙芯片接收辅助处理单元发送的第一MAC地址和第二服务信息。
可选的,在BLE中,第二服务信息包括:目标服务包括的至少一个特征中目标特征的逻辑通道索引和特征属性。
可选的,如果目标特征需要被使能,第二服务信息还可以包括:目标特征的描述符的逻辑通道索引。可以参见S1001中的说明,此处不再赘述。
可选的,第二服务信息还可以包括:目标服务的UUID。
可选的,在经典蓝牙中,第二服务信息包括:目标服务的逻辑通道信道号和目标服务的角色;其中,角色为客户端或服务端。
可选的,第二服务信息还可以包括:目标服务的UUID。需要说明的是,如果第一服务信息不包括目标服务的UUID,则第二服务信息不包括目标服务的UUID。如果第一服务信息包括目标服务的UUID,那么,第二服务信息可以包括目标服务的UUID,也可以不包括目标服务的UUID。
可选的,结合图9,下沉管理业务模块921、蓝牙业务模块922和接口模块931可以通过调用相关的API接口,实现辅助处理单元向蓝牙芯片发送第一MAC地址和第二服务信息。
S1003、蓝牙芯片根据第一MAC地址和第二服务信息,在信息列表中增加目标设备的设备标识和目标服务的逻辑通道信息。目标设备的设备标识和目标服务的逻辑通道信息用于蓝牙芯片处理目标服务的蓝牙数据。
之后,蓝牙芯片和辅助处理单元可以处理目标服务的蓝牙数据。
具体的,设备标识供蓝牙芯片使用,可以唯一区分不同的设备。可选的,目标设备的设备标识包括:目标设备和终端设备之间蓝牙连接的ACL链路的标识。可选的,ACL链路标识可以表示为ACL handle(句柄)。
服务的逻辑通道信息,可以在一个设备支持的所有蓝牙服务中,唯一区分不同的蓝牙服务。对于目标服务的逻辑通道信息,如果目标服务是目标设备支持的蓝牙服务,通过目标服务的逻辑通道信息,可以在目标设备支持的所有蓝牙服务中唯一识别出目标服务;如果目标服务是终端设备支持的蓝牙服务,通过目标服务的逻辑通道信息,可以在终端设备支持的所有蓝牙服务中唯一识别出目标服务。
可选的,目标服务的逻辑通道信息和目标设备的设备标识具有关联关系。举例说明。在BLE通信中,蓝牙服务采用“应用-服务-特征-描述符”的分层结构进行描述, 参见图4和图5所示。对于每个设备,服务、特征和描述符的属性索引(attribute handle)内部排序,这有可能导致不同设备支持的不同服务的逻辑通道信息相同。比如,设备1支持的速率计服务的属性索引(attribute handle)范围是21-30,功率计服务的属性索引(attribute handle)范围是31-40,速率计服务中特征1的value handle(值索引)取值为25。设备2支持的功率计服务的属性索引(attribute handle)范围是21-30,功率计服务中特征1的value handle(值索引)取值为25。可见,对于value handle(值索引)取值25,在设备1和设备2中对应的服务和特征是不同的,设备1对应速率计服务的特征1,设备2对应功率计服务的特征1。因此,目标服务的逻辑通道信息和目标设备的设备标识可以具有关联关系,通过目标设备的设备标识以及目标服务的逻辑通道信息,可以唯一区分不同设备的不同服务。
终端设备和目标设备进行蓝牙通信的方式不同时,使用的蓝牙协议不同,目标服务的逻辑通道信息有所不同。
可选的,在BLE中,目标服务的逻辑通道信息包括:目标服务包括的至少一个特征中目标特征的逻辑通道索引和特征属性。
可选的,如果目标特征需要被使能,目标服务的逻辑通道信息还可以包括:目标特征的描述符的逻辑通道索引。可以参见S1001中的说明,此处不再赘述。
可选的,在经典通信中,目标服务的逻辑通道信息包括目标服务的DLCI。在该实现方式中,目标服务的DLCI也可以称为目标服务的逻辑通道索引。
在本实施例中,信息列表用于存储目标设备的设备标识和目标服务的逻辑通道信息。本实施例对信息列表的实现方式不做限定,可以为数据列表或者预设格式的文件,可以为一个数据列表或者多个数据列表,或者一个文件或者多个文件。
可选的,信息列表包括设备列表和下沉业务列表。设备列表包括目标设备的设备标识。下沉业务列表包括目标服务的逻辑通道信息。可选的,下沉业务列表还可以包括目标设备的设备标识,可以指示出目标设备的设备标识和目标服务的逻辑通道信息的关联关系。
可选的,在BLE中,蓝牙芯片根据第一MAC地址和第二服务信息,在信息列表中增加目标设备的设备标识和目标服务的逻辑通道信息,可以包括:
蓝牙芯片根据第一MAC地址确定目标设备的设备标识。
蓝牙芯片根据第二服务信息确定目标服务的逻辑通道信息。
在信息列表中增加目标设备的设备标识和目标服务的逻辑通道信息。
具体的,在BLE中,主处理单元向辅助处理单元发送第一MAC地址和第一服务信息,辅助处理单元向蓝牙芯片发送第一MAC地址和第二服务信息。蓝牙芯片可以根据第一MAC地址得到目标设备的ACL handle,并且根据第二服务信息确定目标服务的逻辑通道信息。
可选的,在经典蓝牙通信中,蓝牙芯片根据第一MAC地址和第二服务信息,在信息列表中增加目标设备的设备标识和目标服务的逻辑通道信息之前,还包括:
主处理单元向蓝牙芯片发送通道信息。通道信息包括目标设备的第二MAC地址和目标服务的DLCI。
相应的,蓝牙芯片根据第一MAC地址和第二服务信息,在信息列表中增加目标 设备的设备标识和目标服务的逻辑通道信息,包括:
蓝牙芯片根据第一MAC地址、第二服务信息、第二MAC地址和DLCI,在信息列表中增加目标设备的设备标识和目标服务的逻辑通道信息。
可选的,蓝牙芯片根据第一MAC地址、第二服务信息、第二MAC地址和DLCI,在信息列表中增加目标设备的设备标识和目标服务的逻辑通道信息,包括:
若第一MAC地址和第二MAC地址相同,蓝牙芯片根据第一MAC地址或第二MAC地址确定目标设备的设备标识。
蓝牙芯片根据DLCI得到待比对逻辑通道信道号和待比对角色。
若待比对逻辑通道信道号和目标服务的逻辑通道信道号相同,且待比对角色和目标服务的角色相同,则蓝牙芯片将DLCI确定为目标服务的逻辑通道信息。
在信息列表中增加目标设备的设备标识和DLCI。
可选的,通道信息还可以包括目标服务的UUID。
具体的,在经典蓝牙中,蓝牙协议栈至少根据服务的逻辑通道信道号和角色计算得到服务的DLCI,也就是说,计算DLCI时还需要其他的信息,其他信息不同时,相同的逻辑通道信道号和角色对应的DLCI可能不同。主处理单元向蓝牙芯片发送目标设备的第二MAC地址和目标服务的DLCI。主处理单元向辅助处理单元发送目标设备的第一MAC地址和目标服务的第一服务信息,辅助处理单元向蓝牙芯片发送第一MAC地址和第二服务信息。为了方便区分,将主处理单元向辅助处理单元发送的目标设备的MAC地址称为第一MAC地址,将主处理单元向蓝牙芯片发送的目标设备的MAC地址称为第二MAC地址。当第一MAC地址和第二MAC地址相同时,说明对应同一个目标设备,蓝牙芯片根据第一MAC地址或第二MAC地址可以确定目标设备的ACL handle。蓝牙芯片根据从主处理单元接收到的DLCI计算得到待比对逻辑通道信道号和待比对角色。如果待比对逻辑通道信道号和从辅助处理单元接收到的目标服务的逻辑通道信道号相同,并且,待比对角色和从辅助处理单元接收到的目标服务的角色相同,那么,蓝牙芯片将从主处理单元接收的DLCI确定为目标服务的逻辑通道信息。
可见,本实施例提供的蓝牙数据的处理方法,终端设备的主处理单元可以将部分蓝牙服务下沉到辅助处理单元上处理。主处理单元和辅助处理单元之间同步目标设备的MAC地址目标服务的第一服务信息,辅助处理单元和蓝牙芯片之间传输目标设备的MAC地址目标服务的第二服务信息,从而,辅助处理单元和蓝牙芯片获知目标服务是在辅助处理单元上处理。后续,辅助处理单元和蓝牙芯片可以处理目标服务的蓝牙数据。本实施例提供的蓝牙数据的处理方法,将主处理单元处理的蓝牙服务的部分或者全部蓝牙数据转移到辅助处理单元处理,形成了数据分流,缩短了主处理单元的工作时间。由于辅助处理单元的耗电量相比于主处理单元较小,因此,降低了终端设备的耗电,延长了终端设备的续航时间。
可选的,本实施例提供的蓝牙数据的处理方法,还可以包括:
S1004、蓝牙芯片接收第一蓝牙数据。
S1005、蓝牙芯片解析第一蓝牙数据,得到第一设备标识和第一逻辑通道索引。判断第一设备标识和第一逻辑通道索引是否在信息列表中。
如果第一设备标识和第一逻辑通道索引在信息列表中,说明第一蓝牙数据为目标服务的蓝牙数据,需要由辅助处理单元处理,则执行S1006和S1007。
如果第一设备标识或第一逻辑通道索引不在信息列表中,说明第一蓝牙数据不是目标服务的蓝牙数据,需要由主处理单元处理,则执行S1008和S1009。
S1006、蓝牙芯片将第一蓝牙数据发送至辅助处理单元。
S1007、辅助处理单元处理第一蓝牙数据。
S1008、蓝牙芯片将第一蓝牙数据发送至主处理单元。
S1009、主处理单元处理第一蓝牙数据。
在该实现方式中,终端设备作为数据接收端,接收并处理目标设备发送的蓝牙数据。具体的,终端设备的蓝牙芯片具有协议数据解析能力,例如,图9中所示的协议数据解析/封装模块933,从第一蓝牙数据中解析出第一设备标识和第一逻辑通道索引,根据信息列表判断第一蓝牙数据是否属于目标服务的数据。如果是目标服务的数据,则由辅助处理单元处理,降低了终端设备的能耗,延长了续航时间。
下面,结合图11和图12对协议数据解析/封装进行示例性说明,但图11和图12并不对数据结构形成限定。
示例性的,图11为本申请实施例提供的BLE通信中的一种数据结构。如图11所示,GATT数据包括:类型(TYPE)、ACL句柄(ACL HANDLE)、ACL数据长度(ACL DATA LENGTH)、L2CAP数据长度(L2CAP DATA LENGTH)、L2CAP CID(communication identifier,通信标识符)、ATT操作码(ATT OPCODE)、ATT句柄(ATT Handle)、ATT数据(ATT DATA)。其中,类型具体为ACL。
图11中的4个箭头指示的位置,依次为:数据解析开始/数据封装结束的位置、设备标识所在的位置、逻辑通道信息所在的位置、数据解析结束/数据封装开始的位置。
示例性的,图12为本申请实施例提供的经典蓝牙通信中的一种数据结构。如图12所示,RFCOMM数据包括:类型(TYPE)、ACL句柄(ACL HANDLE)、ACL数据长度(ACL DATA LENGTH)、L2CAP数据长度(L2CAP DATA LENGTH)、L2CAP CID、RFCOMM DLCI、RFCOMM控制(RFCOMM CONTROL)、RFCOMM数据(RFCOMM DATA)。其中,类型具体为ACL。
图12中的4个箭头指示的位置,依次为:数据解析开始/数据封装结束的位置、设备标识所在的位置、逻辑通道信息所在的位置、数据解析结束/数据封装开始的位置。
可选的,本实施例提供的蓝牙数据的处理方法,还可以包括:
S1010、辅助处理单元生成目标服务的第二蓝牙数据。
S1011、辅助处理单元将第二蓝牙数据发送至蓝牙芯片。
S1012、蓝牙芯片根据目标设备的设备标识和目标服务的逻辑通道信息,对第二蓝牙数据进行封装,得到待发送数据。
S1013、蓝牙芯片向目标设备发送待发送数据。
在该实现方式中,终端设备作为数据发送端,向目标设备发送目标服务的数据。具体的,辅助处理单元处理目标服务的数据后,将第二蓝牙数据发送给蓝牙芯片。蓝牙芯片具有协议数据封装能力,例如,图9中所示的协议数据解析/封装模块933,根据信息列表将第二蓝牙数据封装后发送给目标设备。由辅助处理单元处理目标服务的 数据,降低了终端设备的能耗,延长了续航时间。
可选的,图13为本申请实施例提供的蓝牙数据的处理方法的另一种流程图。如图13所示,本实施例提供的蓝牙数据的处理方法,还可以包括:
S1301、主处理单元向辅助处理单元发送第一信息。第一信息用于指示主处理单元处理目标服务的蓝牙数据。
可选的,第一信息可以包括目标设备的第一MAC地址和目标服务的第一服务信息。
可选的,如图9所示,下沉管理业务模块921可以通过调用API接口,例如数据取消同步接口,实现主处理单元向辅助处理单元发送第一信息。
S1302、辅助处理单元根据第一信息删除第一服务信息。
可选的,辅助处理单元根据第一信息还删除第一MAC地址。
S1303、辅助处理单元向蓝牙芯片发送第二信息。第二信息用于指示主处理单元处理目标服务的蓝牙数据。
可选的,第二信息可以包括目标设备的第一MAC地址和目标服务的第二服务信息。
可选的,如图9所示,下沉管理业务模块921、蓝牙业务模块922和接口模块931可以通过调用相关的API接口,实现辅助处理单元向蓝牙芯片发送第二信息。
S1304、蓝牙芯片根据第二信息在信息列表中删除目标服务的逻辑通道信息。
可选的,蓝牙芯片根据第二信息还删除目标设备的设备标识。
在该实现方式中,目标服务可以重新部署在主处理单元上。因此,主处理单元、辅助处理单元和蓝牙芯片之间需要删除目标服务的相关信息,从而使得主处理单元可以处理目标服务的蓝牙数据。通过该实现方式,可以在主处理单元和辅助处理单元上灵活布置需要处理的蓝牙服务。
可选的,在上述实施例的基础上,结合图1A所示场景,本申请的另一个实施例提供了BLE通信中蓝牙数据的处理方法的一种实现方式。参见图14和图15,图14为本申请实施例提供的BLE通信中终端设备处理蓝牙数据的另一种原理示意图。图15为本申请实施例提供的蓝牙数据的处理方法的又一种流程图。
如图9和图14所示,在BLE通信中,下沉管理业务模块921对应图14中的下沉管理业务模块,蓝牙业务模块922对应图14中的GATT蓝牙业务模块,接口模块931对应图14中的GATT接口模块,信息列表932对应图14中的设备列表和下沉业务列表,协议数据解析/封装模块933对应图14中的协议数据解析/封装模块。其中,下沉管理业务模块、GATT蓝牙业务模块、GATT接口模块提供的API执行GATT协议。
图14和图7相比,图14中的粗实线和粗虚线,示出了蓝牙数据处理过程中的数据流向。在图7中,在智能手表中,由AP处理蓝牙服务的数据,BT芯片并不对数据进行解析/封装。而在图14中,在智能手表中,目标服务部署在MCU上。智能手表作为数据接收方时,智能手表的BT芯片接收到运动单车发送的蓝牙数据后,进行数据解析,判断是否属于目标服务的数据。如果属于目标服务的数据,则发送给MCU处理,由MCU实现目标服务数据的屏幕送显;如果不属于目标服务的数据,则发送给 AP处理,由AP实现屏幕送显。智能手表作为数据发送方时,MCU对目标服务的蓝牙数据进行处理后发送给BT芯片,BT芯片对数据封装后发送给运动单车。
在本实施例中,终端设备为智能手表,目标设备为运动单车。目标服务为速率计服务。如图5所示,速率计服务包括特征1和特征2。特征1(character1)不需要使能,特征2(character2)需要使能。character1的逻辑通道索引为handle取值24。character2的逻辑通道索引为handle取值26,character2的descriptor的逻辑通道索引为handle取值27。
可选的,在一种实现方式中,目标特征为速率计服务的character1,不需要使能。如图15所示,蓝牙数据的处理方法包括:
S1501、AP向MCU发送运动单车的第一MAC地址和速率计服务的第一服务信息。
第一服务信息包括:速率计服务的UUID、character1的逻辑通道索引(handle取值24)和特征属性(property)。
S1502、MCU向BT芯片发送第一MAC地址和第二服务信息。
第二服务信息包括:character1的逻辑通道索引(handle取值24)和特征属性(property)。
可选的,第二服务信息还可以包括:速率计服务的UUID。
S1506、BT芯片根据第一MAC地址和第二服务信息,在信息列表中增加运动单车的设备标识和速率计服务的逻辑通道信息。
其中,速率计服务的逻辑通道信息包括:character1的逻辑通道索引(handle取值24)和特征属性(property)。
可选的,在另一种实现方式中,目标特征为速率计服务的character2,需要使能。AP已经使能character2,MCU不需要使能。如图15所示,蓝牙数据的处理方法包括:
S1501、AP向MCU发送运动单车的第一MAC地址和速率计服务的第一服务信息。
第一服务信息包括:速率计服务的UUID、character2的逻辑通道索引(handle取值26)和特征属性(property)。
S1502、MCU向BT芯片发送第一MAC地址和第二服务信息。
第二服务信息包括:character2的逻辑通道索引(handle取值26)和特征属性(property)。
可选的,第二服务信息还可以包括:速率计服务的UUID。
S1503、AP通知BT芯片使能速率计服务的特征2。
S1505、BT芯片使能速率计服务的特征2。
S1506、BT芯片根据第一MAC地址和第二服务信息,在信息列表中增加运动单车的设备标识和速率计服务的逻辑通道信息。
其中,速率计服务的逻辑通道信息包括:character2的逻辑通道索引(handle取值26)和特征属性(property)。
其中,本实施方式对S1503、S1505与S1501、S1502、S1506之间的执行顺序不作限定。
可选的,在又一种实现方式中,目标特征为速率计服务的character2,需要使能。AP没有使能character2,需要由MCU使能。如图15所示,蓝牙数据的处理方法包括:
S1501、AP向MCU发送运动单车的第一MAC地址和速率计服务的第一服务信息。
第一服务信息包括:速率计服务的UUID、character2的逻辑通道索引(handle取值26)和特征属性(property)、character2的descriptor的逻辑通道索引(handle取值27)。
S1502、MCU向BT芯片发送第一MAC地址和第二服务信息。
第二服务信息包括:character2的逻辑通道索引(handle取值26)和特征属性(property)、character2的descriptor的逻辑通道索引(handle取值27)。
可选的,第二服务信息还可以包括:速率计服务的UUID。
S1504、MCU通知BT芯片使能速率计服务的特征2。
S1505、BT芯片使能速率计服务的特征2。
S1506、BT芯片根据第一MAC地址和第二服务信息,在信息列表中增加运动单车的设备标识和速率计服务的逻辑通道信息。
其中,速率计服务的逻辑通道信息包括:character2的逻辑通道索引(handle取值26)和特征属性(property)、character2的descriptor的逻辑通道索引(handle取值27)。
其中,本实施方式对S1504、S1505与S1506之间的执行顺序不作限定。
可选的,在本实施例中,GATT蓝牙业务模块提供的API可以包括但不限于下列中的至少一项:GATT虚拟连接接口、写character&descripter接口、读characteristic接口、offload服务信息注册接口(需要offload业务的characteristic信息)、GATT回调接口(包含连接事件、characteristic变化事件、读取characterisc回调事件等),或者,使能服务接口。BT芯片中的GATT接口模块可以包含相应的对等接口。
可选的,在S1502中,MCU向BT芯片发送第一MAC地址和第二服务信息,一种实现方式可以包括:下沉管理业务模块调用GATT蓝牙业务模块提供的GATT虚拟连接接口,发起虚拟连接,将运动单车的MAC地址通过核间通讯告知BT芯片,指示了MCU准备接收运动单车的offload业务的数据。需要说明,由于AP侧的运动健康APP已经完成了对运动单车的实际物理通道的连接,此处发起的连接,是要通知BT芯片将运动单车的设备标识加入设备列表中,以便于后续BT芯片可以过滤、识别运动单车的数据,所以称为虚拟连接。在MCU获取回调虚拟连接的结果(例如,可以指示运动单车的设备标识加入设备列表是否成功)后,下沉管理业务模块调用GATT蓝牙业务模块提供的offload服务信息注册接口,将速率计服务的characteric和descripter的handle、property等信息(第二服务信息)通知到BT芯片。
后续,BT芯片获得第二服务信息后,可以将第二服务信息加入到下沉业务列表中。
可选的,在S1504中,MCU通知BT芯片使能速率计服务的特征2,一种实现方式可以包括:下沉管理业务模块调用GATT蓝牙业务模块提供的使能服务接口,通知BT芯片对速率计服务的character进行使能。
可选的,在上述实施例的基础上,结合图1B所示场景,本申请的又一个实施例提供了经典蓝牙通信中蓝牙数据的处理方法的一种实现方式。参见图16和图17,图16为本申请实施例提供的经典蓝牙中终端设备处理蓝牙数据的另一种原理示意图。图17为本申请实施例提供的蓝牙数据的处理方法的又一种流程图。
如图9和图16所示,在经典蓝牙通信中,下沉管理业务模块921对应图16中的下沉管理业务模块,蓝牙业务模块922对应图16中的Socket蓝牙业务模块,接口模块931对应图16中的Socket接口模块,信息列表932对应图16中的设备列表和下沉业务列表,协议数据解析/封装模块933对应图14中的协议数据解析/封装模块。其中,下沉管理业务模块、Socket蓝牙业务模块、Socket接口模块提供的API执行RFCOMM协议。
可选的,在图16中,BT芯片还可以包括状态管理模块,用于维护BT芯片的状态,例如,芯片sniff状态、RFCOMM通道流控等。
在本实施例中,终端设备为智能手表,目标设备为手机。目标服务为消息通知服务。手机为消息通知服务的服务端。智能手表为消息通知服务的客户端,即角色为客户端。
如图17所示,蓝牙数据的处理方法可以包括:
S1701、AP向BT芯片发送通道信息。
其中,通道信息包括手机的第二MAC地址和消息通知服务的DLCI。
可选的,通道信息还可以包括消息通知服务的UUID。例如,如图16所示,AP通过MCU向BT芯片发送通道信息时,需要携带消息通知服务的UUID。
S1702、AP向MCU发送手机的第一MAC地址和消息通知服务的第一服务信息。
第一服务信息包括:消息通知服务的逻辑通道信道号和消息通知服务的角色(具体为客户端)。
可选的,第一服务信息还可以包括:消息通知服务的UUID。
S1703、MCU向BT芯片发送第一MAC地址和第二服务信息。
第二服务信息包括:消息通知服务的逻辑通道信道号和消息通知服务的角色(具体为客户端)。
可选的,第二服务信息还可以包括:消息通知服务的UUID。
S1704、BT芯片根据第一MAC地址、第二MAC地址、第二服务信息和DLCI,在信息列表中增加手机的设备标识和消息通知服务的逻辑通道信息。
需要说明,图14和图15所示的BLE通信方式,以及,图16和图17所示的经典蓝牙通信方式,对于本实施例提供的蓝牙数据的处理方法,终端设备中的新增模块和方法流程相似,相互间可以参考。区别在于,在BLE通信中,具有特征的使能过程。而在经典蓝牙中,BT芯片和AP需要传输通道数据,不需要服务使能。
可以理解的是,终端设备为了实现上述功能,其包含了执行各个功能相应的硬件和/或软件模块。结合本文中所公开的实施例描述的各示例的算法步骤,本申请能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。本领域技术人员可以结合实施例对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
本申请实施例可以根据上述方法示例对终端设备进行功能模块的划分,例如,可以对应各个功能划分各个功能模块,也可以将两个或两个以上的功能集成在一个模块 中。需要说明的是,本申请实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。需要说明的是,本申请实施例中模块的名称是示意性的,实际实现时对模块的名称不做限定。
示例性的,图18为本申请实施例提供的蓝牙数据的处理装置的一种结构示意图。蓝牙数据的处理装置应用于终端设备。如图18所示,蓝牙数据的处理装置,可以包括:
接收模块1801,用于接收第一蓝牙数据;
第一处理模块1802,用于在确定所述第一蓝牙数据满足预设条件时,将所述第一蓝牙数据发送至第二处理模块1803;
所述第二处理模块1803,用于处理所述第一蓝牙数据。
可选的,所述第一处理模块1802用于:
解析所述第一蓝牙数据,得到第一设备标识和第一逻辑通道索引;
若所述第一设备标识和所述第一逻辑通道索引在信息列表中,则确定所述第一蓝牙数据满足所述预设条件;所述信息列表用于存储目标设备的设备标识和目标服务的逻辑通道信息,所述第二处理模块1803用于处理所述目标服务的蓝牙数据。
可选的,所述第一处理模块1802还用于:
若所述第一设备标识或所述第一逻辑通道索引不在所述信息列表中,则将所述第一蓝牙数据发送至第三处理模块1804;
所述第三处理模块1804,用于处理所述第一蓝牙数据。
可选的,所述第二处理模块1803还用于:
生成目标服务的第二蓝牙数据,将所述第二蓝牙数据发送至所述第一处理模块1802;
所述第一处理模块1802还用于:
对所述第二蓝牙数据进行封装,得到待发送数据;
还包括发送模块1805,用于向目标设备发送所述待发送数据。
可选的,所述第三处理模块1804,还用于:
在所述接收模块1801接收第一蓝牙数据之前,向所述第二处理模块1803发送目标设备的第一MAC地址和目标服务的第一服务信息;所述目标设备为和所述终端设备蓝牙通信的设备,所述第一服务信息用于所述第二处理模块1803处理所述目标服务的蓝牙数据;
所述第二处理模块1803,还用于:向所述第一处理模块1802发送所述第一MAC地址和第二服务信息;所述第二服务信息为所述第一服务信息中的部分或全部信息;
所述第一处理模块1802,还用于:根据所述第一MAC地址和所述第二服务信息,在信息列表中增加所述目标设备的设备标识和所述目标服务的逻辑通道信息;所述目标设备的设备标识和所述目标服务的逻辑通道信息用于所述第一处理模块1802处理所述目标服务的蓝牙数据。
可选的,所述目标设备的设备标识包括ACL标识。
可选的,所述终端设备和所述目标设备支持GATT协议,所述目标服务包括至少一个特征;
所述第一服务信息、所述第二服务信息和所述目标服务的逻辑通道信息,包括: 所述至少一个特征中目标特征的逻辑通道索引和特征属性;
所述第一服务信息还包括:所述目标服务的UUID,所述第一服务信息用于所述第二处理模块1803处理所述目标特征的蓝牙数据。
可选的,所述目标特征需要被使能;
所述第一服务信息、所述第二服务信息和所述目标服务的逻辑通道信息,还包括:所述目标特征的描述符的逻辑通道索引。
可选的,所述目标特征没有被所述第三处理模块1804使能。
可选的,所述第三处理模块1804和/或所述第二处理模块1803,还用于:
在所述接收模块1801接收第一蓝牙数据之前,使能所述目标特征。
可选的,所述终端设备和所述目标设备支持RFCOMM协议;
所述第一服务信息和所述第二服务信息,包括:所述目标服务的逻辑通道信道号和所述目标服务的角色;其中,所述角色为客户端或服务端。
可选的,所述第一服务信息还包括所述目标服务的UUID。
可选的,所述第三处理模块1804还用于:
向所述第一处理模块1802发送通道信息;所述通道信息包括所述目标设备的第二MAC地址和所述目标服务的DLCI;
所述第一处理模块1802用于:
根据所述第一MAC地址、所述第二服务信息、所述第二MAC地址和所述DLCI,在所述信息列表中增加所述目标设备的设备标识和所述目标服务的逻辑通道信息。
可选的,所述第一处理模块1802用于:
若所述第一MAC地址和所述第二MAC地址相同,根据所述第一MAC地址或所述第二MAC地址确定所述目标设备的设备标识;
根据所述DLCI得到待比对逻辑通道信道号和待比对角色;
若所述待比对逻辑通道信道号和所述目标服务的逻辑通道信道号相同,且所述待比对角色和所述目标服务的角色相同,则将所述DLCI确定为所述目标服务的逻辑通道信息;
在所述信息列表中增加所述目标设备的设备标识和所述DLCI。
可选的,所述第三处理模块1804,还用于:
向所述第二处理模块1803发送第一信息;所述第一信息用于指示所述第三处理模块1804处理所述目标服务的蓝牙数据;
所述第二处理模块1803,还用于:
根据所述第一信息删除所述第一服务信息,并向所述第一处理模块1802发送第二信息;所述第二信息用于指示所述第三处理模块1804处理所述目标服务的蓝牙数据;
所述第一处理模块1802,还用于:
根据所述第二信息在所述信息列表中删除所述目标服务的逻辑通道信息。
可选的,所述信息列表包括设备列表和下沉业务列表;所述设备列表包括所述目标设备的设备标识,所述下沉业务列表包括所述目标设备的设备标识和所述目标服务的逻辑通道信息。
可选的,所述终端设备为所述目标服务的客户端,所述目标设备为所述目标服务 的服务端。
本实施例提供的蓝牙数据的处理装置,用于执行本申请实施例提供的蓝牙数据的处理方法,技术原理和技术效果相似,此处不再赘述。
可选的,在一种实现方式中,参见图18和图9所示,第一处理模块可以包括接口模块931、信息列表932和协议数据解析/封装模块933;第二处理模块可以包括下沉管理业务模块921和蓝牙业务模块922。
本申请实施例还提供一种计算机程序产品,当所述计算机程序产品在设备运行时,使得所述设备执行上述实施例中的技术方案,其实现原理和技术效果与上述相关实施例类似,此处不再赘述。
本申请实施例提供一种计算机可读存储介质,其上存储有程序指令,所述程序指令被设备执行时,使得所述设备执行上述实施例的技术方案。其实现原理和技术效果与上述相关实施例类似,此处不再赘述。
综上所述,以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的范围。

Claims (19)

  1. 一种蓝牙数据的处理方法,其特征在于,应用于终端设备,所述终端设备包括主处理单元、辅助处理单元和蓝牙芯片;所述方法包括:
    所述蓝牙芯片接收第一蓝牙数据;
    若所述蓝牙芯片确定所述第一蓝牙数据满足预设条件,则将所述第一蓝牙数据发送至所述辅助处理单元;
    所述辅助处理单元处理所述第一蓝牙数据。
  2. 根据权利要求1所述的方法,其特征在于,所述蓝牙芯片确定所述第一蓝牙数据满足预设条件,包括:
    所述蓝牙芯片解析所述第一蓝牙数据,得到第一设备标识和第一逻辑通道索引;
    若所述第一设备标识和所述第一逻辑通道索引在信息列表中,所述蓝牙芯片确定所述第一蓝牙数据满足所述预设条件;所述信息列表用于存储目标设备的设备标识和目标服务的逻辑通道信息,所述辅助处理单元用于处理所述目标服务的蓝牙数据。
  3. 根据权利要求2所述的方法,其特征在于,所述方法还包括:
    若所述第一设备标识或所述第一逻辑通道索引不在所述信息列表中,所述蓝牙芯片将所述第一蓝牙数据发送至所述主处理单元;
    所述主处理单元处理所述第一蓝牙数据。
  4. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    所述辅助处理单元生成目标服务的第二蓝牙数据;
    所述辅助处理单元将所述第二蓝牙数据发送至所述蓝牙芯片;
    所述蓝牙芯片对所述第二蓝牙数据进行封装,得到待发送数据;
    所述蓝牙芯片向目标设备发送所述待发送数据。
  5. 根据权利要求1-4中任一项所述的方法,其特征在于,所述蓝牙芯片接收第一蓝牙数据之前,还包括:
    所述主处理单元向所述辅助处理单元发送目标设备的第一媒体访问控制MAC地址和目标服务的第一服务信息;所述目标设备为和所述终端设备蓝牙通信的设备,所述第一服务信息用于所述辅助处理单元处理所述目标服务的蓝牙数据;
    所述辅助处理单元向所述蓝牙芯片发送所述第一MAC地址和第二服务信息;所述第二服务信息为所述第一服务信息中的部分或全部信息;
    所述蓝牙芯片根据所述第一MAC地址和所述第二服务信息,在信息列表中增加所述目标设备的设备标识和所述目标服务的逻辑通道信息;所述目标设备的设备标识和所述目标服务的逻辑通道信息用于所述蓝牙芯片处理所述目标服务的蓝牙数据。
  6. 根据权利要求5所述的方法,其特征在于,所述目标设备的设备标识包括面向连接的异步链路ACL标识。
  7. 根据权利要求5所述的方法,其特征在于,所述终端设备和所述目标设备支持通用属性协议GATT,所述目标服务包括至少一个特征;
    所述第一服务信息、所述第二服务信息和所述目标服务的逻辑通道信息,包括:所述至少一个特征中目标特征的逻辑通道索引和特征属性;
    所述第一服务信息还包括:所述目标服务的通用唯一标识符UUID,所述第一服 务信息用于所述辅助处理单元处理所述目标特征的蓝牙数据。
  8. 根据权利要求7所述的方法,其特征在于,所述目标特征需要被使能;
    所述第一服务信息、所述第二服务信息和所述目标服务的逻辑通道信息,还包括:所述目标特征的描述符的逻辑通道索引。
  9. 根据权利要求8所述的方法,其特征在于,所述目标特征没有被所述主处理单元使能。
  10. 根据权利要求8或9所述的方法,其特征在于,所述蓝牙芯片接收第一蓝牙数据之前,还包括:
    所述主处理单元和/或所述辅助处理单元使能所述目标特征。
  11. 根据权利要求5所述的方法,其特征在于,所述终端设备和所述目标设备支持无线电频率通信协议RFCOMM;
    所述第一服务信息和所述第二服务信息,包括:所述目标服务的逻辑通道信道号和所述目标服务的角色;其中,所述角色为客户端或服务端。
  12. 根据权利要求11所述的方法,其特征在于,所述第一服务信息还包括所述目标服务的UUID。
  13. 根据权利要求11所述的方法,其特征在于,所述蓝牙芯片根据所述第一MAC地址和所述第二服务信息,在信息列表中增加所述目标设备的设备标识和所述目标服务的逻辑通道信息之前,还包括:
    所述主处理单元向所述蓝牙芯片发送通道信息;所述通道信息包括所述目标设备的第二MAC地址和所述目标服务的数据链路连接标识DLCI;
    所述蓝牙芯片根据所述第一MAC地址和所述第二服务信息,在信息列表中增加所述目标设备的设备标识和所述目标服务的逻辑通道信息,包括:
    所述蓝牙芯片根据所述第一MAC地址、所述第二服务信息、所述第二MAC地址和所述DLCI,在所述信息列表中增加所述目标设备的设备标识和所述目标服务的逻辑通道信息。
  14. 根据权利要求13所述的方法,其特征在于,所述蓝牙芯片根据所述第一MAC地址、所述第二服务信息、所述第二MAC地址和所述DLCI,在所述信息列表中增加所述目标设备的设备标识和所述目标服务的逻辑通道信息,包括:
    若所述第一MAC地址和所述第二MAC地址相同,所述蓝牙芯片根据所述第一MAC地址或所述第二MAC地址确定所述目标设备的设备标识;
    所述蓝牙芯片根据所述DLCI得到待比对逻辑通道信道号和待比对角色;
    若所述待比对逻辑通道信道号和所述目标服务的逻辑通道信道号相同,且所述待比对角色和所述目标服务的角色相同,则所述蓝牙芯片将所述DLCI确定为所述目标服务的逻辑通道信息;
    在所述信息列表中增加所述目标设备的设备标识和所述DLCI。
  15. 根据权利要求5所述的方法,其特征在于,所述方法还包括:
    所述主处理单元向所述辅助处理单元发送第一信息;所述第一信息用于指示所述主处理单元处理所述目标服务的蓝牙数据;
    所述辅助处理单元根据所述第一信息删除所述第一服务信息;
    所述辅助处理单元向所述蓝牙芯片发送第二信息;所述第二信息用于指示所述主处理单元处理所述目标服务的蓝牙数据;
    所述蓝牙芯片根据所述第二信息在所述信息列表中删除所述目标服务的逻辑通道信息。
  16. 根据权利要求5所述的方法,其特征在于,所述信息列表包括设备列表和下沉业务列表;所述设备列表包括所述目标设备的设备标识,所述下沉业务列表包括所述目标设备的设备标识和所述目标服务的逻辑通道信息。
  17. 根据权利要求5所述的方法,其特征在于,所述终端设备为所述目标服务的客户端,所述目标设备为所述目标服务的服务端。
  18. 一种终端设备,其特征在于,包括处理器和蓝牙芯片,所述处理器包括主处理单元和辅助处理单元,所述处理器与存储器耦合,所述处理器执行存储器中存储的计算机程序,以实现如权利要求1-17任一项所述的方法。
  19. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机指令,当所述计算机指令在设备上运行时,使得所述设备执行如权利要求1-17中任一项所述的方法。
PCT/CN2023/100748 2022-06-23 2023-06-16 蓝牙数据的处理方法、终端设备和可读存储介质 WO2023246648A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210718449.6 2022-06-23
CN202210718449.6A CN117336702A (zh) 2022-06-23 2022-06-23 蓝牙数据的处理方法、终端设备和可读存储介质

Publications (1)

Publication Number Publication Date
WO2023246648A1 true WO2023246648A1 (zh) 2023-12-28

Family

ID=89274212

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/100748 WO2023246648A1 (zh) 2022-06-23 2023-06-16 蓝牙数据的处理方法、终端设备和可读存储介质

Country Status (2)

Country Link
CN (1) CN117336702A (zh)
WO (1) WO2023246648A1 (zh)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019199049A1 (ko) * 2018-04-10 2019-10-17 엘지전자 주식회사 무선 통신 시스템에서 디바이스를 제어하기 위한 방법 및 이를 위한 장치
CN110611524A (zh) * 2019-09-26 2019-12-24 联想(北京)有限公司 蓝牙数据信息传输方法及装置
CN110891259A (zh) * 2019-11-27 2020-03-17 出门问问信息科技有限公司 一种智能手表的低功耗蓝牙ble数据的传输方法、装置
CN111713141A (zh) * 2018-04-04 2020-09-25 华为技术有限公司 一种蓝牙播放方法及电子设备
CN114554463A (zh) * 2020-11-24 2022-05-27 华为终端有限公司 蓝牙通信方法、蓝牙广播方法、蓝牙设备以及存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111713141A (zh) * 2018-04-04 2020-09-25 华为技术有限公司 一种蓝牙播放方法及电子设备
WO2019199049A1 (ko) * 2018-04-10 2019-10-17 엘지전자 주식회사 무선 통신 시스템에서 디바이스를 제어하기 위한 방법 및 이를 위한 장치
CN110611524A (zh) * 2019-09-26 2019-12-24 联想(北京)有限公司 蓝牙数据信息传输方法及装置
CN110891259A (zh) * 2019-11-27 2020-03-17 出门问问信息科技有限公司 一种智能手表的低功耗蓝牙ble数据的传输方法、装置
CN114554463A (zh) * 2020-11-24 2022-05-27 华为终端有限公司 蓝牙通信方法、蓝牙广播方法、蓝牙设备以及存储介质

Also Published As

Publication number Publication date
CN117336702A (zh) 2024-01-02

Similar Documents

Publication Publication Date Title
US10693969B2 (en) Electronic device using logical channels for communication
EP3420759B1 (en) A source device broadcasts synchronization information associated with a bluetooth isochronous channel.
EP3550888B1 (en) Wireless connection switching method and terminal
WO2020132922A1 (zh) 一种连接蓝牙设备方法及设备
US11489614B2 (en) High-speed audio data transmission method and apparatus
US11172530B2 (en) Communication establishment method and terminal
WO2022143071A1 (zh) 连接建立方法及电子设备
JP2021180510A (ja) 通信装置、通信方法、及びプログラム
US20220030505A1 (en) Method and device for providing audio service using bluetooth technology
EP4311314A1 (en) Sleep scheduling method and device
WO2022205234A1 (zh) 一种通信方法及装置
WO2012088906A1 (zh) 物联网终端互通的方法及系统
WO2022143508A1 (zh) 一种近场中传输数据的方法、设备及系统
WO2022228051A1 (zh) 一种设备组网方法、电子设备及存储介质
JP6880719B2 (ja) 通信装置、通信方法、電子時計及びプログラム
WO2023246648A1 (zh) 蓝牙数据的处理方法、终端设备和可读存储介质
CN113301113B (zh) 一种profile版本确定方法、系统、电子设备及计算机存储介质
US20230103916A1 (en) Audio data reception method using short-range wireless communication in wireless communication system, and apparatus therefor
CN115669051A (zh) 用于在无线通信系统中选择通道的方法、设备和计算机程序及其记录介质
WO2023179728A1 (zh) 通信系统的数据传输方法、终端及网络侧设备
WO2024109221A1 (zh) 一种网络切片匹配方法和装置
WO2024007998A1 (zh) 一种数据传输的方法、电子设备和通信系统
WO2023051204A1 (zh) 跨设备连接方法、电子设备及存储介质
WO2024104122A1 (zh) 分享方法、电子设备及计算机存储介质
WO2023246104A1 (zh) 通信方法及相关装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23826297

Country of ref document: EP

Kind code of ref document: A1