Device connection switching method, device, electronic device and computer-readable storage medium
When receiving a connection request, the Bluetooth device determines whether the device is the recently disconnected device, which solves the problem of connection interruption caused by connection grabbing, optimizes the user experience and improves data security.
Patent Information
- Application Number
- CN202111448859.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-30
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2041-11-30
AI Technical Summary
The connection-grabbing method of existing Bluetooth devices leads to normal connection interruption and lacks data security, especially when terminal devices frequently switch between them.
When the Bluetooth device receives the connection request, it determines whether the requesting device is the last disconnected device. If so, it does not respond to the connection request and determines the device connection time and identification, and performs connection switching under the appropriate time difference and legality judgment.
It avoids frequent connection interruptions, optimizes user experience, and improves data security and rationality of connection processes.
Smart Images

Figure CN114125803B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a device connection switching method, apparatus, electronic device, and computer-readable storage medium. Background Art
[0002] As people's lives become more enriched, users own more and more electronic devices, and Bluetooth device technology is also rapidly advancing. In real life, the same Bluetooth device may switch to connect to different terminal devices. In order to provide users with a more convenient switching experience, Bluetooth devices often need to support preemptive connection mode.
[0003] In the prior art, there is a method for reconnecting Bluetooth devices without any restrictions, that is, when a Bluetooth device is connected to terminal device A, after receiving a connection request from terminal device B, the connection with terminal device A is interrupted to connect to terminal device B; in addition, there is also a situation where a connected device is passively reconnected multiple times after being disconnected.
[0004] However, the connection preemption methods of the above-mentioned Bluetooth devices all have the problem of unreasonable preemption, which leads to the problem of disconnection of normally connected Bluetooth devices. Summary of the Invention
[0005] The embodiments of the present application provide a device connection switching method, apparatus, electronic device and computer-readable storage medium, which can solve the problem of unreasonable terminal preemption in the prior art and also improve the data security of terminals and Bluetooth devices.
[0006] In a first aspect, a device connection switching method is provided, the method comprising:
[0007] When a Bluetooth connection is established with the first terminal device, receiving a connection request sent by the second terminal device;
[0008] Determining whether the second terminal device is the terminal device that was most recently disconnected from the Bluetooth device;
[0009] If the second terminal device is the terminal device that was most recently disconnected from the Bluetooth device, it does not respond to the connection request.
[0010] In a second aspect, a Bluetooth device connection grabbing device is provided, the device comprising:
[0011] A receiving module, configured to receive a connection request sent by a second terminal device when a Bluetooth connection is established with the first terminal device;
[0012] a determination module, configured to determine whether the second terminal device is the terminal device that was most recently disconnected from the Bluetooth device;
[0013] The execution module is configured to not respond to the connection request if the second terminal device is the terminal device that was most recently disconnected from the Bluetooth device.
[0014] In a third aspect, an electronic device is provided, comprising a memory and a processor, wherein the memory stores a computer program; when the computer program is executed by the processor, the processor executes the device connection switching method as described in the first aspect.
[0015] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the device connection switching method described in the first aspect is implemented.
[0016] The above-mentioned device connection switching method, apparatus, electronic device and computer-readable storage medium, when establishing a Bluetooth connection with a first terminal device, receives a connection request sent by a second terminal device, determines whether the second terminal device is the terminal device that was most recently disconnected from the Bluetooth device, and does not respond to the connection request if the second terminal device is the terminal device that was most recently disconnected from the Bluetooth device. In this method, after establishing a Bluetooth connection with the first terminal device, the Bluetooth device can, upon receiving a connection request from the second terminal device, determine whether the second terminal device is the device that was most recently disconnected from the Bluetooth device, and does not respond to the connection request from the second terminal device after the second terminal device is the device that was most recently disconnected from the Bluetooth device. This avoids the problem of the second client frequently re-establishing a connection with the Bluetooth device after being disconnected from the Bluetooth device, thereby affecting the service interaction of the currently connected first terminal device, thereby ensuring the service interaction between the Bluetooth device and the first terminal device, optimizing the process of connection preemption by other clients, and further optimizing the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0018] Figure 1 A diagram illustrating an application environment of a device connection switching method according to an embodiment;
[0019] Figure 2 is a flow chart of a device connection switching method in one embodiment;
[0020] Figure 3 is a flow chart of a device connection switching method in another embodiment;
[0021] Figure 4 is a flow chart of a device connection switching method in another embodiment;
[0022] Figure 5 is a flow chart of a device connection switching method in another embodiment;
[0023] Figure 6 is a flow chart of a device connection switching method in another embodiment;
[0024] Figure 7 is a flow chart of a device connection switching method in another embodiment;
[0025] Figure 8 A structural block diagram of a device connection switching apparatus in one embodiment;
[0026] Figure 9 FIG. 1 is a schematic structural diagram of an electronic device in an embodiment. DETAILED DESCRIPTION
[0027] In order to make the purpose, technical solutions and advantages of this application more clearly understood, the present application is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0028] It will be understood that the terms "first," "second," and the like used herein may be used to describe various elements, but these elements are not limited by these terms. These terms are used solely to distinguish a first element from another element. For example, a first client may be referred to as a second client, and similarly, a second client may be referred to as a first client, without departing from the scope of this application. The first client and the second client are both clients, but they are not the same client.
[0029] During the connection process between a Bluetooth device and a first terminal device, there may be a situation where the second terminal device initiates a connection request to the Bluetooth device. Generally, in the prior art, a Bluetooth device needs to have a one-to-many connection function, or needs to have a function that allows switching connections with other terminal devices in a one-to-one connection scenario. In the case where a Bluetooth device has a function that allows switching connections with other terminal devices in a one-to-one connection scenario, the Bluetooth device in the prior art either directly responds to the connection request of the second terminal device, thereby interrupting the connection with the first terminal device, affecting the business execution of the first client, and also threatening the data security of the Bluetooth device; or does not respond to the connection request of the second terminal device, and cannot achieve the effect of switching connections with other terminal devices.
[0030] At present, Bluetooth technology supports one-to-one connection between Bluetooth devices and terminal devices. Therefore, when a Bluetooth device has established a Bluetooth connection with a first terminal device, the Bluetooth device needs to support a preemptive connection function so that the Bluetooth device can receive a connection request sent by another terminal device, thereby performing corresponding operations according to the connection request. For example, in the prior art, Bluetooth devices that support the preemptive connection function are roughly divided into two categories. One type of Bluetooth device supports preemptive connection without any restrictions. That is, when a first terminal device establishes a connection with a Bluetooth device, if there is a second terminal device that initiates a connection request to the Bluetooth device, the Bluetooth device will directly respond to the connection request, disconnect the connection with the first terminal device, and establish a connection with the second terminal device, thereby realizing the preemptive connection of the second terminal device to the Bluetooth device. The other type of Bluetooth device supports preemptive connection with certain restrictions. For example, after receiving the connection request initiated by the second terminal device, the Bluetooth device sends the identifier of the second terminal device (for example, a local area network address (Media Access Control Address, MAC address), a cloud account) to the server. The server determines whether the second terminal device can perform the preemptive connection operation based on the identifier of the second terminal device, so that the Bluetooth device performs the corresponding connection switching operation according to the determination result returned by the server.
[0031] Although the above-mentioned method of unlimited support for preemptive connection or the method of legal judgment via the server can achieve the purpose of switching between different terminal devices and using Bluetooth devices, both have certain technical defects. For example, whether in the scenario of unlimited support for preemptive connection or in the scenario of legal judgment via the server, the terminal devices that have been connected to the Bluetooth device can achieve the purpose of quick reconnection. For example, when the Bluetooth device has established a connection with the second terminal device, the first terminal device that was disconnected from the Bluetooth device last time may frequently reconnect to the Bluetooth device, thereby causing the Bluetooth device to unconditionally respond to the connection request of the first client, interrupting the connection with the second terminal device, and seriously affecting the user experience of the second terminal device.
[0032] Based on this, this embodiment provides a device connection switching method to solve the problems existing in the above-mentioned prior art.
[0033] Figure 1 FIG. 1 is a schematic diagram of an application environment of a device connection switching method in an embodiment. Figure 1As shown, the application environment includes a Bluetooth device 1 and at least two terminal devices 2. Among them, the Bluetooth device can be a Bluetooth headset, a True Wireless Stereo (TWS) headset, a Bluetooth watch, a mobile phone, a tablet computer, a computer, a wearable device, a car-mounted Bluetooth device, etc.; the terminal device can be a Bluetooth watch, a wearable device, a mobile phone, a tablet computer, a computer, a server, etc. Specifically, after the Bluetooth headset establishes a Bluetooth connection with the headset, it can turn on the connection-preempting function of the Bluetooth headset and receive the connection establishment request sent by the Bluetooth watch, thereby realizing the switching connection of the Bluetooth device to the mobile phone and the Bluetooth watch according to any one of the device connection switching methods provided in the following embodiments.
[0034] Figure 2 FIG. 1 is a flow chart of a device connection switching method in one embodiment. The device connection switching method in this embodiment is to run on Figure 1 This article describes the Bluetooth device in the following example. Figure 2 As shown, the device connection switching method includes steps 201 to 203.
[0035] Step 201: When a Bluetooth connection is established with a first terminal device, a connection request sent by a second terminal device is received.
[0036] The establishment of a Bluetooth connection between the Bluetooth device and the first terminal device refers to a state in which the Bluetooth device and the first terminal device have completed the Bluetooth asynchronous transmission logical link (Asynchronous Connection-oriented, ACL) connection, Bluetooth pairing, and Bluetooth connection process. When the Bluetooth connection is established, the first terminal device can interact with the Bluetooth device for services. For example, if the Bluetooth device is a Bluetooth headset, the first terminal device can conduct audio and video calls, audio playback, and other services through the Bluetooth headset.
[0037] When a Bluetooth device establishes a Bluetooth connection with a first terminal device, it can receive connection requests from other terminal devices. This includes situations where the Bluetooth device has a one-to-many connection feature and can directly receive connection requests from a second terminal device while connected to the first terminal device. Alternatively, for scenarios similar to Bluetooth connections, the Bluetooth device needs to enable the "allow preemptive connection" feature in order to receive connection requests from a second terminal device.
[0038] Step 202: Determine whether the second terminal device is the terminal device that was most recently disconnected from the Bluetooth device.
[0039] Among them, the most recent disconnection from the Bluetooth device refers to the terminal device that last disconnected from the Bluetooth device based on the time domain dimension. The Bluetooth device can record the time when it establishes a Bluetooth connection with each terminal device and / or the time when it disconnects the Bluetooth connection. Furthermore, the Bluetooth device can also generate a record table based on the above-mentioned record of the time when each terminal device establishes a Bluetooth connection and the time when the Bluetooth connection is disconnected. The record table includes the device identification of each terminal device and its corresponding time when the Bluetooth connection is established and the time when the Bluetooth connection is disconnected. In this way, when the Bluetooth device determines that the second terminal device is an associated device of the first terminal device, it obtains the device identification of the second terminal device, and based on the device identification of the terminal device that last disconnected the Bluetooth connection and the device identification of the second terminal device in the record table, determines whether the second terminal device is the terminal device that last disconnected from the Bluetooth device. For example, if the device identification of the terminal device that last disconnected the Bluetooth connection is consistent with the device identification of the second terminal device, then the second terminal device is determined to be the terminal device that last disconnected from the Bluetooth device; if the device identification of the terminal device that last disconnected the Bluetooth connection is inconsistent with the device identification of the second terminal device, then it is determined that the second terminal device is not the terminal device that last disconnected from the Bluetooth device. For example, the device identification of the terminal device may be a MAC address of the terminal device, a device serial number of the terminal device, a factory serial number of the terminal device, etc., which is not limited in this embodiment.
[0040] Step 203: If the second terminal device is the terminal device that was most recently disconnected from the Bluetooth device, then the second terminal device does not respond to the connection request.
[0041] In this embodiment, if the Bluetooth device determines that the second terminal device is the terminal device that was most recently disconnected from the Bluetooth device, that is, in step 202, the Bluetooth device determines that the device identifier of the terminal device that last disconnected the Bluetooth connection is consistent with the device identifier of the second terminal device. In this case, it can be considered that the second terminal device may automatically trigger an operation to initiate a connection with the Bluetooth device in a short period of time, that is, the connection request initiated by the second terminal device is not an actual need. In this case, in order to ensure that the business interaction between the Bluetooth device and the first terminal device is not interrupted, the Bluetooth device can choose not to respond to the connection request of the second client. The non-response to the connection request here can also include sending a response rejecting the connection to the second terminal device, or the Bluetooth device ignores the connection request and does not perform any operation. This embodiment does not limit this.
[0042] The above-mentioned standby connection switching method, when establishing a Bluetooth connection with the first terminal device, receives a connection request sent by the second terminal device, determines whether the second terminal device is the terminal device that was most recently disconnected from the Bluetooth device, and does not respond to the connection request if the second terminal device is the terminal device that was most recently disconnected from the Bluetooth device. In this method, after establishing a Bluetooth connection with the first terminal device, the Bluetooth device can, upon receiving a connection request from the second terminal device, determine whether the second terminal device is the device that was most recently disconnected from the Bluetooth device. After the second terminal device is the device that was most recently disconnected from the Bluetooth device, the device does not respond to the connection request from the second terminal device. This avoids the problem of the second client frequently re-establishing a connection with the Bluetooth device after being disconnected from the Bluetooth device, thereby affecting the service interaction of the currently connected first terminal device. This ensures the service interaction between the Bluetooth device and the first terminal device, optimizes the process of connection preemption by other clients, and further optimizes the user experience.
[0043] However, in order to further optimize the judgment of the second terminal device and ensure that the second terminal device does not frequently send connection requests to the Bluetooth device in a short period of time, in one of the optional embodiments, as Figure 3 As shown, the method further includes:
[0044] Step 301: If the second terminal device is the terminal device that was most recently disconnected from the Bluetooth device, then obtain the time difference between the moment of most recently disconnecting from the Bluetooth device and the current moment.
[0045] In this embodiment, if the Bluetooth device determines that the second terminal device is the terminal device that most recently disconnected from the Bluetooth device, to avoid the second terminal device frequently sending connection requests to the Bluetooth device within a short period of time, the Bluetooth device needs to determine whether the time difference between the second terminal device's most recent disconnection and the time of initiating a new connection request satisfies a preset condition. Optionally, the Bluetooth device can obtain the time of the most recent disconnection from the Bluetooth device based on the record table in the above embodiment, obtain the current time from the local clock module, and thereby calculate the time difference between the most recent disconnection from the Bluetooth device and the current time.
[0046] Step 302: If the time difference is greater than the time difference threshold, in response to the connection request, disconnect the Bluetooth connection with the first terminal device and establish a Bluetooth connection with the second terminal device.
[0047] In this embodiment, the time difference threshold can be 1 hour, 3 hours, 5 hours, 1 day, etc. If the time difference is greater than the time difference threshold, it means that although the second terminal device is the terminal device that disconnected the Bluetooth connection with the Bluetooth device last time, it has been a long time since the last disconnection of the Bluetooth connection. The connection request initiated by it to the Bluetooth device can be considered not to be a spontaneous request, but to be initiated due to actual conditions. In this case, the situation where the second terminal device spontaneously sends connection requests to the Bluetooth device multiple times in a short period of time is excluded. In response to the connection request, the Bluetooth connection with the first terminal device is disconnected, and a Bluetooth connection with the second terminal device is established.
[0048] Step 303: If the time difference is not greater than the time difference threshold, then the connection request is not responded to.
[0049] In this embodiment, if the time difference is not greater than the time difference threshold, the second terminal device may automatically trigger a connection, that is, the connection request sent by the second terminal device to the Bluetooth device is not due to actual needs. In this case, in order not to affect the connection between the Bluetooth device and the first terminal device, the Bluetooth device chooses not to respond to the connection request of the second terminal device. Similar to step 203, the Bluetooth device does not respond to the connection request, which may be ignoring the connection request and not performing any response operation; it may also be sending a response to reject the connection to the second terminal device. This embodiment does not limit this.
[0050] In this embodiment, after determining that the second terminal device is an associated device of the first terminal device, the Bluetooth device can also determine whether the second terminal device is a terminal device that frequently initiates connection requests in a short period of time based on parameters such as the terminal device that last disconnected from the Bluetooth device and the time of last disconnection from the Bluetooth device, thereby further ensuring that the connection of the second client is a valid connection, making connection switching more accurate, and optimizing user experience.
[0051] In another case of step 203, if the second terminal device is not the device that was most recently disconnected from the Bluetooth device, then the second terminal device is excluded as a device that frequently sends connection requests to the Bluetooth device in a short period of time. In one optional embodiment, the method further includes:
[0052] If the second terminal device is not the terminal device that was most recently disconnected from the Bluetooth device, then in response to the connection request, the Bluetooth connection with the first terminal device is disconnected, and a Bluetooth connection with the second terminal device is established.
[0053] In this embodiment, if the Bluetooth device determines that the second terminal device is not the terminal device that was most recently disconnected from the Bluetooth device, that is, the second terminal device is not the terminal device that last established a Bluetooth connection with the Bluetooth device, in this case, the situation where the second terminal device spontaneously sends connection requests to the Bluetooth device multiple times in a short period of time is excluded. In this case, the Bluetooth device responds to the connection request, disconnects the Bluetooth connection with the first terminal device, and establishes a Bluetooth connection with the second terminal device.
[0054] In this embodiment, when the Bluetooth device determines that the second terminal device is not the terminal device that was most recently disconnected from the Bluetooth device, it responds to the connection request, disconnects the Bluetooth connection with the first terminal device, and establishes a Bluetooth connection with the second terminal device, thereby avoiding the second terminal device frequently establishing connections to the Bluetooth device in a short period of time, and further optimizing the user experience.
[0055] In order to further confirm the legitimacy of the second client, Figure 4 As shown, in one of the optional embodiments, before responding to the connection request, the method further includes:
[0056] Step 401: Determine whether a second terminal device is an associated device of the first terminal device based on the first associated device information of the first terminal device.
[0057] The first associated device information includes device information of other terminal devices that the first terminal device can trust. It should be noted that the other trusted terminal devices may include terminal devices that have been connected to the first terminal device, terminal devices of the same type as the first terminal device, terminal devices belonging to the same account as the first terminal device, terminal devices in the same local area network as the first terminal device, etc.
[0058] Optionally, the first associated device information may include device information of a terminal device that has been connected to the first terminal device. For example, when the Bluetooth device is a Bluetooth device and the first terminal device is a mobile phone, the terminal device that has been connected to the first terminal device may be a smart watch, tablet computer, smart bracelet or other terminal device with a Bluetooth module that has been connected to the mobile phone within a preset historical period. Correspondingly, the device information of the client includes the device name, device type, MAC address, device serial number, factory serial number, service type, etc. The preset historical period may be the past month, the past six months, etc. In this scenario, in view of the defect in the prior art that the terminal device cannot achieve connection switching if it does not have the account login function, the first associated information provided by this embodiment can be used to determine the terminal device that has been connected to the first terminal device as a legitimate device that can be switched to a connection, thereby achieving the purpose of switching the connection of the Bluetooth device.
[0059] Optionally, the first associated device information may also include device information of a terminal device of the same type as the first terminal device. Exemplarily, the same type may be the same as the brand type of the first terminal device. For example, when the first terminal device is a brand A mobile phone, the first associated device information may include device information of other terminal devices of brand A with a Bluetooth module, such as brand A smartwatches and brand A tablets. It should be noted that the same brand type here can be considered to be the same as the factory serial number, device serial number, or a specified field in the terminal model of the first terminal device, where the specified field represents the brand type. In addition, exemplarily, the same type may also be the same as the terminal type of the first terminal device. For example, when the first terminal device is a mobile phone, the first associated device information includes device information of other terminal devices whose terminal type is a mobile phone.
[0060] Optionally, the first associated device information may also include device information of terminal devices belonging to the same account as the first terminal device. For example, if the cloud account of the first terminal device is user A, the first associated device information may include device information of other terminal devices logged in by user A, such as device information of a smartwatch logged in by user A, device information of a smart bracelet logged in by user A, device information of a tablet logged in by user A, etc. This embodiment does not limit this.
[0061] In this embodiment, the first associated device information may be information sent by the first terminal device to the Bluetooth device after establishing a Bluetooth connection with the Bluetooth device; or the first associated device information may be information sent by the first terminal device to the Bluetooth device after updating its corresponding associated information. Thus, the Bluetooth device can, based on the first associated device information, traverse and query the device identification of the second terminal device against the device information in the first associated device information. If device information matching the device identification of the second terminal device exists in the first associated device information, the second terminal device is determined to be an associated device of the first terminal device; if device information matching the device identification of the second terminal device does not exist in the first associated device information, the second terminal device is determined not to be an associated device of the first terminal device. For example, the Bluetooth device can compare the device identification field of the second terminal device with the device identification fields of all terminal devices in the first associated device information. If the device identification field of any terminal device matches the device identification field of the second terminal device, the second terminal device is determined to be an associated device of the first terminal device; if the device identification field of the second terminal device does not match the device identification fields of all terminal devices, the second terminal device is determined not to be an associated device of the first terminal device. This embodiment is not limited to this.
[0062] Step 402: If the second terminal device is an associated device of the first terminal device, the steps of disconnecting the Bluetooth connection with the first terminal device and establishing a Bluetooth connection with the second terminal device are executed in response to the connection request.
[0063] In this embodiment, after the Bluetooth device determines that the second terminal device is an associated device of the first terminal device, that is, after the Bluetooth device determines that the second terminal device is a legitimate device, it responds to the connection request initiated by the second terminal device, disconnects the Bluetooth connection with the first terminal device, and establishes a Bluetooth connection with the second terminal device. Optionally, in order to ensure the user experience of the user of the first terminal device using the Bluetooth device, the Bluetooth device may also respond to the connection request initiated by the second terminal device based on the priority of the first terminal device and the second terminal device. For example, the Bluetooth device determines that the priority of the second terminal device is lower than the priority of the first terminal device. In this case, the Bluetooth device may return a rejection response to the second terminal device. If the priority of the second terminal device is higher than the priority of the first terminal device, the Bluetooth device disconnects the Bluetooth connection with the first terminal device in response to the Bluetooth connection request of the second terminal device and establishes a Bluetooth connection with the second terminal device. The priority may be the priority of the terminal type or the priority of the service initiated by the terminal. For example, the terminal types include mobile phones, watches, headphones, computers, etc., and their corresponding priorities are mobile phones > computers > headphones > watches; the terminal types also include brands A, brand B, brand C, etc., and their corresponding priorities are brand A > brand B > brand C; the services include call services, audio playback services, etc., and their corresponding priorities are call services > audio playback services. The Bluetooth device may respond to the connection request initiated by the second terminal device based on the pre-set terminal type priority or service priority when it is determined that the priority of the second terminal device is greater than the priority of the first terminal device. This embodiment is not limited to this.
[0064] In this embodiment, the Bluetooth device can determine whether the second terminal device sending the connection request is an associated device of the first terminal device based on the first associated device information of the first terminal device with which the Bluetooth connection has been established, that is, perform a legitimacy judgment on the second terminal device sending the connection request. When it is determined that the second terminal device is an associated device of the first terminal device, that is, when it is determined that the second terminal device is a legitimate device, the Bluetooth device responds to the connection request of the second terminal device, thereby avoiding the problem of current service interruption of the server terminal caused by an illegal client terminal initiating a connection request to the Bluetooth device. Furthermore, since the second terminal device is an associated device of the first terminal device, that is, the second terminal device is the default legitimate connection device of the Bluetooth device, the data security of the Bluetooth device, the first terminal device, and the second terminal device is guaranteed to a certain extent.
[0065] After the Bluetooth device establishes a Bluetooth connection with the second terminal device, that is, after the Bluetooth device completes the handover connection of the second terminal device, in one optional embodiment, the method further includes:
[0066] After establishing a Bluetooth connection with the second terminal device, second associated device information sent by the second terminal device is received.
[0067] In this embodiment, after establishing a Bluetooth connection with a second terminal device, the Bluetooth device needs to receive second associated device information from the second terminal device. The second associated device information can be an operation triggered by the second terminal device after determining that a connection has been established with the Bluetooth device; it can also be an associated device information request sent by the Bluetooth device to the second terminal device, so that the second terminal device returns the second associated device information to the Bluetooth device in response to the request. Similar to the first associated device information in step 401, the second associated device information includes information about devices associated with the second terminal device. For example, the second associated device information includes at least one of the following: device information of terminal devices that have been connected to the second terminal device, device information of terminal devices of the same type as the second terminal device, and device information of terminal devices belonging to the same account as the second terminal device.
[0068] After the Bluetooth device receives the second associated device information, it can store the second associated device information in the storage space for the first associated device information. That is, the second associated device information is combined with the historical terminal device associated information and stored. This embodiment does not limit this.
[0069] In this embodiment, after establishing a Bluetooth connection with the second terminal device, the Bluetooth device promptly receives and stores the second associated device information sent by the second terminal device, and stores the second associated device information in a local storage space to provide data support for subsequent steps of performing associated device judgment based on the second associated device information.
[0070] However, in reality, the storage space of Bluetooth devices is limited. In this case, it also includes:
[0071] The second associated device information replaces the first associated device information stored in the Bluetooth device.
[0072] In this embodiment, the Bluetooth device can overwrite the second associated device information with the first associated device information, that is, use the second associated device information as the final local associated device information of the Bluetooth device; the Bluetooth device can also use the union of the first associated device information and the second associated device information as the final local associated device information, and reduce the storage space occupied by the Bluetooth device. This embodiment does not limit this.
[0073] In this embodiment, after establishing a Bluetooth connection with the second terminal device, the Bluetooth device promptly receives the second associated device information sent by the second terminal device to update the local associated device information, providing effective data support for the Bluetooth device to perform associated device judgment based on the associated device information.
[0074] Similar to receiving the second associated device information of the second terminal device, in one optional embodiment, the method further includes:
[0075] When a Bluetooth connection is established between the Bluetooth device and the first terminal device, first associated device information sent by the first terminal device is received.
[0076] In this embodiment, when the Bluetooth device establishes a Bluetooth connection with the first terminal device, it can receive the first associated device information of the first terminal device. The first associated device information can be an operation triggered and executed by the first terminal device after determining to establish a connection with the Bluetooth device; it can also be the Bluetooth device sending an associated device information request to the first terminal device, so that the first terminal device returns the first associated device information to the Bluetooth device in response to the request.
[0077] In this embodiment, every time the Bluetooth device establishes a Bluetooth connection with a new terminal device, the Bluetooth device needs to receive the associated device information sent by the new terminal device and promptly update the locally stored associated device information, so that the locally stored associated device information is more accurate and effective.
[0078] Since the terminal device is always in a dynamic operation state, the associated devices of the terminal device are also updated in real time. That is, after the terminal device establishes a connection with the Bluetooth device, its corresponding associated device information will still be updated. In one optional embodiment, the method further includes:
[0079] Receive and save third associated device information sent by the first terminal device, where the third associated device information indicates changes and updates of associated devices of the first terminal device.
[0080] In this embodiment, the Bluetooth device can receive third-association device information sent by the first terminal device at any time. Here, the third-association device information refers to the updated associated device information corresponding to the first terminal device determined when the associated device of the first terminal device is updated after the first terminal device establishes a Bluetooth connection with the Bluetooth device. Optionally, upon detecting a change in the associated device, the first terminal device can generate the third-association device information and send the third-association device information to the Bluetooth device. Alternatively, before performing the first terminal device's association determination operation based on the associated device information, the Bluetooth device can send an association device acquisition request to the first terminal device to obtain the third-association device information returned by the first terminal device in response to the acquisition request, thereby allowing the Bluetooth device to update the locally stored associated device information based on the third-association device information.
[0081] In this embodiment, the Bluetooth device can receive the third associated device information sent by the first terminal device, and complete the update of the local associated information according to the third associated device information, ensuring that the locally stored associated device information is the latest associated device information, thereby improving the accuracy of determining the associated device based on the associated device information.
[0082] For example, after the Bluetooth device establishes a Bluetooth connection with the first terminal device, if the Bluetooth device wants to receive a connection request sent by another terminal device, the Bluetooth device needs to have a function of allowing the other terminal device to switch the connection. In one optional embodiment, receiving the Bluetooth connection request sent by the second terminal device includes:
[0083] When the Bluetooth device enables the connection grabbing mode, a connection request sent by the second terminal device is received.
[0084] For example, the Bluetooth device enabling the preemptive connection mode means that after the Bluetooth device establishes a Bluetooth connection with the first terminal device, it can still receive connection requests sent by other terminal devices. The Bluetooth device being in the preemptive connection mode means that after the Bluetooth device establishes a Bluetooth connection with the first terminal device, the Bluetooth device is still visible in the Bluetooth search state, that is, other terminal devices can still obtain the Bluetooth signal of the Bluetooth device when performing a Bluetooth search, and can thereby initiate a Bluetooth connection request to the Bluetooth device.
[0085] Specifically, for the scenario in this embodiment, the connection preemption mode indicates that other terminal devices except the terminal device that was most recently disconnected from the Bluetooth device are allowed to preempt the Bluetooth connection between the Bluetooth device and the first terminal device.
[0086] That is, the Bluetooth device enables preemptive connection mode to receive a connection request sent by a second terminal device. If the second terminal device is not the terminal device that most recently disconnected from the Bluetooth device, the preemptive connection mode of the Bluetooth device allows the associated device of the first terminal device to preempt the Bluetooth connection between the Bluetooth device and the first terminal device. In other words, the Bluetooth device disconnects the Bluetooth connection with the first terminal device and establishes a Bluetooth connection with the associated device of the first terminal device, thus implementing preemptive connection switching.
[0087] In this embodiment, the connection request initiated by the second terminal device can only be received when the Bluetooth device enables the pre-emptive connection mode. By determining whether the connection request of the second terminal device can be received based on whether the Bluetooth device enables the pre-emptive connection mode, the number of second terminal devices that initiate connection requests is reduced to a certain extent, and interference with the first terminal device caused by the connection request initiated by the second terminal device is avoided, thereby optimizing the user experience of users using Bluetooth devices.
[0088] Then accordingly, how to control the Bluetooth device to be in the mode of allowing connection grabbing, in one of the optional embodiments, as Figure 5 As shown, the method further includes:
[0089] Step 501: When a Bluetooth connection is established with a first terminal device, it is determined whether the Bluetooth device is executing a service of the first terminal device.
[0090] In this embodiment, when determining that a Bluetooth connection is established with the first terminal device, the Bluetooth device determines whether the service of the first terminal device is currently being executed. For example, the Bluetooth device can obtain the currently running application and determine whether the service of the first terminal device exists from the running application; or the Bluetooth device can also monitor whether there is data interaction with the first terminal device. If there is data interaction, it is determined that the service of the first terminal device is currently being executed.
[0091] Step 502: If the Bluetooth device does not execute the service of the first terminal device, the Bluetooth device enables the connection grabbing mode.
[0092] In this embodiment, the Bluetooth device determines that there is no currently running application that matches the service of the first terminal device, or detects that there is no data interaction with the first terminal device. In this case, the Bluetooth device determines that the service of the first terminal device is not executed. At this time, since the current Bluetooth device has no service to execute, switching connections with other terminal devices will not cause service interruption and other problems for the Bluetooth device to execute the service of the first terminal device. Based on this, the Bluetooth device enables the preemptive connection mode, that is, the Bluetooth device turns on the preemptive connection mode.
[0093] However, in reality, when the Bluetooth device is executing the service of the first terminal device, there is also an actual need to switch the connection to the second terminal device. In this demand scenario, further conditional judgment can be made on the second terminal device to determine whether to enable the Bluetooth device's preemptive connection function, thereby achieving the actual switching connection purpose. In one of the optional embodiments, such as Figure 6 As shown, the method further includes:
[0094] Step 601: If the Bluetooth device is executing the service of the first terminal device, it is determined whether the first terminal device has an associated device.
[0095] Among them, the Bluetooth device is executing the service of the first terminal device means that the Bluetooth device and the first terminal device are performing service interaction. Taking the Bluetooth device as a Bluetooth headset and the first terminal device as a mobile phone as an example, the Bluetooth device is executing the service of the first terminal device for example that the Bluetooth headset is playing music on the mobile phone, or that the mobile phone is making a voice call through the Bluetooth headset, etc.
[0096] In this embodiment, when the Bluetooth device determines that the service of the first client is being executed, in order to avoid a one-size-fits-all failure to switch the connection of the second terminal device, the Bluetooth device can determine whether the Bluetooth device enables the preemptive connection mode based on further judgment conditions. The further judgment condition here can be that the Bluetooth device determines whether the first terminal device has an associated device. For example, the Bluetooth device can obtain the first associated device information of the first terminal device, and determine whether the first terminal device has an associated device based on the first associated device information. For example, if the first associated device information is empty, it is determined that the first terminal device does not have an associated device; if the first associated device information is not empty, it is determined that the first terminal device has an associated device.
[0097] Step 602: If the first terminal device has an associated device, the Bluetooth device enables a connection grabbing mode.
[0098] In this embodiment, if the Bluetooth device determines that the first terminal device has an associated device, in this case the Bluetooth device enables the connection grabbing mode, the purpose of which is to allow the Bluetooth device to receive connection requests sent by other second terminal devices, or to set the Bluetooth device to allow responding to connection requests from other terminal devices.
[0099] In this embodiment, especially for the case where the Bluetooth device is executing the service of the first terminal device, in order to protect the currently ongoing service to the greatest extent, the Bluetooth device controls the Bluetooth device to be in the allowed connection mode only when it is determined that there is an associated device with the first terminal device. This fundamentally avoids the problem of some unrelated devices trying to connect to the Bluetooth device, enhances the data security of the first terminal device and the Bluetooth device, and also optimizes the user experience.
[0100] Optionally, the specific implementation of enabling the connection grabbing mode by the Bluetooth device in the above steps 502 and 602 includes:
[0101] Enable the Bluetooth device's paging scan function, or enable the Bluetooth device to respond to connection requests.
[0102] In this embodiment, turning on the paging scan function of the Bluetooth device by the Bluetooth device refers to putting the Bluetooth device in a state where the Bluetooth search is visible. For example, the relevant information of the Bluetooth device can be displayed in the Bluetooth search list of the terminal device within the coverage range of its Bluetooth signal, wherein the paging scan function can be controlled by setting the parameter Page scan to control whether it is turned on. Exemplarily, when the parameter value of Page scan is the first value, it indicates that the paging scan function of the Bluetooth device is turned on; when the parameter value of Page scan is the second value, it indicates that the paging scan function of the Bluetooth device is turned off, wherein the first value can be 0 or 1, and the second value can be 1 or 0; the first value and the second value can also be other specified characters. The Bluetooth device turns on the paging scan function by setting the value of Page scan, thereby enabling the connection grabbing mode when it is determined that the paging scan function is turned on, so as to receive the connection request initiated by the second terminal device.
[0103] The above-mentioned paging scanning function of turning on the Bluetooth device is described from the perspective that the Bluetooth device can receive connection requests from other terminal devices; enabling the Bluetooth device to respond to connection requests means that after the Bluetooth device receives the connection requests from other terminal devices, it is allowed to respond to connection requests from other terminal devices, that is, the Bluetooth device is always in a Bluetooth search visible state and can always receive connection requests sent by other terminal devices, but only when the Bluetooth device is enabled to respond to connection requests, that is, only when the Bluetooth device enables the connection grabbing mode, it will respond to the connection request sent by the terminal device. Otherwise, even if it receives a connection request sent by other devices, it will not respond to the connection request. The non-response here can be the Bluetooth device sending a rejection response to the second terminal device or directly ignoring the connection request.
[0104] In this embodiment, when the Bluetooth device determines that there is no service of the first terminal device currently being executed and / or determines that there is an associated device for the first terminal device, the Bluetooth device enables the connection grabbing mode by turning on the paging scanning function or allowing the Bluetooth device to respond to the connection request setting, so that it can receive and respond to connection requests sent by other second terminal devices. Since there is no service of the first terminal device being executed, connection requests sent by other terminal devices will not cause service interruption to the first terminal device or the Bluetooth device. Alternatively, the first terminal device has an associated device, and its associated device, that is, a legal device, allows the connection grabbing operation. Based on this, the Bluetooth device realizes fast switching connections between different terminal devices.
[0105] There is another scenario for the above step 602. In one optional embodiment, the method further includes:
[0106] If the first terminal device has no associated device, the Bluetooth device prohibits the connection-grabbing mode and does not respond to the connection request sent by the second terminal device.
[0107] If the Bluetooth device determines that the first terminal device has no associated devices, that is, the first associated device information is empty, in this case, all other terminal devices can be considered as illegal devices. In order to prevent other unfamiliar second terminal devices from sending connection requests to the Bluetooth device, the Bluetooth device prohibits the connection-preemption mode. If the Bluetooth device is in the prohibition connection-preemption mode, the Bluetooth device will not receive connection requests from other terminal devices, or will not respond to connection requests from other terminal devices. In other words, other terminal devices are not allowed to send connection requests to the Bluetooth device to affect the service execution of the first terminal device.
[0108] Exemplarily, the Bluetooth device's prohibited connection-grabbing mode means that after the Bluetooth device establishes a Bluetooth connection with the first terminal device, the Bluetooth device is in an invisible Bluetooth search state, that is, other terminal devices cannot obtain the Bluetooth signal of the Bluetooth device when performing a Bluetooth search. Obviously, other terminal devices cannot initiate a Bluetooth connection request to the Bluetooth device, and accordingly, the Bluetooth device cannot receive Bluetooth connection requests sent by other terminal devices; or, the Bluetooth device can receive connection requests sent by other terminal devices, but does not respond to connection requests sent by other terminal devices. The non-response here can be sending a rejection response to the other terminal device or directly ignoring the connection request.
[0109] In this embodiment, after determining that there is no associated device for the first terminal device, that is, after determining that there are no other terminal devices that are legally eligible to connect except the first terminal device, the Bluetooth device prohibits the connection mode, thereby ensuring the business operation of the currently executing first terminal device, optimizing the user experience, and protecting the data security of the first terminal device and the Bluetooth device to a certain extent.
[0110] The above-mentioned Bluetooth device prohibits the connection-grabbing mode in the following ways:
[0111] Turn off the page scanning function of the Bluetooth device, or prohibit the Bluetooth device from responding to connection requests.
[0112] In this embodiment, when the Bluetooth device turns off the paging scan function of the Bluetooth device, it means that the Bluetooth device is in a state where the Bluetooth search is invisible. For example, the relevant information of the Bluetooth device may not be displayed in the Bluetooth search list of the terminal device within the coverage range of its Bluetooth signal. Among them, similar to turning on the paging scan function as mentioned above, the parameter Page scan can be set to control whether to turn off the paging scan function. Exemplarily, when the parameter value of Page scan is the first value, it indicates that the paging scan function of the Bluetooth device is turned on; when the parameter value of Page scan is the second value, it indicates that the paging scan function of the Bluetooth device is turned off, wherein the first value can be 0 or 1, and the second value can be 1 or 0; the first value and the second value can also be other specified characters. The Bluetooth device turns off the paging scan function by setting the value of Page scan, so that when it is determined that the paging scan function is turned off, the Bluetooth device prohibits the connection grabbing mode, thereby refusing to receive a connection request initiated by any second terminal device.
[0113] The above-mentioned turning off the paging scanning function of the Bluetooth device is described from the perspective that the Bluetooth device cannot receive connection requests from other terminal devices; prohibiting the Bluetooth device from responding to connection requests means that the Bluetooth device can receive connection requests from other terminal devices, but the Bluetooth device does not respond to connection requests from other terminal devices, that is, not responding to the connection request here can be that the Bluetooth device sends a rejection response to the second terminal device or directly ignores the connection request.
[0114] In this embodiment, when the Bluetooth device determines that there is no associated device for the first terminal device, the Bluetooth device prohibits the connection-grabbing mode by turning off the paging scanning function or prohibiting the Bluetooth device from responding to the connection request, thereby not receiving or responding to the connection request sent by other second terminal devices. Since there is no associated device for the first terminal device, that is, there is no other legal device allowed to perform the connection-grabbing operation, based on this, the Bluetooth device turns off the paging scanning function to put the Bluetooth device in the prohibited connection-grabbing mode, which can achieve the purpose of maintaining the services of the terminal device and the Bluetooth device and optimize the user experience.
[0115] Optionally, when establishing a Bluetooth connection, in order to better meet user needs, the Bluetooth device may also determine the device priority of the terminal device that initiates the connection request based on local associated device information. In one optional embodiment, the method further includes:
[0116] When the Bluetooth device has not established a Bluetooth connection with any terminal device, if it receives connection requests from at least two third terminal devices, it determines the third terminal device with the highest priority based on the currently stored fourth associated device information and responds to the connection request of the third terminal device with the highest priority.
[0117] In this embodiment, when the Bluetooth device has not established a connection with any terminal device, it receives a connection request sent by at least two third terminal devices. The Bluetooth device needs to determine a target terminal device to establish a connection with from the at least two third terminal devices. In the process of determining the target terminal device, the Bluetooth device can determine the target terminal device based on the fourth associated device information stored locally. Here, the fourth associated device information can also be the associated device information finally stored locally after the Bluetooth device is updated in the above embodiment. In the process of determining the target terminal device, the Bluetooth device can determine the third terminal device with the highest device type priority and / or the highest service priority as the target terminal device based on the priorities of different dimensions such as preset device type priority and service priority; it can also determine the third terminal device with the highest factory serial number priority as the target terminal device based on the preset factory serial number priority. This embodiment does not limit this.
[0118] In this embodiment, after the Bluetooth device establishes a connection with the terminal device, it will synchronize the associated device information of the terminal device. That is, after establishing a Bluetooth connection with the terminal device, the associated device information always exists in the local storage space of the Bluetooth device. In the case where multiple terminal devices initiate Bluetooth backconnection, the Bluetooth device can determine the terminal device with the highest priority based on the local associated device information to establish a Bluetooth connection, which optimizes the process of backconnection between the terminal device and the Bluetooth device to a certain extent and improves the backconnection efficiency of the terminal device.
[0119] To better illustrate the above method, Figure 7 As shown, this embodiment provides a device connection switching method involving interaction between a Bluetooth device, a first terminal device, and a second terminal device, specifically including:
[0120] Step 101: When a Bluetooth device establishes a Bluetooth connection with a first terminal device, the first terminal device synchronizes first associated device information with the Bluetooth device;
[0121] Step 102: The Bluetooth device determines whether there is a currently executing service; if not, step 103 is executed; if so, step 104 is executed;
[0122] Step 103: The Bluetooth device enables a connection grabbing mode, receives a connection request sent by a second terminal device, and in response to the connection request, disconnects the Bluetooth connection with the first terminal device and establishes a Bluetooth connection with the second terminal device.
[0123] Step 104: Determine whether the first terminal device has associated device information. If so, proceed to step 105; if not, proceed to step 112.
[0124] Step 105: The Bluetooth device enables a connection grabbing mode, receives a connection request sent by the second terminal device, and updates the first associated device information from the first terminal device to obtain the updated first associated device information;
[0125] Step 106: Determine whether the second terminal device is an associated device of the first terminal device based on the device identifier and the updated first associated device information; if it is an associated device, execute step 107; if it is not an associated device, execute step 112;
[0126] Step 107: If the second terminal device is an associated device of the first terminal device, determine whether the second terminal device is the terminal device that was most recently disconnected from the Bluetooth device; if not, execute step 108; if so, execute step 109;
[0127] Step 108: In response to the connection request, disconnect the Bluetooth connection with the first terminal device and establish a Bluetooth connection with the second terminal device;
[0128] Step 109: Obtain the time difference between the last time the Bluetooth device was disconnected and the current time;
[0129] Step 110: Determine whether the time difference is greater than a time difference threshold. If so, execute step 112; if not, execute step 112;
[0130] Step 111: In response to the connection request, disconnect the Bluetooth connection with the first terminal device and establish a Bluetooth connection with the second terminal device;
[0131] Step 112: The Bluetooth device disables the connection-grabbing mode and does not respond to the connection request.
[0132] In this embodiment, after the Bluetooth device establishes a Bluetooth connection with the first terminal device, when the Bluetooth device determines that the service of the first terminal device is not currently being executed, the Bluetooth device is placed in a mode allowing connection grabbing, thereby receiving a connection request from the second terminal device, and then determining whether to respond to the connection request of the second terminal device based on the first associated device information sent by the first terminal device, the terminal device information of the Bluetooth device that was most recently disconnected, etc., multiple conditional judgments ensure that when the Bluetooth device switches the connection, the completion of the interaction with the first terminal device is guaranteed to the greatest extent, and the legitimacy of the second terminal device is guaranteed to the greatest extent, so that the Bluetooth device can achieve switching connection with legitimate terminal devices in a safe and effective scenario, thereby optimizing the user experience.
[0133] The device connection switching method provided in the above embodiment has similar implementation principles and technical effects to those of the above method embodiment, and will not be described in detail here.
[0134] It should be understood that although Figure 2-7 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 2-7 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0135] Figure 8 FIG. 1 is a structural block diagram of a device connection switching device according to an embodiment. Figure 8 As shown, the device includes:
[0136] Receiving module 01, configured to receive a connection request sent by a second terminal device when establishing a Bluetooth connection with a first terminal device;
[0137] Determination module 02, used to determine whether the second terminal device is the terminal device that was most recently disconnected from the Bluetooth device;
[0138] The execution module 03 is configured to not respond to the connection request if the second terminal device is the terminal device that was most recently disconnected from the Bluetooth device.
[0139] In one of the optional embodiments, the execution module 03 is also used to obtain the time difference between the moment of last disconnection from the Bluetooth device and the current moment if the second terminal device is the terminal device that was last disconnected from the Bluetooth device; if the time difference is greater than the time difference threshold, then in response to the connection request, disconnect the Bluetooth connection with the first terminal device and establish a Bluetooth connection with the second terminal device; if the time difference is not greater than the time difference threshold, then do not respond to the connection request.
[0140] In one of the optional embodiments, the execution module 03 is also used to disconnect the Bluetooth connection with the first terminal device and establish a Bluetooth connection with the second terminal device in response to the connection request if the second terminal device is not the terminal device that was last disconnected from the Bluetooth device.
[0141] In one of the optional embodiments, the execution module 03 is also used to determine whether the second terminal device is an associated device of the first terminal device based on the first associated device information of the first terminal device; if the second terminal device is an associated device of the first terminal device, then executing the steps of disconnecting the Bluetooth connection with the first terminal device and establishing a Bluetooth connection with the second terminal device in response to the connection request.
[0142] In one of the optional embodiments, the receiving module 01 is further configured to receive second associated device information sent by the second terminal device after establishing a Bluetooth connection with the second terminal device.
[0143] In one optional embodiment, the receiving module 01 is further configured to replace the first associated device information stored in the Bluetooth device with the second associated device information.
[0144] In one of the optional embodiments, the receiving module 01 is further configured to receive the first associated device information sent by the first terminal device when the Bluetooth device establishes a Bluetooth connection with the first terminal device.
[0145] In one optional embodiment, the receiving module 01 is further configured to receive and save third associated device information sent by the first terminal device, where the third associated device information is used to indicate changes and updates in associated devices of the first terminal device.
[0146] In one of the optional embodiments, the receiving module 01 is also used to receive a connection request sent by a second terminal device when the Bluetooth device enables the preemptive connection mode; the preemptive connection mode indicates that other terminal devices except the terminal device that was most recently disconnected from the Bluetooth device are allowed to preempt the Bluetooth connection between the Bluetooth device and the first terminal device.
[0147] In one of the optional embodiments, the execution module 03 is also used to determine whether the Bluetooth device is executing the service of the first terminal device when establishing a Bluetooth connection with the first terminal device; if the Bluetooth device is not executing the service of the first terminal device, the Bluetooth device enables the connection grabbing mode.
[0148] In one optional embodiment, the execution module 03 is further used to determine whether the first terminal device has an associated device if the Bluetooth device is executing the service of the first terminal device; if the first terminal device has an associated device, the Bluetooth device enables the connection grabbing mode.
[0149] In one optional embodiment, the execution module 03 is further configured to enable a paging scanning function of the Bluetooth device; or enable the Bluetooth device to respond to a connection request.
[0150] In one optional embodiment, the execution module 03 is further configured to disable the connection-preemption mode of the Bluetooth device if there is no associated device for the first terminal device, and the Bluetooth device does not respond to the connection request sent by the second terminal device.
[0151] In one optional embodiment, the execution module 03 is further configured to disable the paging scanning function of the Bluetooth device; or prohibit the Bluetooth device from responding to a connection request.
[0152] In one optional embodiment, the first associated device information includes at least one of the following:
[0153] Device information of terminal devices that have been connected to the first terminal device;
[0154] Device information of a terminal device of the same type as the first terminal device;
[0155] Device information of a terminal device that belongs to the same account as the first terminal device.
[0156] The division of the modules in the above-mentioned Bluetooth device preemptive connection device is only for illustration. In other embodiments, the Bluetooth device preemptive connection device may be divided into different modules as needed to complete all or part of the functions of the above-mentioned Bluetooth device preemptive connection device.
[0157] For the specific definition of the Bluetooth device connection grabbing device, please refer to the definition of the device connection switching method above, which will not be repeated here. The various modules in the above-mentioned Bluetooth device connection grabbing device can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0158] Figure 9Schematic diagram of the internal structure of an electronic device in one embodiment. The electronic device may be an intelligent electronic device including a Bluetooth module, for example, any terminal device such as a Bluetooth headset, a mobile phone, a tablet computer, a laptop computer, a desktop computer, a car computer, a wearable device, etc. The electronic device includes a processor and a memory connected via a system bus. The processor may include one or more processing units. The processor may be a CPU (Central Processing Unit) or a DSP (Digital Signal Processing), etc. The memory may include a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The computer program can be executed by the processor to implement a device connection switching method provided in each of the following embodiments. The internal memory provides a cached operating environment for the operating system computer program in the non-volatile storage medium.
[0159] The various modules in the device connection switching apparatus provided in the embodiments of the present application may be implemented in the form of a computer program. The computer program may be executed on a terminal or server. The program modules comprising the computer program may be stored in a memory of an electronic device. When the computer program is executed by a processor, the steps of the method described in the embodiments of the present application are implemented.
[0160] The present application also provides a computer-readable storage medium, one or more non-volatile computer-readable storage media containing computer-executable instructions, which, when executed by one or more processors, cause the processors to perform the steps of the device connection switching method.
[0161] An embodiment of the present application also provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute a device connection switching method.
[0162] As used herein, any reference to memory, storage, database, or other medium may include non-volatile and / or volatile memory. Non-volatile memory may include ROM (Read-Only Memory), PROM (Programmable Read-only Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-only Memory), or flash memory. Volatile memory may include RAM (Random Access Memory), which serves as an external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as SRAM (Static Random Access Memory), DRAM (Dynamic Random Access Memory), SDRAM (Synchronous Dynamic Random Access Memory), Double Data Rate DDRSDRAM (Double Data Rate Synchronous Dynamic Random Access memory), ESDRAM (Enhanced Synchronous Dynamic Random Access memory), SLDRAM (Sync Link Dynamic Random Access Memory), RDRAM (Rambus Dynamic Random Access Memory), and DRDRAM (Direct Rambus Dynamic Random Access Memory).
[0163] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present invention, all of which fall within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be determined by the appended claims.
Claims
1. A device connection switching method, characterized in that: Applied to a Bluetooth device, the method includes: When a Bluetooth connection is established with the first terminal device, receiving a connection request sent by the second terminal device; Determining whether the second terminal device is the terminal device that was most recently disconnected from the Bluetooth device; If the second terminal device is the terminal device that was most recently disconnected from the Bluetooth device, the connection request is not responded to.
2. The method according to claim 1, characterized in that The method further comprises: If the second terminal device is the terminal device that was most recently disconnected from the Bluetooth device, obtaining a time difference between the moment of most recently disconnecting from the Bluetooth device and the current moment; If the time difference is greater than a time difference threshold, disconnecting the Bluetooth connection with the first terminal device and establishing a Bluetooth connection with the second terminal device in response to the connection request; If the time difference is not greater than the time difference threshold, the connection request is not responded to.
3. The method according to claim 1, characterized in that The method further comprises: If the second terminal device is not the terminal device that was most recently disconnected from the Bluetooth device, then in response to the connection request, the Bluetooth connection with the first terminal device is disconnected, and a Bluetooth connection with the second terminal device is established.
4. The method according to claim 2 or 3, characterized in that Before responding to the connection request, the method further includes: determining, based on the first associated device information of the first terminal device, whether the second terminal device is an associated device of the first terminal device; If the second terminal device is an associated device of the first terminal device, the steps of disconnecting the Bluetooth connection with the first terminal device and establishing a Bluetooth connection with the second terminal device in response to the connection request are performed.
5. The method according to claim 4, characterized in that The method further comprises: After establishing a Bluetooth connection with the second terminal device, second associated device information sent by the second terminal device is received.
6. The method according to claim 5, characterized in that The method further comprises: The first associated device information stored in the Bluetooth device is replaced by the second associated device information.
7. The method according to claim 4, characterized in that The method further comprises: When the Bluetooth device establishes a Bluetooth connection with the first terminal device, the first associated device information sent by the first terminal device is received.
8. The method according to claim 7, characterized in that After receiving the first associated device information sent by the first terminal device, the method further includes: Receive and save third associated device information sent by the first terminal device, where the third associated device information is used to indicate a change or update of an associated device of the first terminal device.
9. The method according to claim 1, characterized in that The receiving a connection request sent by the second terminal device includes: When the Bluetooth device enables the preemptive connection mode, a connection request sent by the second terminal device is received; the preemptive connection mode indicates that other terminal devices except the terminal device that was most recently disconnected from the Bluetooth device are allowed to preempt the Bluetooth connection between the Bluetooth device and the first terminal device.
10. The method according to claim 9, characterized in that The method further comprises: When a Bluetooth connection is established with the first terminal device, determining whether the Bluetooth device is executing a service of the first terminal device; If the Bluetooth device does not execute the service of the first terminal device, the Bluetooth device enables the connection-preemption mode.
11. The method according to claim 10, characterized in that The method further comprises: If the Bluetooth device is executing the service of the first terminal device, determining whether the first terminal device has an associated device; If the first terminal device has an associated device, the Bluetooth device enables the connection-preemption mode.
12. The method according to claim 10 or 11, characterized in that The enabling connection grabbing mode of the Bluetooth device includes: Turn on the paging scanning function of the Bluetooth device; Or, enable the Bluetooth device to respond to the connection request.
13. The method according to claim 11, characterized in that The method further comprises: If the first terminal device has no associated device, the Bluetooth device prohibits the connection-grabbing mode, and the Bluetooth device does not respond to the connection request sent by the second terminal device.
14. The method according to claim 13, characterized in that The Bluetooth device prohibits the connection-grabbing mode, including: Turn off the paging scanning function of the Bluetooth device; Or, prohibit the Bluetooth device from responding to the connection request.
15. The method according to claim 4, characterized in that The first associated device information includes at least one of the following: Device information of terminal devices that have been connected to the first terminal device; Device information of a terminal device of the same type as the first terminal device; Device information of a terminal device that belongs to the same account as the first terminal device.
16. A device connection switching device, characterized in that: Applicable to Bluetooth devices, including: A receiving module, configured to receive a connection request sent by a second terminal device when a Bluetooth connection is established with the first terminal device; a determination module, configured to determine whether the second terminal device is the terminal device that was most recently disconnected from the Bluetooth device; An execution module is configured to not respond to the connection request if the second terminal device is a terminal device that was most recently disconnected from the Bluetooth device.
17. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the computer program is executed by the processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 15.
18. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 15 are implemented.
Citation Information
Patent Citations
Audio playing control method and mobile terminal
CN108319442A
Bluetooth connection method, device and system
CN110191442A