WO2022042314A1 - 用于蓝牙通信的方法和电子设备 - Google Patents

用于蓝牙通信的方法和电子设备 Download PDF

Info

Publication number
WO2022042314A1
WO2022042314A1 PCT/CN2021/112164 CN2021112164W WO2022042314A1 WO 2022042314 A1 WO2022042314 A1 WO 2022042314A1 CN 2021112164 W CN2021112164 W CN 2021112164W WO 2022042314 A1 WO2022042314 A1 WO 2022042314A1
Authority
WO
WIPO (PCT)
Prior art keywords
operating system
layer
hci
bluetooth
data packet
Prior art date
Application number
PCT/CN2021/112164
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 华为技术有限公司
Priority to US18/043,211 priority Critical patent/US20230337300A1/en
Priority to EP21860153.2A priority patent/EP4195520A4/en
Publication of WO2022042314A1 publication Critical patent/WO2022042314A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04BTRANSMISSION
    • H04B5/00Near-field transmission systems, e.g. inductive or capacitive transmission systems
    • H04B5/40Near-field transmission systems, e.g. inductive or capacitive transmission systems characterised by components specially adapted for near-field transmission
    • H04B5/48Transceivers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/10Connection setup
    • H04W76/14Direct-mode setup
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04MTELEPHONIC COMMUNICATION
    • H04M1/00Substation equipment, e.g. for use by subscribers
    • H04M1/72Mobile telephones; Cordless telephones, i.e. devices for establishing wireless links to base stations without route selection
    • H04M1/724User interfaces specially adapted for cordless or mobile telephones
    • H04M1/72403User interfaces specially adapted for cordless or mobile telephones with means for local support of applications that increase the functionality
    • H04M1/72409User interfaces specially adapted for cordless or mobile telephones with means for local support of applications that increase the functionality by interfacing with external accessories
    • H04M1/72412User interfaces specially adapted for cordless or mobile telephones with means for local support of applications that increase the functionality by interfacing with external accessories using two-way short-range wireless interfaces
    • 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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/10Connection setup
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/4411Configuring for operating with peripheral devices; Loading of device drivers
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04MTELEPHONIC COMMUNICATION
    • H04M2250/00Details of telephonic subscriber devices
    • H04M2250/02Details of telephonic subscriber devices including a Bluetooth interface
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W84/00Network topologies
    • H04W84/18Self-organising networks, e.g. ad-hoc networks or sensor networks

