CN114040465A - Device connection switching method and device, electronic device and computer readable storage medium - Google Patents

Device connection switching method and device, electronic device and computer readable storage medium Download PDF

Info

Publication number
CN114040465A
CN114040465A CN202111447052.XA CN202111447052A CN114040465A CN 114040465 A CN114040465 A CN 114040465A CN 202111447052 A CN202111447052 A CN 202111447052A CN 114040465 A CN114040465 A CN 114040465A
Authority
CN
China
Prior art keywords
bluetooth
terminal
equipment
connection
terminal device
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111447052.XA
Other languages
Chinese (zh)
Inventor
包建全
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Oppo Mobile Telecommunications Corp Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN202111447052.XA priority Critical patent/CN114040465A/en
Publication of CN114040465A publication Critical patent/CN114040465A/en
Priority to PCT/CN2022/119656 priority patent/WO2023098234A1/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W36/00Hand-off or reselection arrangements
    • H04W36/34Reselection control
    • H04W36/36Reselection control by user or terminal equipment
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W12/00Security arrangements; Authentication; Protecting privacy or anonymity
    • H04W12/50Secure pairing of devices
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/80Services using short range communication, e.g. near-field communication [NFC], radio-frequency identification [RFID] or low energy communication

Abstract

The application relates to a device connection switching method, a device connection switching apparatus, an electronic device and a computer-readable storage medium. The method comprises the following steps: the method comprises the steps that under the condition that Bluetooth connection is established between Bluetooth equipment and first terminal equipment, a connection request which carries an equipment identifier of the second terminal equipment and is sent by the second terminal equipment is received, and whether the second terminal equipment is the associated equipment of the first terminal equipment or not is determined according to first associated equipment information of the first terminal equipment and the equipment identifier of the second terminal equipment, wherein the equipment identifier of the second terminal equipment is included in the received connection request; and if the second terminal equipment is the associated equipment of the first terminal equipment, responding to the connection request, disconnecting the Bluetooth connection with the first terminal equipment and establishing the Bluetooth connection with the second terminal equipment. In the method, the Bluetooth device responds to the connection request of the second terminal device under the condition that the Bluetooth device determines that the second terminal device is the associated device of the first terminal device according to the first associated device information, so that the data security of the Bluetooth device and the terminal device is improved.

Description

