Multi-Bluetooth driving method, device, equipment, medium and vehicle
By receiving and processing service instructions for identification information, calling Bluetooth framework interfaces and services, and loading the protocol stack dynamic library, the problem that existing Bluetooth frameworks cannot support multiple Bluetooth work simultaneously is solved, and the function of running multiple Bluetooth simultaneously is realized, improving the user experience.
Patent Information
- Application Number
- CN202210608996.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-31
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2042-05-31
AI Technical Summary
The existing Bluetooth framework design can only support one Bluetooth work and cannot meet the user's needs for multiple Bluetooth work simultaneously. For example, the main driver and co-pilot use Bluetooth to operate simultaneously in the vehicle for telephone and entertainment operations.
By receiving service instructions sent by the target program process, identifying the target Bluetooth chip from multiple Bluetooth chips using identification information, calling the associated framework interface class to obtain interface instances, calling Bluetooth services, and loading the protocol stack dynamic library to drive the Bluetooth chip to perform service operations.
The function of multi-Bluetooth running simultaneously meets users' needs for multi-Bluetooth driving simultaneously and improves user experience.
Smart Images

Figure CN115442781B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of Bluetooth technology, and in particular to a multi-Bluetooth driving method, device, equipment, medium and vehicle. Background Art
[0002] With the development of Bluetooth technology, various Bluetooth functions have attracted more and more attention and popularity among people. For example, vehicles are usually equipped with Bluetooth to realize Bluetooth functions such as Bluetooth phones and Bluetooth headsets.
[0003] However, the current Bluetooth framework design of some systems (such as Android systems) can only support one Bluetooth working, and cannot support multiple Bluetooth working at the same time. This will not meet the user's demand for multiple Bluetooth working at the same time. For example, in a vehicle scenario, when the main driver needs to use Bluetooth to connect to the mobile phone to operate the phone function, the co-driver or the rear passenger needs to use another Bluetooth to connect to the headset to listen to the car audio and video for entertainment operations. The existing Bluetooth framework design cannot meet the requirements. Summary of the invention
[0004] In order to solve the above technical problems, the present disclosure provides a multi-Bluetooth driving method, device, equipment, medium and vehicle.
[0005] In a first aspect, the present disclosure provides a multi-Bluetooth driver method, comprising:
[0006] Receive a service instruction sent by a target program process; wherein the service instruction carries identification information, and the identification information is used to identify a target Bluetooth chip corresponding to the service instruction from a plurality of Bluetooth chips;
[0007] Based on the identification information of the target Bluetooth chip, call the framework interface class associated with the service instruction to obtain the interface instance corresponding to the target Bluetooth chip;
[0008] Based on the interface instance corresponding to the target Bluetooth chip, call the Bluetooth service corresponding to the target Bluetooth chip;
[0009] Based on the Bluetooth service corresponding to the target Bluetooth chip, the protocol stack dynamic library corresponding to the target Bluetooth chip is loaded to drive the target Bluetooth chip to execute the service operation corresponding to the service instruction.
[0010] In another embodiment of the present disclosure, based on the identification information of the target Bluetooth chip, the framework interface class associated with the service instruction is called to obtain the interface instance corresponding to the target Bluetooth chip, including:
[0011] Based on the identification information of the target Bluetooth chip, calling a first calling function corresponding to the framework interface class associated with the service instruction;
[0012] Based on the first calling function, the framework interface class associated with the service instruction is called to obtain an interface instance corresponding to the target Bluetooth chip.
[0013] In another embodiment of the present disclosure, based on the identification information of the target Bluetooth chip, the framework interface class associated with the service instruction is called to obtain the interface instance corresponding to the target Bluetooth chip, including:
[0014] Calling a second calling function corresponding to the framework interface class associated with the service instruction;
[0015] Based on the second calling function, the target Bluetooth chip corresponding to the identification information is determined, and the framework interface class associated with the service instruction is called to obtain an interface instance corresponding to the target Bluetooth chip.
[0016] In another embodiment of the present disclosure, before calling the protocol stack dynamic library corresponding to the target Bluetooth chip based on the Bluetooth service corresponding to the target Bluetooth chip, the method further includes:
[0017] For each Bluetooth chip, based on its corresponding compilation information, the protocol stack component is compiled to obtain its corresponding protocol stack dynamic library.
[0018] In yet another embodiment of the present disclosure, before receiving the service instruction sent by the target program process, the method further includes:
[0019] Start the Bluetooth management service process;
[0020] Receiving an opening instruction sent by a target program process; wherein the opening instruction carries identification information;
[0021] Based on the identification information of the target Bluetooth chip, the Bluetooth service corresponding to the target Bluetooth chip is started through the Bluetooth management service process.
[0022] In another embodiment of the present disclosure, starting the Bluetooth management service process includes:
[0023] The Bluetooth management service class is called to obtain multiple Bluetooth management service instances; wherein the multiple Bluetooth management service instances include a Bluetooth management service instance corresponding to the target Bluetooth chip.
[0024] In another embodiment of the present disclosure, a Bluetooth management service class is called to obtain multiple Bluetooth management service instances, including:
[0025] The Bluetooth management service class is called to obtain a Bluetooth management service array; wherein the Bluetooth management service array includes multiple Bluetooth management service instances.
[0026] In a second aspect, the present disclosure provides a multi-Bluetooth driver device, comprising:
[0027] The first receiving module is used to receive the service instruction sent by the target program process; wherein the service instruction carries identification information, and the identification information is used to identify the target Bluetooth chip corresponding to the service instruction from multiple Bluetooth chips.
[0028] A first calling module is used to call the framework interface class associated with the service instruction based on the identification information of the target Bluetooth chip to obtain the interface instance corresponding to the target Bluetooth chip;
[0029] The second calling module is used to call the Bluetooth service corresponding to the target Bluetooth chip based on the interface instance corresponding to the target Bluetooth chip;
[0030] The first loading module is used to load the protocol stack dynamic library corresponding to the target Bluetooth chip based on the Bluetooth service corresponding to the target Bluetooth chip, so as to drive the target Bluetooth chip to execute the service operation corresponding to the service instruction.
[0031] In a third aspect, the present disclosure provides an electronic device, including:
[0032] processor;
[0033] A memory for storing executable instructions;
[0034] The processor is used to read executable instructions from the memory and execute the executable instructions to implement the multi-Bluetooth driving method described in the first aspect.
[0035] In a fourth aspect, the present disclosure provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor implements the multi-Bluetooth driving method described in the first aspect.
[0036] In a fifth aspect, the present disclosure provides a vehicle, comprising at least one of the following:
[0037] The multi-Bluetooth driver device according to the second aspect;
[0038] The electronic device according to the third aspect;
[0039] The computer-readable storage medium described in the fourth aspect.
[0040] Compared with the prior art, the technical solution provided by the embodiments of the present disclosure has the following advantages:
[0041] The multi-Bluetooth driving method, device, equipment, medium and vehicle of the disclosed embodiment can receive the service instruction sent by the target program process; wherein the service instruction carries identification information, and the identification information is used to identify the target Bluetooth chip corresponding to the service instruction from multiple Bluetooth chips; based on the identification information of the target Bluetooth chip, the framework interface class associated with the service instruction is called to obtain the interface instance corresponding to the target Bluetooth chip; based on the interface instance corresponding to the target Bluetooth chip, the Bluetooth service corresponding to the target Bluetooth chip is called; based on the Bluetooth service corresponding to the target Bluetooth chip, the protocol stack dynamic library corresponding to the target Bluetooth chip is loaded to drive the target Bluetooth chip to perform the service operation corresponding to the service instruction. Since the native framework interface, native Bluetooth service and native protocol stack are expanded in the original Bluetooth framework design, the expanded Bluetooth framework can meet the simultaneous operation of multiple Bluetooths. Therefore, based on the expanded Bluetooth framework, for each target Bluetooth chip, the disclosed embodiment can call the Bluetooth service corresponding to the target Bluetooth chip based on the identification information corresponding to the target Bluetooth chip, and then load the protocol stack dynamic library corresponding to the target Bluetooth chip to drive the target Bluetooth chip, so that the user's demand for simultaneous driving of multiple Bluetooths can be met and the user experience can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0043] Figure 1 A schematic diagram of a multi-Bluetooth driver method provided by an embodiment of the present disclosure is shown;
[0044] Figure 2 A schematic diagram of the framework structure of a Bluetooth module provided by an embodiment of the present disclosure is shown;
[0045] Figure 3 A schematic diagram of the structure of a multi-Bluetooth driver device provided by an embodiment of the present disclosure is shown;
[0046] Figure 4 A schematic structural diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0047] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0048] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0049] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0050] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0051] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0052] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0053] In order to solve the above problems, the embodiments of the present disclosure provide a multi-Bluetooth driver method, device, equipment, medium and vehicle, which can receive a service instruction sent by a target program process; wherein the service instruction carries identification information for identifying the corresponding target Bluetooth chip, and the target Bluetooth chip is one of multiple Bluetooth chips; based on the identification information of the target Bluetooth chip, the framework interface class associated with the service instruction is called to obtain the interface instance corresponding to the target Bluetooth chip; based on the interface instance corresponding to the target Bluetooth chip, the Bluetooth service corresponding to the target Bluetooth chip is called; based on the Bluetooth service corresponding to the target Bluetooth chip, the protocol stack dynamic library corresponding to the target Bluetooth chip is loaded to drive the target Bluetooth chip to execute the service operation corresponding to the service instruction. Below, the multi-Bluetooth driver method provided by the embodiments of the present disclosure is first described.
[0054] Figure 1 A schematic flow chart of a multi-Bluetooth driver method provided in an embodiment of the present disclosure is shown.
[0055] In some embodiments of the present disclosure, Figure 1 The multi-Bluetooth driving method shown can be applied to a Bluetooth module including multiple Bluetooth chips, for example, and the Bluetooth module can include a car-mounted Bluetooth module, which is not specifically limited.
[0056] like Figure 1 As shown, the multi-Bluetooth driving method may include the following steps.
[0057] S110: Receive a service instruction sent by the target program process.
[0058] The service instruction carries identification information, and the identification information is used to identify a target Bluetooth chip corresponding to the service instruction from multiple Bluetooth chips.
[0059] In the embodiment of the present disclosure, the Bluetooth module can receive the service instruction sent by the target program process. The framework structure of the Bluetooth module can be set by a person skilled in the art according to the actual situation, and is not limited here, as long as it can execute the multi-Bluetooth driving method provided by the embodiment of the present disclosure. For example, Figure 2 FIG. 1 is a schematic diagram showing a framework structure of a Bluetooth module provided by an embodiment of the present disclosure. Figure 2, the Bluetooth module includes a framework interface layer 210, a Bluetooth service layer 220, a protocol stack layer 230, a Bluetooth management service layer 240, and a Bluetooth chip layer 250, and the Bluetooth chip layer 250 includes N Bluetooth chips (N is a positive integer greater than 1). Compared with the native framework interface layer, the framework interface layer 210 in the embodiment of the present disclosure extends the native framework interface; compared with the native Bluetooth service layer, the Bluetooth service layer 220 in the embodiment of the present disclosure extends the native Bluetooth service, and the number of Bluetooth services included in the Bluetooth service layer 220 is greater than or equal to the number of Bluetooth chips; compared with the native protocol stack layer, the protocol stack layer 230 in the embodiment of the present disclosure extends the native Bluetooth protocol stack, and the Bluetooth service layer 220 includes a protocol stack dynamic library corresponding to each Bluetooth chip; compared with the native Bluetooth management service layer, the Bluetooth management service layer 240 in the embodiment of the present disclosure includes multiple Bluetooth management service threads in the corresponding Bluetooth management service process after startup, and the number of Bluetooth management service threads is greater than or equal to the number of Bluetooth chips.
[0060] Specifically, the target program process can be any program process that needs the Bluetooth service layer of the Bluetooth module to provide services. For example, the target program process can include an application program process and a framework program process, and the application program process can include an application program loaded in the terminal where the Bluetooth module is located (i.e. Figure 2 The framework program process may include a process inside the framework structure of the Bluetooth module. At this time, the framework interface layer in the Bluetooth module receives the service instructions sent by the process inside the framework structure.
[0061] Specifically, the service instruction may be any instruction that instructs the target Bluetooth chip to perform a service operation. For example, the service instruction may include a service instruction associated with a Bluetooth adapter, a service instruction associated with advanced audio, a stereo specification, an instruction associated with receiving audio, or an instruction associated with communication, but is not limited thereto.
[0062] Specifically, the target Bluetooth chip is the Bluetooth chip corresponding to the service instruction. When the Bluetooth module receives multiple service instructions for different Bluetooth chips, each service instruction corresponds to a target Bluetooth chip.
[0063] Specifically, the identification information is used to indicate the target Bluetooth chip corresponding to the service instruction. For example, the identification information may include the process number of the target program process and / or the identity document (ID) of the target Bluetooth chip corresponding to the service instruction, but is not limited thereto.
[0064] S120: Based on the identification information of the target Bluetooth chip, call the framework interface class associated with the service instruction to obtain an interface instance corresponding to the target Bluetooth chip.
[0065] In the disclosed embodiment, the framework interface layer of the Bluetooth module may call the framework interface class associated with the service instruction based on the identification information of the target Bluetooth chip to obtain the interface instance corresponding to the target Bluetooth chip.
[0066] Specifically, the framework interface layer includes multiple framework interfaces, which may exist in the form of classes, and the framework interface class is the class corresponding to the framework interface. The framework interface class may include, for example, BluetoothAdapter.java (a class associated with a Bluetooth adapter), BluetoothA2dp.java / BluetoothA2dpSink.java (a class associated with advanced audio and stereo specifications), or BluetoothHeadset.java / BluetoothHeadsetClient.java (a class associated with voice communication), etc., but is not limited thereto.
[0067] Specifically, the interface instance is an instance corresponding to the framework interface class.
[0068] Compared to the native framework interface layer, the framework interface layer in the embodiment of the present disclosure extends the native framework interface, mainly by modifying the native call function of the calling interface class. Specifically, in the native framework interface layer, since the native Bluetooth framework only supports one Bluetooth chip, the native call function does not need to know the identification information corresponding to the Bluetooth chip, and the interface instance obtained by the native call function calling the framework interface class associated with the service instruction must correspond to the native Bluetooth chip. However, in the embodiment of the present disclosure, the expanded Bluetooth framework can support the operation of multiple Bluetooth chips, so it is necessary to modify the native call function. In order to obtain the interface instance corresponding to the target Bluetooth chip, the modified call function needs to know the identification information corresponding to the Bluetooth chip, and based on the identification information of the target Bluetooth chip, call the framework interface class associated with the service instruction to obtain the interface instance corresponding to the target Bluetooth chip. It can be understood that by expanding the native framework interface to obtain the framework interface layer in the embodiment of the present disclosure, it can be compatible with the design of the original framework interface, reducing the workload and development cost of software development.
[0069] For example, if the framework interface layer receives service instruction 1 and service instruction 2, service instruction 1 carries the identification information of Bluetooth chip 1, that is, Bluetooth chip 1 is the target Bluetooth chip corresponding to service instruction 1, and service instruction 2 carries the identification information of Bluetooth chip 2, that is, Bluetooth chip 2 is the target Bluetooth chip corresponding to service instruction 2, then the framework interface layer can call function 1 based on the identification information of Bluetooth chip 1 to call framework interface class 1 associated with service instruction 1, and obtain interface instance 1 corresponding to Bluetooth chip 1, so that subsequent interface instance 1 calls Bluetooth service 1 corresponding to Bluetooth chip 1; the framework interface layer can also call function 2 based on the identification information of Bluetooth chip 2 to call framework interface class 2 associated with service instruction 2, and obtain interface instance 2 corresponding to Bluetooth chip 2, so that subsequent interface instance 2 calls Bluetooth service 2 corresponding to Bluetooth chip 2. It should be noted that the same is true when the framework interface layer receives service instructions for more different Bluetooth chips, which will not be repeated here, and it can be understood based on the framework interface layer receiving two service instructions for more different Bluetooth chips.
[0070] S130: Based on the interface instance corresponding to the target Bluetooth chip, call the Bluetooth service corresponding to the target Bluetooth chip.
[0071] In the embodiment of the present disclosure, the interface instance corresponding to the target Bluetooth chip can call the Bluetooth service corresponding to the target Bluetooth chip in the Bluetooth service layer.
[0072] Compared with the native Bluetooth service layer, the Bluetooth service layer in the embodiment of the present disclosure extends the native Bluetooth service. Specifically, on the basis of the native Bluetooth service, multiple extended Bluetooth services are added to implement the upper layer service of the extended Bluetooth chip, that is, the Bluetooth service layer in the embodiment of the present disclosure includes multiple Bluetooth services, each of which has the same structure and logic, but different names, and they implement upper layer services for different Bluetooth chips. For example, the Bluetooth service Bluetooth apk corresponding to the native Bluetooth chip can be copied multiple times to obtain multiple extended Bluetooth services Sub1Bluetooth apk, Sub2Bluetooth apk...SubNBluetoothapk.
[0073] Specifically, the Bluetooth service layer includes multiple Bluetooth services, each Bluetooth service includes multiple service components, and different service components correspond to different framework interface classes (i.e., framework interfaces). For example, the service component associated with the Bluetooth adapter corresponds to BluetoothAdapter.java, the service component associated with the advanced audio and stereo specifications corresponds to BluetoothA2dp.java / BluetoothA2dpSink.java, and the service component associated with voice communication corresponds to BluetoothHeadset.java / BluetoothHeadsetClient.java, but is not limited to this. In this way, when the interface instance calls the Bluetooth service corresponding to the target Bluetooth chip, it specifically calls the service component corresponding to the framework interface class associated with the service instruction. It can be understood that by expanding the native Bluetooth service to obtain the Bluetooth service layer in the embodiment of the present disclosure, it can be compatible with the design of the original Bluetooth service, reducing the workload and development cost of software development.
[0074] For example, if Bluetooth chip 1 is the target Bluetooth chip corresponding to service instruction 1, Bluetooth service 1 is the Bluetooth service corresponding to Bluetooth chip 1, and service instruction 1 is associated with framework interface class 1 (i.e., framework interface 1), framework interface class 1 corresponds to service component 1, Bluetooth chip 2 is the target Bluetooth chip corresponding to service instruction 2, Bluetooth service 2 is the Bluetooth service corresponding to Bluetooth chip 2, and service instruction 2 is associated with framework interface class 2 (i.e., framework interface 2), framework interface class 2 corresponds to service component 2, then interface instance 1 can call service component 1 in Bluetooth service 1 corresponding to Bluetooth chip 1, and interface instance 2 can call service component 2 in Bluetooth service 2 corresponding to Bluetooth chip 2.
[0075] S140: Based on the Bluetooth service corresponding to the target Bluetooth chip, load the protocol stack dynamic library corresponding to the target Bluetooth chip to drive the target Bluetooth chip to execute the service operation corresponding to the service instruction.
[0076] In the disclosed embodiment, the Bluetooth service corresponding to the target Bluetooth chip can load the protocol stack dynamic library corresponding to the target Bluetooth chip, so that the protocol stack dynamic library corresponding to the target Bluetooth chip drives the target Bluetooth chip to execute the service operation corresponding to the service instruction.
[0077] Specifically, the protocol stack dynamic library includes multiple protocols that can drive the Bluetooth chip.
[0078] Compared with the native protocol stack layer, the protocol stack layer in the embodiment of the present disclosure expands the native protocol stack dynamic library. Specifically, the protocol stack layer adds a compilation script to compile corresponding protocol stack dynamic libraries for different Bluetooth chips. For example, the libbluetooth-fc.so dynamic library is compiled for Bluetooth chip 1, and the libbluetooth-fr.so dynamic library is compiled for Bluetooth chip 2. Different protocol stack dynamic libraries are connected to different Bluetooth chips through different serial ports (such as universal asynchronous receiver and transmitter serial ports).
[0079] In some embodiments, a corresponding protocol stack dynamic library may be configured in advance for each Bluetooth chip at the protocol stack layer. Optionally, before S140, the method further includes: for each Bluetooth chip, based on its corresponding compilation information, compiling the protocol stack component to obtain its corresponding protocol stack dynamic library. In this way, the Bluetooth service corresponding to the target Bluetooth chip can quickly load the protocol stack dynamic library corresponding to the target Bluetooth chip, thereby improving the speed at which the Bluetooth module responds to service instructions.
[0080] In other embodiments, when the protocol stack dynamic library corresponding to the target Bluetooth chip needs to be loaded, the protocol stack dynamic library corresponding to the target Bluetooth chip can be configured. Optionally, before S140, the method further includes: compiling the protocol stack component based on the compilation information corresponding to the target Bluetooth chip to obtain the protocol stack dynamic library corresponding to the target Bluetooth chip. In this way, the configured protocol stack dynamic library will inevitably be loaded and will not be idle, which can improve the utilization rate of each protocol stack dynamic library in the protocol stack layer.
[0081] The multi-Bluetooth driving method of the embodiment of the present disclosure can receive the service instruction sent by the target program process; wherein the service instruction carries identification information, and the identification information is used to identify the target Bluetooth chip corresponding to the service instruction from multiple Bluetooth chips; based on the identification information of the target Bluetooth chip, the framework interface class associated with the service instruction is called to obtain the interface instance corresponding to the target Bluetooth chip; based on the interface instance corresponding to the target Bluetooth chip, the Bluetooth service corresponding to the target Bluetooth chip is called; based on the Bluetooth service corresponding to the target Bluetooth chip, the protocol stack dynamic library corresponding to the target Bluetooth chip is loaded to drive the target Bluetooth chip to perform the service operation corresponding to the service instruction. Since the native framework interface, native Bluetooth service and native protocol stack are expanded in the original Bluetooth framework design, the expanded Bluetooth framework can meet the simultaneous operation of multiple Bluetooths. Therefore, based on the expanded Bluetooth framework, for each target Bluetooth chip, the embodiment of the present disclosure can call the Bluetooth service corresponding to the target Bluetooth chip based on the identification information corresponding to the target Bluetooth chip, and then load the protocol stack dynamic library corresponding to the target Bluetooth chip to drive the target Bluetooth chip, so that the user's demand for simultaneous driving of multiple Bluetooths can be met and the user experience can be improved.
[0082] In another embodiment of the present disclosure, S120 may include: S1211. Based on the identification information of the target Bluetooth chip, calling the first calling function corresponding to the framework interface class associated with the service instruction; S1212. Based on the first calling function, calling the framework interface class associated with the service instruction to obtain the interface instance corresponding to the target Bluetooth chip.
[0083] In the disclosed embodiment, the framework interface layer of the Bluetooth module can call the first calling function corresponding to the framework interface class associated with the service instruction based on the identification information of the target Bluetooth chip. The framework interface class associated with the service instruction can be called through the first calling function to obtain the interface instance corresponding to the target Bluetooth chip.
[0084] Specifically, the first calling function is a function that can obtain the identification information of the target Bluetooth chip and can call the framework interface class associated with the service instruction. It can be understood that in the native framework interface layer, different framework interface classes correspond to different native calling functions. The extended framework interface layer in the embodiment of the present disclosure has modified the native calling function relative to the native framework interface layer. The modified calling function includes the first calling function, that is, in the extended framework interface layer, different framework interface classes correspond to different first calling functions, and the first calling function can call its corresponding native calling function.
[0085] In some embodiments, in the native framework interface layer, the native calling function corresponding to the framework interface class is an interface function, then in the extended framework interface layer, the first calling function corresponding to the framework interface class may also be an interface function.
[0086] For example, for the framework interface class BluetoothAdapter.java, in the native framework interface layer, the framework interface class BluetoothAdapter.java can obtain the BluetoothAdapter instance through the native interface function getDefaultAdapter(), and in the extended framework interface layer, the framework interface class BluetoothAdapter.java can be called by the interface function getAdapterByID(int ID) (i.e., the first calling function) to obtain the BluetoothAdapter instance corresponding to the target Bluetooth chip.
[0087] In other embodiments, at the native framework interface layer, the native call function corresponding to the framework interface class is a constructor (i.e., a native constructor), then at the extended framework interface layer, the first call function corresponding to the framework interface class may also be a constructor. At this time, the first call function may include a first constructor and a native constructor, then S1212 may include: calling the native constructor based on the first constructor, and calling the framework interface class associated with the service instruction based on the native constructor corresponding to the first constructor.
[0088] For example, for the framework interface class BluetoothA2dp.java, in the native framework interface layer, the framework interface class BluetoothA2dp.java can be called by the native constructor BluetoothA2dp(Context context,ServiceListener listener), and in the extended framework interface layer, the framework interface class BluetoothA2dp.java can be called by the native constructor BluetoothA2dp(Context context,ServiceListener listener), and the native constructor BluetoothA2dp(Context context,ServiceListener listener) can be called by BluetoothA2dp(Context context,ServiceListenerlistener,int id) to obtain the BluetoothA2dp instance corresponding to the target Bluetooth chip. The same is true for other framework interface classes, such as BluetoothA2dpSink.java BluetoothHeadset.java, which will not be repeated here.
[0089] It is understandable that by modifying the native call functions of each framework interface class, the framework interface class can be expanded. The degree of modification in this expansion method is small, which is conducive to reducing development costs. In addition, based on the expanded framework interface layer, when multiple service instructions for different Bluetooth chips are received, for each service instruction, the first call function corresponding to the framework interface class associated with the service instruction can call the framework interface class associated with the service instruction based on the identification information of the target Bluetooth chip to obtain the interface instance of the Bluetooth chip corresponding to the service instruction. In this way, multiple Bluetooth can be supported to run simultaneously.
[0090] In another embodiment of the present disclosure, S120 may include: S1221, calling a second calling function corresponding to the framework interface class associated with the service instruction; S1222, based on the second calling function, determining the target Bluetooth chip corresponding to the identification information, and calling the framework interface class associated with the service instruction to obtain the interface instance corresponding to the target Bluetooth chip.
[0091] In the embodiment of the present disclosure, the framework interface layer of the Bluetooth module can call the second calling function corresponding to the framework interface class associated with the service instruction. Through the second calling function, the target Bluetooth chip corresponding to the identification information can be determined, and the framework interface class associated with the service instruction can be called to obtain the interface instance corresponding to the target Bluetooth chip.
[0092] Specifically, the second calling function is a function that can determine the target Bluetooth chip corresponding to the identification information and can call the framework interface class associated with the service instruction. It can be understood that in the native framework interface layer, different framework interface classes correspond to different native calling functions. The extended framework interface layer in the embodiment of the present disclosure has modified the native calling function relative to the native framework interface layer. The modified calling function includes the second calling function, that is, in the extended framework interface layer, different framework interface classes correspond to different second calling functions. The second calling function adds the function of determining the target Bluetooth chip according to the identification information on the basis of the native calling function.
[0093] Specifically, when the target program process is an application process, the service instruction may carry the process number of the target program process. The second calling function may pre-store the association relationship between the ID of the Bluetooth chip and the process number of the program process, so that the second calling function may determine the ID of the target Bluetooth chip corresponding to the service instruction based on the process number of the target program process, and then the second calling function may call the framework interface class associated with the service instruction to obtain the interface instance corresponding to the target Bluetooth chip.
[0094] It can be understood that by adding a function that can determine the target Bluetooth chip based on the identification information on the basis of the native call function, the second call function is obtained, so that the modification degree of the native call function is small, which is conducive to reducing the development cost. In addition, based on the expanded framework interface layer, when multiple service instructions for different Bluetooth chips are received, for each service instruction, the second call function corresponding to the framework interface class associated with the service instruction can determine the target Bluetooth chip corresponding to the identification information carried by the service instruction, and call the framework interface class associated with the service instruction to obtain the interface instance of the Bluetooth chip corresponding to the service instruction. In this way, multiple Bluetooth can be supported to run simultaneously.
[0095] In another embodiment of the present disclosure, before S110, the method also includes: starting a Bluetooth management service process; receiving an enable instruction sent by a target program process; wherein the enable instruction carries identification information; and based on the identification information of the target Bluetooth chip, starting the Bluetooth service corresponding to the target Bluetooth chip through the Bluetooth management service process.
[0096] In the embodiment of the present disclosure, when the operating system loaded on the terminal where the Bluetooth module is located is started, a Bluetooth management service process can be started. The Bluetooth management service process includes multiple Bluetooth management service threads. The Bluetooth management service thread is used to manage the switch and service status of the corresponding Bluetooth chip. Specifically, when the framework interface layer of the Bluetooth module receives an enable instruction, the Bluetooth management service thread corresponding to the target Bluetooth chip that the enable instruction wants to turn on will start the Bluetooth service corresponding to the target Bluetooth chip, so that the Bluetooth service corresponding to the target Bluetooth chip can communicate directly with the framework interface layer later. In this way, the framework interface layer calls the framework interface class associated with the service instruction based on the identification information of the target Bluetooth chip. After obtaining the interface instance corresponding to the target Bluetooth chip, the interface instance corresponding to the target Bluetooth chip can directly call the Bluetooth service corresponding to the target Bluetooth chip.
[0097] Specifically, the activation instruction is an instruction that can activate the Bluetooth chip and start the Bluetooth service corresponding to the Bluetooth chip.
[0098] Specifically, the Bluetooth management service process is a process corresponding to when a Bluetooth management service layer component in the Bluetooth management service layer is running.
[0099] Compared to the native Bluetooth management service layer, the Bluetooth management service layer in the disclosed embodiment expands the native Bluetooth management service component. Specifically, when the Bluetooth management service component corresponding to the Bluetooth management service layer in the disclosed embodiment is running, the Bluetooth management service process includes multiple Bluetooth management service threads, and different Bluetooth management service threads manage the switches and service states of different Bluetooth chips. For example, the Bluetooth module includes Bluetooth chip 1, Bluetooth chip 2..., Bluetooth chip N. Then, when the Bluetooth management service component corresponding to the Bluetooth management service layer in the disclosed embodiment is running, the Bluetooth management service process includes N Bluetooth management service threads, which respectively manage the switches and service states of the N Bluetooth chips.
[0100] Specifically, the native Bluetooth management service component BluetoothManagerService.java includes IBluetoothManager.aidl and other functional components, and multiple interfaces are defined in IBluetoothManager.aidl, that is, each framework interface class (i.e., framework interface) in the framework interface layer is implemented in IBluetoothManager.aidl. The specific implementation method for expanding the native Bluetooth management service component can be as follows: encapsulate the other functional components in BluetoothManagerService.java except IBluetoothManager.aidl as a Bluetooth management service class, and add a parameter A to the parameters of each interface defined by IBluetoothManager.aidl, such as an int type parameter int A, A represents the identification information of the Bluetooth chip to be operated (i.e., the target Bluetooth chip), so that the identification information in the service instruction can be passed to the framework interface layer. Correspondingly, starting the Bluetooth management service process includes: calling the Bluetooth management service class to obtain multiple Bluetooth management service instances; wherein the multiple Bluetooth management service instances include the Bluetooth management service instance corresponding to the target Bluetooth chip.
[0101] Specifically, when the Bluetooth management service component is running, the Bluetooth management service class can be called to obtain multiple Bluetooth management service instances, and the Bluetooth management service instances correspond to the management service processes.
[0102] It can be understood that by adding a parameter A to the parameters of each interface defined by IBluetoothManager.aidl, and encapsulating the functional components in BluetoothManagerService.java except IBluetoothManager.aidl as private classes, the modification of the Bluetooth management service component can be reduced, and the corresponding Bluetooth management service process when the Bluetooth management service component is running can include multiple Bluetooth management service threads, thereby supporting multiple Bluetooths to run simultaneously.
[0103] Optionally, calling a Bluetooth management service class to obtain multiple Bluetooth management service instances includes: calling a Bluetooth management service class to obtain a Bluetooth management service array; wherein the Bluetooth management service array includes multiple Bluetooth management service instances.
[0104] Specifically, the Bluetooth management service array may be a one-dimensional array, each element in the array corresponds to a Bluetooth management service instance, and the Bluetooth management service instance is an instance corresponding to the calling Bluetooth management service class.
[0105] Specifically, when BluetoothManagerService.java is run, a Bluetooth ManagerServiceAsID type array (i.e., Bluetooth management service array) can be initialized. For example, the length of the Bluetooth management service array is the number of supported Bluetooth chips, and the subscripts of the elements in the Bluetooth management service array (i.e., Bluetooth management service instances) correspond to the IDs of the Bluetooth chips.
[0106] It can be understood that by setting a Bluetooth management service array, it is convenient to manage multiple Bluetooth management service instances, and when the subscript of the Bluetooth management service instance is the same as the ID of the Bluetooth chip corresponding to the corresponding Bluetooth management service instance, it is convenient to quickly determine the correspondence between each Bluetooth management service instance and each Bluetooth chip.
[0107] Figure 3 A schematic structural diagram of a multi-Bluetooth driver device provided in an embodiment of the present disclosure is shown.
[0108] In some embodiments of the present disclosure, Figure 3 The multi-Bluetooth driving device shown can be applied to a Bluetooth module including multiple Bluetooth chips, such as a car-mounted Bluetooth module, and is not specifically limited thereto.
[0109] like Figure 3 As shown, the multi-Bluetooth driving device 300 may include:
[0110] The first receiving module 310 is used to receive a service instruction sent by a target program process; wherein the service instruction carries identification information, and the identification information is used to identify a target Bluetooth chip corresponding to the service instruction from multiple Bluetooth chips;
[0111] The first calling module 320 is used to call the framework interface class associated with the service instruction based on the identification information of the target Bluetooth chip to obtain the interface instance corresponding to the target Bluetooth chip;
[0112] The second calling module 330 is used to call the Bluetooth service corresponding to the target Bluetooth chip based on the interface instance corresponding to the target Bluetooth chip;
[0113] The first loading module 340 is used to load the protocol stack dynamic library corresponding to the target Bluetooth chip based on the Bluetooth service corresponding to the target Bluetooth chip, so as to drive the target Bluetooth chip to execute the service operation corresponding to the service instruction.
[0114] The multi-Bluetooth driver device of the embodiment of the present disclosure can receive the service instruction sent by the target program process; wherein the service instruction carries identification information, and the identification information is used to identify the target Bluetooth chip corresponding to the service instruction from multiple Bluetooth chips; based on the identification information of the target Bluetooth chip, the framework interface class associated with the service instruction is called to obtain the interface instance corresponding to the target Bluetooth chip; based on the interface instance corresponding to the target Bluetooth chip, the Bluetooth service corresponding to the target Bluetooth chip is called; based on the Bluetooth service corresponding to the target Bluetooth chip, the protocol stack dynamic library corresponding to the target Bluetooth chip is loaded to drive the target Bluetooth chip to perform the service operation corresponding to the service instruction. Since the native framework interface, native Bluetooth service and native protocol stack are expanded in the original Bluetooth framework design, the expanded Bluetooth framework can meet the simultaneous operation of multiple Bluetooths. Therefore, based on the expanded Bluetooth framework, for each target Bluetooth chip, the embodiment of the present disclosure can call the Bluetooth service corresponding to the target Bluetooth chip based on the identification information corresponding to the target Bluetooth chip, and then load the protocol stack dynamic library corresponding to the target Bluetooth chip to drive the target Bluetooth chip, so that the user's demand for simultaneous driving of multiple Bluetooths can be met and the user experience can be improved.
[0115] In another embodiment of the present disclosure, the first calling module 320 may include:
[0116] A first calling submodule, used for calling a first calling function corresponding to the framework interface class associated with the service instruction based on the identification information of the target Bluetooth chip;
[0117] The second calling submodule is used to call the framework interface class associated with the service instruction based on the first calling function to obtain the interface instance corresponding to the target Bluetooth chip.
[0118] In yet another embodiment of the present disclosure, the first calling module 320 may include:
[0119] A third calling submodule is used to call a second calling function corresponding to the framework interface class associated with the service instruction;
[0120] The fourth calling submodule is used to determine the target Bluetooth chip corresponding to the identification information based on the second calling function, and call the framework interface class associated with the service instruction to obtain the interface instance corresponding to the target Bluetooth chip.
[0121] In another embodiment of the present disclosure, the device further comprises:
[0122] The first compiling module is used to compile the protocol stack component for each Bluetooth chip based on its corresponding compilation information to obtain its corresponding protocol stack dynamic library before calling the protocol stack dynamic library corresponding to the target Bluetooth chip based on the Bluetooth service corresponding to the target Bluetooth chip.
[0123] In another embodiment of the present disclosure, the device further comprises:
[0124] A first starting module, used for starting a Bluetooth management service process before receiving a service instruction sent by a target program process;
[0125] The first receiving module 310 is used to receive an opening instruction sent by a target program process; wherein the opening instruction carries identification information;
[0126] The second starting module is used to start the Bluetooth service corresponding to the target Bluetooth chip through the Bluetooth management service process based on the identification information of the target Bluetooth chip.
[0127] In another embodiment of the present disclosure, the first startup module includes: a first startup submodule, used to call the Bluetooth management service class to obtain multiple Bluetooth management service instances; wherein the multiple Bluetooth management service instances include a Bluetooth management service instance corresponding to the target Bluetooth chip.
[0128] In another embodiment of the present disclosure, the first initiator module is specifically used to call the Bluetooth management service class to obtain a Bluetooth management service array; wherein the Bluetooth management service array includes multiple Bluetooth management service instances.
[0129] It should be noted that Figure 3 The multi-Bluetooth driving device 300 shown can execute each step in the above method embodiment and realize each process and effect in the above method embodiment, which will not be described in detail here.
[0130] Figure 4 A schematic structural diagram of an electronic device provided by an embodiment of the present disclosure is shown.
[0131] like Figure 4 As shown, the electronic device may include a controller 401 and a memory 402 storing computer program instructions.
[0132] Specifically, the controller 401 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0133] The memory 402 may include a large capacity memory for information or instructions. By way of example and not limitation, the memory 402 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a tape, or a universal serial bus (USB) drive or a combination of two or more of these. Where appropriate, the memory 402 may include a removable or non-removable (or fixed) medium. Where appropriate, the memory 402 may be inside or outside the integrated gateway device. In a particular embodiment, the memory 402 is a non-volatile solid-state memory. In a particular embodiment, the memory 402 includes a read-only memory (ROM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (Electrically Erasable Programmable ROM, EEPROM), an electrically rewritable ROM (EAROM) or a flash memory, or a combination of two or more of these.
[0134] The controller 401 reads and executes the computer program instructions stored in the memory 402 to perform the steps of the multi-Bluetooth driving method provided in the embodiment of the present disclosure.
[0135] In one example, the electronic device may further include a transceiver 403 and a bus 404. Figure 4 As shown, the controller 401, the memory 402 and the transceiver 403 are connected via a bus 404 and communicate with each other.
[0136] The bus 404 includes hardware, software, or both. For example, but not limitation, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industrial Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a Memory bus, a MicroChannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses or a combination of two or more of these. Where appropriate, the bus 404 may include one or more buses. Although embodiments of the present application describe and illustrate a particular bus, the present application contemplates any suitable bus or interconnect.
[0137] The embodiment of the present disclosure further provides a computer-readable storage medium, which may store a computer program. When the computer program is executed by a processor, the processor implements the multi-Bluetooth driving method provided by the embodiment of the present disclosure.
[0138] The above-mentioned storage medium may, for example, include a memory 402 of computer program instructions, and the above-mentioned instructions may be executed by a processor 401 of an electronic device to complete the multi-Bluetooth driving method provided in the embodiment of the present disclosure. Optionally, the storage medium may be a non-temporary computer-readable storage medium, for example, the non-temporary computer-readable storage medium may be a ROM, a random access memory (Random Access Memory, RAM), a compact disc read-only memory (Compact DiscROM, CD-ROM), a magnetic tape, a floppy disk, and an optical data storage device, etc.
[0139] The present disclosure also provides a vehicle, including at least one of the following:
[0140] The multi-Bluetooth driver device described in the above embodiment;
[0141] The electronic device described in the above embodiment;
[0142] The computer-readable storage medium described in the above embodiment.
[0143] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprising" is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0144] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A multi-Bluetooth driver method, characterized in that: include: Receive a service instruction sent by a target program process; wherein the service instruction carries identification information, and the identification information is used to identify a target Bluetooth chip corresponding to the service instruction from a plurality of Bluetooth chips, and the identification information includes a process number of the target program process and / or an identity number of the target Bluetooth chip; Based on the identification information of the target Bluetooth chip, calling the framework interface class associated with the service instruction to obtain an interface instance corresponding to the target Bluetooth chip; Based on the interface instance corresponding to the target Bluetooth chip, calling the Bluetooth service corresponding to the target Bluetooth chip; Based on the Bluetooth service corresponding to the target Bluetooth chip, a protocol stack dynamic library corresponding to the target Bluetooth chip is loaded to drive the target Bluetooth chip to execute a service operation corresponding to the service instruction.
2. The method according to claim 1, characterized in that The step of calling the framework interface class associated with the service instruction based on the identification information of the target Bluetooth chip to obtain an interface instance corresponding to the target Bluetooth chip includes: Based on the identification information of the target Bluetooth chip, calling a first calling function corresponding to the framework interface class associated with the service instruction; Based on the first calling function, the framework interface class associated with the service instruction is called to obtain an interface instance corresponding to the target Bluetooth chip.
3. The method according to claim 1, characterized in that The step of calling the framework interface class associated with the service instruction based on the identification information of the target Bluetooth chip to obtain an interface instance corresponding to the target Bluetooth chip includes: Calling a second calling function corresponding to the framework interface class associated with the service instruction; Based on the second calling function, the target Bluetooth chip corresponding to the identification information is determined, and the framework interface class associated with the service instruction is called to obtain an interface instance corresponding to the target Bluetooth chip.
4. The method according to claim 1, characterized in that: Before calling the protocol stack dynamic library corresponding to the target Bluetooth chip based on the Bluetooth service corresponding to the target Bluetooth chip, the method further includes: For each Bluetooth chip, based on its corresponding compilation information, the protocol stack component is compiled to obtain its corresponding protocol stack dynamic library.
5. The method according to claim 1, characterized in that: Before receiving the service instruction sent by the target program process, the method further includes: Start the Bluetooth management service process; Receiving a start instruction sent by the target program process; wherein the start instruction carries the identification information; Based on the identification information of the target Bluetooth chip, the Bluetooth service corresponding to the target Bluetooth chip is started through the Bluetooth management service process.
6. The method according to claim 5, characterized in that The process of starting the Bluetooth management service includes: The Bluetooth management service class is called to obtain a plurality of Bluetooth management service instances; wherein the plurality of Bluetooth management service instances include a Bluetooth management service instance corresponding to the target Bluetooth chip.
7. The method according to claim 6, characterized in that The calling of the Bluetooth management service class obtains multiple Bluetooth management service instances, including: The Bluetooth management service class is called to obtain a Bluetooth management service array; wherein the Bluetooth management service array includes the multiple Bluetooth management service instances.
8. A multi-Bluetooth driver, characterized in that: include: A first receiving module is used to receive a service instruction sent by a target program process; wherein the service instruction carries identification information, and the identification information is used to identify a target Bluetooth chip corresponding to the service instruction from a plurality of Bluetooth chips, and the identification information includes a process number of the target program process and / or an identity number of the target Bluetooth chip; A first calling module is used to call the framework interface class associated with the service instruction based on the identification information of the target Bluetooth chip to obtain an interface instance corresponding to the target Bluetooth chip; A second calling module, used to call the Bluetooth service corresponding to the target Bluetooth chip based on the interface instance corresponding to the target Bluetooth chip; The first loading module is used to load the protocol stack dynamic library corresponding to the target Bluetooth chip based on the Bluetooth service corresponding to the target Bluetooth chip, so as to drive the target Bluetooth chip to execute the service operation corresponding to the service instruction.
9. An electronic device, characterized in that: include: processor; A memory for storing executable instructions; The processor is used to read the executable instructions from the memory and execute the executable instructions to implement the multi-Bluetooth driving method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program. When the computer program is executed by a processor, the processor implements the multi-Bluetooth driving method according to any one of claims 1 to 7.
11. A vehicle, comprising a plurality of Bluetooth modules, characterized in that: The Bluetooth module includes at least one of the following: The multi-Bluetooth driver device as described in claim 8 above; The electronic device as claimed in claim 9; The computer readable storage medium of claim 10.
Citation Information
Patent Citations
Dynamic management method for multiple Bluetooth chips on Android intelligent equipment
CN109451472A
Bluetooth device capable of simultaneously connecting to multiple terminals
CN110199535A
Multi-Bluetooth interaction method and system for Android system
CN113543097A