Definitions

  • the present application relates to the field of communications, and more particularly to methods and electronic devices for Bluetooth communication in the field of communications.
  • the communication can be specifically performed through an operating system running on the two devices.
  • the first device has two different operating systems, and the second device needs to communicate with both operating systems in the first device, it may only communicate with one of the operating systems in the first device due to the limitation of the Bluetooth hardware.
  • Bluetooth communication the second device cannot communicate via Bluetooth with another operating system.
  • the operating system in the container cannot communicate with an external second device.
  • the first device is a computer
  • the second device is a mobile phone
  • the container of the computer runs the Android system
  • the mobile phone is the Android system
  • the Android system of the mobile phone cannot perform Bluetooth communication with the Android system in the container of the computer.
  • Embodiments of the present application provide a method and an electronic device for Bluetooth communication, which enable a first operating system of a first device to perform Bluetooth communication with an operating system of a second device.
  • a method for Bluetooth communication is provided, the method is applicable to a first device, the first device includes a first operating system and a second operating system, the method includes: the first operating system passes the A host controller interface (host controller interface, HCI) channel sends a first instruction to the second operating system, where the first instruction is used to establish a first Bluetooth connection between the first device and the second device; the second operating system The first Bluetooth connection between the first device and the second device is established according to the first instruction; the second operating system sends a second instruction to the first through the HCI channel, the second instruction It is used to indicate that the first Bluetooth connection is established successfully.
  • a host controller interface host controller interface
  • the first operating system in the first device can establish a first Bluetooth connection between the first device and the second device through the HCI channel and with the help of the second operating system, so as to be the first operating system of the first device
  • the Bluetooth communication with the second device provides the possibility to implement Bluetooth communication between the first operating system of the first device and the second device.
  • the first Bluetooth connection is used for the Bluetooth communication between the first operating system and the second device.
  • the first instruction is the first instruction grouping.
  • the second instruction is the first event grouping.
  • the HCI channel is a channel corresponding to the first HCI interface of the first operating system and the HCI layer of the second operating system.
  • the first operating system is an Android system
  • the second operating system is a Linux system or a Windows system.
  • the container in the first device runs the first operating system.
  • the method further includes: establishing, by the second operating system, a data channel for data transmission between the second operating system and the first operating system according to the first Bluetooth connection.
  • the second operating system establishes a data channel for data transmission between the second operating system and the first operating system according to the first Bluetooth connection, including: the second operation The system determines the first routing identification information corresponding to the first Bluetooth connection; the HCI channel of the second operating system sends the first routing identification information to the first operating system; the first operating system determines first port information corresponding to the first routing identification information, where the first port information is used to identify a port in the first operating system; The system sends the first port information and the first routing identification information;
  • the second operating system and the first operating system establish the data channel between the second operating system and the first operating system according to the first port information.
  • the second instruction may include first routing identification information.
  • the first port information is used to identify a port number or an index of the port number of the first port in the first operating system.
  • the second operating system stores the first port information and the first routing identification information.
  • the action performed by the second operating system may be performed by an HCI management module of the HCI layer of the second operating system.
  • the method further includes: receiving, by the second operating system, a first data packet sent by the second device through the first Bluetooth connection; relationship and the first Bluetooth connection to determine the first routing identification information, the first correspondence is used to indicate that at least one routing identification information is in a one-to-one correspondence with at least one Bluetooth connection, and the at least one routing identification information includes the first routing identification information, the at least one Bluetooth connection includes the first Bluetooth connection;
  • the second operating system determines the first port information corresponding to the first routing identification information according to a second corresponding relationship, and the second corresponding relationship is used to indicate that at least one routing identification information and at least one port information are in one-to-one correspondence , the at least one port information includes the first port information;
  • the second operating system sends the first data packet to the first operating system through the data channel corresponding to the first port information.
  • the at least one port information is used to identify port numbers of different ports.
  • different Bluetooth connections correspond to different routing identification information
  • the second operating system may generate different routing identification information for different Bluetooth connections
  • the different Bluetooth connections may be Bluetooth connections between the second operating system and different devices.
  • the Bluetooth connection corresponding to different devices for example, the first Bluetooth connection corresponds to the second device, and the second operating system generates the first routing identification information corresponding to the first Bluetooth connection, which specifically includes: the second operating system can be based on the device identification of the second device. Generate first routing identification information corresponding to the first Bluetooth connection.
  • the second operating system includes a Bluetooth hardware layer, a kernel layer, and an HCI layer
  • the first operating system includes a system layer, an application framework layer, and an application layer
  • the second operating system Receiving the first data packet sent by the second device through the first Bluetooth connection includes:
  • the second operating system sequentially receives the first data packet sent by the second device through the first Bluetooth connection through the Bluetooth hardware layer, the kernel layer and the HCI layer;
  • the second operating system sends the first data packet to the first operating system through the data channel corresponding to the first port information, including:
  • the second operating system sends the first data packet to the system layer of the first operating system through the HCI layer;
  • the system layer of the first operating system After receiving the first data packet, the system layer of the first operating system sequentially sends the data packet to the application framework layer and the application layer of the first operating system.
  • the second operating system can receive the first data packet sent by the second device through the Bluetooth hardware layer, the kernel layer, and the HCI layer in sequence, and the second operating system can send the first data packet received at the HCI layer to In the system layer of the first operating system, the first data packet arrives at the system layer, application framework layer and application layer of the first operating system in sequence, so that the process of sending data from the second device to the first operating system can be implemented.
  • the method further includes: receiving, by the second operating system, a second data packet sent by the first operating system through the data channel;
  • the correspondence relationship and the first port information corresponding to the data channel determine the first routing identification information corresponding to the first port information;
  • the second operating system sends the second data packet to the second device through the first Bluetooth connection.
  • the second operating system can not only send the first data packet from the second device to the first operating system through the data channel corresponding to the first port information.
  • the first operating system may also send the second data packet to the second operating system through the data channel corresponding to the first port information, and the second operating system then sends the second data packet to the second device.
  • a process of mutual transmission of Bluetooth data between the first operating system in the first device and the second device can be implemented.
  • the second operating system includes a Bluetooth hardware layer, a kernel layer, and an HCI layer
  • the first operating system includes an application layer, an application framework layer, and a system layer
  • the second operating system includes an application layer, an application framework layer, and a system layer.
  • the operating system receives the second data packet sent by the first operating system through the data channel, including:
  • the first data packet of the first operating system reaches the system layer through the application layer and the application framework layer in sequence;
  • the first operating system sends the first data packet to the HCI layer of the second operating system through the system layer;
  • the second operating system sends the second data packet to the second device through the first Bluetooth connection, including:
  • the second data packet arrives at the Bluetooth hardware layer through the HCI layer and the kernel layer of the second operating system in turn;
  • the second operating system sends the second data packet to the second device at the hardware layer of the second operating system through the first Bluetooth connection.
  • the first operating system can sequentially pass the second data packet through the application layer to the application framework layer and then to the system layer, and the first operating system sends the second data packet to the HCI layer of the second operating system through the system layer , the second data packet reaches the Bluetooth hardware layer through the kernel layer of the second operating system in turn, the second operating system sends the second data packet to the second device at the Bluetooth hardware layer, and the second device receives the second data packet at the Bluetooth hardware layer in turn.
  • the second data packet reaches the application layer through the kernel layer, the system layer, and the application framework layer of the second device in sequence.
  • the first operating system is an Android system
  • the second operating system is system or system.
  • the first operating system runs in a container of the second operating system.
  • the first device is a computer, and the second device is a mobile phone.
  • the first device is a tablet, and the second device is a mobile phone.
  • a method for Bluetooth communication including: the method is applicable to a first device, the first device includes a first operating system and a second operating system, and the method includes: a second operation The system receives the first data packet sent by the second device through the first Bluetooth connection; the second operating system determines the first routing identification information according to the first correspondence and the first Bluetooth connection, and the first correspondence is used for Indicate that at least one routing identification information is in one-to-one correspondence with at least one Bluetooth connection, the at least one routing identification information includes the first routing identification information, and the at least one Bluetooth connection includes the first Bluetooth connection; the second operating system according to The second correspondence determines the first port information of the container corresponding to the first route identification information, and the second correspondence is used to indicate that at least one route identification information corresponds to at least one port information one-to-one, and the at least one The port information includes the first port information; the second operating system sends the first data packet to the first operating system through a data channel corresponding to the first port information.
  • the first device can serve as the host of the first operating system
  • the first device can include Bluetooth hardware
  • the container has no Bluetooth device
  • the second operating system of the first device can communicate with at least one Bluetooth device according to at least one routing identification information.
  • the first correspondence of the connection determines the first routing identification information corresponding to the first Bluetooth connection;
  • the second operating system determines the first port information according to the first routing identification information and the second correspondence between the at least one routing identification information and the at least one port information , the second operating system sends the first data packet to the first operating system through the data channel corresponding to the first port information.
  • the second operating system can determine the routing direction of the first data packet from the second device by means of the correspondence between the first Bluetooth connection, the first routing identification information and the first port information, so as to provide the first data packet for the first
  • the first operating system of a device and the second device provide the possibility to transmit data, which facilitates the communication between the first operating system of the first device and the second device.
  • the container of the first device runs the first operating system, and the first device itself runs the second operating system.
  • the action performed by the second operating system may be performed by an HCI management module of the HCI layer of the second operating system.
  • the at least one port information is used to identify the port numbers of different ports, for example, the first port information is used to identify the port number or the index of the port number of the port of the container.
  • different Bluetooth connections correspond to different routing identification information
  • the second operating system may generate different routing identification information for different Bluetooth connections
  • the different Bluetooth connections may be Bluetooth connections between the second operating system and different devices.
  • the Bluetooth connection corresponding to different devices for example, the first Bluetooth connection corresponds to the second device, and the second operating system generates the first routing identification information corresponding to the first Bluetooth connection, which specifically includes: the second operating system can be based on the device identification of the second device. Generate first routing identification information corresponding to the first Bluetooth connection.
  • the method further includes: the second operating system receives a second data packet sent by the first operating system through the data channel; the second operating system receives the second data packet according to the second corresponding relationship and the The first port information corresponding to the data channel determines the first routing identification information corresponding to the first port information; the second operating system determines the first Bluetooth connection corresponding to the first routing identification information according to the first correspondence ; the second operating system sends the second data packet to the second device through the first Bluetooth connection.
  • the second operating system can not only send the first data packet from the second device to the first operating system of the first device through the data channel corresponding to the first port information.
  • the first operating system may also send the second data packet to the second operating system through the data channel corresponding to the first port information, and the second operating system then sends the second data packet to the second device.
  • a process of mutually transmitting data between the first operating system in the first device and the second device can be implemented.
  • the method before the receiving the first data packet sent by the second device through the first Bluetooth connection, the method further includes: the second operating system receiving the data packet sent by the first operating system through the HCI channel A first instruction, the first instruction is used to establish a first Bluetooth connection between the first operating system and the second device; the second operating system is based on the first instruction between the first operating system and the second device. a Bluetooth connection; the second operating system generates the first routing identification information according to the first Bluetooth connection.
  • the second operating system establishes the first Bluetooth connection between the first operating system and the second device by using the first instruction that triggers the establishment of the first Bluetooth connection, and the second operating system can use the identifier of the first Bluetooth connection to generate the first Bluetooth connection. routing identification information, so that the first Bluetooth connection can be bound with the first routing identification information so as to route data.
  • the second operating system may determine the first routing identification information by using the Hand ID included in the data packet sent by the first Bluetooth connection.
  • establishing the first Bluetooth connection with the second device by the second operating system according to the first instruction includes: the second operating system establishing the first Bluetooth connection with the second device according to the Bluetooth hardware in the second operating system. .
  • the HCI channel is generated by loading a host driver by the first operating system on the first device.
  • the host driver is Native
  • the Native includes a BTso file
  • the first operating system can load the BTso to generate an HCI channel.
  • the HCI channel is a dedicated channel for peering with the HCI layer of the second operating system.
  • the HCI channel on the first operating system side may be the first HCI, and the first HCI may be preset in the first operating system of the first device or generated by a real-time loading driver, which is not limited in this application.
  • the method further includes: the second operating system sends the first routing identification information to the container through the HCI channel; the first operating system determines the first routing identification information with the first routing identification information Corresponding first port information, where the first port information is used to identify a port in the first operating system; the first operating system sends the first port to the second operating system through the HCI channel information and the first routing identification information; the second operating system and the first operating system establish the data between the second operating system and the first operating system according to the first port information aisle.
  • the second operating system may store the correspondence between the first routing identification information and the first port information.
  • the method further includes: the second operating system receives a third instruction sent by the first operating system through the HCI channel, where the third instruction is used to indicate that the data channel is successfully established.
  • the second operating system can receive the first data packet from the second device based on the third instruction, or send the first data packet to the first operating system based on the third instruction.
  • the first operating system is an Android system
  • the system of the second device is an Android system. In this way, it is possible to implement Bluetooth communication between the Android system of the system in the first device and the Android system of the second device.
  • the method further includes: the second operating system can parse the instruction for establishing Bluetooth from the second device, and if the instruction is sent to the first operating system, sending the instruction to the The first operating system, if the instruction is not sent to the first operating system, discards the instruction or processes it separately.
  • the method further includes: the second operating system can parse the instruction from the first operating system transmitted through the HCI channel, and if the instruction is sent to the second device, sending the instruction to the second device , if the instruction is not sent to the second device, the instruction is discarded or processed separately.
  • a method for Bluetooth communication is provided, the method is applicable to a first device, the first device includes a first operating system and a second operating system, the method includes: the second operating system receives the the second data packet sent by the first operating system through the data channel; the second operating system determines the first port information corresponding to the first port information according to the second correspondence relationship and the first port information corresponding to the data channel routing identification information, the second correspondence is used to indicate that at least one routing identification information corresponds to at least one port information one-to-one, the at least one routing identification information includes the first routing identification information, and the at least one port information includes the first port information; the second operating system determines the first Bluetooth connection corresponding to the first routing identification information according to the first correspondence, where the first correspondence is used to indicate at least one routing identification information and at least one There is a one-to-one correspondence between Bluetooth connections, and the at least one Bluetooth connection includes the first Bluetooth connection; the second operating system sends the second data packet to the second device through the first Bluetooth connection.
  • the container of the first device runs the first operating system.
  • the action performed by the second operating system may be performed by an HCI management module of the HCI layer of the second operating system.
  • the method before the second operating system receives the second data packet sent by the container through the data channel, the method further includes: the second operating system receives the first operating system through the data channel The first instruction sent by the HCI channel, where the first instruction is used to establish a first Bluetooth connection between the first device and the second device; the second operating system establishes the first Bluetooth connection with the second device according to the first instruction Bluetooth connection; the second operating system generates the first routing identification information according to the first Bluetooth connection.
  • the method further includes: the second operating system sending the first routing identification information to the first operating system through an HCI channel;
  • the second operating system receives the first routing identification information sent by the first operating system through the HCI channel and the first routing identification information corresponding to the first routing identification information of the port established in the first operating system Port information; the second operating system establishes a data channel for data transmission between the second operating system and the first operating system according to the first port information.
  • the first operating system is an Android system
  • the second operating system is system or system.
  • an apparatus for Bluetooth communication is provided, and the apparatus is configured to perform the method in each of the above aspects or any possible implementation manner of each aspect.
  • the apparatus may include modules for performing the methods in each aspect or any possible implementation of the various aspects.
  • a fifth aspect provides an apparatus for Bluetooth communication, the apparatus comprising a processor, the processor is coupled with a memory, the memory is used for storing computer programs or instructions, and the processor is used for executing the computer programs or instructions stored in the memory, so that the above The methods of various aspects are performed.
  • a processor is used to execute a computer program or instructions stored in a memory to cause the apparatus to perform the methods of the various aspects.
  • a computer-readable storage medium having stored thereon a computer program (which may also be referred to as instructions or codes) for implementing the methods of the various aspects.
  • the computer program when executed by a computer, causes the computer to perform the methods of the various aspects.
  • the present application provides a chip including a processor.
  • the processor is used to read and execute the computer program stored in the memory to perform the methods of the aspects and any possible implementations thereof.
  • the chip further includes a memory, and the memory and the processor are connected to the memory through a circuit or a wire.
  • the chip further includes a communication interface.
  • the present application provides a computer program product, the computer program product comprising a computer program (also referred to as instructions or code) that, when executed by a computer, causes the computer to implement the methods in the various aspects.
  • a computer program also referred to as instructions or code
  • FIG. 1 is a schematic diagram of a Bluetooth search interface provided by an embodiment of the present application.
  • FIG. 2 is a schematic diagram of an application scenario provided by an embodiment of the present application.
  • FIG. 3 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • FIG. 4 is a block diagram of a software interface of an electronic device provided by an embodiment of the present application.
  • FIG. 5 is a schematic diagram of a system architecture provided by an embodiment of the present application.
  • FIG. 6 is a schematic diagram of a method for Bluetooth communication provided by an embodiment of the present application.
  • FIG. 7 is a schematic diagram of a format of an instruction group provided by an embodiment of the present application.
  • FIG. 8 is a schematic diagram of another Bluetooth search interface provided by an embodiment of the present application.
  • FIG. 9 is a schematic diagram of another Bluetooth search interface provided by an embodiment of the present application.
  • FIG. 10 is a format of a data packet from a second device provided by an embodiment of the present application.
  • FIG. 11 is a schematic diagram of a format of an event grouping provided by an embodiment of the present application.
  • the communication can be specifically performed through the operating systems running on the two devices. If the first device runs the first operating system and the second operating system, possibly due to the limitation of the Bluetooth hardware, the second device can only perform Bluetooth communication with one of the operating systems of the first device, and the second device cannot communicate with the other operating system.
  • the first operating system is the operating system running on the container in the first device
  • the second operating system is the system of the first device itself.
  • the first operating system is the Android system
  • the second operating system is the system.
  • the second device When the second device needs to communicate with the first operating system on the container in the first device, since the container has no Bluetooth hardware and the first operating system in the container is in a closed operating environment, the second device cannot communicate with the first operating system.
  • a container in a device for Bluetooth communication since the container has no Bluetooth hardware and the first operating system in the container is in a closed operating environment, the second device cannot communicate with the first operating system.
  • the container can be a (Linux container), the resources in the container can be isolated from the first device, and the container does not need to simulate the hardware device and kernel of the first device, and the performance of the container is better than that of the virtual machine.
  • the container in this embodiment of the present application may be replaced with a virtual machine.
  • the container in the first device and the second device can trigger communication through the operation interface or touch and other trigger communication. If the communication is triggered through the interface, as shown in FIG. There is no container identifier 1, only the first device HUAWEI P30, so that the second device cannot find the container, which will cause abnormal communication between the container of the first device and the second device.
  • FIG. 2 is a schematic diagram of an application scenario provided by an embodiment of the present application.
  • the container on the first device can communicate with the Bluetooth device of the second device through the Bluetooth device on the first device, so that the communication between the container of the first device and the second device can be realized.
  • the container in FIG. 2 can also be replaced with a virtual machine.
  • the first device and the second device shown in FIG. 2 may be the electronic device 300 shown in FIG. 3 .
  • the electronic device 300 may include a processor 310, a memory 320, a communication module 330, a display screen 340, and the like.
  • the processor 310 may include one or more processing units, and the memory 320 is used to store program codes and data. In this embodiment of the present application, the processor 310 can execute the computer-executed instructions stored in the memory 320 to control and manage the actions of the electronic device 300 .
  • the communication module 330 may be used for communication between various internal modules of the electronic device 300, or communication between the electronic device 300 and other external electronic devices, and the like.
  • the communication module 330 may include an interface, such as a USB interface, and the USB interface may be an interface conforming to the USB standard specification, specifically a Mini USB interface, a Micro USB interface, and the like.
  • the USB interface can be used to connect a charger to charge the electronic device 300, and can also be used to transmit data between the electronic device 300 and peripheral devices. It can also be used to connect headphones to play audio through the headphones.
  • the interface can also be used to connect other electronic devices, such as AR devices.
  • the communication module 330 may include an audio device, a radio frequency circuit, a Bluetooth device 331, a wireless fidelity (Wi-Fi) chip, a near-field communication (NFC) module, etc. Interactions between the electronic device 300 and other electronic devices are implemented in different ways.
  • the Bluetooth device 331 may be the Bluetooth device of the first device or the Bluetooth device of the second device in FIG. 2 .
  • the display screen 340 is used to display images, videos, and the like.
  • the electronic device 300 may further include peripheral devices 350, such as a mouse, a keyboard, a speaker, a microphone, and the like.
  • the structure of the electronic device 300 is not specifically limited in this embodiment of the present application. In other embodiments of the present application, the electronic device 300 may further include more or less components than shown, or some components are combined, or some components are separated, or different components are arranged.
  • the illustrated components may be implemented in hardware, software, or a combination of software and hardware.
  • the software system of the electronic device 300 may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture.
  • the first device may be the electronic device 300.
  • the container and the second device in the first device may be the first operating system.
  • the first operating system is system
  • FIG. 4 shows an embodiment of the present application with a layered architecture Taking the system as an example, the container in the first device has a function similar to that of the first device, and the container can virtualize a specific function by using the module shown in FIG. 3 of the first device.
  • the software structure of the container in the first device and the second device is exemplified.
  • FIG. 4 is a software structural block diagram of an example of a first operating system in a container of a second device or a first device provided by an embodiment of the present application.
  • the software structure diagram divides the software into several layers, and each layer has a clear role and division of labor. Layers communicate with each other through software interfaces.
  • the The system is divided into four layers, from top to bottom, the application layer, the application framework layer, the system layer, and the kernel layer.
  • the application layer can include a series of application packages. As shown in Figure 2, the application package can include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and so on.
  • applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and so on.
  • the application framework layer provides an application programming interface (application programming interface, API) and a programming framework for applications in the application layer.
  • the application framework layer includes some predefined functions.
  • the application framework layer may include window managers, content providers, view systems, telephony managers, resource managers, notification managers, and the like.
  • a window manager is used to manage window programs.
  • the window manager can get the size of the display screen, determine whether there is a status bar, lock the screen, take screenshots, etc.
  • Content providers are used to store and retrieve data and make these data accessible to applications.
  • the data may include video, images, audio, calls made and received, browsing history and bookmarks, phone book, etc.
  • the view system includes visual controls, such as controls for displaying text, controls for displaying pictures, and so on. View systems can be used to build applications.
  • a display interface can consist of one or more views.
  • the display interface including the short message notification icon may include a view for displaying text and a view for displaying pictures.
  • the phone manager is used to provide the communication function of the electronic device 300 .
  • the management of call status including connecting, hanging up, etc.).
  • the resource manager provides various resources for the application, such as localization strings, icons, pictures, layout files, video files and so on.
  • the notification manager enables applications to display notification information in the status bar, which can be used to convey notification-type messages, and can disappear automatically after a brief pause without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc.
  • the notification manager can also display notifications in the status bar at the top of the system in the form of graphs or scroll bar text, such as notifications of applications running in the background, and notifications on the screen in the form of dialog windows. For example, text information is prompted in the status bar, a prompt sound is issued, the electronic device vibrates, and the indicator light flashes.
  • the system layer is responsible for the scheduling and management of the Android system.
  • the system layer includes Native, and the Native includes a Bluetooth (bluetooth, BT) so file.
  • BT so is also called BT vendor so.
  • the electronic device 300 can load the BT vendor so to generate the communication between the system library in FIG. 5 and the HCI management module. The first HCI.
  • the system layer can also include multiple functional modules.
  • surface manager surface manager
  • media library media library
  • 3D graphics processing library eg: OpenGL ES
  • 2D graphics engine eg: SGL
  • the Surface Manager is used to manage the display subsystem and provides a fusion of 2D and 3D layers for multiple applications.
  • the media library supports playback and recording of a variety of commonly used audio and video formats, as well as still image files.
  • the media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
  • the 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
  • 2D graphics engine is a drawing engine for 2D drawing.
  • the kernel layer is the layer between hardware and software.
  • the kernel layer contains at least display drivers, camera drivers, audio drivers, and sensor drivers.
  • the first device includes a first operating system and a second operating system
  • the first operating system and the second operating system can communicate
  • the communication between the two operating systems can be understood Communicate for the corresponding modules in the two operating systems.
  • the communication between the two devices can also be understood as the communication between the operating systems of the two devices.
  • the following embodiments are described by taking the communication between the first operating system running on the container and the HCI management module in the second operating system as an example, but it should not cause any restrictions on the embodiments of the present application, and the communication between the container and the HCI management module can be understood as Communication between the first operating system and the second operating system.
  • FIG. 5 a schematic diagram of the architecture provided by the embodiment of the present application is shown.
  • the container of the first device runs the first operating system
  • the first device itself runs the second operating system
  • the second device runs the first operating system.
  • the HCI management module in the Bluetooth system can be used to transmit the instruction
  • the first device is also called the host of the container
  • the container is called the guest.
  • the container in the first device may have the same first operating system as the second device, for example, both system.
  • the HCI management module and container shown in FIG. 5 may run in the processor 310 shown in FIG. 3 .
  • the communication module 330 shown in FIG. 3 may include the first HCI shown in FIG. 5 .
  • the method 600 for Bluetooth transmission provided by the embodiment of the present application is described in detail below with reference to FIG. 6 .
  • the container in the first device can load a driver at the system layer, for example, the driver is BT so, and loading BT so can generate the first HCI, which is also called the HCI driver layer user space key interface , the first HCI may need to be customized and modified, the channel between the first HCI and the HCI management module of the HCI layer of the Bluetooth system of the first device may be called an HCI channel, and the HCI channel is used to transmit an instruction to establish a Bluetooth connection In other words, as shown in FIG. 6 , the HCI channel is used to communicate with the HCI layer of the Bluetooth system. For example, the container can transmit instructions with the HCI management module through the HCI channel.
  • the second device sends an instruction to search for Bluetooth signals.
  • sending the instruction of searching for Bluetooth signals by the second device may be understood as sending the instruction of searching for Bluetooth signals by the first operating system of the second device.
  • the second device may send an instruction to search for bluetooth signals to the application framework layer through the application layer of the first operating system, and the second device calls the application framework layer of the first operating system and the instruction to search for bluetooth signals
  • the system layer and the kernel layer of the first operating system are used to drive the Bluetooth hardware device and wait for establishing Bluetooth communication with the container in the first device.
  • the user can trigger sending an instruction to search for Bluetooth signals based on a certain application of the second device. Turn on the Bluetooth of the mobile phone of the second device, and the mobile phone searches for pairable devices. Or the second device may touch the first device to trigger sending an instruction to search for Bluetooth signals.
  • the container of the first device sends an instruction to search for Bluetooth signals.
  • the container of the first device sends an instruction to search for Bluetooth signals to the application framework layer through the application layer of the first operating system.
  • the first device calls some predefined functions of the application framework layer of the first operating system of the container related to the instruction to search for Bluetooth signals, and sends the instruction to search for Bluetooth to the system layer.
  • the user can trigger the container to send an instruction to search for Bluetooth signals based on an application in the container.
  • the first device can be a computer, and the user can trigger the container in the computer to send a control instruction to search for Bluetooth signals. Search for pairable devices.
  • the first device may touch the second device to trigger the container in the first device to send an instruction to search for Bluetooth signals through the first operating system.
  • S601 may be performed before, after or at the same time as S602, which is not limited in this application.
  • the container of the first device after the container of the first device receives the instruction to search for the Bluetooth signal at the system layer, it sends a first instruction through the HCI channel between the first HCI and the HCI management module of the system layer, where the first instruction is used to establish the first instruction
  • a first Bluetooth connection between a device and a second device For example, the first instruction is used to request the establishment of a Bluetooth connection.
  • the first Bluetooth connection between the first device and the second device is also referred to as the Bluetooth connection between the first operating system in the first device and the second device, or the container of the first device and the second device. Bluetooth connection between second devices.
  • the first instruction may be an instruction of the HCI layer of the Bluetooth protocol, also referred to as a first instruction packet, and the format of the first instruction packet is shown in FIG. 7 .
  • each field such as the operation code (OpCode), the operation code group field (opcode group field, OGF), and the operation command field (opcode command field, OCF) in FIG. 7, refer to the definition of the HCI protocol.
  • the OGF in the first command is 0x37
  • the OCF is 0x200 to indicate that the first command is used to request the establishment of a Bluetooth connection.
  • the method further includes: the HCI management module can parse any instruction received through the HCI channel, and if the parsed first instruction is used to request the establishment of a Bluetooth connection, then execute S604; If an instruction parsed by the HCI management module is not for requesting to establish a Bluetooth connection or for Bluetooth pairing, but for modifying the name of the Bluetooth system of the first device, the HCI management module may discard it or process it separately.
  • the HCI channel between the first HCI and the HCI management module may be a bidirectional channel, that is, the command that the container can send to the HCI management module through the HCI channel is called a command packet, and the container sends the command to the HCI management module through the HCI channel. Instructions are called event groupings.
  • the HCI management module of the first device after receiving the first instruction, establishes a first Bluetooth connection between the first device and the second device according to the first instruction.
  • the container in the first device can transmit the first command through the HCI channel, so that the container in the first device can discover each other with the second device through the Bluetooth device of the first device, so that the second device can be Containers in the first device can be discovered, and containers can also be discovered in the second device.
  • the container in the first device and the second device can trigger a Bluetooth search through the operation interface, as shown in Figure 8, if the second device is a mobile phone and the first device is a computer, then the Bluetooth interface of the second device is available The identifier 1 of the container can be searched in the device, and the second device in Figure 8 is the HUAWEI P40.
  • the second device HUAWEI P40 can also be found in the available devices of the Bluetooth interface of the container in the first device.
  • the HCI management module of the first device can filter the instruction from the HCI channel with the container, if the instruction is for establishing a Bluetooth connection, then according to the HCI management module, the driver of the kernel layer is loaded according to the instruction to call the Bluetooth hardware and the second.
  • the Bluetooth hardware of the device proceeds to establish the first Bluetooth connection. If the command is not for establishing a Bluetooth connection, the command is discarded or processed separately. For example, if the command is for modifying the name of the Bluetooth system of the first device, the control command may be discarded. As shown in FIG. 7 , the OpCode of the instruction is 0x0013, indicating that the instruction is used to modify the name of the Bluetooth system of the first device, and the filtering will not be processed. For another example, if the instruction from the HCI channel indicates that the system of the container is abnormal, the filtering will not be processed.
  • the HCI management module of the first device parses the command for establishing Bluetooth from the second device, and if the command is sent to the HCI channel between the container and the HCI management module, the command is sent to the container through the HCI channel. If the command is not sent to the container, the command is discarded or processed separately.
  • instructions for establishing Bluetooth are transmitted to different layers and may have different formats, which are not limited in this embodiment of the present application.
  • first Bluetooth connection can be understood as the Bluetooth connection between the second device and the container in the first device, and can also be understood as the Bluetooth connection between the second device and the first device.
  • the container in the first device can be Bluetooth communication is performed with the second device via the first Bluetooth connection.
  • the HCI management module after the HCI management module of the first device successfully establishes the first Bluetooth connection with the second device, the HCI management module sends a second command to the first HCI through the HCI channel, where the second command is used to indicate that the first Bluetooth connection is successfully established.
  • the HCI management module after the HCI management module of the first device successfully establishes the first Bluetooth connection with the second device, the HCI management module generates first routing identification information corresponding to the first Bluetooth connection.
  • the HCI management module of the first device after the HCI management module of the first device establishes the first Bluetooth connection with the second device, it can generate the first routing identification information for the established first Bluetooth connection.
  • the data transmitted by the first Bluetooth connection between the two devices needs to be routed to the first port information corresponding to the first routing identification information.
  • the HCI management module of the first device may generate first routing identification information corresponding to the first Bluetooth connection according to a preset rule.
  • the HCI management module of the first device can generate the corresponding first routing identification information according to the identification of the first Bluetooth connection.
  • Different Bluetooth connections correspond to different devices, and the HCI management module of the first device can generate the first routing identification information according to the identification of the second device.
  • the HCI management module of the first device can generate the first routing identification information according to the identification of the packet header of any data packet from the first Bluetooth connection, as shown in FIG. 10 , which shows the data of the first Bluetooth connection.
  • the format of the packet, the first routing identification information can be generated according to the routing identification of the data packet, the routing identification can be generated by (Handle ID), the first 10 or the first 12 bits of the Handle ID can be taken as the first routing identification information or can be based on The Handle ID is mapped according to a specific rule to generate the first routing identification information.
  • the HCI management module on the first device can establish one or more Bluetooth connections with multiple devices (such as the second device), and the HCI management module on the first device can be one or more different Bluetooth connections One or more different routing identification information is generated, so that the first device can save the first correspondence between the one or more routing identification information and one or more Bluetooth connection pairs.
  • the method 600 only takes the first Bluetooth connection and the first routing identification information as an example.
  • the correspondence between other Bluetooth connections and other routing identification information refer to the correspondence between the first Bluetooth connection and the first routing identification information.
  • the HCI management module of the first device sends the first routing identification information to the container through the HCI channel.
  • the HCI management module can send the first event packet to the container through the HCI channel, where the first event packet includes the first routing identification information, as shown in Figure 11 .
  • the first routing identification information can be any event parameter in the event parameter 1, event parameter 2, ..., event parameter N in the event packet, including the first Routing identification information.
  • the HCI management module of the first device may simultaneously indicate through an instruction that the first Bluetooth connection is successfully established and may also carry the first routing identification information.
  • the second instruction in S605 may be the first event grouping in S607.
  • the second instruction in S605 and the first event grouping in S607 may be two different instructions.
  • the container of the first device establishes a port number corresponding to the port used for Bluetooth transmission on the container side according to the first routing identification information in S607.
  • the container of the first device may establish a port number of a port for Bluetooth transmission, and the port number corresponds to the first routing identification information.
  • the container of the first device sends the first port information and the first route identification information to the HCI management module of the first device through the HCI channel, where the first port information is used to identify the port number.
  • the container of the first device sends a second command packet to the HCI management module of the first device through the HCI channel, the second command packet is used to request the establishment of a data channel, and the second command packet also includes the first port. information and first routing identification information.
  • the container of the first device sends the second command packet to the HCI management module of the first device through the HCI channel, and the format of the second command packet is shown in FIG. 7 .
  • the OGF in the second instruction packet is 0x37
  • the OCF is 0x201 to indicate that the second instruction packet is used to request establishment of a data channel.
  • One or two parameters of parameter 0, parameter 1, ..., parameter N in the second instruction packet may include the first port information and the first route identification information, if the two parameters include the first port information and the first route identification information respectively routing identification information, there is a corresponding relationship between these two parameters.
  • the instruction grouping for requesting the establishment of the data channel and the instruction grouping including the first port information and the first routing identification information may be different instruction groups or the same instruction grouping (second instruction grouping), which is implemented in this application. Examples are not limited.
  • the HCI management module of the first device saves the correspondence between the first port information and the first routing identification information in S609, and sends confirmation information to the container through the HCI channel, where the confirmation information is used to indicate confirmation of S609.
  • the second event group includes confirmation information
  • the second event group may be the confirmation event group in the second instruction group in S609
  • the second event group may indicate that the HCI management module of the first device has received the second instruction group.
  • one or more containers may exist on the first device, different containers correspond to different HCI interfaces, and the HCI management module of the first device and different HCI interfaces of different containers correspond to different HCI channels.
  • the HCI management module of a device may store a second correspondence between one or more routing identification information and one or more port information. To avoid repetition, the method 600 only takes the first port information and the first routing identification information as an example, and the corresponding relationship between other port information and other routing identification information refers to the corresponding relationship between the first port information and the first routing identification information.
  • the HCI management module of the first device establishes a data channel with the container according to the first port information.
  • the data channel established between the HCI management module of the first device and the container can be identified by the first port information.
  • the container of the first device sends indication information indicating that the data channel is successfully established to the HCI management module through the HCI channel.
  • the third instruction packet includes indication information
  • the HCI management module receives the third instruction packet sent by the container of the first device through the HCI channel, and the third instruction packet is used to indicate that the data channel is successfully established.
  • the container of the first device establishes the port number of the port used for Bluetooth transmission in S608, and waits for the HCI management module to establish a data channel with the port corresponding to the port number.
  • the container sends a third instruction packet to the HCI management module through the HCI channel, which is used to indicate that the data channel is successfully established, so that the overhead caused by the continuous establishment of the data channel by the HCI management module can be avoided.
  • the format of the third instruction packet is shown in FIG. 7 .
  • the OGF in the third instruction packet is 0x37
  • the OCF is 0x202 to indicate that the third instruction packet is used to indicate that the data channel is successfully established.
  • S612 may trigger the HCI management module to execute S613 or S616.
  • the HCI management module may receive the first data packet from the second device after determining that the data channel is successfully established, or the HCI management module may determine the first data packet to the container of the first device after determining that the data channel is successfully established. An HCI sends the first packet.
  • the HCI management module may detect whether the data channel is successful, or try to send a probe data packet to the first HCI of the container to determine whether the data channel is successful, which is not limited in this embodiment of the present application.
  • the container of the first device can send Bluetooth data to the second device through the data channel established in S611, and the second device can also send Bluetooth data to the second device through the data channel established in S610.
  • the container of the first device sends the Bluetooth data. For example, if the second device sends data to the container in the first device through the data channel established in S611, execute S613-S616; if the container in the first device sends data to the second device through the data channel established in S611, then Execute S617-S620.
  • the second device sends data to the container in the first device through the data channel established in S611
  • the container in the first device sends data to the second device through the data channel established in S611
  • execute S613-S616 and S617-S620 and the order of any one of the steps S613-S616 and any one of the steps of S617-S620 is not limited, and any one of the steps of S613-S616 can be performed before or after any of the steps of S617-S620 or simultaneously.
  • the second device sends the first data packet to the HCI management module of the first device through the first Bluetooth connection established in S604, and the HCI management module of the first device receives the first data packet sent by the second device through the first Bluetooth connection established in S604 data pack.
  • the data in the first data packet is encapsulated in different order from the application layer of the second device to the application framework layer, the system layer, the kernel layer and the Bluetooth hardware layer, which can reach the Bluetooth hardware of the Bluetooth system of the first device. layer.
  • the Bluetooth hardware layer of the Bluetooth system of the first device After receiving the first data packet, the Bluetooth hardware layer of the Bluetooth system of the first device sends the first data packet to the kernel layer and then to the HCI management module.
  • the first data packet may have different formats at different layers, which is not limited in this application.
  • the first data packet may be data of a certain application.
  • the HCI management module of the first device determines first routing identification information corresponding to the first Bluetooth connection according to the first Bluetooth connection and the first correspondence.
  • the HCI management module of the first device in S606 Since the HCI management module of the first device in S606 generates the first routing identification information according to the first Bluetooth connection, when the HCI management module of the first device receives the first data packet through the first Bluetooth connection, the HCI management module needs to If the first routing identification information corresponding to the first Bluetooth connection is determined in the first correspondence, the first data packet needs to be routed according to the determined first routing identification information.
  • the HCI management module of the first device determines, according to the first routing identification information and the first port information saved in S610, that the first data packet from S612 needs to be sent to the data identified by the first port information corresponding to the first routing identification information channel, the data channel is the data channel established in S611.
  • the HCI management module of the first device may determine the first port information corresponding to the first routing identification information in the saved second correspondence between one or more routing identification information and one or more ports, thereby The first data packet from the second device may be sent to the data channel identified by the first port information.
  • the HCI management module of the first device sends the first data packet from the second device to the system layer of the container through the data channel determined in S615.
  • the first data packet in S613 may be the HCI management module sent by the second device to the first device after the first Bluetooth connection is successfully established in S604 and before the data channel is established in S611. If the first data packet can be received by the HCI management module before establishing the data channel of S611 with the first HCI of the container, the HCI management module can first buffer the received data packet and not send it, and then send it through the data channel in S617,
  • the embodiments of the present application are not limited.
  • the HCI management module of the first device can transparently transmit the first data packet from S613 to the container through the data channel in S617, or can also modify the packet header of the first data packet, and the modified first data packet
  • the packet header may carry the identifier of the HCI management module of the first device.
  • the packet header of the first data packet in S617 and the packet header of the first data packet in S613 may be different, and the data part is the same.
  • the system layer of the container after receiving the first data packet from the HCI management module, transmits the first data packet to the application framework layer, and then transmits the first data packet to the application layer of the container.
  • the container receives the first data packet, it is displayed at the application layer of the container that the data reception is successful; after the second device sends the first data packet to the first device, the sent result is returned from the lower layer to the upper layer to the first device.
  • the application layer of the second device for example, shows that the data is sent successfully at the application layer of the second device.
  • the first device sends the second data packet to the HCI management module of the first device through the data channel established in S611, and the HCI management module of the first device receives the second data packet sent by the first HCI through the data channel established in S611.
  • the second data packet passes through the application framework layer and the system layer in sequence from the application layer of the first device, and then is sent to the HCI management module through the system layer of the container, and the second data packet can be encapsulated differently at different layers Format, this application is not limited.
  • the second data packet may be data of a certain application.
  • the HCI management module of the first device determines the first routing identification information according to the first port information of the data channel for receiving the second data packet.
  • the HCI management module of the first device may determine the first routing identification information corresponding to the first port information in the saved second correspondence between the one or more routing identification information and the one or more port information.
  • the HCI management module of the first device determines the first Bluetooth connection corresponding to the first routing identification information according to the first routing identification information.
  • the HCI management module of the first device may determine the first Bluetooth connection corresponding to the first routing identification information in the stored correspondence between one or more routing identification information and one or more Bluetooth connections, so that the HCI The management module may determine to send the second data packet from the first HCI to the first Bluetooth connection.
  • the HCI management module of the first device sends the second data packet to the second device through the first Bluetooth connection.
  • the HCI management module of the first device can transparently transmit the second data packet from S617 to the second device in S620, or can also modify the packet header of the second data packet, and the modified second data packet's
  • the packet header may carry the identifier of the HCI management module of the first device.
  • the packet header of the second data packet in S617 may be different from the packet header of the second data packet in S620, and the data part is the same.
  • the second data packet reaches the Bluetooth hardware layer through the kernel layer of the Bluetooth system, and is transmitted from the Bluetooth hardware layer of the first device to the Bluetooth hardware layer of the second device.
  • the Bluetooth hardware layer of the second device receives the second data packet
  • the kernel layer, the system layer, and the application framework layer are sequentially channeled to the application layer, and the second data packet may have different encapsulation formats at different layers, which is not limited in this application.
  • the application layer of the second device shows that the data reception is successful; after the HCI management module sends the second data packet to the second device, it sends the result from the lower layer to the second device.
  • the upper layer returns to the application layer of the first device, for example, the application layer of the first device displays that the data is sent successfully.
  • the instructions transmitted between the first HCI of the container of the first device and the HCI management module can be divided into event groups and instruction groups, and the control instructions sent by the HCI management module to the first HCI are called Event grouping, the control instruction sent by the first HCI to the HCI management module is called an instruction grouping.
  • Event grouping the control instruction sent by the first HCI to the HCI management module is called an instruction grouping.
  • the difference between an event grouping and an instruction grouping is that the flow of the control instructions is different.
  • the instruction grouping refers to the sent control instruction
  • the event grouping refers to the received control instruction.
  • S601-S612 are pre-configured processes
  • S613-S620 are data packet transmission processes
  • the container of the first device and the second device can transmit multiple data packets based on one configuration.
  • S601-S612 can be executed once
  • S613-S620 can be executed multiple times.
  • the method 600 may include more steps or fewer steps, and the method 600 is merely an exemplary description.
  • the method 600 may not have S601 and S602, but only include S603-S605.
  • the purpose of the solution is to establish the first Bluetooth connection.
  • this embodiment of the present application does not limit it.
  • the method 600 may only have S613-S616 without other steps, that is, there is only a process in which the second device sends the first data packet to the container of the first device, and the steps before S613 may be obtained in the process of historical data processing. or preset.
  • method 600 may only exist
  • S617-S620 there are no other steps, that is, there is only a process in which the container of the first device sends the second data packet to the second device, and other steps may be obtained in the historical data processing process or preset.
  • the method 600 may only have S613-S620 without other steps, that is, only the second device sends the first data packet to the container of the first device and the container of the first device sends the second data packet to the second device. process, the steps before S613 may be obtained in the historical data processing process or preset.
  • a certain module may modify the header of the control data packet to adapt to the encapsulation format of the module, or a certain module may The format of the first data packet or the second data packet is not modified, and it is directly transparently transmitted to the next node, which is not limited in this application.
  • the container can be replaced with a virtual machine.
  • the virtual machine on the first device can share the Bluetooth system of the first device through the first HCI, so that the Bluetooth system can be shared with the first device. system.
  • the second operating system of the first device may be system or system.
  • the first device and the second device may be divided into functional modules according to the above-mentioned method example, or this embodiment may be divided into functional modules for the container and the HCI management module in the first device according to the above-mentioned method example, for example,
  • Each function module can be divided into each function, or two or more functions can be integrated into one processing module.
  • the above-mentioned integrated modules can be implemented in the form of hardware. It should be noted that, the division of modules in this embodiment is schematic, and is only a logical function division, and there may be other division manners in actual implementation.
  • the first device and the second device provided in this embodiment are used to execute the above-mentioned method for Bluetooth communication, and thus can achieve the same effect as the above-mentioned implementation method.
  • the first device and the second device may include a processing module, a storage module and a communication module, respectively.
  • the processing module can be used to control and manage the HCI management module and container of the first device and the actions of the second device.
  • it can be used to support the HCI management module and container of the first device and the second device to execute the execution of the processing unit.
  • the storage module can be used to support the HCI management module and container of the first device and the second device to execute stored program codes and data, and the like.
  • the communication module can be used to support the HCI management module and the container of the first device and the communication between the second device and other devices, or to support the communication inside the device.
  • the processing module may be a processor or a controller. It may implement or execute the various exemplary logical blocks, modules and circuits described in connection with this disclosure.
  • the processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, and the like.
  • the storage module may be a memory.
  • the communication module may specifically be a device that interacts with other electronic devices, such as a radio frequency circuit, a Bluetooth chip, and a Wi-Fi chip.
  • the electronic device involved in this embodiment may be a device having the structure shown in FIG. 3 .
  • This embodiment also provides a computer-readable storage medium, where computer instructions are stored in the computer-readable storage medium, and when the computer instructions are executed on the electronic device, the electronic device executes the above-mentioned related method steps to realize the above-mentioned embodiments.
  • a method for Bluetooth communication is also provided.
  • This embodiment also provides a computer program product, which, when the computer program product runs on the computer, causes the computer to execute the above-mentioned relevant steps, so as to realize the method for Bluetooth communication in the above-mentioned embodiment.
  • the embodiments of the present application also provide an apparatus, which may specifically be a chip, a component or a module, and the apparatus may include a connected processor and a memory; wherein, the memory is used for storing computer execution instructions, and when the apparatus is running, The processor can execute the computer-executed instructions stored in the memory, so that the chip executes the method for securely accessing data in the foregoing method embodiments.
  • the electronic device, computer storage medium, computer program product or chip provided in this embodiment are all used to execute the corresponding method provided above. Therefore, for the beneficial effects that can be achieved, reference can be made to the corresponding provided above. The beneficial effects in the method will not be repeated here.
  • the disclosed apparatus and method may be implemented in other manners.
  • the apparatus embodiments described above are only illustrative.
  • the division of modules or units is only a logical function division. In actual implementation, there may be other division methods.
  • multiple units or components may be combined or May be integrated into another device, or some features may be omitted, or not implemented.
  • the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, and may be in electrical, mechanical or other forms.
  • Units described as separate components may or may not be physically separated, and components shown as units may be one physical unit or multiple physical units, that is, may be located in one place, or may be distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units may be implemented in the form of hardware, or may be implemented in the form of software functional units.
  • the integrated unit if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a readable storage medium.
  • a readable storage medium including several instructions to make a device (which may be a single chip microcomputer, a chip, etc.) or a processor (processor) to execute all or part of the steps of the methods in the various embodiments of the present application.
  • the aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (random access memory, RAM), magnetic disk or optical disk and other media that can store program codes.