Device connection switching method and device, electronic device and computer readable storage medium
Technical Field
The present application relates to the field of communications technologies, and in particular, to a device connection switching method and apparatus, an electronic device, and a computer-readable storage medium.
Background
Along with the abundance of life contents of people, more and more electronic equipment owned by users are provided, and the technology of Bluetooth equipment is rapidly improved. In actual life, the same bluetooth device may be switched to be connected with different terminal devices, and in order to provide more convenient switching experience for users, the bluetooth device often needs to support a connection robbing function.
In the prior art, there is a connection preemption method for a bluetooth device without any limitation, that is, when the bluetooth device is connected to a terminal device a, after receiving a connection request from the terminal device B, the connection with the terminal device a is interrupted, so as to implement the connection with the terminal device B.
However, the connection preemption method of the bluetooth device without any limitation may have the problems of unreasonable preemption and unsafe data.
Disclosure of Invention
The embodiment of the application provides a device connection switching method and device, an electronic device and a computer readable storage medium, which can solve the problem of unreasonable terminal preemption in the prior art and can improve the data security of a terminal device and a Bluetooth device.
In a first aspect, a device connection switching method is provided, which is applied to a bluetooth device, and includes:
under the condition of establishing Bluetooth connection with first terminal equipment, receiving a connection request sent by second terminal equipment; the connection request comprises a device identification of the second terminal device;
determining whether the second terminal equipment is the associated equipment of the first terminal equipment or not according to the first associated equipment information of the first terminal equipment and the equipment identifier of the second terminal equipment, which is included in the received connection request;
and if the second terminal equipment is the associated equipment of the first terminal equipment, responding to the connection request, disconnecting the Bluetooth connection with the first terminal equipment and establishing the Bluetooth connection with the second terminal equipment.
In a second aspect, a device connection switching method is provided, which is applied to a terminal device, and includes:
under the condition that the first terminal equipment establishes Bluetooth connection with the Bluetooth equipment, first associated equipment information is sent to the Bluetooth equipment, so that when the Bluetooth equipment determines that the second terminal equipment is associated equipment of the first terminal equipment according to the first associated equipment information, the Bluetooth connection with the first terminal equipment is disconnected in response to a connection request sent by the second terminal equipment, and the Bluetooth connection with the second terminal equipment is established.
In a third aspect, a device connection switching system is provided, including:
the first terminal equipment is used for sending first associated equipment information to the Bluetooth equipment under the condition of keeping connection with the Bluetooth equipment;
the Bluetooth device is used for receiving a connection request sent by the second terminal device under the condition of keeping connection with the first terminal device; the connection request comprises a device identification of the second terminal device; determining whether the second terminal equipment is the associated equipment of the first terminal equipment or not according to the first associated equipment information of the first terminal equipment and the equipment identifier of the second terminal equipment, which is included in the received connection request; and if the second terminal equipment is the associated equipment of the first terminal equipment, responding to the connection request, disconnecting the Bluetooth connection with the first terminal equipment and establishing the Bluetooth connection with the second terminal equipment.
In a fourth aspect, there is provided a device connection switching apparatus, the apparatus including:
the receiving module is used for receiving a connection request sent by second terminal equipment under the condition of establishing Bluetooth connection with first terminal equipment; the connection request comprises a device identification of the second terminal device;
a determining module, configured to determine whether a second terminal device is a related device of a first terminal device according to first related device information of the first terminal device and a device identifier of the second terminal device included in the received connection request;
and the execution module is used for responding to the connection request, disconnecting the Bluetooth connection with the first terminal equipment and establishing the Bluetooth connection with the second terminal equipment if the second terminal equipment is the associated equipment of the first terminal equipment.
In a fifth aspect, there is provided a device connection switching apparatus, the apparatus including:
the sending module is used for sending first associated equipment information to the Bluetooth equipment under the condition that the Bluetooth connection is established between the first terminal equipment and the Bluetooth equipment, so that when the Bluetooth equipment determines that the second terminal equipment is associated equipment of the first terminal equipment according to the first associated equipment information, the Bluetooth connection with the first terminal equipment is disconnected in response to a connection request sent by the second terminal equipment, and the Bluetooth connection with the second terminal equipment is established.
In a sixth aspect, an electronic device is provided that includes a communication module, a memory, and a processor; the memory stores a computer program; the computer program, when executed by the processor, causes the processor to perform the device connection switching method according to the first aspect or the second aspect.
In a seventh aspect, a computer-readable storage medium is provided, on which a computer program is stored, and the computer program, when executed by a processor, implements the device connection switching method according to the first aspect or the second aspect.
According to the device connection switching method, the device, the electronic device and the computer readable storage medium, under the condition that the Bluetooth device establishes Bluetooth connection with the first terminal device, the Bluetooth device receives a connection request which is sent by the second terminal device and carries a device identifier of the second terminal device, and determines whether the second terminal device is the associated device of the first terminal device or not according to the first associated device information of the first terminal device and the device identifier of the second terminal device included in the received connection request; and if the second terminal equipment is the associated equipment of the first terminal equipment, responding to the connection request, disconnecting the Bluetooth connection with the first terminal equipment and establishing the Bluetooth connection with the second terminal equipment. In the method, the bluetooth device may determine whether a second terminal device sending a connection request is a related device of the first terminal device based on first related device information of the first terminal device having established the bluetooth connection, that is, perform validity judgment on the second terminal device sending the connection request, and when it is determined that the second terminal device is the related device of the first terminal device, that is, when it is determined that the second terminal device is a valid device, respond to the connection request of the second terminal device, thereby avoiding a problem of current service interruption of the bluetooth device caused by an illegal terminal device initiating a connection request to the bluetooth device Data security of the second terminal device.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a schematic diagram illustrating an exemplary system for switching device connections;
FIG. 2 is a flow diagram of a method for device connection switching in one embodiment;
FIG. 3 is a flowchart of a method for device connection switching in another embodiment;
FIG. 4 is a flowchart of a method for device connection switching in another embodiment;
FIG. 5 is a flowchart of a method for device connection switching in another embodiment;
FIG. 6 is a flowchart of a method for device connection switching in another embodiment;
fig. 7 is a flowchart of a device connection switching method in another embodiment;
FIG. 8 is a block diagram showing the configuration of a device connection switching apparatus according to an embodiment;
fig. 9 is a block diagram showing the configuration of a device connection switching apparatus according to another embodiment;
fig. 10 is a schematic structural diagram of an electronic device in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
It will be understood that, as used herein, the terms "first," "second," and the like may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish one element from another. 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 the present application. Both the first client and the second client are clients, but they are not the same client.
In the process of connecting the bluetooth device and the first terminal device, there may be a case where the second terminal device initiates a connection establishment request to the bluetooth device. Generally, a bluetooth device in the prior art needs to have a one-to-many connection function, or needs to have a function of allowing a connection to be switched with other terminal devices in a one-to-one connection scenario. Under the condition that the Bluetooth device has the function of allowing switching connection with other terminal devices in a one-to-one connection scene, the Bluetooth device in the prior art directly responds to a connection request of a second terminal device, so that the connection with a first terminal device is interrupted, the service execution of a first client side is influenced, and meanwhile, the data security of the Bluetooth device is threatened; or the effect of switching connection of other terminal equipment cannot be realized without responding to the connection request of the second terminal equipment.
Currently, bluetooth technology supports one-to-one connection between a bluetooth device and a terminal device, and therefore, in a situation where the bluetooth device has established a bluetooth connection with a first terminal device, the bluetooth device needs to support a connection preemption function, so that the bluetooth device can receive a connection request sent by another terminal device, and thus perform a corresponding operation according to the connection request. For example, in the prior art, bluetooth devices supporting a connection preemption function are roughly divided into two types, one type of bluetooth device supports connection preemption without any restriction condition, that is, when a first terminal device establishes a connection with a bluetooth device, if a connection request initiated by a second terminal device to the bluetooth device exists, the bluetooth device directly responds to the connection request, disconnects the connection with the first terminal device, establishes a connection with the second terminal device, and realizes connection preemption of the bluetooth device by the second terminal device. Another type of bluetooth device supports connection preemption with a certain limitation, for example, after receiving a connection request initiated by a second terminal device, the bluetooth device sends an identifier (e.g., a local area network Address (MAC Address) and a cloud account) of the second terminal device to a server, and the server determines whether the second terminal device can perform connection preemption operation according to the identifier of the second terminal device, so that the bluetooth device performs corresponding connection switching operation according to a determination result returned by the server.
Although the above-mentioned method of unrestrained support of the connection preemption or the method of legal discrimination via the server can achieve the purpose of switching different terminal devices to use the bluetooth device, they all have certain technical defects. Exemplarily, for a first class of bluetooth devices which support connection preemption without limit, there may exist a situation that when a bluetooth device is executing a service, the bluetooth device is connected to a strange second terminal device in a preemption mode, which causes a bluetooth service interruption of a first terminal device, brings a bad user experience to a user of the first terminal device, and cannot guarantee data security of a first client device and the bluetooth device; for the second type of bluetooth device, it often needs to judge whether the second terminal device to be preemptively connected can be trusted by means of the server, but in an actual situation, there are some specific scenarios, for example, the second terminal device does not support logging in a cloud account or logging in the server, and in this case, the server cannot judge the trusted device for the second terminal device through the second terminal device identifier, so that the purpose of connection switching cannot be realized by the bluetooth device according to the judgment result given by the server, and the user experience is also affected.
Based on this, the present embodiment provides a device connection switching method to solve the above problems in the prior art.
Fig. 1 is a schematic structural diagram of a device connection switching system in an embodiment, and a device connection switching method provided in the following embodiment is applied to the device connection switching system provided in this embodiment. As shown in fig. 1, the system includes a bluetooth device 1, a first terminal device 2, and a second terminal device 3.
The first terminal equipment is used for sending first associated equipment information to the Bluetooth equipment under the condition of keeping connection with the Bluetooth equipment;
the Bluetooth device is used for receiving a connection request sent by the second terminal device under the condition of keeping connection with the first terminal device; the connection request comprises a device identification of the second terminal device; determining whether the second terminal equipment is the associated equipment of the first terminal equipment or not according to the first associated equipment information of the first terminal equipment and the equipment identifier of the second terminal equipment, which is included in the received connection request; and if the second terminal equipment is the associated equipment of the first terminal equipment, responding to the connection request, disconnecting the Bluetooth connection with the first terminal equipment and establishing the Bluetooth connection with the second terminal equipment.
The bluetooth device may be an electronic device including a bluetooth module, such as a bluetooth headset, a True Wireless Stereo (TWS) headset, a bluetooth watch, a mobile phone, a tablet computer, a wearable device, and a vehicle-mounted bluetooth device; the terminal device can be an electronic device which is provided with a Bluetooth module and can be in communication connection with the Bluetooth device, such as a Bluetooth watch, a wearable device, a mobile phone, a tablet computer, a computer and a server. Specifically, after the bluetooth headset establishes a bluetooth connection with the headset, the bluetooth headset may receive a connection establishment request sent by the bluetooth watch by starting a connection preemption function of the bluetooth headset, so as to implement a connection switching of the bluetooth device with respect to the mobile phone and the bluetooth watch according to any one of the device connection switching methods provided in the following embodiments. The device connection switching method implemented by the device connection switching system in the present embodiment is described below from the perspective of the bluetooth device and the terminal device, respectively.
Fig. 2 is a flowchart of a device connection switching method according to an embodiment. The device connection switching method in this embodiment is described by taking the bluetooth device in fig. 1 as an example. As shown in fig. 2, the device connection switching method includes steps 201 to 203.
Step 201, receiving a connection request sent by a second terminal device under the condition of establishing a bluetooth connection with a first terminal device; the connection request comprises a device identification of the second terminal device.
The condition that the bluetooth device establishes the bluetooth Connection with the first terminal device refers to a state in which the bluetooth device and the first terminal device have completed the procedures of Asynchronous transfer Access Control (ACL) Connection, bluetooth pairing, and bluetooth Connection. Under the condition of establishing the bluetooth connection, the first terminal device may perform service interaction with the bluetooth device, for example, under the condition that the bluetooth device is a bluetooth headset, the first terminal device may perform services such as audio and video call, audio playing, and the like through the bluetooth headset.
Under the condition that the Bluetooth device establishes Bluetooth connection with the first terminal device, the Bluetooth device can receive connection requests sent by other terminal devices. The Bluetooth device has a one-to-many connection function, and can directly receive a connection request sent by a second terminal device under the condition of being connected with a first terminal device; or the bluetooth device needs to start the connection allowing function, so as to receive the connection request sent by the second terminal device. The connection request sent by the second terminal device often carries a device identifier of the second terminal device, for example, the device identifier may be an MAC address of the second terminal device, a device serial number of the second terminal device, a factory serial number of the second terminal device, and the like, and the connection request may also carry information of a device type, a service type, and the like of the second terminal device, which is not limited in this embodiment.
Step 202, determining whether the second terminal device is the associated device of the first terminal device according to the first associated device information of the first terminal device and the device identifier of the second terminal device included in the received connection request.
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 terminal devices that can be trusted may be a terminal device connected to the first terminal device, a terminal device of the same type as the first terminal device, a terminal device of the same account as the first terminal device belongs to, a terminal device in the same local area network as the first terminal device, and the like.
Optionally, the first associated device information may include device information of a terminal device 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 connected to the first terminal device may be a smart watch, a tablet computer, a smart bracelet, or another terminal device having a bluetooth module, which is connected to the mobile phone within a preset historical duration, and correspondingly, the device information of the client includes a device name, a device type, an MAC address, a device serial number, a factory serial number, a service type, and the like. The preset historical time period may be the past month, the past half year, etc. In this scenario, aiming at the defect that the connection switching cannot be realized if the terminal device does not have the function of account login in the prior art, the terminal device connected with the first terminal device can be determined as a legal device capable of performing connection switching through the first association information provided in this embodiment, so as to realize the purpose of connection switching of the bluetooth device.
Optionally, the first associated device information may further include device information of a terminal device of the same type as the first terminal device. For example, in the case that the first terminal device is a brand a mobile phone, the first associated device information may include device information of other terminal devices having a bluetooth module of the brand a, such as a smart watch of the brand a and a tablet computer of the brand a; it should be noted that the same brand type may be considered as the same as a specified field in the factory serial number, the device serial number, or the terminal model number of the first terminal device, where the specified field indicates the brand type. In addition, for example, the type may 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 types are mobile phones.
Optionally, the first associated device information may further include device information of a terminal device of the same account to which the first terminal device belongs. For example, the cloud account of the first terminal device is the user a, and then the first associated device information includes device information of other terminal devices that the user a logs in, for example, device information of a smart watch that the user a logs in, device information of a smart band that the user a logs in, device information of a tablet computer that the user a logs in, and the like.
In this embodiment, the first associated device information may be information that is sent to the bluetooth device by the first terminal device after establishing a bluetooth connection with the bluetooth device; or the first associated device information may be information sent to the bluetooth device after the first terminal device updates its corresponding associated information. Therefore, the bluetooth device may perform traversal query on the device identifier of the second terminal device included in the connection request sent by the second terminal device and the device information in the first associated device information according to the first associated device information, and if the device information matched with the device identifier of the second terminal device exists in the first associated device information, determine that the second terminal device is the associated device of the first terminal device; and if the first associated device information does not contain the device information matched with the device identifier of the second terminal device, determining that the second terminal device is not the associated device of the first terminal device. For example, the bluetooth device may compare the field of the device identifier of the second terminal device with the device identifier fields of all terminal devices in the first associated device information, and if the field of the device identifier of the terminal device is consistent with the field of the device identifier of the second terminal device, determine that the second terminal device is an associated device of the first terminal device; if the field of the device identifier of the second terminal device is not consistent with the device identifier fields of all the terminal devices, it is determined that the second terminal device is not the associated device of the first terminal device, which is not limited in this embodiment.
Step 203, if the second terminal device is the associated device of the first terminal device, responding to the connection request, disconnecting the bluetooth connection with the first terminal device, and establishing the bluetooth connection with the second terminal device.
In this embodiment, after determining that the second terminal device is the associated device of the first terminal device, that is, after determining that the second terminal device is a legal device, the bluetooth device responds to the connection request initiated by the second terminal device, disconnects the bluetooth connection with the first terminal device, and establishes the 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 further respond to the connection request initiated by the second terminal device according to the priorities 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, and if the priority of the second terminal device is higher than the priority of the first terminal device, the bluetooth device responds to the bluetooth connection request of the second terminal device, disconnects the bluetooth connection with the first terminal device, and establishes the bluetooth connection with the second terminal device; the priority can be the priority of the terminal type or the priority of the service initiated by the terminal; exemplarily, the terminal types include a mobile phone, a watch, an earphone, a computer, and the like, and the corresponding priorities are mobile phone > computer > earphone > watch; the terminal type further comprises a brand A, a brand B, a brand C and the like, and the corresponding priority is brand A > brand B > brand C; the services include a call service, an audio playing service, and the like, and the priority corresponding to the call service > the audio playing service, and the bluetooth device may respond to the connection request initiated by the second terminal device according to the preset priority of the terminal type or the preset priority of the service, under the condition that the priority of the second terminal device is determined to be greater than the priority of the first terminal device, which is not limited in this embodiment.
In the device connection switching method in this embodiment, a bluetooth device receives, when establishing a bluetooth connection with a first terminal device, a connection request that is sent by a second terminal device and carries a device identifier of the second terminal device, and determines whether the second terminal device is a related device of the first terminal device according to first related device information of the first terminal device and the device identifier of the second terminal device included in the received connection request; and if the second terminal equipment is the associated equipment of the first terminal equipment, responding to the connection request, disconnecting the Bluetooth connection with the first terminal equipment and establishing the Bluetooth connection with the second terminal equipment. In the method, the bluetooth device may determine whether a second terminal device sending a connection request is a related device of the first terminal device based on first related device information of the first terminal device having established the bluetooth connection, that is, perform validity judgment on the second terminal device sending the connection request, and when it is determined that the second terminal device is the related device of the first terminal device, that is, when it is determined that the second terminal device is a valid device, respond to the connection request of the second terminal device, thereby avoiding a problem of current service interruption of the bluetooth device caused by an illegal terminal device initiating a connection request to the bluetooth device Data security of the second terminal device.
After the bluetooth device establishes a bluetooth connection with a 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 another terminal device to perform a connection handover, in one optional embodiment, receiving the connection request sent by a second terminal device includes:
and receiving a connection request sent by the second terminal equipment under the condition that the Bluetooth equipment enables the connection preemption mode.
The Bluetooth device connection enabling mode means that after the Bluetooth device establishes Bluetooth connection with the first terminal device, the connection grabbing function is in an open state, and the Bluetooth device can receive connection requests sent by other terminal devices. For example, the bluetooth device enabling connection preemption mode means that the bluetooth device still exists in a state that bluetooth search is visible, that is, other terminal devices can still acquire a bluetooth signal of the bluetooth device when performing bluetooth search, so that a bluetooth connection request can be initiated to the bluetooth device.
If the associated device of the first terminal device initiates a connection request to the bluetooth device, in this case, optionally, the connection preemption mode of the bluetooth device indicates that the associated device of the first terminal device is allowed to preempt the bluetooth connection between the bluetooth device and the first terminal device.
That is, under the condition that the bluetooth device enables the connection preemption mode, determining that the terminal device initiating the connection request is the associated device of the first terminal device, allowing the associated device of the first terminal device to preempt the bluetooth connection between the bluetooth device and the first terminal device, that is, the bluetooth device cuts off the bluetooth connection with the first terminal device, establishes the bluetooth connection with the associated device of the first terminal device, and realizes the connection preemption switching.
In this embodiment, only when the bluetooth device enables the connection preemption mode, the bluetooth device may receive the connection request initiated by the second terminal device, and determine whether to receive the connection request of the second terminal device based on whether the bluetooth device enables the connection preemption mode, thereby reducing the number of the second terminal devices initiating the connection request to a certain extent, avoiding the interference to the first terminal device caused by the connection request initiated by the second terminal device, and optimizing the user experience of the user using the bluetooth device.
Then, further, the situation that the bluetooth device enables the contention mode includes a plurality of cases, in one optional embodiment, as shown in fig. 3, the method further includes:
step 301, under the condition of establishing bluetooth connection with the first terminal device, determining whether the bluetooth device is executing the service of the first terminal device.
In this embodiment, the bluetooth device determines whether the service of the first terminal device is currently executed under the condition that the bluetooth device determines to establish the bluetooth connection with the first terminal device, for example, the bluetooth device may acquire a currently running application program, and determine whether the service of the first terminal device exists in the running application program; or, the bluetooth device may also monitor whether there is data interaction with the first terminal device, and if there is data interaction, determine that the service of the first terminal device is currently being executed.
Step 302, if the bluetooth device does not execute the service of the first terminal device, the bluetooth device enables the connection preemption mode.
In this embodiment, the bluetooth device determines that there is no currently running application program matching the service of the first terminal device, or detects that there is no data interaction with the first terminal device currently, in this case, the bluetooth device determines that the service of the first terminal device is not executed, at this time, because there is no service execution by the current bluetooth device, the problem of service interruption and the like caused by the switching connection of other terminal devices to the service of the first terminal device executed by the bluetooth device is also not caused, based on this, the bluetooth device enables the connection preemption mode, that is, the bluetooth device starts the connection preemption mode.
Optionally, the implementation method for enabling the connection preemption mode by the bluetooth device includes at least two of the following:
and starting a paging scanning function of the Bluetooth device, or enabling the Bluetooth device to respond to the connection request.
In this embodiment, the bluetooth device turning on the Page scanning function of the bluetooth device refers to placing the bluetooth device in a state where bluetooth search is visible, for example, the relevant information of the bluetooth device may be displayed in a bluetooth search list of a terminal device within a bluetooth signal coverage range of the bluetooth device, where the Page scanning function may control whether to turn on or not by setting a parameter Page scan. Illustratively, when the parameter value of the Page scan is a first value, it indicates that the Page scanning function of the bluetooth device is turned on; when the parameter value of the Page scan is a second value, indicating that the Page scanning function of the bluetooth device is turned off, wherein the first value may be 0 or 1, and the second value may be 1 or 0; the first and second values may also be other specified characters. The Bluetooth device starts the Page scanning function by setting the value of the Page scan, so that the connection preemption mode is enabled under the condition of determining that the Page scanning function is started, and the connection request initiated by the second terminal device is received.
The starting of the paging scanning function of the Bluetooth device is described from the point that the Bluetooth device can receive connection requests of other terminal devices; enabling the bluetooth device to respond to the connection request means that the bluetooth device is allowed to respond to the connection request of other terminal devices after receiving the connection request sent by other terminal devices, that is, the bluetooth device is always in a state that bluetooth search is visible, and can always receive the connection request sent by other terminal devices, but only in a state that the bluetooth device is enabled to respond to the connection request, that is, only in a case that the bluetooth device is enabled to perform a connection preemption mode, the connection request sent by the terminal device is responded, otherwise, even if the connection request of other devices is received, the connection request cannot be responded, and here, the non-response may be that the bluetooth device sends a rejection response to the second terminal device or directly ignores the connection request.
In this embodiment, when determining that there is no currently executed service of the first terminal device, the bluetooth device enables the connection preemption mode by starting a page scanning function or allowing the bluetooth device to respond to a connection request, so that connection requests sent by other second terminal devices can be received and responded.
In another case based on the above step 302, in an alternative embodiment, the method further includes:
and if the Bluetooth equipment is executing the service of the first terminal equipment, the Bluetooth equipment forbids the connection robbing mode.
Under the condition that the Bluetooth device determines that the service of the first terminal device is being executed, in order to avoid causing the problem of the service terminal to the service of the first terminal device, the Bluetooth device prohibits the connection robbing mode, that is, if the Bluetooth device prohibits the connection robbing mode, the Bluetooth device is in a state that the Bluetooth search is invisible, that is, when other terminal devices perform the Bluetooth search, the Bluetooth signal of the Bluetooth device cannot be acquired, so obviously, other terminal devices cannot initiate a Bluetooth connection request to the Bluetooth device, and correspondingly, the Bluetooth device cannot receive the Bluetooth connection request sent by other terminal devices; alternatively, the bluetooth device may receive the connection request sent by the other terminal device, but does not respond to the connection request sent by the other terminal device, where the non-response may be to send a reject response to the other terminal device or directly ignore the connection request.
Optionally, in one implementation, the method for disabling the connection preemption mode by the bluetooth device includes:
the page scanning function of the bluetooth device is turned off, or the bluetooth device is prohibited from responding to the connection request.
In this embodiment, the bluetooth device turning off the page scanning function of the bluetooth device refers to placing the bluetooth device in a state where 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 bluetooth signal coverage range. Similar to the above-mentioned opening of the Page scanning function, whether to close the Page scanning function can be controlled by setting a parameter Page scan. Illustratively, when the parameter value of the Page scan is a first value, it indicates that the Page scanning function of the bluetooth device is turned on; when the parameter value of the Page scan is a second value, indicating that the Page scanning function of the bluetooth device is turned off, wherein the first value may be 0 or 1, and the second value may be 1 or 0; the first and second values may also be other specified characters. The Bluetooth device closes the Page scanning function by setting the value of the Page scan, so that under the condition that the Page scanning function is determined to be closed, the Bluetooth device forbids the connection grabbing mode, and thus, connection requests initiated by any second terminal device are refused to be received.
The turning off of the page scanning function of the bluetooth device is from the point of view that the bluetooth device does not receive a connection request to other terminal devices; the prohibition of the bluetooth device responding to the connection request refers to that the bluetooth device may receive a connection request of another terminal device, but the bluetooth device does not respond to the connection request of the other terminal device, that is, here, the non-response to the connection request may be that the bluetooth device sends a rejection response to the second terminal device or directly ignores the connection request.
In this embodiment, when determining that the service of the first terminal device that is currently being executed exists, the bluetooth device disables the connection robbery mode by turning off the page scanning function or disabling the bluetooth device from responding to the connection request, so as not to receive or respond to the connection request sent by the other second terminal device.
However, in actual situations, when the bluetooth device is executing the service of the first terminal device, there is an actual requirement for performing the connection switching of the second terminal device, and in such a requirement scenario, it may be determined whether the bluetooth device enables the connection preemption function through further condition judgment on the second terminal device, so as to achieve the purpose of connection switching in the actual requirement. In one optional embodiment, as shown in fig. 4, the method further includes:
step 401, if the bluetooth device is executing the service of the first terminal device, further determining whether the first terminal device has an associated device.
The service that the bluetooth device is executing the first terminal device refers to that the bluetooth device and the first terminal device are performing service interaction, which is exemplified by taking the bluetooth device as a bluetooth headset and the first terminal device as a mobile phone, and the service that the bluetooth device is executing the first terminal device may be that the bluetooth headset is playing music of the mobile phone, or that the mobile phone is performing voice call through the bluetooth headset.
In this embodiment, in order to avoid that the switching connection of the second terminal device cannot be performed by one time when the bluetooth device determines that the service of the first client is being executed, the bluetooth device may determine whether the bluetooth device enables the connection preemption mode according to a further determination condition. Here, a further determination condition may be that the bluetooth device determines whether the first terminal device has the associated device, for example, the bluetooth device may obtain first associated device information of the first terminal device, and determine whether the first terminal device has the 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 the associated device; and if the first associated equipment information is not null, determining that the first terminal equipment has associated equipment.
Step 402, if the first terminal device has the associated device, the bluetooth device enables the connection preemption mode.
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 preemption mode, and aims to allow the bluetooth device to receive or respond to a connection request sent by another second terminal device. Referring to the example of the foregoing embodiment, the bluetooth device may control to start the Page scanning function by setting a parameter value of the Page scan, or set that the bluetooth device allows responding to a connection request of another terminal device, which is not limited in this embodiment.
In this embodiment, particularly for the case that the bluetooth device is executing the service of the first terminal device, the bluetooth device is controlled to be in the connection preemption allowed mode only when it is determined that the first terminal device has the associated device, so that the problem that some unrelated devices rob the bluetooth device is fundamentally avoided, the data security of the first terminal device and the bluetooth device is enhanced, and the user experience is optimized.
In another scenario, that is, the bluetooth device determines whether there is another condition of the associated device in the first terminal device, in an optional embodiment, the method further includes:
and if the first terminal equipment does not have associated equipment, the Bluetooth equipment forbids the connection robbing mode, and the Bluetooth equipment does not respond to the connection request sent by the second terminal equipment.
If the bluetooth device determines that the first terminal device does not have the associated device, that is, the first associated device information is null, in this case, all other terminal devices may be regarded as illegal devices, and in order to avoid that another strange second terminal device sends a connection request to the bluetooth device, the bluetooth device prohibits the connection preemption mode, that is, the other terminal devices are not allowed to send connection requests to the bluetooth device to affect the service execution of the first terminal device, or do not respond to the connection requests of other terminal devices, referring to the example of the above embodiment, the bluetooth device may control to close the paging scanning function by setting a parameter value of Page scan, or set the bluetooth device to prohibit responding to the connection requests of other terminal devices, which is not limited in this embodiment.
In this embodiment, after it is determined that the first terminal device does not have the associated device, that is, after it is determined that there is no other terminal device except the first terminal device that is legitimate for the connection, the bluetooth device is controlled to enter the connection prohibition mode, so that the currently executed service operation of the first terminal device is ensured, the user experience is optimized, and the data security of the first terminal device and the bluetooth device is protected to a certain extent.
After the bluetooth device establishes the bluetooth connection with the second terminal device, that is, after the bluetooth device completes the handover connection of the second terminal device, in an optional embodiment of the present invention, the method further includes:
and after the Bluetooth connection with the second terminal equipment is established, receiving second associated equipment information sent by the second terminal equipment.
In this embodiment, after the bluetooth device establishes the bluetooth connection with the second terminal device, the bluetooth device needs to receive second associated device information of the second terminal device, where the second associated device information may be an operation triggered and executed by the second terminal device after determining that the bluetooth device establishes the bluetooth connection with the second terminal device; the bluetooth device may also send a request for associating device information to the second terminal device, so that the second terminal device returns the second associating device information to the bluetooth device in response to the request. Similar to the first associated device information in step 202, the second associated device information includes information of a device associated with the second terminal device, and exemplarily, the second associated device information includes at least one of device information of a terminal device connected to the second terminal device, device information of a terminal device of the same type as the second terminal device, and device information of a terminal device of the same account to which the second terminal device belongs.
After the bluetooth device receives the second associated device information, the second associated device information may be stored in the storage space where the first associated device information is stored, that is, the second associated device information and the associated information of the history terminal device are merged and stored, which is not limited in this embodiment.
In this embodiment, after the bluetooth device establishes the bluetooth connection with the second terminal device, the bluetooth device timely receives and stores the second associated device information sent by the second terminal device, and stores the second associated device information in the local storage space, so as to provide data support for the subsequent step of performing associated device judgment based on the second associated device information.
However, in practical situations, the storage space of the bluetooth device is limited, and in this case, the method further includes:
and replacing the first associated device information stored by the Bluetooth device with the second associated device information.
In this embodiment, the bluetooth device may overwrite the second associated device information to the first associated device information, that is, take the second associated device information as the local final associated device information of the bluetooth device; the bluetooth device may also use a union of the first associated device information and the second associated device information as local final associated device information, which is not limited in this embodiment.
In this embodiment, after the bluetooth device establishes the bluetooth connection with the second terminal device, the bluetooth device timely receives the second associated device information sent by the second terminal device to update the associated device information in the local area, so as to provide effective data support for the bluetooth device to perform associated device judgment based on the associated device information, and reduce the occupation of the storage space of the bluetooth device.
Similar to receiving the second associated device information of the second terminal device, in one optional embodiment, the method further includes:
under the condition that the Bluetooth device establishes Bluetooth connection with the first terminal device, first associated device information sent by the first terminal device is received.
In this embodiment, the bluetooth device may receive first associated device information of the first terminal device when establishing a bluetooth connection with the first terminal device, where the first associated device information may be an operation triggered and executed by the first terminal device after determining that the bluetooth connection is established with the bluetooth device; the bluetooth device may also send a request for associating device information to the first terminal device, so that the first terminal device returns the first associating device information to the bluetooth device in response to the request.
In this embodiment, each time after the bluetooth device establishes the bluetooth connection with the new terminal device, the bluetooth device needs to receive the associated device information sent by the current new terminal device, and update the associated device information stored locally in time, so that the associated device information stored locally is more accurate and effective.
Because the terminal device is always in a dynamic operating state, the associated device of the terminal device is also updated in real time, that is, after the terminal device establishes a connection with the bluetooth device, the corresponding associated device information of the terminal device is still updated and changed, in one optional embodiment, the method further includes:
and receiving and storing third associated device information sent by the first terminal device, wherein the third associated device information indicates the change update of the associated device of the first terminal device.
In this embodiment, the bluetooth device may receive, at any time, third associated device information sent by the first terminal device, where the third associated device information refers to associated device information obtained by updating the associated device of the first terminal device after the bluetooth connection is established between the first terminal device and the bluetooth device, so as to determine the updated associated device information corresponding to the first terminal device. Optionally, the first terminal device may generate third associated device information when detecting that the associated device changes, and send the third associated device information to the bluetooth device; or, the bluetooth device may further send an acquisition request of the associated device to the first terminal device before performing a determination operation of the associated device of the first terminal device based on the associated device information to acquire third associated device information returned by the first terminal device in response to the acquisition request, so that the bluetooth device updates the locally stored associated device information according to the third associated device information.
In this embodiment, the bluetooth device may receive the third associated device information sent by the first terminal device, and update the local associated information according to the third associated device information, so as to ensure 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.
In order to further make the handover connection more effective in the case that it is determined that the second terminal device is the associated device of the first terminal device, in an alternative embodiment, as shown in fig. 5, if the second terminal device is the associated device of the first terminal device, in response to the connection request, the bluetooth connection with the first terminal device is disconnected and the bluetooth connection with the second terminal device is established, which includes:
step 501, if the second terminal device is the associated device of the first terminal device, determining whether the second terminal device is the terminal device which has been disconnected from the bluetooth device last time.
Wherein, the last disconnection from the bluetooth device refers to the terminal device which is disconnected from the bluetooth device for the last time determined based on the time domain dimension. The bluetooth device may record the time when it establishes bluetooth connection with each terminal device and/or the time when it disconnects bluetooth, further, the bluetooth device may generate a record table based on the recorded time when it establishes bluetooth connection with each terminal device and the time when it disconnects bluetooth, where the record table includes the device identifier of each terminal device and its corresponding time when establishing bluetooth connection and time when disconnecting bluetooth connection, so that, in the case that the bluetooth device determines that the second terminal device is the associated device of the first terminal device, the bluetooth device acquires the device identifier of the second terminal device, and based on the device identifier of the terminal device which last disconnects bluetooth connection and the device identifier of the second terminal device in the record table, determines whether the second terminal device is the terminal device which last disconnects bluetooth connection with the bluetooth device, exemplarily, if the device identifier of the terminal device which last disconnects bluetooth connection is consistent with the device identifier of the second terminal device, determining that the second terminal equipment is the terminal equipment which is disconnected with the Bluetooth equipment for the last time; if the device identifier of the terminal device that has last disconnected from the bluetooth connection is not consistent with the device identifier of the second terminal device, it is determined that the second terminal device is not the terminal device that has last disconnected from the bluetooth connection, which is not limited in this embodiment.
Step 502, if the second terminal device is not the terminal device which has been disconnected from the bluetooth device for the last time, responding to the connection request, disconnecting the bluetooth connection with the first terminal device, and establishing the bluetooth connection with the second terminal device.
In this embodiment, if the bluetooth device determines that the second terminal device is not the terminal device that has been disconnected from the bluetooth device most recently, that is, the second terminal device is not the last terminal device that has established the bluetooth connection with the bluetooth device, in this case, a situation that the second terminal device spontaneously sends a connection request to the bluetooth device multiple times in a short period is excluded, and in this case, the bluetooth device responds to the connection request, disconnects the bluetooth connection with the first terminal device, and establishes the bluetooth connection with the second terminal device.
In this embodiment, the bluetooth device responds to the connection request to disconnect the bluetooth connection with the first terminal device and establish the bluetooth connection with the second terminal device when determining that the second terminal device is not the terminal device that was disconnected from the bluetooth device most recently, thereby avoiding the second terminal device from frequently establishing a connection with the bluetooth device in a short time and further optimizing user experience.
In the above step 501, in a case that the bluetooth device determines whether the second terminal device is the terminal device that has been disconnected from the bluetooth device most recently, there is another scenario, and in an alternative embodiment, as shown in fig. 6, the method further includes:
step 601, if the second terminal device is the terminal device which has been disconnected from the bluetooth device last time, acquiring a time difference between the moment of disconnecting from the bluetooth device last time and the current moment.
In this embodiment, if the bluetooth device determines that the second terminal device is the terminal device that has been disconnected from the bluetooth device most recently, in order to avoid a situation that the second terminal device frequently sends a connection request to the bluetooth device in a short time, the bluetooth device needs to determine whether a time difference between a time of the last disconnection of the second terminal device and a time of a new connection request initiated currently satisfies a preset condition. Alternatively, the bluetooth device may obtain the time of the last disconnection from the bluetooth device based on the log table in the above embodiment, and obtain the current time from the local clock module, so as to calculate the time difference between the time of the last disconnection from the bluetooth device and the current time.
Step 602, if the time difference is greater than the time difference threshold, responding to the connection request, disconnecting the bluetooth connection with the first terminal device, and establishing the bluetooth connection with the second terminal device.
In this embodiment, the time difference threshold may be 1 hour, 3 hours, 5 hours, 1 day, etc., and if the time difference is greater than the time difference threshold, it indicates that the second terminal device is the terminal device that has disconnected the bluetooth connection from the bluetooth device last time, but has been separated from the last time of disconnecting the bluetooth connection by a long time, and the connection request initiated to the bluetooth device may be considered as not an autonomous initiation request but an actual initiation request.
Step 603, if the time difference is not greater than the time difference threshold, the connection request is not responded.
In this embodiment, if the time difference is not greater than the time difference threshold, there may be a situation that the second terminal device automatically triggers connection, that is, the connection request sent by the second terminal device to the bluetooth device is not due to an actual requirement, in this situation, in order to not 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, that is, the bluetooth device does not perform any response operation for the connection request sent by the second terminal device; optionally, the unresponsive connection request may further include sending a response to reject connection to the second terminal device, which is not limited in this embodiment.
In this embodiment, after determining that the second terminal device is the associated device of the first terminal device, the bluetooth device may further determine whether the second terminal device is the terminal device that frequently initiates the connection request in a short period according to parameters such as the terminal device that was disconnected from the bluetooth device most recently, the time when the second terminal device was disconnected from the bluetooth device most recently, and the like, thereby further ensuring that the connection of the second client is an effective connection, making the connection switching more accurate, and optimizing the user experience.
Optionally, in order to better adapt to the requirement of the user when the bluetooth device establishes the bluetooth connection, the method may further perform device priority determination on the terminal device initiating the connection request to the terminal device according to the local associated device information, and in one optional embodiment, the method further includes:
and under the condition that the Bluetooth device does not establish Bluetooth connection with any terminal device, if connection requests sent by at least two third terminal devices are received, determining the third terminal device with the highest priority according to the currently stored fourth associated device information, and responding to the connection request of the third terminal device with the highest priority.
In this embodiment, when the bluetooth device does not establish a connection with any terminal device, a connection request sent by at least two third terminal devices is received, the bluetooth device needs to determine, from the at least two third terminal devices, one target terminal device with which a connection is established, and in the process of determining the target terminal device, the bluetooth device may determine the target terminal device based on locally stored fourth associated device information. Here, the fourth associated device information may also be the updated associated device information finally stored to the local after the bluetooth device in the above embodiment. In the process of determining the target terminal device, the bluetooth device may determine, according to the preset device type priority, the service priority and other priorities of different dimensions, a third terminal device with the highest device type priority and/or the highest service priority as the target terminal device; a third terminal device with the highest factory serial number priority may also be determined as the target terminal device according to a preset factory serial number priority, which is not limited in this embodiment.
In this embodiment, after the bluetooth device establishes a connection with the terminal device, the associated device information of the terminal device is synchronized, that is, after the bluetooth connection with the terminal device is established, the associated device information always exists in the local storage space of the bluetooth device, and when the bluetooth reconnection is initiated by a plurality of terminal devices, the bluetooth device may determine, based on the local associated device information, the terminal device with the highest priority to establish the bluetooth connection, so that the procedure of the bluetooth device and the terminal device for reconnection is optimized to a certain extent, and the reconnection efficiency of the terminal device is improved.
The device connection switching method in this embodiment is described by taking the terminal device in fig. 1 as an example. The device connection switching method provided by the embodiment comprises the following steps:
under the condition that the first terminal equipment establishes Bluetooth connection with the Bluetooth equipment, first associated equipment information is sent to the Bluetooth equipment, so that when the Bluetooth equipment determines that the second terminal equipment is associated equipment of the first terminal equipment according to the first associated equipment information, the Bluetooth connection with the first terminal equipment is disconnected in response to a connection request sent by the second terminal equipment, and the Bluetooth connection with the second terminal equipment is established.
The bluetooth device is taken as a bluetooth device for example to explain, and in a case that the bluetooth device is a bluetooth device, the bluetooth connection established between the bluetooth device and the first terminal device is a bluetooth connection, that is, the condition that the bluetooth connection is established between the bluetooth device and the first terminal device refers to a state that the bluetooth device and the first terminal device have completed processes of ACL connection, bluetooth pairing and bluetooth connection. Under the condition of establishing Bluetooth connection, first associated device information is sent to the Bluetooth device by the first terminal device, wherein the first associated device information comprises device information of other terminal devices which can be trusted by the first terminal device. It should be noted that the other terminal devices that can be trusted may be a terminal device connected to the first terminal device, a terminal device of the same type as the first terminal device, a terminal device of the same account as the first terminal device belongs to, a terminal device in the same local area network as the first terminal device, and the like. Therefore, under the condition that the Bluetooth device can determine that the second terminal device is the associated device of the first terminal device according to the first associated device information, the Bluetooth device responds to the connection request sent by the second terminal device, disconnects the Bluetooth connection with the first terminal device, and establishes the Bluetooth connection with the second terminal device. Optionally, the device switching connection scheme executed by the bluetooth device may refer to the embodiments provided in fig. 2 to fig. 6, which is not described in detail in this embodiment.
In the device connection switching method in this embodiment, when the first terminal device establishes a bluetooth connection with the bluetooth device, first associated device information is sent to the bluetooth device, so that the bluetooth device determines, according to the first associated device information, that the second terminal device is an associated device of the first terminal device, and in response to a connection request sent by the second terminal device, disconnects the bluetooth connection with the first terminal device, and establishes the bluetooth connection with the second terminal device. In the method, after the Bluetooth device establishes Bluetooth connection, the first terminal device sends first associated device information to the Bluetooth device in time, so that the Bluetooth device can determine whether a second terminal device sending a connection request is an associated device of the first terminal device based on the first associated device information, that is, perform validity judgment on the second terminal device sending the connection request, and respond to the connection request of the second terminal device when the second terminal device is determined to be the associated device of the first terminal device, that is, when the second terminal device is determined to be a valid device, so as to avoid the problem of current service interruption of the Bluetooth device caused by the connection request initiated by an illegal terminal device to the Bluetooth device, and further, since the second terminal device is an associated device of the first terminal device, that is, the second terminal device is a default valid 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.
To better explain the above method, as shown in fig. 7, this embodiment provides a device connection switching method involving interaction between a bluetooth device, a first terminal device, and a second terminal device, which specifically includes:
step 101, under the condition that a Bluetooth device establishes Bluetooth connection with a first terminal device, the first terminal device synchronizes first associated device information to the Bluetooth device;
step 102, the Bluetooth device determines whether a currently executed service exists; if not, go to step 103; if yes, go to step 104;
103, enabling a connection preemption mode by the Bluetooth equipment, receiving a connection request sent by second terminal equipment, responding to the connection request, disconnecting the Bluetooth connection with the first terminal equipment, and establishing the Bluetooth connection with the second terminal equipment;
step 104, judging whether the first terminal equipment has associated equipment information, if so, executing step 105; if not, go to step 112;
105, enabling a connection preemption mode by the Bluetooth equipment, receiving a connection request sent by the second terminal equipment, and updating first associated equipment information from the first terminal equipment to obtain the updated first associated equipment information;
step 106, determining whether the second terminal equipment is the associated equipment of the first terminal equipment or not according to the equipment identifier and the updated first associated equipment information; if the device is a related device, go to step 107; if not, go to step 112;
step 107, under the condition that the second terminal device is the associated device of the first terminal device, judging whether the second terminal device is the terminal device which is disconnected with the Bluetooth device for the last time; if not, go to step 108; if yes, go to step 109;
step 108, responding to the connection request, disconnecting the Bluetooth connection with the first terminal device, and establishing the Bluetooth connection with the second terminal device;
step 109, acquiring the time difference between the moment of disconnecting the Bluetooth device for the last time and the current moment;
step 110, judging whether the time difference is greater than a time difference threshold value, if so, executing step 112; if not, go to step 112;
step 111, responding to the connection request, disconnecting the Bluetooth connection with the first terminal device, and establishing the Bluetooth connection with the second terminal device;
and step 112, the Bluetooth equipment forbids the connection robbing mode and does not respond to the connection request.
In this embodiment, after the bluetooth connection is established between the bluetooth device and the first terminal device, when the bluetooth device determines that the service of the first terminal device is not currently executed, the bluetooth device is in a connection preemption allowing mode, so as to receive a connection request of the second terminal device, and then determine whether to respond to the connection request of the second terminal device according to the first associated device information sent by the first terminal device, the terminal device information of the bluetooth device which is disconnected for the last time, and the like, and judge conditions for multiple times, so that when the bluetooth device performs connection switching, the completeness of interaction with the first terminal device is ensured to the maximum extent, the legality of the second terminal device is also ensured to the maximum extent, so that the bluetooth device can realize switching connection of legal terminal devices in a safe and effective scene, and user experience is optimized.
The implementation principle and technical effect of the device connection switching method provided by the above embodiment are similar to those of the method embodiment, and are not described herein again.
It should be understood that although the various steps in the flow charts of fig. 2-7 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2-7 may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performance of the sub-steps or stages is not necessarily sequential, but may be performed in turn or alternating with other steps or at least some of the sub-steps or stages of other steps.
Fig. 8 is a block diagram of a device connection switching apparatus according to an embodiment. As shown in fig. 8, the apparatus includes:
the receiving module 01 is used for receiving a connection request sent by a second terminal device under the condition that Bluetooth connection is established with a first terminal device; the connection request comprises a device identification of the second terminal device;
a determining module 02, configured to determine whether the second terminal device is a related device of the first terminal device according to the first related device information of the first terminal device and the device identifier of the second terminal device included in the received connection request;
the executing module 03 is configured to, if the second terminal device is a related device of the first terminal device, respond to the connection request, disconnect the bluetooth connection with the first terminal device, and establish the bluetooth connection with the second terminal device.
In one optional embodiment, the receiving module 01 is configured to receive a connection request sent by the second terminal device when the bluetooth device enables the connection preemption mode; the connection preemption mode indicates that the associated device of the first terminal device is allowed to preempt the bluetooth connection between the bluetooth device and the first terminal device.
In one optional embodiment, the executing module 03 is configured to determine, when a bluetooth connection is established with the first terminal device, whether the bluetooth device is executing a service of the first terminal device; the bluetooth device enables the preemptive connection mode without performing a service of the first terminal device.
In an alternative embodiment, the executing module 03 is configured to start a page scanning function of the bluetooth device, or enable the bluetooth device to respond to the connection request.
In one optional embodiment, the executing module 03 is configured to disable the contention mode by the bluetooth device while the service of the first terminal device is being executed.
In an alternative embodiment, the executing module 03 is configured to turn off a page scanning function of the bluetooth device, or prohibit the bluetooth device from responding to the connection request.
In one optional embodiment, the executing module 03 is configured to further determine whether an associated device exists in the first terminal device when the bluetooth device is executing a service of the first terminal device; and under the condition that the first terminal equipment has the associated equipment, the Bluetooth equipment enables the connection robbing mode.
In one optional embodiment, the executing module 03 is configured to, in a case that the first terminal device does not have an associated device, disable the contention mode by the bluetooth device, and the bluetooth device does not respond to the connection request sent by the second terminal device.
In an optional embodiment, the receiving module 01 is further configured to receive second associated device information sent by the second terminal device after the bluetooth connection is established with the second terminal device.
In an 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.
In an optional embodiment, the receiving module 01 is further configured to receive first associated device information sent by the first terminal device, when the bluetooth device establishes a bluetooth connection with the first terminal device.
In an optional embodiment, the receiving module 01 is further configured to receive and store third associated device information sent by the first terminal device, where the third associated device information is used to indicate a change update of an associated device of the first terminal device.
In one optional embodiment, the executing module 03 is configured to, in a case that the second terminal device is an associated device of the first terminal device, determine whether the second terminal device is a terminal device that has been disconnected from the bluetooth device last time; if the second terminal equipment is not the terminal equipment which is disconnected with the Bluetooth equipment for the last time, responding to the connection request, disconnecting the Bluetooth connection with the first terminal equipment and establishing the Bluetooth connection with the second terminal equipment
In one optional embodiment, the executing module 03 is configured to, when the second terminal device is a terminal device that has been disconnected from the bluetooth device last time, obtain a time difference between a time of the disconnection from the bluetooth device last time and a current time; if the time difference is larger than the time difference threshold value, responding to the connection request, disconnecting the Bluetooth connection with the first terminal equipment, and establishing the Bluetooth connection with the second terminal equipment; if the time difference is not greater than the time difference threshold, the connection request is not responded to.
In an optional embodiment, the first associated device information includes at least one of:
device information of the terminal device connected to the first terminal device;
device information of a terminal device of the same type as the first terminal device;
and the equipment information of the terminal equipment of the same account number with the first terminal equipment.
Fig. 9 is a block diagram showing a configuration of a device connection switching apparatus according to another embodiment. As shown in fig. 9, the apparatus includes:
the sending module 11 is configured to send first associated device information to the bluetooth device when the bluetooth connection is established between the first terminal device and the bluetooth device, so that when the bluetooth device determines that the second terminal device is the associated device of the first terminal device according to the first associated device information, the bluetooth connection with the first terminal device is disconnected in response to a connection request sent by the second terminal device, and the bluetooth connection with the second terminal device is established.
The division of each module in the device connection switching apparatus is merely used for illustration, and in other embodiments, the device connection switching apparatus may be divided into different modules as needed to complete all or part of the functions of the device connection switching apparatus.
For the specific limitation of the device connection switching apparatus, reference may be made to the above limitation on the device connection switching method, which is not described herein again. The respective modules in the above-described device connection switching apparatus may be wholly or partially implemented by software, hardware, and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
Fig. 10 is a schematic diagram of an internal structure of an electronic device in one embodiment. The electronic device can be an intelligent electronic device comprising a Bluetooth module, for example, any terminal device such as a Bluetooth headset, a mobile phone, a tablet computer, a notebook computer, a desktop computer, a vehicle-mounted computer and a wearable device. The electronic device includes a processor and a memory connected by a system bus. The processor may include one or more processing units, among others. The processor may be a CPU (Central Processing Unit), a DSP (Digital Signal processor), or the like. 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 a processor to implement a device connection switching method provided in the following embodiments. The internal memory provides a cached execution environment for the operating system computer programs in the non-volatile storage medium.
The implementation of each module in the device connection switching apparatus provided in the embodiments of the present application may be in the form of a computer program. The computer program may be run on a terminal or a server. Program modules constituted by such computer programs may be stored on the memory of the electronic device. Which when executed by a processor, performs the steps of the method described in the embodiments of the present application.
The embodiment of the application also provides a computer readable storage medium. One or more non-transitory computer-readable storage media containing computer-executable instructions that, when executed by one or more processors, cause the processors to perform the steps of the device connection switching method.
Embodiments of the present application also provide a computer program product containing instructions that, when run on a computer, cause the computer to perform a device connection switching method.
Any reference to memory, storage, database, or other medium used herein may include non-volatile and/or volatile memory. The nonvolatile Memory may include a ROM (Read-Only Memory), a PROM (Programmable Read-Only Memory), an EPROM (Erasable Programmable Read-Only Memory), an EEPROM (Electrically Erasable Programmable Read-Only Memory), or a flash Memory. Volatile Memory can include RAM (Random Access Memory), which acts as 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 DDR SDRAM (Double Data Rate Synchronous Random Access Memory), ESDRAM (Enhanced Synchronous Dynamic Random Access Memory), SLDRAM (Synchronous Link Dynamic Random Access Memory), RDRAM (Random Dynamic Random Access Memory), and DRmb DRAM (Dynamic Random Access Memory).
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present application. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (21)

1. A device connection switching method is applied to a Bluetooth device, and comprises the following steps:
under the condition of establishing Bluetooth connection with first terminal equipment, receiving a connection request sent by second terminal equipment; the connection request comprises a device identification of the second terminal device;
determining whether the second terminal equipment is the associated equipment of the first terminal equipment or not according to the first associated equipment information of the first terminal equipment and the equipment identifier of the second terminal equipment included in the received connection request;
and if the second terminal equipment is the associated equipment of the first terminal equipment, responding to the connection request, disconnecting the Bluetooth connection with the first terminal equipment and establishing the Bluetooth connection with the second terminal equipment.
2. The method of claim 1, wherein the receiving the connection request sent by the second terminal device comprises:
receiving a connection request sent by the second terminal equipment under the condition that the Bluetooth equipment enables the connection preemption mode; the connection preemption mode represents that the associated equipment of the first terminal equipment is allowed to preempt the Bluetooth connection between the Bluetooth equipment and the first terminal equipment.
3. The method of claim 2, further comprising:
under the condition of establishing Bluetooth connection with the first terminal equipment, judging whether the Bluetooth equipment executes the service of the first terminal equipment or not;
and if the Bluetooth equipment does not execute the service of the first terminal equipment, enabling the connection preempting mode by the Bluetooth equipment.
4. The method according to claim 3, wherein the enabling of the connection preemption mode by the Bluetooth device specifically comprises:
starting a paging scanning function of the Bluetooth equipment;
or enabling the Bluetooth device to respond to a connection request.
5. The method of claim 3, further comprising:
and if the Bluetooth equipment is executing the service of the first terminal equipment, the Bluetooth equipment forbids the connection robbing mode.
6. The method according to claim 5, wherein the bluetooth device disables the connection preemption mode, specifically comprising:
turning off a page scanning function of the Bluetooth device;
or forbidding the Bluetooth equipment to respond to the connection request.
7. The method of claim 3, further comprising:
if the Bluetooth equipment is executing the service of the first terminal equipment, further judging whether the first terminal equipment has associated equipment;
and if the first terminal equipment has associated equipment, enabling the connection preempting mode by the Bluetooth equipment.
8. The method of claim 7, further comprising:
and if the first terminal equipment does not have associated equipment, the Bluetooth equipment prohibits the connection robbing mode, and the Bluetooth equipment does not respond to the connection request sent by the second terminal equipment.
9. The method of claim 1, further comprising:
and after the Bluetooth connection with the second terminal equipment is established, receiving second associated equipment information sent by the second terminal equipment.
10. The method of claim 9, further comprising:
and replacing the first associated equipment information stored by the Bluetooth equipment with the second associated equipment information.
11. The method according to any one of claims 1-6, further comprising:
and receiving the first associated device information sent by the first terminal device under the condition that the Bluetooth device establishes Bluetooth connection with the first terminal device.
12. The method according to claim 11, wherein after the step of receiving the first associated device information sent by the first terminal device, the method further comprises:
and receiving third associated device information sent by the first terminal device, wherein the third associated device information is used for indicating the change update of the associated device of the first terminal device.
13. The method according to any one of claims 1 to 6, wherein if the second terminal device is an associated device of the first terminal device, disconnecting the Bluetooth connection with the first terminal device and establishing the Bluetooth connection with the second terminal device in response to the connection request comprises:
if the second terminal equipment is the associated equipment of the first terminal equipment, judging whether the second terminal equipment is the terminal equipment which is disconnected with the Bluetooth equipment at the latest time;
and if the second terminal equipment is not the terminal equipment which is disconnected with the Bluetooth equipment for the last time, responding to the connection request, disconnecting the Bluetooth connection with the first terminal equipment, and establishing the Bluetooth connection with the second terminal equipment.
14. The method of claim 13, further comprising:
if the second terminal equipment is the terminal equipment which is disconnected with the Bluetooth equipment for the last time, acquiring the time difference between the moment of disconnection with the Bluetooth equipment for the last time and the current moment;
if the time difference is larger than a time difference threshold value, responding to the connection request, disconnecting the Bluetooth connection with the first terminal device, and establishing the Bluetooth connection with the second terminal device;
and if the time difference is not larger than the time difference threshold value, not responding to the connection request.
15. The method of claim 1, wherein the first associated device information comprises at least one of:
device information of the terminal device connected to the first terminal device;
device information of a terminal device of the same type as the first terminal device;
and the equipment information of the terminal equipment of the same account number as the first terminal equipment.
16. A device connection switching method is applied to a terminal device, and comprises the following steps:
under the condition that a first terminal device establishes Bluetooth connection with a Bluetooth device, first associated device information is sent to the Bluetooth device, so that the Bluetooth device responds to a connection request sent by a second terminal device when the Bluetooth device determines that the second terminal device is the associated device of the first terminal device according to the first associated device information, the Bluetooth connection with the first terminal device is disconnected, and the Bluetooth connection with the second terminal device is established.
17. A device connection switching system, comprising:
the first terminal equipment is used for sending first associated equipment information to the Bluetooth equipment under the condition of keeping connection with the Bluetooth equipment;
the Bluetooth device is used for receiving a connection request sent by a second terminal device under the condition of keeping connection with the first terminal device; the connection request comprises a device identification of the second terminal device; determining whether the second terminal equipment is the associated equipment of the first terminal equipment or not according to the first associated equipment information of the first terminal equipment and the equipment identifier of the second terminal equipment included in the received connection request; and if the second terminal equipment is the associated equipment of the first terminal equipment, responding to the connection request, disconnecting the Bluetooth connection with the first terminal equipment and establishing the Bluetooth connection with the second terminal equipment.
18. An apparatus connection switching apparatus, characterized in that the apparatus comprises:
the receiving module is used for receiving a connection request sent by second terminal equipment under the condition of establishing Bluetooth connection with first terminal equipment; the connection request comprises a device identification of the second terminal device;
a determining module, configured to determine whether the second terminal device is a related device of the first terminal device according to first related device information of the first terminal device and a device identifier of the second terminal device included in the received connection request;
and the execution module is used for responding to the connection request, disconnecting the Bluetooth connection with the first terminal equipment and establishing the Bluetooth connection with the second terminal equipment if the second terminal equipment is the associated equipment of the first terminal equipment.
19. An apparatus connection switching apparatus, characterized in that the apparatus comprises:
the sending module is used for sending first associated device information to the Bluetooth device under the condition that the Bluetooth connection is established between a first terminal device and the Bluetooth device, so that the Bluetooth device responds to a connection request sent by a second terminal device when the Bluetooth device determines that the second terminal device is the associated device of the first terminal device according to the first associated device information, the Bluetooth connection with the first terminal device is disconnected, and the Bluetooth connection with the second terminal device is established.
20. An electronic device, comprising a communication module, a memory and a processor, wherein the memory stores a computer program; the computer program, when executed by the processor, causes the processor to perform the steps of the device connection switching method of any one of claims 1 to 16.
21. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the device connection switching method according to any one of claims 1 to 16.
CN202111447052.XA 2021-11-30 2021-11-30 Device connection switching method and device, electronic device and computer readable storage medium Pending CN114040465A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202111447052.XA CN114040465A (en) 2021-11-30 2021-11-30 Device connection switching method and device, electronic device and computer readable storage medium
PCT/CN2022/119656 WO2023098234A1 (en) 2021-11-30 2022-09-19 Device connection switching method and apparatus, and electronic device and computer-readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111447052.XA CN114040465A (en) 2021-11-30 2021-11-30 Device connection switching method and device, electronic device and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN114040465A true CN114040465A (en) 2022-02-11