Landscapes

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

Abstract

本申请提供了一种用于蓝牙通信的方法和电子设备。该方法包括:第一设备中的第一操作系统可以通过HCI通道并借助第二操作系统建立第一设备与第二设备之间的第一蓝牙连接,从而为第一设备的第一操作系统与第二设备进行蓝牙通信提供了可能,有助于第一设备的容器与第二设备通信。

Description

用于蓝牙通信的方法和电子设备
本申请要求于2020年08月31日提交国家知识产权局、申请号为202010899012.8、申请名称为“用于蓝牙通信的方法和电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及通信领域,并且更具体地涉及通信领域中的用于蓝牙通信的方法和电子设备。
背景技术
两个设备通过蓝牙进行通信时,具体可以通过两个设备上所运行的操作系统进行通信。如果第一设备有两个不同的操作系统,第二设备需要与第一设备中的两个操作系统都进行通信时,可能由于蓝牙硬件的限制,只能与第一设备其中的一个操作系统进行蓝牙通信,第二设备无法与另一个操作系统进行蓝牙通信。例如,当另一个操作系统运行在容器或者虚拟机中时,会导致容器中的操作系统无法与外部的第二设备进行通信,举例来说,第一设备为电脑,第二设备为手机,电脑上运行有
Figure PCTCN2021112164-appb-000001
系统,电脑的容器运行有安卓系统,手机为安卓系统,则手机的安卓系统无法与电脑的容器中的安卓系统进行蓝牙通信。
发明内容
本申请实施例提供了一种用于蓝牙通信的方法和电子设备,能够使得第一设备的第一操作系统可以与第二设备的操作系统进行蓝牙通信。
第一方面,提供了一种用于蓝牙通信的方法,所述方法适用于第一设备,所述第一设备包括第一操作系统和第二操作系统,所述方法包括:第一操作系统通过主机控制接口(host controller interface,HCI)通道向第二操作系统发送第一指令,所述第一指令用于建立所述第一设备与第二设备的第一蓝牙连接;所述第二操作系统根据所述第一指令建立所述第一设备与第二设备的所述第一蓝牙连接;所述第二操作系统通过所述HCI通道向所述第一发送第二指令,所述第二指令用于指示所述第一蓝牙连接建立成功。
在上述方案中,第一设备中的第一操作系统可以通过HCI通道并借助第二操作系统建立第一设备与第二设备之间的第一蓝牙连接,从而为第一设备的第一操作系统与第二设备进行蓝牙通信提供了可能,能够实现第一设备的第一操作系统与第二设备之间进行蓝牙通信。
其中,第一蓝牙连接用于所述第一操作系统与第二设备进行蓝牙通信。
例如,第一指令为第一指令分组。第二指令为第一事件分组。
可选地,HCI通道为第一操作系统的第一HCI接口以及所述第二操作系统的HCI层对应的通道。
可选地,所述第一操作系统为安卓系统,所述第二操作系统为Linux系统或者Windows系统。
可选地,所述第一设备中的容器运行有所述第一操作系统。
在一些可能的实现方式中,所述方法还包括:所述第二操作系统根据所述第一蓝牙连接建立所述第二操作系统与所述第一操作系统之间传输数据的数据通道。
在一些可能的实现方式中,所述第二操作系统根据所述第一蓝牙连接建立所述第二操作系统与所述第一操作系统之间传输数据的数据通道,包括:所述第二操作系统确定所述第一蓝牙连接对应的第一路由标识信息;所述第二操作系统所述HCI通道向所述第一操作系统发送所述第一路由标识信息;所述第一操作系统确定与所述第一路由标识信息对应的第一端口信息,所述第一端口信息用于标识所述第一操作系统中的端口;所述第一操作系统通过所述HCI通道向所述第二操作系统发送所述第一端口信息和所述第一路由标识信息;
所述第二操作系统与所述第一操作系统根据所述第一端口信息建立所述第二操作系统与所述第一操作系统之间的所述数据通道。
可选地,第二指令可以包括第一路由标识信息。
可选地,第一端口信息用于标识第一操作系统中的第一端口的端口号或者端口号的索引。
可选地,第二操作系统保存第一端口信息和第一路由标识信息。
可选地,第二操作系统执行的动作可以由第二操作系统的HCI层的HCI管理模块执行。
在一些可能的实现方式中,所述方法还包括:所述第二操作系统接收所述第二设备通过所述第一蓝牙连接发送的第一数据包;所述第二操作系统根据第一对应关系和所述第一蓝牙连接确定所述第一路由标识信息,所述第一对应关系用于指示至少一个路由标识信息与至少一个蓝牙连接一一对应,所述至少一个路由标识信息包括所述第一路由标识信息,所述至少一个蓝牙连接包括所述第一蓝牙连接;
所述第二操作系统根据第二对应关系确定所述第一路由标识信息对应的所述第一端口信息,所述第二对应关系用于指示至少一个路由标识信息与至少一个端口信息一一对应,所述至少一个端口信息包括所述第一端口信息;
所述第二操作系统通过所述第一端口信息对应的所述数据通道向所述第一操作系统发送所述第一数据包。
可选地,至少一个端口信息用于标识不同端口的端口号。
可选地,不同蓝牙连接对应不同的路由标识信息,第二操作系统可以为不同蓝牙连接生成不同的路由标识信息,不同的蓝牙连接可以是第二操作系统与不同设备之间的蓝牙连接,不同的蓝牙连接对应不同的设备,例如第一蓝牙连接对应第二设备,第二操作系统生成第一蓝牙连接对应的第一路由标识信息,具体包括:第二操作系统可以根据第二设备的设备标识生成第一蓝牙连接对应的第一路由标识信息。
在一些可能的实现方式中,所述第二操作系统包括蓝牙硬件层、内核层、HCI层,所述第一操作系统包括系统层、应用程序框架层和应用程序层,所述第二操作系统接收所述第二设备通过所述第一蓝牙连接发送的第一数据包,包括:
所述第二操作系统依次通过所述蓝牙硬件层、所述内核层和所述HCI层接收所述第二设备通过所述第一蓝牙连接发送的所述第一数据包;
其中,所述第二操作系统通过所述第一端口信息对应的数据通道向所述第一操作系统发送所述第一数据包,包括:
所述第二操作系统通过所述HCI层向第一操作系统的所述系统层发送所述第一数据包;
所述第一操作系统的所述系统层接收所述第一数据包之后依次发送到所述第一操作系统的所述应用程序框架层和所述应用程序层。
在上述方案中,第二操作系统可以依次通过蓝牙硬件层、内核层、依次HCI层接收第二设备发送的第一数据包,第二操作系统将在HCI层接收到的第一数据包发送到第一操作系统的系统层,第一数据包依次到达第一操作系统的系统层、应用程序框架层以及应用层,从而可以实现第二设备向第一操作系统发送数据的过程。
在一些可能的实现方式中,所述方法还包括:所述第二操作系统接收所述第一操作系统通过所述数据通道发送的第二数据包;所述第二操作系统根据所述第二对应关系和所述数据通道所对应的第一端口信息确定所述第一端口信息对应的第一路由标识信息;
所述第二操作系统根据所述第一对应关系确定所述第一路由标识信息对应的第一蓝牙连接;
所述第二操作系统通过所述第一蓝牙连接向所述第二设备发送所述第二数据包。
在上述方案中,第二操作系统不仅可以将来自第二设备的第一数据包通过第一端口信息对应的数据通道发送给第一操作系统。第一操作系统也可以通过第一端口信息对应的数据通道向第二操作系统发送第二数据包,第二操作系统再向第二设备发送第二数据包。从而可以实现第一设备中的第一操作系统与第二设备互相传输蓝牙数据的过程。
在一些可能的实现方式中,其中,所述第二操作系统包括蓝牙硬件层、内核层、HCI层,所述第一操作系统包括应用程序层、应用程序框架层和系统层,所述第二操作系统接收所述第一操作系统通过所述数据通道发送的第二数据包,包括:
所述第一操作系统的第一数据包依次通过所述应用程序层、所述应用程序框架层到达所述系统层;
所述第一操作系统通过所述系统层将所述第一数据包发送到所述第二操作系统的HCI层;
其中,所述第二操作系统通过所述第一蓝牙连接向所述第二设备发送所述第二数据包,包括:
所述第二数据包依次通过所述第二操作系统的HCI层、内核层到达所述蓝牙硬件层;
所述第二操作系统通过所述第一蓝牙连接在所述第二操作系统的硬件层向所述第二设备发送所述第二数据包。
在上述方案中,第一操作系统可以依次将第二数据包经过应用程序层到应用程序框架层再到系统层,第一操作系统通过系统层向第二操作系统的HCI层发送第二数据 包,第二数据包依次经过第二操作系统的内核层到达蓝牙硬件层,第二操作系统将第二数据包在蓝牙硬件层发送给第二设备,第二设备依次在蓝牙硬件层接收到第二数据包,第二数据包依次经过第二设备的内核层、系统层、应用程序框架层到达应用程序层。
在一些可能的实现方式中,所述第一操作系统为安卓系统,所述第二操作系统为
Figure PCTCN2021112164-appb-000002
系统或者
Figure PCTCN2021112164-appb-000003
系统。
在一些可能的实现方式中,所述第一操作系统运行于所述第二操作系统的容器中。
在一些可能的实现方式中,所述第一设备为电脑,所述第二设备为手机。或者所述第一设备为平板,所述第二设备为手机。
第二方面,提供了一种用于蓝牙通信的方法,包括:所述方法适用于第一设备,所述第一设备包括第一操作系统和第二操作系统,所述方法包括:第二操作系统接收第二设备通过第一蓝牙连接发送的第一数据包;第二操作系统根据第一对应关系和所述第一蓝牙连接确定所述第一路由标识信息,所述第一对应关系用于指示至少一个路由标识信息与至少一个蓝牙连接一一对应,所述至少一个路由标识信息包括所述第一路由标识信息,所述至少一个蓝牙连接包括所述第一蓝牙连接;第二操作系统根据第二对应关系确定所述第一路由标识信息对应的所述容器的第一端口信息,所述第二对应关系用于指示至少一个路由标识信息与至少一个端口信息一一对应,所述至少一个端口信息包括所述第一端口信息;第二操作系统通过所述第一端口信息对应的数据通道向所述第一操作系统发送所述第一数据包。
在上述方案中,第一设备可以作为第一操作系统的宿主机,第一设备可以包括蓝牙硬件,容器没有蓝牙设备,第一设备的第二操作系统可以根据至少一个路由标识信息与至少一个蓝牙连接的第一对应关系确定第一蓝牙连接对应的第一路由标识信息;第二操作系统根据第一路由标识信息以及至少一个路由标识信息与至少一个端口信息的第二对应关系确定第一端口信息,第二操作系统通过第一端口信息对应的数据通道向第一操作系统发送第一数据包。换句话说,第二操作系统可以借助第一蓝牙连接、第一路由标识信息以及第一端口信息三者之间的对应关系,确定来自第二设备的第一数据包的路由方向,从而为第一设备的第一操作系统与第二设备传输数据提供了可能,有助于第一设备的第一操作系统与第二设备通信。
可选地,第一设备的容器上运行有所述第一操作系统,第一设备本身运行第二操作系统。
可选地,第二操作系统执行的动作可以由第二操作系统的HCI层的HCI管理模块执行。
可选地,至少一个端口信息用于标识不同端口的端口号,例如,第一端口信息用于标识所述容器的端口的端口号或者端口号的索引等。
可选地,不同蓝牙连接对应不同的路由标识信息,第二操作系统可以为不同蓝牙连接生成不同的路由标识信息,不同的蓝牙连接可以是第二操作系统与不同设备之间的蓝牙连接,不同的蓝牙连接对应不同的设备,例如第一蓝牙连接对应第二设备,第二操作系统生成第一蓝牙连接对应的第一路由标识信息,具体包括:第二操作系统可以根据第二设备的设备标识生成第一蓝牙连接对应的第一路由标识信息。
在一些可能的实现方式中,所述方法还包括:第二操作系统接收所述第一操作系统通过所述数据通道发送的第二数据包;第二操作系统根据所述第二对应关系和所述数据通道所对应的第一端口信息确定所述第一端口信息对应的第一路由标识信息;第二操作系统根据所述第一对应关系确定所述第一路由标识信息对应的第一蓝牙连接;第二操作系统通过所述第一蓝牙连接向所述第二设备发送所述第二数据包。
在上述方案中,第二操作系统不仅可以将来自第二设备的第一数据包通过第一端口信息对应的数据通道发送给第一设备的第一操作系统。第一操作系统也可以通过第一端口信息对应的数据通道向第二操作系统发送第二数据包,第二操作系统再向第二设备发送第二数据包。从而可以实现第一设备中的第一操作系统与第二设备互相传输数据的过程。
在一些可能的实现方式中,在所述接收第二设备通过第一蓝牙连接发送的第一数据包之前,所述方法还包括:第二操作系统通过HCI通道接收所述第一操作系统发送的第一指令,所述第一指令用于建立所述第一操作系统与第二设备的第一蓝牙连接;第二操作系统根据所述第一指令第一操作系统与第二设备之间的第一蓝牙连接;第二操作系统根据所述第一蓝牙连接生成所述第一路由标识信息。
在上述方案中,第二操作系统利用触发建立第一蓝牙连接的第一指令建立第一操作系统与第二设备的第一蓝牙连接,第二操作系统可以利用第一蓝牙连接的标识生成第一路由标识信息,从而可以将第一蓝牙连接与第一路由标识信息绑定,以便路由数据。
可选地,第二操作系统可以通过第一蓝牙连接发送的数据包包括的Hand ID确定第一路由标识信息。
可选地,第二操作系统根据所述第一指令与第二设备建立所述第一蓝牙连接,包括:第二操作系统根据第二操作系统中的蓝牙硬件与第二设备建立第一蓝牙连接。
可选地,通过HCI通道是第一设备上的第一操作系统加载主机驱动生成的。例如主机驱动为Native,Native包括BTso文件,第一操作系统可以加载BT so生成HCI通道。HCI通道是用于与第二操作系统的HCI层进行同行的专用通道。HCI通道在第一操作系统侧可以为第一HCI,第一HCI可以预置在第一设备的第一操作系统中的也可以是实时加载驱动程序生成,本申请不予限制。
在一些可能的实现方式中,所述方法还包括:第二操作系统通过HCI通道向所述容器的发送所述第一路由标识信息;所述第一操作系统确定与所述第一路由标识信息对应的第一端口信息,所述第一端口信息用于标识所述第一操作系统中的端口;所述第一操作系统通过所述HCI通道向所述第二操作系统发送所述第一端口信息和所述第一路由标识信息;所述第二操作系统与所述第一操作系统根据所述第一端口信息建立所述第二操作系统与所述第一操作系统之间的所述数据通道。
可选地,第二操作系统可以保存第一路由标识信息以及第一端口信息之间的对应关系。
在一些可能的实现方式中,所述方法还包括:第二操作系统通过HCI通道接收第一操作系统发送的第三指令,所述第三指令用于指示数据通道建立成功。这样,第二操作系统可以基于第三指令从第二设备接收第一数据包,或者基于第三指令向第一操 作系统发送第一数据包。
在一些可能的实现方式中,所述第一操作系统为安卓系统,所述第二设备的系统为安卓系统。这样,可以实现第一设备中系统的安卓系统与第二设备的安卓系统进行蓝牙通信。
在一些可能的实现方式中,所述方法还包括:第二操作系统可以解析来自第二设备的用于建立蓝牙指令,若指令是发送给第一操作系统的,则将指令通过HCI通道发送给第一操作系统,若指令不是发送给第一操作系统的,则将指令丢弃或者单独处理。
在一些可能的实现方式中,所述方法还包括:第二操作系统可以解析通过HCI通道传输的来自第一操作系统指令,若指令是发送给第二设备的,则将指令发送给第二设备,若指令不是发送给第二设备,则将指令丢弃或者单独处理。
第三方面,提供了一种用于蓝牙通信的方法,所述方法适用于第一设备,第一设备包括第一操作系统和第二操作系统,所述方法包括:第二操作系统接收所述第一操作系统通过所述数据通道发送的第二数据包;第二操作系统根据所述第二对应关系和所述数据通道所对应的第一端口信息确定所述第一端口信息对应的第一路由标识信息,所述第二对应关系用于指示至少一个路由标识信息与至少一个端口信息一一对应,所述至少一个路由标识信息包括所述第一路由标识信息,所述至少一个端口信息包括所述第一端口信息;第二操作系统根据所述第一对应关系确定所述第一路由标识信息对应的第一蓝牙连接,所述第一对应关系用于指示至少一个路由标识信息与至少一个蓝牙连接一一对应,所述至少一个蓝牙连接包括所述第一蓝牙连接;第二操作系统通过所述第一蓝牙连接向所述第二设备发送所述第二数据包。
可选地,第一设备的容器上运行有第一操作系统。
可选地,第二操作系统执行的动作可以由第二操作系统的HCI层的HCI管理模块执行。
在一些可能的实现方式中,在所述第二操作系统接收所述容器通过所述数据通道发送的第二数据包之前,所述方法还包括:第二操作系统接收所述第一操作系统通过HCI通道发送的第一指令,所述第一指令用于建立所述第一设备与第二设备的第一蓝牙连接;第二操作系统根据所述第一指令与第二设备建立所述第一蓝牙连接;第二操作系统根据所述第一蓝牙连接生成所述第一路由标识信息。
在一些可能的实现方式中,所述方法还包括:第二操作系统通过HCI通道向所述第一操作系统发送所述第一路由标识信息;
第二操作系统接收所述第一操作系统通过所述HCI通道发送的所述第一路由标识信息以及与所述第一路由标识信息对应的所述第一操作系统中建立的端口的所述第一端口信息;第二操作系统根据所述第一端口信息建立所述第二操作系统与所述第一操作系统之间传输数据的数据通道。
在一些可能的实现方式中,所述第一操作系统为安卓系统,所述第二操作系统为
Figure PCTCN2021112164-appb-000004
系统或者
Figure PCTCN2021112164-appb-000005
系统。
第四方面,提供一种用于蓝牙通信的装置,所述装置用于执行上述各方面或各方面的任一可能的实现方式中的方法。具体地,所述装置可以包括用于执行各方面或各方面的任一可能的实现方式中的方法的模块。
第五方面,提供一种用于蓝牙通信的装置,所述装置包括处理器,处理器与存储器耦合,存储器用于存储计算机程序或指令,处理器用于执行存储器存储的计算机程序或指令,使得上述各方面中的方法被执行。
例如,处理器用于执行存储器存储的计算机程序或指令,使得该装置执行各方面中的方法。
第六方面,提供一种计算机可读存储介质,其上存储有用于实现各方面中的方法的计算机程序(也可称为指令或代码)。
例如,该计算机程序被计算机执行时,使得该计算机可以执行各方面中的方法。
第七方面,本申请提供一种芯片,包括处理器。处理器用于读取并执行存储器中存储的计算机程序,以执行各方面及其任意可能的实现方式中的方法。
可选地,所述芯片还包括存储器,存储器与处理器通过电路或电线与存储器连接。
进一步可选地,所述芯片还包括通信接口。
第八方面,本申请提供一种计算机程序产品,所述计算机程序产品包括计算机程序(也可称为指令或代码),所述计算机程序被计算机执行时使得所述计算机实现各方面中的方法。
附图说明
图1是本申请实施例提供的蓝牙搜索界面示意图。
图2是本申请实施例提供的应用场景示意图。
图3是本申请实施例提供的电子设备的架构示意图。
图4是本申请实施例提供的电子设备的软件接口框图。
图5是本申请实施例提供的系统架构示意图。
图6是本申请实施例提供的用于蓝牙通信的方法示意图。
图7是本申请实施例提供的指令分组的格式示意图。
图8是本申请实施例提供的另一蓝牙搜索界面示意图。
图9是本申请实施例提供的又一蓝牙搜索界面示意图。
图10是本申请实施例提供的来自第二设备的数据包的格式。
图11是本申请实施例提供的事件分组的格式示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行描述。
第一设备与第二设备通过蓝牙进行通信时,具体可以通过两个设备上所运行的操作系统进行通信。如果第一设备运行有第一操作系统和第二操作系统,可能由于蓝牙硬件的限制,第二设备只能与第一设备其中的一个操作系统进行蓝牙通信,第二设备无法与另一个操作系统进行蓝牙通信。例如,第一操作系统是第一设备中容器运行的操作系统,第二操作系统是第一设备本身的系统,例如,第一操作系统为安卓系统,第二操作系统为
Figure PCTCN2021112164-appb-000006
系统。第二设备需要与第一设备中的容器上的第一操作系统进行通信时,由于容器没有蓝牙硬件且容器中的第一操作系统处于封闭的运行环境,则会导致第二设备无法与第一设备中的容器进行蓝牙通信。
容器可以是(Linux container),容器中的资源能够与第一设备隔绝,此外容器也不需要模拟第一设备的硬件设备和内核,容器的性能比虚拟机的性能好。当然,本申请实施例中的容器可以替换成虚拟机。
例如,第一设备中的容器与第二设备可以通过操作界面触发通信或者碰一碰等触发通信,若通过界面触发通信,则如图1所示第二设备的蓝牙搜索界面的可用设备列表中没有容器的标识1,只有第一设备HUAWEI P30,这样导致第二设备不能发现容器,这样会导致第一设备的容器与第二设备之间通信异常。
图2是本申请实施例提供的应用场景示意图。如图2所示,第一设备上的容器可以通过第一设备上的蓝牙设备与第二设备的蓝牙设备进行通信,从而可以实现第一设备的容器与第二设备的通信。可选地,图2中的容器也可以替换成虚拟机。
图2所示第一设备和第二设备可以为如图3所示的电子设备300。如图3所示,电子设备300可以包括处理器310、存储器320、通信模块330、显示屏340等。
其中,处理器310可以包括一个或多个处理单元,存储器320用于存储程序代码和数据。在本申请实施例中,处理器310可执行存储器320存储的计算机执行指令,用于对电子设备300的动作进行控制管理。
通信模块330可以用于电子设备300的各个内部模块之间的通信、或者电子设备300和其他外部电子设备之间的通信等。示例性的,如果电子设备300通过有线连接的方式和其他电子设备通信,通信模块330可以包括接口等,例如USB接口,USB接口可以是符合USB标准规范的接口,具体可以是Mini USB接口,Micro USB接口,USB Type C接口等。USB接口可以用于连接充电器为电子设备300充电,也可以用于电子设备300与外围设备之间传输数据。也可以用于连接耳机,通过耳机播放音频。该接口还可以用于连接其他电子设备,例如AR设备等。
或者,通信模块330可以包括音频器件、射频电路、蓝牙设备331、无线保真(wireless fidelity,Wi-Fi)芯片、近距离无线通讯技术(near-field communication,NFC)模块等,可以通过多种不同的方式实现电子设备300与其他电子设备之间的交互。其中,蓝牙设备331可以是图2中的第一设备的蓝牙设备或者第二设备的蓝牙设备。
显示屏340用于显示图像、视频等。可选地,电子设备300还可以包括外设设备350,例如鼠标、键盘、扬声器、麦克风等。
应理解,除了图3中列举的各种部件或者模块之外,本申请实施例对电子设备300的结构不做具体限定。在本申请另一些实施例中,电子设备300还可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。
电子设备300的软件系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构。
第一设备可以为电子设备300,例如,第一设备中的容器和第二设备可以为第一操作系统,如第一操作系统为
Figure PCTCN2021112164-appb-000007
系统,图4示出了本申请实施例以分层架构的
Figure PCTCN2021112164-appb-000008
系统为例,第一设备中的容器具有类似第一设备的功能,容器可以利用第一设备的图3所示的模块虚拟出特定的功能。示例性说明第一设备中的容器和第二设备的软件结构。
图4是本申请实施例提供的一例第二设备或者第一设备的容器中的第一操作系统的软件结构框图。软件结构框图将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,可以将
Figure PCTCN2021112164-appb-000009
系统分为四层,从上至下分别为应用程序层,应用程序框架层,系统层,以及内核层。
应用程序层可以包括一系列应用程序包。如图2所示,应用程序包可以包括相机,图库,日历,通话,地图,导航,WLAN,蓝牙,音乐,视频,短信息等应用程序。
应用程序框架层为应用程序层的应用程序提供应用编程接口(application programming interface,API)和编程框架。应用程序框架层包括一些预先定义的函数。
如图4所示,应用程序框架层可以包括窗口管理器,内容提供器,视图系统,电话管理器,资源管理器,通知管理器等。
窗口管理器用于管理窗口程序。窗口管理器可以获取显示屏大小,判断是否有状态栏,锁定屏幕,截取屏幕等。
内容提供器用来存放和获取数据,并使这些数据可以被应用程序访问。所述数据可以包括视频,图像,音频,拨打和接听的电话,浏览历史和书签,电话簿等。
视图系统包括可视控件,例如显示文字的控件,显示图片的控件等。视图系统可用于构建应用程序。显示界面可以由一个或多个视图组成的。例如,包括短信通知图标的显示界面,可以包括显示文字的视图以及显示图片的视图。
电话管理器用于提供电子设备300的通信功能。例如通话状态的管理(包括接通,挂断等)。
资源管理器为应用程序提供各种资源,比如本地化字符串,图标,图片,布局文件,视频文件等等。
通知管理器使应用程序可以在状态栏中显示通知信息,可以用于传达告知类型的消息,可以短暂停留后自动消失,无需用户交互。比如通知管理器被用于告知下载完成,消息提醒等。通知管理器还可以是以图表或者滚动条文本形式出现在系统顶部状态栏的通知,例如后台运行的应用程序的通知,还可以是以对话窗口形式出现在屏幕上的通知。例如在状态栏提示文本信息,发出提示音,电子设备振动,指示灯闪烁等。
系统层,负责安卓系统的调度和管理。系统层包括Native,Native包括蓝牙(bluetooth,BT)so文件,BT so也称为BT vendor so,电子设备300可以加载BT vendor so从而可以生成图5中的系统库与HCI管理模块之间的通信的第一HCI。
系统层还可以包括多个功能模块。例如:表面管理器(surface manager),媒体库(media libraries),三维图形处理库(例如:OpenGL ES),2D图形引擎(例如:SGL)等。
表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了2D和3D图层的融合。
媒体库支持多种常用的音频,视频格式回放和录制,以及静态图像文件等。媒体库可以支持多种音视频编码格式,例如:MPEG4,H.264,MP3,AAC,AMR,JPG,PNG等。
三维图形处理库用于实现三维图形绘图,图像渲染,合成,和图层处理等。
2D图形引擎是2D绘图的绘图引擎。
内核层是硬件和软件之间的层。内核层至少包含显示驱动,摄像头驱动,音频驱动,传感器驱动。
需要说明的是,在本申请实施例中,第一设备包括第一操作系统和第二操作系统,第一操作系统与第二操作系统之间可以通信,两个操作系统之间的通信可以理解为两个操作系统中对应的模块通信。当然两个设备之间的通信也可以理解为两个设备的之间的操作系统进行通信。下面的实施例中以容器运行的第一操作系统与第二操作系统中的HCI管理模块通信为例描述,但是不应该造成对本申请实施例的任何限制,容器与HCI管理模块的通信可以理解为第一操作系统与第二操作系统之间的通信。
为了便于理解,本申请以下实施例将以具有图3和图4所示结构的电子设备为例,结合附图和应用场景,对本申请实施例提供的用于蓝牙通信的方法进行具体阐述。
在本申请实施例中,为了能让第一设备中的容器与第二设备进行蓝牙通信,如图5所示示出了本申请实施例提供的架构示意图。图5中第一设备的容器运行的第一操作系统,第一设备本身运行第二操作系统,第二设备运行第一操作系统。可以利用蓝牙系统中的HCI管理模块传输指令,第一设备也称为容器的宿主机(host),容器称为客户机(guest)。第一设备中的容器可以与第二设备具有相同的第一操作系统,例如都为
Figure PCTCN2021112164-appb-000010
系统。图5所示的HCI管理模块和容器可以运行在图3所示的处理器310中。图3所示的处理器310可以加载容器的系统层的驱动程序生成第一HCI,第一HCI接口与HCI管理模块之间的通道为HCI通道。图3所示的通信模块330可以包括图5所示的第一HCI。具体地,下面结合图6对本申请实施例提供的用于蓝牙传输的方法600进行具体阐述。
在执行方法600之前,第一设备中的容器可以加载系统层的驱动程序,例如该驱动程序为BT so,加载BT so可以生成第一HCI,第一HCI也称为HCI驱动层用户空间关键接口,该第一HCI可以需要进行自定义修改,该第一HCI与第一设备的蓝牙系统的HCI层的HCI管理模块之间的通道可以称为HCI通道,HCI通道用于传输建立蓝牙连接的指令,换句话说,如图6所示HCI通道用于与蓝牙系统的HCI层进行通信,例如容器可以通过HCI通道与HCI管理模块传输指令。
S601,第二设备发送搜索蓝牙信号的指令。例如,第二设备发送搜索蓝牙信号的指令可以理解为第二设备的第一操作系统发送搜索蓝牙信号的指令。
具体地,第二设备可以通过第一操作系统的应用程序(application)层向应用程序框架层发送搜索蓝牙信号的指令,第二设备调用第一操作系统的应用程序框架层与搜索蓝牙信号的指令相关的一些预定义的函数,利用第一操作系统的系统层和内核层驱动蓝牙硬件设备等待与第一设备中的容器建立蓝牙通信。
可以理解的是,用户可以基于第二设备的某一应用触发发送搜索蓝牙信号的指令,例如,手机用户触发将作为第二设备的手机中的图片传送给第一设备的容器,则手机用户可以打开第二设备的手机的蓝牙,手机搜索可配对的设备。或者第二设备可以与第一设备碰一碰会触发发送搜索蓝牙信号的指令。
S602,第一设备的容器发送搜索蓝牙信号的指令。
具体地,第一设备的容器通过第一操作系统的应用程序层向应用程序框架层发送搜索蓝牙信号的指令。第一设备调用容器的第一操作系统的应用程序框架层与搜索蓝 牙信号的指令相关的一些预定义的函数,并将搜索蓝牙的指令发送到系统层。
可以理解的是,S602中用户可以基于容器中的某一应用触发容器发送搜索蓝牙信号的指令,例如,第一设备可以是电脑,用户可以触发电脑中的容器发送搜索蓝牙信号的控制指令,容器搜索可配对的设备。或者第一设备可以与第二设备碰一碰会触发第一设备中的容器通过第一操作系统发送搜索蓝牙信号的指令。
需要说明的是,S601与S602之间的顺序并不限定,S601可以在S602之前或者之后或者同时进行,本申请不予限制。
S603,第一设备的容器在系统层接收到搜索蓝牙信号的指令之后,通过在系统层的第一HCI与HCI管理模块之间的HCI通道发送第一指令,该第一指令用于建立第一设备与第二设备之间的第一蓝牙连接。例如,第一指令用于请求建立蓝牙连接。
本申请实施例中,第一设备与第二设备之间的第一蓝牙连接也称为第一设备中的第一操作系统与第二设备之间的蓝牙连接或者称为第一设备的容器与第二设备之间的蓝牙连接。
可选地,第一指令可以为蓝牙协议HCI层的指令,也称为第一指令分组,第一指令分组的格式如图7所示。图7的操作码(OpCode)、操作码组段(opcode group field,OGF)、操作指令段(opcode command field,OCF)等各个字段的定义参见HCI协议的定义。例如第一指令中的OGF为0x37,OCF为0x200用于指示该第一指令用于请求建立蓝牙连接。
可选地,在S603之后,S604之前,所述方法还包括:HCI管理模块可以解析从通过HCI通道接收到的任一指令,如解析的第一指令用于请求建立蓝牙连接,则执行S604;若HCI管理模块解析的一个指令不是用于请求建立蓝牙连接,也不是用于进行蓝牙配对的,而是用于修改第一设备的蓝牙系统的名称的,则HCI管理模块可以丢弃或者单独处理。
需要说明的是,第一HCI与HCI管理模块之间的HCI通道可以是双向通道,即容器可以通过HCI通道向HCI管理模块发送的指令称为指令分组,容器通过HCI通道向HCI管理模块发送的指令称为事件分组。
S604,第一设备的HCI管理模块接收到第一指令之后,根据第一指令建立第一设备与第二设备之间的第一蓝牙连接。
需要说明的是,第一设备中的容器能够通过HCI通道传送第一指令,这样,第一设备中的容器可以借助第一设备的蓝牙设备可以与第二设备互相发现,从而可以使得第二设备能够发现第一设备中的容器,容器也能发现第二设备。例如,如果第一设备中的容器与第二设备可以通过操作界面触发蓝牙搜索,如图8所示,若第二设备为手机,第一设备为电脑,此时第二设备蓝牙的界面的可用设备中能搜索到容器的标识1,图8中的第二设备为HUAWEI P40。同样的,如图9所示,此时第一设备中的容器的蓝牙界面的可用设备中也能搜索到第二设备HUAWEI P40。
可选地,第一设备的HCI管理模块可以过滤来自与容器的HCI通道的指令,若指令是用于建立蓝牙连接的,则根据HCI管理模块根据指令加载内核层的驱动调用蓝牙硬件与第二设备的蓝牙硬件进行建立第一蓝牙连接。若指令不是用于建立蓝牙连接的,则将指令丢弃或者单独处理。例如,若指令是用于修改第一设备的蓝牙系统的名称的, 则可以将控制指令丢弃。如图7中的指令的OpCode为0x0013表示该指令用于修改第一设备蓝牙系统的名称,则过滤不做处理。又例如,来自HCI通道的指令指示容器的系统异常,则过滤不作处理。
可选地,第一设备的HCI管理模块解析来自第二设备的用于建立蓝牙指令,若指令是发送到容器的与HCI管理模块之间的HCI通道的,则将指令通过HCI通道发送给容器的第一HCI,若指令不是发送给容器的,则将指令丢弃或者单独处理。
需要说明的是,用于建立蓝牙的指令传递到不同的层,可以有不同的格式,本申请实施例对此不作限制。
需要说明的是,第一蓝牙连接可以理解为第二设备与第一设备中的容器的蓝牙连接,也可以理解为第二设备与第一设备之间的蓝牙连接,第一设备中的容器能够借助第一蓝牙连接与第二设备进行蓝牙通信。
具体地,第一设备的HCI管理模块与第二设备建立第一蓝牙连接的具体流程参见现有技术的流程,本申请不进行详细描述。
S605,第一设备的HCI管理模块与第二设备建立第一蓝牙连接成功之后,HCI管理模块通过HCI通道向第一HCI发送第二指令,第二指令用于指示第一蓝牙连接建立成功。
S606,第一设备的HCI管理模块与第二设备建立第一蓝牙连接成功之后,HCI管理模块生成第一蓝牙连接对应的第一路由标识信息。
换句话说,第一设备的HCI管理模块与第二设备建立第一蓝牙连接之后,可以为建立好的第一蓝牙连接生成第一路由标识信息,这样,通过第一设备的HCI管理模块与第二设备之间的第一蓝牙连接传输的数据需要路由到第一路由标识信息对应的第一端口信息。
可选地,第一设备的HCI管理模块可以根据预设规则生成第一蓝牙连接对应的第一路由标识信息。例如,第一设备的HCI管理模块可以根据第一蓝牙连接的标识生成对应的第一路由标识信息,不同的蓝牙连接对应不同的设备,第一设备的HCI管理模块可以根据第二设备标识生成第一蓝牙连接对应的第一路由标识信息。又例如,第一设备的HCI管理模块可以根据来自第一蓝牙连接的任一一个数据包的包头的标识生成第一路由标识信息,如图10所示,示出了第一蓝牙连接的数据包的格式,第一路由标识信息可以根据数据包的路由标识生成的,路由标识可以是(Handle ID)生成,可以取Handle ID的前10位或者前12位作为第一路由标识信息或者可以根据Handle ID按照特定的规则映射生成第一路由标识信息。
需要说明的是,第一设备上的HCI管理模块可以与多个设备(如第二设备)建立一个或多个蓝牙连接,第一设备上的HCI管理模块可以为一个或多个不同的蓝牙连接生成一个或多个不同的路由标识信息,这样,第一设备可以保存一个或多个路由标识信息与一个或多个蓝牙连接对之间的第一对应关系。为了避免赘述,方法600中仅以第一蓝牙连接与第一路由标识信息为例,其他的蓝牙连接与其他的路由标识信息的对应关系参见第一蓝牙连接与第一路由标识信息的对应关系。
S607,第一设备的HCI管理模块通过HCI通道向容器发送第一路由标识信息。
例如,HCI管理模块可以通过HCI通道向容器发送第一事件分组,第一事件分组 包括第一路由标识信息,如图11所示。第一事件分组的各个字段的含义参见HCI协议中的定义,第一路由标识信息可以为事件分组中的事件参数1、事件参数2、……、事件参数N中的任何一个事件参数包括第一路由标识信息。
可选地,第一设备的HCI管理模块可以通过一个指令同时指示第一蓝牙连接建立成功也可以携带第一路由标识信息,此时S605中的第二指令可以为S607中的第一事件分组。当然S605中的第二指令和S607的第一事件分组可以是两个不同的指令。
S608,第一设备的容器根据S607中的第一路由标识信息建立容器侧的用于蓝牙传输的端口对应的端口号。
换句话说,第一设备的容器可以建立用于蓝牙传输的端口的端口号,并且端口号与第一路由标识信息对应。
S609,第一设备的容器通过HCI通道向第一设备的HCI管理模块发送第一端口信息和第一路由标识信息,所述第一端口信息用于标识端口号。可选地,在S609中,第一设备的容器通过HCI通道向第一设备的HCI管理模块发送第二指令分组,第二指令分组用于请求建立数据通道,第二指令分组还包括第一端口信息和第一路由标识信息。
例如,第一设备的容器通过HCI通道向第一设备的HCI管理模块发送第二指令分组,第二指令分组的格式如图7所示。例如第二指令分组中的OGF为0x37,OCF为0x201用于指示该第二指令分组用于请求建立数据通道。第二指令分组中的参数0、参数1、……、参数N中的一个或两个参数可以包括第一端口信息与第一路由标识信息,若两个参数分别包括第一端口信息与第一路由标识信息,则这两个参数存在对应关系。
可以理解的是,用于请求建立数据通道的指令分组和包括第一端口信息和第一路由标识信息的指令分组可以是不同的指令分组或者同一个指令分组(第二指令分组),本申请实施例不予限制。
S610,第一设备的HCI管理模块保存S609中的第一端口信息与第一路由标识信息之间的对应关系,并向通过HCI通道向容器发送确认信息,确认信息用于指示对S609的确认。
例如,第二事件分组包括确认信息,第二事件分组可以为S609中第二指令分组中的确认事件分组,第二事件分组可以指示第一设备的HCI管理模块接收到了第二指令分组。
需要说明的是,第一设备上可以存在一个或多个容器,不同的容器对应不同的HCI接口,第一设备的HCI管理模块与不同的容器的不同HCI接口对应不同的HCI通道,这样,第一设备的HCI管理模块可以保存一个或多个路由标识信息与一个或多个端口信息之间的第二对应关系。为了避免赘述,方法600中仅以第一端口信息与第一路由标识信息为例,其他的端口信息与其他的路由标识信息的对应关系参见第一端口信息与第一路由标识信息的对应关系。
S611,第一设备的HCI管理模块根据第一端口信息与容器建立数据通道。
换句话说,可以用第一端口信息标识第一设备的HCI管理模块与容器建立的数据通道。
在S611中,也可以理解为第一设备的第二操作系统与第一操作系统建立数据通道。
S612,第一设备的容器通过HCI通道向HCI管理模块发送指示数据通道建立成功 的指示信息。
例如,第三指令分组包括指示信息,HCI管理模块接收第一设备的容器的通过HCI通道发送的第三指令分组,第三指令分组用于指示数据通道建立成功。
具体地,S612中,第一设备的容器在S608中建立了用于蓝牙传输的端口的端口号,等待HCI管理模块与端口号对应的端口建立数据通道,当数据通道建立之后,第一设备的容器通过HCI通道向HCI管理模块发送第三指令分组,用于指示数据通道建立成功,这样,可以避免HCI管理模块不停的建立数据通道所带来的开销。
可选地,第三指令分组的格式如图7所示。例如第三指令分组中的OGF为0x37,OCF为0x202用于指示该第三指令分组用于指示数据通道建立成功。
可选地,S612可以触发HCI管理模块执行S613或者S616。换句话说,HCI管理模块可以在确定数据通道建立成功之后,再接收来自第二设备的第一数据包,或者HCI管理模块在确定数据通道建立成功之后,再确定向第一设备的容器的第一HCI发送第一数据包。
可以理解的是,S612是可选步骤。HCI管理模块可以检测数据通道是否成功,或者尝试向容器的第一HCI发送探测数据包确定数据通道是否成功,本申请实施例不予限制。
在第一设备的容器与第二设备进行蓝牙通信的过程中,第一设备的容器可以通过S611建立的数据通道向第二设备发送蓝牙数据,第二设备也可以通过S610中建立的数据通道向第一设备的容器发送蓝牙数据。例如,若第二设备通过S611中建立的数据通道向第一设备中的容器发送数据,则执行S613-S616;若第一设备中的容器通过S611建立的数据通道向第二设备发送数据,则执行S617-S620。若第二设备通过S611中建立的数据通道向第一设备中的容器发送数据,且第一设备中的容器通过S611建立的数据通道向第二设备发送数据,则执行S613-S616和S617-S620,并且S613-S616中任一一个步骤与S617-S620中任何一个步骤的顺序没有任何限制,S613-S616中任一一个步骤可以在S617-S620中任何一个步骤之前或之后或者同时进行。
S613,第二设备通过S604建立的第一蓝牙连接向第一设备的HCI管理模块发送第一数据包,第一设备的HCI管理模块接收第二设备通过S604建立的第一蓝牙连接发送的第一数据包。
具体地,第一数据包中的数据是从第二设备的应用程序层开始依次应用程序框架层、系统层、内核层和蓝牙硬件层进行不同的封装能够到达第一设备的蓝牙系统的蓝牙硬件层,第一设备的蓝牙系统的蓝牙硬件层接收到第一数据包之后依次将第一数据包发送到内核层,再到HCI管理模块。第一数据包在不同的层可以有不同的格式,本申请不予限制。
可选地,第一数据包可以是某一应用的数据。
S614,第一设备的HCI管理模块根据第一蓝牙连接和第一对应关系确定第一蓝牙连接对应的第一路由标识信息。
由于S606中第一设备的HCI管理模块是根据第一蓝牙连接生成的第一路由标识信息,因此当第一设备的HCI管理模块通过第一蓝牙连接接收到第一数据包时,HCI管理模块需要在第一对应关系中确定第一蓝牙连接对应的第一路由标识信息,则该第 一数据包需要根据确定的第一路由标识信息进行路由。
S615,第一设备的HCI管理模块根据S610中保存的第一路由标识信息和第一端口信息确定来自S612的第一数据包需要发送到第一路由标识信息对应的第一端口信息所标识的数据通道,该数据通道即为S611中建立的数据通道。
在S615中,第一设备的HCI管理模块可以在保存的一个或多个路由标识信息与一个或多个端口之间的第二对应关系中确定第一路由标识信息对应的第一端口信息,从而可以将来自第二设备的第一数据包发送到第一端口信息所标识的数据通道。
S617,第一设备的HCI管理模块通过S615中确定的数据通道向容器的系统层发送来自第二设备的第一数据包。
需要说明的是,S613的第一数据包可以是第二设备在S604中的第一蓝牙连接建立成功之后与S611中的建立数据通道之前发送给第一设备的HCI管理模块。若第一数据包是HCI管理模块在与容器的第一HCI建立S611的数据通道之前可以接收到,HCI管理模块可以先将接收到数据包进行缓存不发送,在S617中再通过数据通道发送,本申请实施例不予限制。
可以理解的是,第一设备的HCI管理模块在S617中可以将来自S613的第一数据包通过数据通道透传给容器,或者也可以修改第一数据包的包头,修改后的第一数据包的包头可以携带第一设备的HCI管理模块的标识,此时,此时S617中的第一数据包的包头与S613中的第一数据包的包头可以不同,数据部分相同。
其中,容器的系统层接收来自HCI管理模块的第一数据包之后,将第一数据包传递到应用程序框架层,再传递到容器的应用程序层。
可选地,容器接收到第一数据包之后,在容器的应用程序层显示数据接收成功;第二设备将第一数据包发送给第一设备之后,将发送的结果从下层到上层返回给第二设备的应用程序层,例如,在第二设备的应用程序层显示数据发送成功。
S617,第一设备通过S611建立的数据通道向第一设备的HCI管理模块发送第二数据包,第一设备的HCI管理模块通过S611建立的数据通道接收第一HCI发送的第二数据包。
具体地,第二数据包从第一设备的应用程序层依次通过应用程序框架层和系统层,然后通过容器的系统层发送到HCI管理模块,第二数据包在不同的层可以有不同的封装格式,本申请不予限制。
可选地,第二数据包可以是某一应用的数据。
S618,第一设备的HCI管理模块根据接收第二数据包的数据通道的第一端口信息确定第一路由标识信息。
在S618中,第一设备的HCI管理模块可以在保存的一个或多个路由标识信息与一个或多个端口信息之间的第二对应关系中确定第一端口信息对应的第一路由标识信息。
S619,第一设备的HCI管理模块根据第一路由标识信息确定第一路由标识信息对应的第一蓝牙连接。
在S619中,第一设备的HCI管理模块可以在保存的一个或多个路由标识信息与一个或多个蓝牙连接之间的对应关系中确定第一路由标识信息对应的第一蓝牙连接, 从而HCI管理模可以确定将来自第一HCI的第二数据包发送到第一蓝牙连接。
S620,第一设备的HCI管理模块将第二数据包通过第一蓝牙连接发送到第二设备。
可以理解的是,第一设备的HCI管理模块在S620中可以将来自S617的第二数据包透传给第二设备,或者也可以修改第二数据包的包头,修改后的第二数据包的包头可以携带第一设备的HCI管理模块的标识,此时,S617中的第二数据包的包头与S620中的第二数据包的包头可以不同,数据部分相同。
具体地,第二数据包通过蓝牙系统的内核层到达蓝牙硬件层,从第一设备的蓝牙硬件层传递到第二设备的蓝牙硬件层,第二设备的蓝牙硬件层接收到第二数据包之后依次通道内核层、系统层、应用程序框架层到达应用程序层,第二数据包在不同的层可以有不同的封装格式,本申请不予限制。
可选地,第二设备接收到第二数据包之后,在第二设备的应用程序层显示数据接收成功;HCI管理模块将第二数据包发送给第二设备之后,将发送的结果从下层到上层返回给第一设备的应用程序层,例如,在第一设备的应用程序层显示数据发送成功。
需要说明的是,本申请实施例,第一设备的容器的第一HCI与HCI管理模块之间传输的指令可以分为事件分组和指令分组,HCI管理模块发送给第一HCI的控制指令称为事件分组,第一HCI发送给HCI管理模块的控制指令称为指令分组。换句话说,事件分组与指令分组的区别在于控制指令的流向不同,以第一设备的容器为参考,指令分组指的是发出去的控制指令,事件分组指的是接收到的控制指令。
也需要说明的是,方法600中,S601-S612为预先配置的过程,S613-S620为传输数据包的过程,第一设备的容器与第二设备可以基于一次配置传输多次数据包。换句话说,S601-S612可以执行一次,S613-S620可以执行多次。
可以理解的是,方法600中可以包括更多的步骤或者更少的步骤,方法600的只是示例性的描述。例如,方法600可以不存在S601和S602,只包括S603-S605,此时该方案的目的是为了建立第一蓝牙连接,至于是如何触发建立第一蓝牙连接的过程,本申请实施例不予限制。又例如,方法600可以只存在S613-S616,不存在其他的步骤,即只存在第二设备向第一设备的容器发送第一数据包的过程,S613之前的步骤可以是历史数据处理过程中得到的或者是预设的。又例如,方法600可以只存在
S617-S620,不存在其他的步骤,即只存在第一设备的容器向第二设备发送第二数据包的过程,其他的步骤可以是历史数据处理过程中得到的或者是预设的。再例如,方法600可以只存在S613-S620,不存在其他的步骤,即只存在第二设备向第一设备的容器发送第一数据包以及第一设备的容器向第二设备发送第二数据包的过程,S613之前的步骤可以是历史数据处理过程中得到的或者是预设的。
要说明的是,第一数据包或者第二数据包在不同的模块或者接口之间传递时,某一模块可以进行修改控制数据包的包头以适应本模块的封装格式,或者某一模块也可以不修改第一数据包或第二数据包的格式,直接透传到下一个节点,本申请不予限制。
可以理解的是,本申请实施例中容器可以替换成虚拟机,换句话说,第一设备上的虚拟机可以通过第一HCI共享第一设备的蓝牙系统,从而可以实现与第一设备共享蓝牙系统。
可选地,上述实施例中,第一设备的第二操作系统可以是
Figure PCTCN2021112164-appb-000011
系统或者
Figure PCTCN2021112164-appb-000012
系统。
本实施例可以根据上述方法示例对第一设备和第二设备进行功能模块的划分,或者本实施例可以根据上述方法示例对第一设备中的容器和HCI管理模块进行功能模块的划分,例如,可以对应各个功能划分各个功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块可以采用硬件的形式实现。需要说明的是,本实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
需要说明的是,上述方法实施例涉及的各步骤的所有相关内容均可以援引到对应功能模块的功能描述,在此不再赘述。
本实施例提供的第一设备和第二设备,用于执行上述用于蓝牙通信的方法,因此可以达到与上述实现方法相同的效果。在采用集成的单元的情况下,第一设备和第二设备分别可以包括处理模块、存储模块和通信模块。例如,处理模块可以用于对第一设备的HCI管理模块和容器以及第二设备的动作进行控制管理,例如,可以用于支持第一设备的HCI管理模块和容器以及第二设备执行处理单元执行的步骤。存储模块可以用于支持第一设备的HCI管理模块和容器以及第二设备执行存储程序代码和数据等。通信模块,可以用于支持第一设备的HCI管理模块和容器以及第二设备与其他设备的通信,或者用于支持设备内部的通信。
其中,处理模块可以是处理器或控制器。其可以实现或执行结合本申请公开内容所描述的各种示例性的逻辑方框,模块和电路。处理器也可以是实现计算功能的组合,例如包含一个或多个微处理器组合,数字信号处理(digital signal processing,DSP)和微处理器的组合等等。存储模块可以是存储器。通信模块具体可以为射频电路、蓝牙芯片、Wi-Fi芯片等与其他电子设备交互的设备。
在一个实施例中,当处理模块为处理器,存储模块为存储器时,本实施例所涉及的电子设备可以为具有图3所示结构的设备。
本实施例还提供一种计算机可读存储介质,该计算机可读存储介质中存储有计算机指令,当该计算机指令在电子设备上运行时,使得电子设备执行上述相关方法步骤实现上述实施例中的用于蓝牙通信的方法。
本实施例还提供了一种计算机程序产品,当该计算机程序产品在计算机上运行时,使得计算机执行上述相关步骤,以实现上述实施例中的用于蓝牙通信的方法。
另外,本申请的实施例还提供一种装置,这个装置具体可以是芯片,组件或模块,该装置可包括相连的处理器和存储器;其中,存储器用于存储计算机执行指令,当装置运行时,处理器可执行存储器存储的计算机执行指令,以使芯片执行上述各方法实施例中的安全访问数据的方法。
其中,本实施例提供的电子设备、计算机存储介质、计算机程序产品或芯片均用于执行上文所提供的对应的方法,因此,其所能达到的有益效果可参考上文所提供的对应的方法中的有益效果,此处不再赘述。
通过以上实施方式的描述,所属领域的技术人员可以了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完 成以上描述的全部或者部分功能。
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个装置,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是一个物理单元或多个物理单元,即可以位于一个地方,或者也可以分布到多个不同地方。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该软件产品存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
以上内容,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。

Claims (11)

  1. 一种用于蓝牙通信的方法,所述方法适用于第一设备,所述第一设备包括第一操作系统和第二操作系统,其特征在于,所述方法包括:
    第一操作系统通过主机控制接口HCI通道向第二操作系统发送第一指令,所述第一指令用于建立所述第一设备与第二设备之间的第一蓝牙连接;
    所述第二操作系统根据所述第一指令建立所述第一设备与所述第二设备的所述第一蓝牙连接;
    所述第二操作系统通过所述HCI通道向所述第一操作系统发送第二指令,所述第二指令用于指示所述第一蓝牙连接建立成功。
  2. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    所述第二操作系统根据所述第一蓝牙连接建立所述第二操作系统与所述第一操作系统之间传输数据的数据通道。
  3. 根据权利要求2所述的方法,其特征在于,所述第二操作系统根据所述第一蓝牙连接建立所述第二操作系统与所述第一操作系统之间传输数据的数据通道,包括:
    所述第二操作系统确定所述第一蓝牙连接对应的第一路由标识信息;
    所述第二操作系统通过所述HCI通道向所述第一操作系统发送所述第一路由标识信息;
    所述第一操作系统确定与所述第一路由标识信息对应的第一端口信息,所述第一端口信息用于标识所述第一操作系统中的端口;
    所述第一操作系统通过所述HCI通道向所述第二操作系统发送所述第一端口信息和所述第一路由标识信息;
    所述第二操作系统与所述第一操作系统根据所述第一端口信息建立所述第二操作系统与所述第一操作系统之间的所述数据通道。
  4. 根据权利要求2或3所述的方法,其特征在于,所述方法还包括:
    所述第二操作系统接收所述第二设备通过所述第一蓝牙连接发送的第一数据包;
    所述第二操作系统根据第一对应关系和所述第一蓝牙连接确定所述第一路由标识信息,所述第一对应关系用于指示至少一个路由标识信息与至少一个蓝牙连接一一对应,所述至少一个路由标识信息包括所述第一路由标识信息,所述至少一个蓝牙连接包括所述第一蓝牙连接;
    所述第二操作系统根据第二对应关系确定所述第一路由标识信息对应的所述第一端口信息,所述第二对应关系用于指示至少一个路由标识信息与至少一个端口信息一一对应,所述至少一个端口信息包括所述第一端口信息;
    所述第二操作系统通过所述第一端口信息对应的所述数据通道向所述第一操作系统发送所述第一数据包。
  5. 根据权利要求4所述的方法,其特征在于,所述第二操作系统包括蓝牙硬件层、内核层、HCI层,所述第一操作系统包括系统层、应用程序框架层和应用程序层,所述第二操作系统接收所述第二设备通过所述第一蓝牙连接发送的第一数据包,包括:
    所述第二操作系统依次通过所述蓝牙硬件层、所述内核层和所述HCI层接收所述第二设备通过所述第一蓝牙连接发送的所述第一数据包;
    其中,所述第二操作系统通过所述第一端口信息对应的数据通道向所述第一操作系统发送所述第一数据包,包括:
    所述第二操作系统通过所述HCI层向第一操作系统的所述系统层发送所述第一数据包;
    所述第一操作系统的所述系统层接收所述第一数据包之后依次发送到所述第一操作系统的所述应用程序框架层和所述应用程序层。
  6. 根据权利要求2至5中任一项所述的方法,其特征在于,所述方法还包括:
    所述第二操作系统接收所述第一操作系统通过所述数据通道发送的第二数据包;
    所述第二操作系统根据所述第二对应关系和所述数据通道所对应的第一端口信息确定所述第一端口信息对应的第一路由标识信息;
    所述第二操作系统根据所述第一对应关系确定所述第一路由标识信息对应的第一蓝牙连接;
    所述第二操作系统通过所述第一蓝牙连接向所述第二设备发送所述第二数据包。
  7. 根据权利要求6所述的方法,其特征在于,其中,所述第二操作系统包括蓝牙硬件层、内核层、HCI层,所述第一操作系统包括应用程序层、应用程序框架层和系统层,所述第二操作系统接收所述第一操作系统通过所述数据通道发送的第二数据包,包括:
    所述第一操作系统的第一数据包依次通过所述应用程序层、所述应用程序框架层到达所述系统层;
    所述第一操作系统通过所述系统层将所述第一数据包发送到所述第二操作系统的HCI层;
    其中,所述第二操作系统通过所述第一蓝牙连接向所述第二设备发送所述第二数据包,包括:
    所述第二数据包依次通过所述第二操作系统的HCI层、内核层到达所述蓝牙硬件层;
    所述第二操作系统通过所述第一蓝牙连接在所述第二操作系统的硬件层向所述第二设备发送所述第二数据包。
  8. 根据权利要求1至7中任一项所述的方法,其特征在于,所述HCI通道为所述第一操作系统的系统层的第一HCI接口以及第二操作系统的HCI层对应的通道。
  9. 根据权利要求1至8中的任一项所述的方法,其特征在于,所述第一操作系统运行于所述第二操作系统的容器中。
  10. 一种电子设备,其特征在于,包括处理器,所述处理器与存储器耦合,所述处理器用于执行所述存储器中存储的计算机程序或指令,以使得所述电子设备实现如权利要求1至9中任一项所述的方法。
  11. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机指令,当所述计算机指令在电子设备上运行时,使得所述电子设备执行如权利要求1至9中任一项所述的方法。