Family

ID=80139338

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111447052.XA Pending CN114040465A (en) 2021-11-30 2021-11-30 Device connection switching method and device, electronic device and computer readable storage medium

Country Status (2)

Country Link
CN (1) CN114040465A (en)
WO (1) WO2023098234A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023098233A1 (en) * 2021-11-30 2023-06-08 Oppo广东移动通信有限公司 Device connection switching method and apparatus, electronic device, and computer readable storage medium
WO2023098234A1 (en) * 2021-11-30 2023-06-08 Oppo广东移动通信有限公司 Device connection switching method and apparatus, and electronic device and computer-readable storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110191442A (en) * 2019-04-18 2019-08-30 华为技术有限公司 A kind of Bluetooth connecting method, equipment and system
CN111246441A (en) * 2020-02-26 2020-06-05 深圳市岍丞技术有限公司 Method, system and storage medium for connecting Bluetooth headset and terminal
CN112399396A (en) * 2021-01-19 2021-02-23 深圳市汇顶科技股份有限公司 Bluetooth connection switching method, Bluetooth chip and Bluetooth device
CN113127190A (en) * 2019-12-31 2021-07-16 华为技术有限公司 Method for occupying equipment and electronic equipment
CN113556715A (en) * 2021-07-02 2021-10-26 Oppo广东移动通信有限公司 Device connection method and apparatus, computer readable medium, and electronic device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111741456A (en) * 2020-06-17 2020-10-02 成都极米科技股份有限公司 Bluetooth device, Bluetooth preemption method and device thereof, and computer-readable storage medium
CN114040465A (en) * 2021-11-30 2022-02-11 Oppo广东移动通信有限公司 Device connection switching method and device, electronic device and computer readable storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110191442A (en) * 2019-04-18 2019-08-30 华为技术有限公司 A kind of Bluetooth connecting method, equipment and system
CN113127190A (en) * 2019-12-31 2021-07-16 华为技术有限公司 Method for occupying equipment and electronic equipment
CN111246441A (en) * 2020-02-26 2020-06-05 深圳市岍丞技术有限公司 Method, system and storage medium for connecting Bluetooth headset and terminal
CN112399396A (en) * 2021-01-19 2021-02-23 深圳市汇顶科技股份有限公司 Bluetooth connection switching method, Bluetooth chip and Bluetooth device
CN113556715A (en) * 2021-07-02 2021-10-26 Oppo广东移动通信有限公司 Device connection method and apparatus, computer readable medium, and electronic device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023098233A1 (en) * 2021-11-30 2023-06-08 Oppo广东移动通信有限公司 Device connection switching method and apparatus, electronic device, and computer readable storage medium
WO2023098234A1 (en) * 2021-11-30 2023-06-08 Oppo广东移动通信有限公司 Device connection switching method and apparatus, and electronic device and computer-readable storage medium