PCT/CN2021/112164 2020-08-31 2021-08-12 用于蓝牙通信的方法和电子设备 WO2022042314A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
US18/043,211 US20230337300A1 (en) 2020-08-31 2021-08-12 BLUETOOTH Communication Method and Electronic Device
EP21860153.2A EP4195520A4 (en) 2020-08-31 2021-08-12 METHOD AND ELECTRONIC DEVICE FOR BLUETOOTH COMMUNICATION

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010899012.8 2020-08-31
CN202010899012.8A CN114124165B (zh) 2020-08-31 2020-08-31 用于蓝牙通信的方法和电子设备

Publications (1)

Publication Number Publication Date
WO2022042314A1 true WO2022042314A1 (zh) 2022-03-03

Family

ID=80354527

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/112164 WO2022042314A1 (zh) 2020-08-31 2021-08-12 用于蓝牙通信的方法和电子设备

Country Status (4)

Country Link
US (1) US20230337300A1 (zh)
EP (1) EP4195520A4 (zh)
CN (2) CN115767776A (zh)
WO (1) WO2022042314A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116033597A (zh) * 2022-08-08 2023-04-28 荣耀终端有限公司 蓝牙连接方法、装置、电子设备及存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8798541B1 (en) * 2011-04-11 2014-08-05 Vmware, Inc. System and method for socket backed host controller interface emulation for virtual bluetooth adapter
CN105718311A (zh) * 2015-07-09 2016-06-29 北京海誉动想科技股份有限公司 智能系统及其实现方法、和用于智能设备的外设
CN106059635A (zh) * 2016-07-15 2016-10-26 北京海誉动想科技股份有限公司 电子设备蓝牙设置方法及装置、蓝牙连接方法
CN106452517A (zh) * 2016-10-28 2017-02-22 宇龙计算机通信科技(深圳)有限公司 蓝牙通信方法、装置和终端

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120240078A1 (en) * 2011-03-17 2012-09-20 I O Interconnect, Ltd. Synchronization method between two electronic devices installed on the same operation system
EP2819007A1 (en) * 2013-06-28 2014-12-31 Orange Method for managing an application running on an operating system from another operating system
KR102273021B1 (ko) * 2015-02-27 2021-07-06 삼성전자주식회사 복수의 운영체제가 구동되는 전자 장치가 주변 기기와 통신하는 방법 및 그 장치
CN106611310B (zh) * 2015-08-14 2020-12-08 华为终端有限公司 数据处理的方法、穿戴式电子设备和系统
CN105376637A (zh) * 2015-09-29 2016-03-02 青岛海信电器股份有限公司 一种共享蓝牙硬件的系统和方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8798541B1 (en) * 2011-04-11 2014-08-05 Vmware, Inc. System and method for socket backed host controller interface emulation for virtual bluetooth adapter
CN105718311A (zh) * 2015-07-09 2016-06-29 北京海誉动想科技股份有限公司 智能系统及其实现方法、和用于智能设备的外设
CN106059635A (zh) * 2016-07-15 2016-10-26 北京海誉动想科技股份有限公司 电子设备蓝牙设置方法及装置、蓝牙连接方法
CN106452517A (zh) * 2016-10-28 2017-02-22 宇龙计算机通信科技(深圳)有限公司 蓝牙通信方法、装置和终端

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP4195520A4

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116033597A (zh) * 2022-08-08 2023-04-28 荣耀终端有限公司 蓝牙连接方法、装置、电子设备及存储介质
CN116033597B (zh) * 2022-08-08 2023-12-12 荣耀终端有限公司 蓝牙连接方法、装置、电子设备及存储介质

Also Published As

Publication number Publication date
US20230337300A1 (en) 2023-10-19
EP4195520A1 (en) 2023-06-14
EP4195520A4 (en) 2024-01-24
CN114124165B (zh) 2022-12-30
CN115767776A (zh) 2023-03-07
CN114124165A (zh) 2022-03-01

Similar Documents

Publication Publication Date Title
AU2022211850B2 (en) Application function implementation method and electronic device
US10341264B2 (en) Technologies for scalable packet reception and transmission
EP4227785A1 (en) Control blurring method and apparatus, terminal device, and readable storage medium
CN113038434B (zh) 设备注册方法、装置、移动终端和存储介质
KR20160042739A (ko) 화면을 공유하기 위한 방법 및 그 전자 장치
WO2019094510A1 (en) Systems and methods for remote control in information technology infrastructure
WO2022042314A1 (zh) 用于蓝牙通信的方法和电子设备
CN104796308A (zh) 设备的网络互联方法和系统
CN115344226A (zh) 一种虚拟化管理下的投屏方法、装置、设备及介质
CN114666864A (zh) 多网络通信方法、终端设备、存储介质和程序产品
US10284614B2 (en) Method for downloading contents of electronic device and electronic device thereof
EP2854426B1 (en) Communication system with transport link mechanism and method of operation thereof
US10742776B1 (en) Accelerating isochronous endpoints of redirected USB devices
WO2022052928A1 (zh) 一种应用接入方法及相关装置
CN114675786A (zh) 一种大容量存储挂载方法、装置、终端及介质
CN111159734A (zh) 通信终端及多应用数据互访处理方法
US11991040B2 (en) Network configuration method and device
CN112839007A (zh) 一种网络攻击的防御方法及装置
CN117216428B (zh) 一种网页资源请求方法、终端设备及计算机可读存储介质
CN110719303A (zh) 一种容器化nrf的方法及系统
EP4357936A1 (en) Map display method, electronic device, and system
CN114461157B (zh) 一种idv客户端多屏分治方法及系统
KR102268552B1 (ko) 디스플레이를 포함하는 무선 이어폰 장치
CA3101813C (en) Application function implementation method and electronic device
WO2024055867A9 (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: 21860153

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2021860153

Country of ref document: EP

Effective date: 20230306

NENP Non-entry into the national phase

Ref country code: DE