Also Published As

Publication number Publication date
WO2023098234A1 (en) 2023-06-08

Similar Documents

Publication Publication Date Title
CN114125803A (en) Device connection switching method and device, electronic device and computer readable storage medium
US20220312166A1 (en) Network Access Method, Device, and System
WO2023098234A1 (en) Device connection switching method and apparatus, and electronic device and computer-readable storage medium
US10485034B2 (en) Method, device and system for accessing wireless network
US11096051B2 (en) Connection establishment method, device, and system
RU2632161C2 (en) Method and device for providing information
US20170141932A1 (en) Internet Access Traffic Sharing Method, Device and Terminal
CN108781473B (en) Method and equipment for sharing files among different terminals
CN110519306B (en) Equipment access control method and device of Internet of things
CN106470115B (en) Security configuration method, related device and system
CN101340444A (en) Fireproof wall and server policy synchronization method, system and apparatus
US9628567B2 (en) Methods and systems for efficient discovery of devices in a peer-to-peer network
CN115086481B (en) Incoming call reminding method and electronic equipment
KR101827724B1 (en) Method and device for marking unknown number
CN105916100A (en) Heartbeat packet agency method, device and communication system
WO2016082656A1 (en) Method and device for mobile terminal to select a resident cell
CN113938971A (en) Device connection switching method and device, electronic device and computer readable storage medium
CN110336794B (en) Intranet access method, system and related device
CN113452770B (en) Data synchronization method, device, computer equipment and storage medium
CN105282830A (en) Network access method and mobile terminal
CN116647572B (en) Access endpoint switching method, device, electronic equipment and storage medium
CN108712280B (en) Network function management method and device, storage medium and intelligent terminal
CN110753308A (en) Positioning device and method for positioning device
US20230096372A1 (en) Localized authorization for secure communication
CN110324826B (en) Intranet access method and related device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination