WO2023098235A1 - 设备连接切换方法、装置、电子设备和计算机可读存储介质 - Google Patents
设备连接切换方法、装置、电子设备和计算机可读存储介质 Download PDFInfo
- Publication number
- WO2023098235A1 WO2023098235A1 PCT/CN2022/119666 CN2022119666W WO2023098235A1 WO 2023098235 A1 WO2023098235 A1 WO 2023098235A1 CN 2022119666 W CN2022119666 W CN 2022119666W WO 2023098235 A1 WO2023098235 A1 WO 2023098235A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- bluetooth
- terminal device
- connection
- terminal
- connection request
- Prior art date
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W4/00—Services specially adapted for wireless communication networks; Facilities therefor
- H04W4/80—Services using short range communication, e.g. near-field communication [NFC], radio-frequency identification [RFID] or low energy communication
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W12/00—Security arrangements; Authentication; Protecting privacy or anonymity
- H04W12/50—Secure pairing of devices
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W76/00—Connection management
- H04W76/10—Connection setup
- H04W76/14—Direct-mode setup
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W76/00—Connection management
- H04W76/10—Connection setup
- H04W76/18—Management of setup rejection or failure
Definitions
- the present application relates to the field of communication technology, and in particular, relates to a device connection switching method, device, electronic device, and computer-readable storage medium.
- Bluetooth devices With the enrichment of people's life content, users have more and more electronic devices, and the technology of Bluetooth devices is also advancing rapidly. In real life, the same Bluetooth device may be switched to connect with different terminal devices. In order to provide users with a more convenient switching experience, Bluetooth devices often need to support the grab connection mode.
- Embodiments of the present application provide a device connection switching method, device, electronic device, and computer-readable storage medium, which can solve the problem of unreasonable terminal preemption in the prior art, and can also improve data security of terminals and Bluetooth devices.
- a device connection switching method includes:
- the second terminal device is the terminal device that disconnected from the Bluetooth device last time, it does not respond to the connection request.
- a device for connecting Bluetooth devices which includes:
- a receiving module configured to receive a connection request sent by the second terminal device when a Bluetooth connection is established with the first terminal device
- a judging module configured to judge whether the second terminal device is the terminal device that was last disconnected from the Bluetooth device
- the execution module is configured to not respond to the connection request if the second terminal device is the terminal device that disconnected from the Bluetooth device last time.
- an electronic device including a memory and a processor, wherein a computer program is stored in the memory; when the computer program is executed by the processor, the processor executes the method described in the first aspect Device connection switching method.
- a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the device connection switching method described in the above-mentioned first aspect is implemented.
- the device connection switching method, device, electronic device, and computer-readable storage medium described above receive a connection request sent by the second terminal device when a Bluetooth connection is established with the first terminal device, and determine whether the second terminal device is the most recent connection with the first terminal device.
- the terminal device disconnected from the Bluetooth device does not respond to the connection request if the second terminal device is the terminal device disconnected from the Bluetooth device last time.
- the Bluetooth device after the Bluetooth device establishes a Bluetooth connection with the first terminal device, when receiving a connection request from the second terminal device, by judging whether the second terminal device is the device that disconnected from the Bluetooth device last time, After the second terminal device is the device that disconnected from the Bluetooth device last time, it does not respond to the connection request of the second terminal device, which prevents the second client from frequently reconnecting with the Bluetooth device after disconnecting from the Bluetooth device.
- the problem affecting the service interaction of the currently connected first terminal device ensures the service interaction between the Bluetooth device and the first terminal device, optimizes the process of connection preemption by other clients, and further optimizes user experience.
- Fig. 1 is an application environment diagram of a device connection switching method in an embodiment
- Fig. 2 is a flowchart of a device connection switching method in an embodiment
- Fig. 3 is a flowchart of a device connection switching method in another embodiment
- FIG. 4 is a flowchart of a device connection switching method in another embodiment
- FIG. 5 is a flowchart of a device connection switching method in another embodiment
- FIG. 6 is a flow chart of a device connection switching method in another embodiment
- FIG. 7 is a flow chart of a device connection switching method in another embodiment
- Fig. 8 is a structural block diagram of a device connection switching device in an embodiment
- Fig. 9 is a schematic structural diagram of an electronic device in an embodiment.
- first, second and the like used in this application may be used to describe various elements herein, but these elements are not limited by these terms. These terms are only used to distinguish one element from another element.
- a first client could be termed a second client, and, similarly, a second client could be termed 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.
- a bluetooth device in the prior art needs to have a one-to-many connection function, or needs to have a function of allowing switching connections with other terminal devices in a one-to-one connection scenario.
- the Bluetooth device in the prior art either directly responds to the connection request of the second terminal device, thereby interrupting the communication with the first terminal device.
- connection which affects the business execution of the first client, and also poses a threat to the data security of the Bluetooth device; or does not respond to the connection request of the second terminal device, and cannot realize the effect of switching connections of other terminal devices.
- Bluetooth technology supports a one-to-one connection between a Bluetooth device and a terminal device. Therefore, when the Bluetooth device has established a Bluetooth connection with the first terminal device, the Bluetooth device needs to support the grab connection function so that the Bluetooth device can receive other terminal devices.
- bluetooth devices that support the connection snatching function are roughly divided into two categories.
- One type of bluetooth device supports snatching connection without any restrictions, that is, when the first terminal device establishes a connection with the bluetooth device, If there is a connection request from the second terminal device to the Bluetooth device, the Bluetooth device will directly respond to the connection request, disconnect the connection with the first terminal device, establish a connection with the second terminal device, and realize the connection between the second terminal device and the Bluetooth device. of grabbing.
- Another type of bluetooth device supports connection snatching with certain restrictions.
- the bluetooth device After the bluetooth device receives the connection request initiated by the second terminal device, it sends the identity of the second terminal device (for example, a LAN address (Media Access Control Address, MAC address), cloud account) are sent to the server, and the server judges whether the second terminal device can execute the connection snatching operation according to the identification of the second terminal device, so that the Bluetooth device performs a corresponding connection switching operation according to the judgment result returned by the server.
- the bluetooth device After the bluetooth device receives the connection request initiated by the second terminal device, it sends the identity of the second terminal device (for example, a LAN address (Media Access Control Address, MAC address), cloud account) are sent to the server, and the server judges whether the second terminal device can execute the connection snatching operation according to the identification of the second terminal device, so that the Bluetooth device performs a corresponding connection switching operation according to the judgment result returned by the server.
- the identity of the second terminal device for example, a LAN address (Media Access Control Address, MAC address), cloud account
- the terminal device that has been connected to the Bluetooth device can achieve the purpose of fast connection back, for example, when the Bluetooth device has been In the case of establishing a connection with the second terminal device, the first terminal device that was disconnected from the Bluetooth device last time may frequently reconnect with the Bluetooth device, resulting in the Bluetooth device unconditionally responding to the connection request of the first client, interrupting The connection with the second terminal device seriously affects the user experience of the second terminal device.
- this embodiment provides a device connection switching method to solve the above-mentioned problems in the prior art.
- Fig. 1 is a schematic diagram of an application environment of a device connection switching method in an embodiment.
- the application environment includes a Bluetooth device 1 and at least two terminal devices 2 .
- the Bluetooth device can be a Bluetooth headset, a true wireless stereo (True Wireless Stereo, TWS) headset, a Bluetooth watch, a mobile phone, a tablet computer, a computer, a wearable device, a car Bluetooth device, etc.
- a terminal device can be a Bluetooth watch, a wearable device , mobile phones, tablets, computers, servers, etc.
- the Bluetooth headset After the Bluetooth headset establishes a Bluetooth connection with the headset, it can receive the connection establishment request sent by the Bluetooth watch by turning on the snatching function of the Bluetooth headset, so as to realize Bluetooth connection according to any of the device connection switching methods provided in the following embodiments.
- Fig. 2 is a flowchart of a device connection switching method in an embodiment.
- the device connection switching method in this embodiment is described by taking the Bluetooth device running on FIG. 1 as an example.
- the device connection switching method includes step 201 to step 203 .
- Step 201 Receive a connection request sent by a second terminal device when a Bluetooth connection is established with the first terminal device.
- the establishment of a Bluetooth connection between the Bluetooth device and the first terminal device means that the Bluetooth device and the first terminal device have completed the process of Bluetooth asynchronous transmission logical link (Asynchronous Connection-oriented, ACL) connection, Bluetooth pairing, and Bluetooth connection. status.
- ACL Bluetooth asynchronous transmission logical link
- the first terminal device can perform business interaction with the Bluetooth device.
- the Bluetooth device is a Bluetooth headset
- the first terminal device can perform services such as audio and video calls and audio playback through the Bluetooth headset.
- the Bluetooth device When the Bluetooth device establishes a 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. When connected to the first terminal device, it can directly receive the connection request sent by the second terminal device; or, for a scenario similar to the Bluetooth connection, the Bluetooth device needs to enable The connection snatching function is used to receive the connection request sent by the second terminal device.
- Step 202 judging whether the second terminal device is the terminal device disconnected from the Bluetooth device last time.
- the latest disconnection from the Bluetooth device refers to the terminal device that disconnected from the Bluetooth device for the last time determined based on the time domain dimension.
- the Bluetooth device can record the moment when it establishes a Bluetooth connection with each terminal device and/or the moment when it disconnects the Bluetooth connection. Further, the Bluetooth device can also generate the A record table, which includes the device identification of each terminal device and its corresponding Bluetooth connection establishment time and disconnection Bluetooth connection time, so that the Bluetooth device determines that the second terminal device is the associated device of the first terminal device In this case, obtain the device identification of the second terminal device, based on the device identification of the terminal device that disconnected the Bluetooth connection for the last time in the record table and the device identification of the second terminal device, determine whether the second terminal device is the last Bluetooth device The disconnected terminal device.
- the device identifier of the terminal device that disconnected the Bluetooth connection last time is consistent with the device identifier of the second terminal device, it is determined that the second terminal device is the one that disconnected the Bluetooth device last time.
- the device identifier of the terminal device may be a MAC address of the terminal device, a device serial number of the terminal device, a factory serial number of the terminal device, etc., which is not limited in this embodiment.
- Step 203 if the second terminal device is the terminal device that disconnected from the Bluetooth device last time, then do not respond to the connection request.
- the Bluetooth device determines that the second terminal device is the terminal device that disconnected from the Bluetooth device last time, that is, in step 202, the Bluetooth device determines the device identifier of the terminal device that disconnected the Bluetooth connection last time It is consistent with the device identifier of the second terminal device.
- the second terminal device may automatically trigger the operation of establishing a connection with the Bluetooth device in a short period of time, that is, the connection establishment request initiated by the second terminal device is not Actual requirements, in this case, in order to ensure that the business interaction between the Bluetooth device and the first terminal device is not interrupted, the Bluetooth device may choose not to respond to the connection request of the second client, and the non-response to the connection request here may also include sending the second client The terminal device sends a connection rejection response, or the Bluetooth device ignores the connection request and does not perform any operation, which is not limited in this embodiment.
- the connection request sent by the second terminal device is received, and it is judged whether the second terminal device is the terminal device that disconnected from the Bluetooth device last time. If the second terminal device is the terminal device disconnected from the Bluetooth device last time, it does not respond to the connection request.
- the Bluetooth device after the Bluetooth device establishes a Bluetooth connection with the first terminal device, when receiving a connection request from the second terminal device, by judging whether the second terminal device is the device that disconnected from the Bluetooth device last time, After the second terminal device is the device that disconnected from the Bluetooth device last time, it does not respond to the connection request of the second terminal device, which prevents the second client from frequently reconnecting with the Bluetooth device after disconnecting from the Bluetooth device.
- the problem affecting the service interaction of the currently connected first terminal device ensures the service interaction between the Bluetooth device and the first terminal device, optimizes the process of connection preemption by other clients, and further optimizes user experience.
- the method also includes:
- Step 301 if the second terminal device is the terminal device that disconnected from the Bluetooth device last time, acquire the time difference between the last disconnection time from the Bluetooth device and the current time.
- the Bluetooth device determines that the second terminal device is the terminal device that disconnected from the Bluetooth device last time, in order to avoid the situation that the second terminal device frequently sends connection requests to the Bluetooth device in a short period of time, the Bluetooth device needs to It is judged whether the time difference between the latest disconnection time of the second terminal device and the current time of initiating a new connection request satisfies a preset condition.
- the bluetooth device can obtain the latest time of disconnection from the bluetooth device based on the recording table in the above embodiment, and obtain the current time from the local clock module, thereby calculating the difference between the last time of the last disconnection with the bluetooth device and the current time The time difference between moments.
- Step 302 if the time difference is greater than the time difference threshold, in response to the connection request, disconnect the Bluetooth connection with the first terminal device, and establish a Bluetooth connection with the second terminal device.
- the time difference threshold can be 1 hour, 3 hours, 5 hours, 1 day, etc. If the time difference is greater than the time difference threshold, it means that the second terminal device disconnected from the Bluetooth device last time Terminal equipment, but it has been a long time since the last disconnection of the Bluetooth connection, the connection request initiated by it to the Bluetooth device can be considered not a spontaneous request, but initiated by the actual situation, in this case , excluding the situation where the second terminal device spontaneously sends a connection request to the Bluetooth device multiple times in a short period of time, in response to the connection request, disconnect the Bluetooth connection with the first terminal device, and establish a Bluetooth connection with the second terminal device .
- Step 303 if the time difference is not greater than the time difference threshold, then do not respond to the connection request.
- the Bluetooth device chooses not to respond to the connection request of the second terminal device. Similar to step 203, the Bluetooth device does not respond to the connection request. Response operation; it may also be sending a connection rejection response to the second terminal device, which is not limited in this embodiment.
- the Bluetooth device after the Bluetooth device determines that the second terminal device is the associated device of the first terminal device, it can also use parameters such as the terminal device that was last disconnected from the Bluetooth device, the time when the Bluetooth device was last disconnected, etc. Determine whether the second terminal device is a terminal device that frequently initiates connection requests in a short period of time, thereby further ensuring that the connection of the second client is an effective connection, making connection switching more accurate, and optimizing user experience.
- step 203 if the second terminal device is not the device that disconnected from the Bluetooth device last time, then exclude the second terminal device as a device that frequently sends connection requests with the Bluetooth device in a short period of time, and one of the optional In an embodiment, the method also includes:
- the second terminal device is not the terminal device disconnected from the Bluetooth device last time, disconnect the Bluetooth connection with the first terminal device in response to the connection request, and establish a Bluetooth connection with the second terminal device.
- the Bluetooth device determines that the second terminal device is not the terminal device that disconnected from the Bluetooth device last time, that is, the second terminal device is not the last terminal device that established a Bluetooth connection with the Bluetooth device, in this case.
- the situation that the second terminal device spontaneously sends a connection request to the Bluetooth device multiple times in a short period of time is excluded, and in this case, the Bluetooth device disconnects the Bluetooth connection with the first terminal device in response to the connection request, And establish a Bluetooth connection with the second terminal device.
- the Bluetooth device when the Bluetooth device determines that the second terminal device is not the terminal device that disconnected from the Bluetooth device last time, it responds to the connection request, disconnects the Bluetooth connection with the first terminal device, and establishes a connection with the second terminal device.
- the Bluetooth connection of the terminal device avoids the situation that the second terminal device frequently establishes a connection with the Bluetooth device in a short period of time, and further optimizes the user experience.
- Step 401 Determine whether the second terminal device is an associated device of the first terminal device according to the first associated device information of the first terminal device.
- the first associated device information includes device information of other terminal devices that the first terminal device can trust. It should be noted that other terminal devices that can be trusted may be terminal devices that have been connected to the first terminal device, terminal devices of the same type as the first terminal device, terminal devices that belong to the same account as the first terminal device, or terminals that are connected to the first terminal device.
- the terminal equipment is in the same local area network as the terminal equipment, etc.
- the first associated device information may include device information of a terminal device that has been connected to the first terminal device, for example, when the Bluetooth device is a Bluetooth device and the first terminal device is a mobile phone, the first terminal device
- the connected terminal device can be a smart watch, tablet computer, smart bracelet or other terminal device with a Bluetooth module that has been connected to the mobile phone within a preset historical period.
- the device information of the client includes the device name, device Type, MAC address, device serial number, factory serial number, service type, etc.
- the preset historical time period may be the past month, the past half year, etc.
- the terminal device is determined to be a legal device capable of switching connection, so as to achieve the purpose of switching connection of the Bluetooth device.
- the first associated device information may further include device information of a terminal device of the same type as the first terminal device.
- the same type may be the same as the brand type of the first terminal device.
- the first terminal device when the first terminal device is a mobile phone of brand A, the first associated device information may include other mobile phones with Bluetooth modules of brand A.
- the device information of the terminal device for example, a smart watch of brand A, a tablet computer of brand A; it should be noted that the same brand type here can be considered as specified in the factory serial number, device serial number, or terminal model of the first terminal device
- the fields are the same, where the specified field represents the brand type.
- the same type may also be the same as the terminal type of the first terminal device.
- the first associated device information includes other terminal devices whose terminal type is a mobile phone. information.
- the first associated device information may further include device information of a terminal device belonging to the same account as the first terminal device.
- the first associated device information includes the device information of other terminal devices logged in by user A, for example, the device information of the smart watch logged in by user A, the device information of the smart watch logged in by user A, The device information of the smart bracelet of user A, the device information of the tablet computer logged in by user A, etc., are not limited in this embodiment.
- the first associated device information may be information sent by the first terminal device to the Bluetooth device after establishing a Bluetooth connection with the Bluetooth device; or the first associated device information may be the first terminal device updating its corresponding associated information The information sent to the bluetooth device afterwards.
- the Bluetooth device can traverse and query the device identifier of the second terminal device and the device information in the first associated device information according to the first associated device information. identify the matched device information, then determine that the second terminal device is the associated device of the first terminal device; if there is no device information matching the device identifier of the second terminal device in the first associated device information, then determine that the second terminal device is not An associated device of the first terminal device.
- the Bluetooth device may compare the device identification field of the second terminal device with the device identification fields of all terminal devices in the first associated device information. If the field of the second terminal device is consistent with that of all terminal devices, it is determined that the second terminal device is not the first terminal device.
- the device associated with the device is not limited in this embodiment.
- Step 402 if the second terminal device is an associated device of the first terminal device, execute a step of disconnecting the Bluetooth connection with the first terminal device and establishing a Bluetooth connection with the second terminal device in response to the connection request.
- the Bluetooth device determines that the second terminal device is an associated device of the first terminal device, that is, after the Bluetooth device determines that the second terminal device is a legal device, it responds to the connection request initiated by the second terminal device and disconnects the Open a Bluetooth connection with the first terminal device, and establish a Bluetooth connection with the second terminal device.
- the Bluetooth device can also 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, Bluetooth
- the device determines that the priority of the second terminal device is lower than that of the first terminal device, in this case, the Bluetooth device can return a rejection response to the second terminal device, if the priority of the second terminal device is higher than that 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 a Bluetooth connection with the second terminal device;
- the priority can be the priority of the terminal type It can also be the priority of the service initiated by the terminal; for example, the terminal type includes mobile phone, watch, earphone, computer, etc., and the corresponding priority is mobile phone > computer > earphone > watch; the terminal type also includes brand A and brand B , brand C, etc., and its corresponding priority is brand A
- the Bluetooth device may determine whether the second terminal device that sends the connection request is an associated device of the first terminal device based on the first associated device information of the first terminal device that has established a Bluetooth connection, that is, the Bluetooth device that sends the connection request If the second terminal device is determined to be an associated device of the first terminal device, that is, if the second terminal device is determined to be a legitimate device, respond to the second terminal device's
- the connection request avoids the current business interruption of the server terminal caused by the illegal client terminal initiating a connection request to the Bluetooth device.
- the second terminal device is an associated device of the first terminal device, that is, the second terminal device It is the default legal connection device of the Bluetooth device, which guarantees the data security of the Bluetooth device, the first terminal device, and the second terminal device to a certain extent.
- the method further includes:
- the Bluetooth connection After the Bluetooth connection is established with the second terminal device, the second associated device information sent by the second terminal device is received.
- the Bluetooth device needs to receive the second associated device information of the second terminal device after the second terminal device establishes the Bluetooth connection, and the second associated device information may be the second terminal device after determining to establish a connection with the Bluetooth device The operation to be executed is triggered; the Bluetooth device may also send an associated device information request to the second terminal device, so that the second terminal device returns the second associated device information to the Bluetooth device in response to the request.
- the second associated device information includes information about devices associated with the second terminal device, for example, the second associated device information includes terminals connected to the second terminal device At least one of device information of the device, device information of a terminal device of the same type as the second terminal device, and device information of a terminal device belonging to the same account as the second terminal device.
- the Bluetooth device After the Bluetooth device receives the second associated device information, it can store the second associated device information in the storage space of the first associated device information storage, that is, merge the second associated device information with the associated information of the historical terminal device Save, which is not limited in this embodiment.
- the Bluetooth device after the Bluetooth device establishes a Bluetooth connection with the second terminal device, it promptly 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 The subsequent step of judging the associated device based on the second associated device information provides data support.
- Bluetooth devices have limited storage space, which in this case also includes:
- the second associated device information is replaced with the first associated device information saved by the Bluetooth device.
- the Bluetooth device can cover the second associated device information with the first associated device information, that is, use the second associated device information as the local final associated device information of the Bluetooth device; the Bluetooth device can also use the first associated device information
- the union of the device information and the second associated device information serves as the final local associated device information, and reduces the storage space occupied by the Bluetooth device, which is not limited in this embodiment.
- the Bluetooth device after the Bluetooth device establishes a Bluetooth connection with the second terminal device, it promptly accepts the second associated device information sent by the second terminal device, so as to update the local associated device information, and the Bluetooth device based on the associated device information
- the associated equipment judgment provides effective data support.
- the method further includes:
- the Bluetooth device When the Bluetooth device establishes a Bluetooth connection with the first terminal device, the first associated device information sent by the first terminal device is received.
- the Bluetooth device when the Bluetooth device establishes a Bluetooth connection with the first terminal device, it can receive the first associated device information of the first terminal device, and the first associated device information can be the An operation triggered after the connection is established; the bluetooth device may also send an associated device information request to the first terminal device, so that the first terminal device returns the first associated device information to the bluetooth device in response to the request.
- the Bluetooth device whenever a Bluetooth device establishes a Bluetooth connection with a new terminal device, the Bluetooth device needs to receive the associated device information sent by the current new terminal device, and update the locally stored associated device information in time, so that the locally stored Associated device information is more accurate and effective.
- the associated device of the terminal device is also being updated in real time, that is, after the terminal device establishes a connection with the Bluetooth device, its corresponding associated device information will still be updated.
- the method also includes:
- the third associated device information sent by the first terminal device is received and stored, where the third associated device information indicates a change update of the associated device of the first terminal device.
- the Bluetooth device can accept the third associated device information sent by the first terminal device at any time, where the third associated device information refers to the information of the first terminal device after the first terminal device establishes a Bluetooth connection with the Bluetooth device.
- the associated device is updated, so that the determined first terminal device corresponds to updated associated device information.
- the first terminal device may generate third associated device information when detecting that the associated device has changed, and send the third associated device information to the Bluetooth device; or, the Bluetooth device may also execute the third associated device information based on the associated device information.
- the associated device of a terminal device Before the judgment operation of the associated device of a terminal device, send an acquisition request of the associated device to the first terminal device, so as to obtain the third associated device information returned by the first terminal device in response to the acquisition request, so that the Bluetooth device according to the third associated device information to update the locally saved associated device information.
- the Bluetooth device may receive the third associated device information sent by the first terminal device, and complete the update of the local associated device 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, Therefore, the correct rate of judging the associated device based on the associated device information is improved.
- receiving the Bluetooth connection request sent by the second terminal device includes:
- the bluetooth device In the case that the bluetooth device enables the connection grabbing mode, a connection request sent by the second terminal device is received.
- the bluetooth device enabling the connection grabbing mode means that the bluetooth device can still receive connection requests sent by other terminal devices after establishing a bluetooth connection with the first terminal device.
- the bluetooth device is in the connection grabbing mode, which means that after the bluetooth device establishes a bluetooth connection with the first terminal device, the bluetooth device still exists in the state of bluetooth search visible, that is, other terminal devices can still obtain the bluetooth search.
- the Bluetooth signal of the Bluetooth device so as to initiate a Bluetooth connection request to the Bluetooth device.
- the preemption mode indicates that other terminal devices are allowed to seize the Bluetooth connection between the Bluetooth device and the first terminal device except the terminal device that was disconnected from the Bluetooth device last time.
- the Bluetooth device enables the connection grabbing mode to receive the connection request sent by the second terminal device.
- An associated device of a terminal device preempts 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 a Bluetooth connection with an associated device of the first terminal device, and implements preemptive connection switching.
- connection request initiated by the second terminal device can only be received when the Bluetooth device enables the connection grabbing mode, and whether the connection request from the second terminal device can be received is determined based on whether the Bluetooth device enables the grabbing connection mode.
- the connection request of the device reduces the number of second terminal devices that initiate connection requests to a certain extent, and also avoids the interference to the first terminal device caused by the connection request initiated by the second terminal device, which optimizes the user experience of users using Bluetooth devices .
- the method also includes:
- Step 501 in the case of establishing a Bluetooth connection with the first terminal device, determine whether the Bluetooth device is executing services of the first terminal device.
- the Bluetooth device when it determines to establish a Bluetooth connection with the first terminal device, it determines whether it is currently executing the business of the first terminal device. For example, the Bluetooth device can obtain the currently running application program, from the running Determine whether there is a service of the first terminal device in the application program; or, the Bluetooth device can 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 502 if the bluetooth device does not execute the service of the first terminal device, enable the bluetooth device to grab the connection mode.
- the Bluetooth device determines that there is no currently running application that matches the service of the first terminal device, or detects that there is currently no data interaction with the first terminal device. In this case, the Bluetooth device It is determined that the business of the first terminal device is not executed. At this time, since the current Bluetooth device has no business execution, other terminal devices switching connections will not cause business interruption to the Bluetooth device executing the business of the first terminal device. Based on this, Bluetooth The device enables the fast connection mode, that is, the Bluetooth device will enable the fast connection mode.
- the method also includes:
- Step 601 if the bluetooth device is executing the service of the first terminal device, it is judged whether there is an associated device in the first terminal device.
- the bluetooth device is executing the service of the first terminal device means that the bluetooth device is interacting with the first terminal device.
- the bluetooth device is executing the first The service of the terminal device may be that the bluetooth headset is playing the music of the mobile phone, and may also be that the mobile phone is making a voice call through the bluetooth headset.
- the Bluetooth device when the Bluetooth device determines that it is executing the business of the first client, in order to avoid that the second terminal device cannot be switched and connected across the board, the Bluetooth device can determine whether the Bluetooth device is enabled according to further judgment conditions. Grab mode.
- the further judgment condition here may be that the Bluetooth device determines whether there is an associated device for the first terminal device.
- the Bluetooth device may acquire the first associated device information of the first terminal device, and determine the first terminal device based on the first associated device information Whether there is an associated device, for example, if the first associated device information is empty, it is determined that there is no associated device in the first terminal device; if the first associated device information is not empty, it is determined that there is an associated device in the first terminal device.
- Step 602 if the first terminal device has an associated device, the Bluetooth device enables a connection grabbing mode.
- the Bluetooth device determines that there is an associated device in the first terminal device, in this case the Bluetooth device enables the snatch connection mode, the purpose is to allow the Bluetooth device to receive connection requests sent by other second terminal devices, or, set The specified Bluetooth device is allowed to respond to connection requests from other terminal devices.
- the Bluetooth device especially for the case where the Bluetooth device is executing the business of the first terminal device, in order to protect the current ongoing business to the greatest extent, the Bluetooth device only controls the Bluetooth when it is determined that the first terminal device has associated devices.
- the device is in the mode of allowing connection snatching, which fundamentally avoids the problem of some irrelevant devices snatching the bluetooth device, enhances the data security of the first terminal device and the bluetooth device, and optimizes the user experience at the same time.
- the specific implementation of the bluetooth device in step 502 and step 602 to enable the connection grabbing mode includes:
- the bluetooth device enables the paging scan function of the bluetooth device refers to making the bluetooth device visible in the bluetooth search, for example, the relevant information of the bluetooth device can be displayed on the terminal device within its bluetooth signal coverage
- the paging scan function can be controlled by setting the parameter Page scan.
- the parameter value of Page scan is the first value, it means that the paging scan function of the Bluetooth device is turned on; when the parameter value of Page scan is the second value, it means that the paging scan 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 value and the second value may also be other specified characters.
- the bluetooth device enables the page scan function by setting the value of Page scan, so that when it is determined that the page scan function is enabled, the connection grabbing mode is enabled to receive the connection request initiated by the second terminal device.
- the above-mentioned paging scanning function of the Bluetooth device is described from the perspective that the Bluetooth device can receive connection requests from other terminal devices; enabling the Bluetooth device to respond to the connection request refers to allowing the Bluetooth device to receive the connection request from other terminal devices.
- Respond to connection requests from other terminal devices that is, the Bluetooth device is always in the visible state of the Bluetooth search, and can always receive connection requests sent by other terminal devices, but only when the Bluetooth device is enabled to respond to the connection request, that is, only in the Bluetooth
- the device will respond to the connection request sent by the terminal device only when the connection grabbing mode is enabled. Otherwise, it will not respond to the connection request even if it receives a connection request sent by other devices.
- the device sends a reject response or simply ignores the connection request.
- the Bluetooth device determines that there is no currently executing business of the first terminal device and/or determines that the first terminal device has an associated device, by enabling the page scanning function or allowing the Bluetooth device to respond
- the setting of the connection request enables the Bluetooth device to enable the connection grabbing mode, so that it can receive and respond to the connection requests sent by other second terminal devices. Since no business of the first terminal device is being executed, other terminal devices will not send connection requests.
- the problem of service interruption caused to the first terminal device or the Bluetooth device, or the first terminal device has an associated device, and its associated device, that is, a legal device allows the connection snatching operation. Based on this, the Bluetooth device realizes the fast switching connection of different terminal devices .
- the method further includes:
- the bluetooth device prohibits the connection snatching mode, and the bluetooth device does not respond to the connection request sent by the second terminal device.
- the Bluetooth device determines that the first terminal device does not have an associated device, that is, the first associated device information is empty, in this case, all other terminal devices can be considered as illegal devices, in order to prevent other unfamiliar second terminal devices from
- the Bluetooth device sends a connection request, and the Bluetooth device prohibits the connection grabbing mode. If the Bluetooth device is in the connection grabbing prohibited mode, the Bluetooth device will not receive the connection request sent by other terminal devices, or will not respond to the connection request of other terminal devices. That is, other terminal devices are not allowed to send connection requests to the Bluetooth device to affect the service execution of the first terminal device.
- the bluetooth device prohibits the connection snatching mode means that after the bluetooth device establishes a bluetooth connection with the first terminal device, the bluetooth device is in a state of being invisible for bluetooth search, that is, when other terminal devices are performing bluetooth search, they cannot obtain Obviously, other terminal devices cannot initiate Bluetooth connection requests to the Bluetooth device.
- the Bluetooth device cannot receive Bluetooth connection requests sent by other terminal devices; or, the Bluetooth device can receive other The connection request sent by the terminal device does not respond to the connection request sent by other terminal devices.
- the non-response here may be sending a rejection response to other terminal devices or directly ignoring the connection request.
- the Bluetooth device disables the connection mode, thereby ensuring The currently executed service operation of the first terminal device is optimized, user experience is optimized, and data security of the first terminal device and the Bluetooth device is protected to a certain extent.
- the above-mentioned bluetooth device prohibits the realization of the mode of snatching connection including:
- turning off the paging scan function of the Bluetooth device by the Bluetooth device refers to making the Bluetooth device invisible in the Bluetooth search.
- the relevant information of the Bluetooth device may not be displayed within the coverage of its Bluetooth signal. in the Bluetooth search list of the terminal device.
- the parameter value of Page scan when the parameter value of Page scan is the first value, it means that the paging scan function of the Bluetooth device is turned on; when the parameter value of Page scan is the second value, it means that the paging scan 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 value and the second value may also be other specified characters.
- the Bluetooth device disables the paging scan function by setting the value of Page scan, so that when the paging scan function is determined to be disabled, the Bluetooth device prohibits the grab connection mode, so as to refuse to receive any connection request initiated by any second terminal device .
- the above-mentioned turning off the paging scan function of the Bluetooth device is described from the perspective that the Bluetooth device cannot receive connection requests from other terminal devices; prohibiting the Bluetooth device from responding to connection requests refers to the connection requests from other terminal devices that the Bluetooth device can receive, but, The Bluetooth device does not respond to the connection request of other terminal devices, that is, the non-response to the connection request here may mean that the Bluetooth device sends a rejection response to the second terminal device or directly ignores the connection request.
- the Bluetooth device when the Bluetooth device determines that there is no associated device in the first terminal device, the Bluetooth device prohibits the connection grabbing mode by turning off the paging scanning function or prohibiting the Bluetooth device from responding to the connection request, so as not to receive or Does not respond to connection requests sent by other second terminal devices. Since the first terminal device does not have associated devices, that is, there are no other legal devices that allow the connection grabbing operation, based on this, the Bluetooth device turns off the paging scan function to make the Bluetooth device in The purpose of maintaining the service of terminal devices and Bluetooth devices can be achieved in the mode of prohibiting connection snatching, and user experience can be optimized.
- a bluetooth device when a bluetooth device establishes a bluetooth connection, in order to better adapt to the user's needs, it can also judge the device priority of the terminal device that initiates a connection request to it according to the local associated device information.
- the method also includes:
- the Bluetooth device has not established a Bluetooth connection with any terminal device, if connection requests sent by at least two third terminal devices are received, the third terminal device with the highest priority is determined according to the currently stored fourth associated device information, And respond to the connection request of the third terminal device with the highest priority.
- the Bluetooth device when the Bluetooth device has not established a connection with any terminal device and receives connection requests sent by at least two third terminal devices, the Bluetooth device needs to determine from at least two third terminal devices to establish a connection with it.
- the Bluetooth device may determine the target terminal device based on locally stored fourth associated device information.
- the fourth associated device information may also be the associated device information that is finally stored locally after being updated by the Bluetooth device in the above embodiment.
- the Bluetooth device can determine the third terminal device with the highest device type priority and/or the highest service priority according to the preset priorities of different dimensions such as device type priority and service priority as The target terminal device; it is also possible to determine the third terminal device with the highest priority of the factory serial number as the target terminal device according to the preset priority of the factory serial number, which is not limited in this embodiment.
- the Bluetooth device after the Bluetooth device establishes a connection with the terminal device, it will synchronize the associated device information of the terminal device, that is, after the Bluetooth connection is established with the terminal device, there will always be an associated device in the local storage space of the Bluetooth device Information, when multiple terminal devices initiate Bluetooth connection back, the Bluetooth device can determine the terminal device with the highest priority to establish a Bluetooth connection based on the local associated device information, which optimizes the connection process between the terminal device and the Bluetooth device to a certain extent , improve the connection efficiency of the terminal equipment.
- 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 when the Bluetooth device establishes a Bluetooth connection with the first terminal device, the first terminal device synchronizes the first associated device information with the Bluetooth device;
- Step 102 the Bluetooth device determines whether there is a service currently being executed; if not, execute step 103; if yes, execute step 104;
- Step 103 the Bluetooth device enables the connection grabbing mode, receives a connection request sent by the second terminal device, and in response to the connection request, disconnects the Bluetooth connection with the first terminal device, and establishes a connection with the second terminal device Bluetooth connection of the device;
- Step 104 judging whether the first terminal device has associated device information, if yes, execute step 105; if not, execute step 112;
- Step 105 The Bluetooth device enables the connection grabbing mode, receives a connection request sent by the second terminal device, and updates the first associated device information from the first terminal device to obtain updated first associated device information;
- Step 106 Determine whether the second terminal device is an associated device of the first terminal device according to the device identifier and the updated first associated device information; if it is an associated device, execute step 107; if not, execute step 112 ;
- Step 107 If the second terminal device is an associated device of the first terminal device, determine whether the second terminal device is the terminal device that disconnected from the Bluetooth device last time; if not, execute step 108; if yes, then Execute step 109;
- Step 108 responding to the connection request, disconnecting the Bluetooth connection with the first terminal device, and establishing a Bluetooth connection with the second terminal device;
- Step 109 obtaining the time difference between the moment when the Bluetooth device was disconnected last time and the current moment
- Step 110 judging whether the time difference is greater than the time difference threshold, if greater, execute step 112; if not greater, execute step 112;
- Step 111 in response to the connection request, disconnect the Bluetooth connection with the first terminal device, and establish a Bluetooth connection with the second terminal device;
- Step 112 the bluetooth device disables the connection snatching mode, and does not respond to the connection request.
- the Bluetooth device After the Bluetooth device establishes a Bluetooth connection with the first terminal device, when the Bluetooth device determines that the business of the first terminal device is not currently being executed, the Bluetooth device is allowed to be in the mode of allowing the connection grabbing, thereby receiving the connection of the second terminal device Request, and then according to the first associated device information sent by the first terminal device, the terminal device information of the last disconnected Bluetooth device, etc., to determine whether to respond to the connection request of the second terminal device, multiple conditional judgments, so that the Bluetooth device is in progress When the connection is switched, the completion of the interaction with the first terminal device is guaranteed to the greatest extent, and the legitimacy of the second terminal device is also guaranteed to the greatest extent, so that the Bluetooth device can realize the switching connection of the legal terminal device in a safe and effective scenario. Optimized user experience.
- steps in the flow charts in FIGS. 2-7 are displayed sequentially as indicated by the arrows, these steps are not necessarily executed sequentially in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least some of the steps in Figures 2-7 may include a plurality of sub-steps or stages, these sub-steps or stages are not necessarily performed at the same time, but may be performed at different times, these sub-steps or stages The order of execution is not necessarily performed sequentially, but may be performed alternately or alternately with at least a part of other steps or sub-steps or stages of other steps.
- Fig. 8 is a structural block diagram of a device connection switching device according to an embodiment. As shown in Figure 8, the device includes:
- the receiving module 01 is configured to receive a connection request sent by the second terminal device when a Bluetooth connection is established with the first terminal device;
- a judging module 02 configured to judge whether the second terminal device is the terminal device that was last disconnected from the Bluetooth device
- the execution module 03 is configured to not respond to the connection request if the second terminal device is the terminal device that disconnected from the Bluetooth device last time.
- the executing module 03 is further configured to obtain the time when the last time the Bluetooth device was disconnected and the current time if the second terminal device is the terminal device that disconnected from the Bluetooth device last time If the time difference is greater than the time difference threshold, then in response to the connection request, disconnect the Bluetooth connection with the first terminal device and establish a Bluetooth connection with the second terminal device; if the time difference is not greater than the time difference threshold, then do not respond to the connection ask.
- the execution module 03 is further configured to disconnect the Bluetooth connection with the first terminal device in response to the connection request if the second terminal device is not the terminal device that disconnected from the Bluetooth device last time. to connect, and establish a Bluetooth connection with the second terminal device.
- the execution module 03 is further configured to judge whether the second terminal device is an associated device of the first terminal device according to the first associated device information of the first terminal device; if the second terminal device is The associated device of the first terminal device executes the steps of disconnecting the Bluetooth connection with the first terminal device and establishing a Bluetooth connection with the second terminal device in response to the connection request.
- the receiving module 01 is further configured to receive the second associated device information sent by the second terminal device after the Bluetooth connection is established with the second terminal device.
- the receiving module 01 is further configured to replace the first associated device information saved by the Bluetooth device with the second associated device information.
- 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.
- the receiving module 01 is further configured to receive and save the third associated device information sent by the first terminal device, the third associated device information is used to indicate the change update of the associated device of the first terminal device .
- the receiving module 01 is also used to receive the connection request sent by the second terminal device when the bluetooth device enables the connecting mode; A terminal device other than the disconnected terminal device preempts the Bluetooth connection between the Bluetooth device and the first terminal device.
- the execution module 03 is also used to determine whether the Bluetooth device is executing the business of the first terminal device when the Bluetooth connection is established with the first terminal device; if the Bluetooth device is not executing the first If the service of the terminal device is not used, the Bluetooth device enables the connection grabbing mode.
- the execution module 03 is also used to determine whether the first terminal device has an associated device if the Bluetooth device is executing the service of the first terminal device; if the first terminal device has an associated device, then The bluetooth device enables the grab connection mode.
- the execution module 03 is also used to enable the paging and scanning function of the Bluetooth device; or enable the Bluetooth device to respond to the connection request.
- the execution module 03 is further configured to disable the connection grabbing mode of the Bluetooth device if the first terminal device does not have an associated device, and the Bluetooth device does not respond to the connection request sent by the second terminal device.
- the executing module 03 is further configured to disable the page scanning function of the Bluetooth device; or, prohibit the Bluetooth device from responding to the connection request.
- the first associated device information includes at least one of the following:
- each module in the above-mentioned bluetooth device connection device is only for illustration. In other embodiments, the bluetooth device connection device can be divided into different modules according to needs, so as to complete all or part of the above-mentioned bluetooth device connection device Function.
- Each module in the above-mentioned bluetooth device snatching device can be fully or partially realized by software, hardware and combinations thereof.
- the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, and can also be stored in the memory of the computer device in the form of software, so that the processor can invoke and execute the corresponding operations of the above-mentioned modules.
- Fig. 9 is a schematic diagram of the internal structure of an electronic device in one embodiment.
- the electronic device may be an intelligent electronic device including a Bluetooth module, for example, any terminal device such as a Bluetooth headset, a mobile phone, a tablet computer, a notebook computer, a desktop computer, a vehicle computer, or a wearable device.
- the electronic device includes a processor and memory connected by a system bus.
- the processor may include one or more processing units.
- the processor can be a CPU (Central Processing Unit, central processing unit) or a DSP (Digital Signal Processing, digital signal processor), etc.
- the memory may include non-volatile storage media and internal memory. Nonvolatile storage media store operating systems and computer programs.
- the computer program can be executed by a processor, so as to implement a device connection switching method provided in the following embodiments.
- the internal memory provides a high-speed running environment for the operating system computer program in the non-volatile storage medium.
- each module in the device connection switching apparatus may be in the form of a computer program.
- the computer program can run on a terminal or a server.
- the program modules constituted by the computer program can be stored in the memory of the electronic device.
- the embodiment of the present 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.
- the embodiment of the present application also provides a computer program product containing instructions, which, when running on a computer, causes the computer to execute the device connection switching method.
- Non-volatile memory can include ROM (Read-Only Memory, read-only memory), PROM (Programmable Read-only Memory, programmable read-only memory), EPROM (Erasable Programmable Read-Only Memory, erasable programmable read-only memory) Memory), EEPROM (Electrically Erasable Programmable Read-only Memory, Electrically Erasable Programmable Read-only Memory) or flash memory.
- Volatile memory can include RAM (Random Access Memory, Random Access Memory), which is used as external cache memory.
- RAM is available in various forms, such as SRAM (Static Random Access Memory, static random access memory), DRAM (Dynamic Random Access Memory, dynamic random access memory), SDRAM (Synchronous Dynamic Random Access Memory , synchronous dynamic random access memory), double data rate DDR SDRAM (Double Data Rate Synchronous Dynamic Random Access memory, double data rate synchronous dynamic random access memory), ESDRAM (Enhanced Synchronous Dynamic Random Access memory, enhanced synchronous dynamic random access memory access memory), SLDRAM (Sync Link Dynamic Random Access Memory, synchronous link dynamic random access memory), RDRAM (Rambus Dynamic Random Access Memory, bus dynamic random access memory), DRDRAM (Direct Rambus Dynamic Random Access Memory, interface dynamic random access memory) memory).
- SRAM Static Random Access Memory, static random access memory
- DRAM Dynanamic Random Access Memory, dynamic random access memory
- SDRAM Synchronous Dynamic Random Access Memory , synchronous dynamic random access memory
- double data rate DDR SDRAM Double Data Rate Synchronous Dynamic Random Access memory, double
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Security & Cryptography (AREA)
- Mobile Radio Communication Systems (AREA)
- Telephone Function (AREA)
Abstract
本申请涉及一种设备连接切换方法、装置、电子设备和计算机可读存储介质。该方法包括:在与第一终端设备建立蓝牙连接的情况下,接收第二终端设备发送的连接请求,判断第二终端设备是否为最近一次与蓝牙设备断开连接的终端设备,若第二终端设备为最近一次与蓝牙设备断开连接的终端设备,则不响应连接请求。在本方法中,蓝牙设备确定第二终端设备是最近一次与蓝牙设备断开连接的设备之后,不响应第二终端设备的连接请求,避免了第二客户端在与蓝牙设备断开连接之后,频繁与蓝牙设备再次建立连接而影响当前连接的第一终端设备的业务交互的问题,从而保证了蓝牙设备与第一终端设备的业务交互,优化了用户体验。
Description
本申请引用于2021年11月30日递交的名称为“设备连接切换方法、装置、电子设备和计算机可读存储介质”,申请号为2021114488595的中国专利申请,其通过引用被全部并入本申请。
本申请涉及通信技术领域,特别是涉及一种设备连接切换方法、装置、电子设备和计算机可读存储介质。
随着人们生活内容的丰富,用户拥有的电子设备也越来越多,蓝牙设备的技术也跟着快速进步。在实际生活中,同一个蓝牙设备可能会切换至与不同的终端设备连接,为了给用户提供更加便捷的切换体验,蓝牙设备往往需要支持抢连模式。
现有技术中,存在无任何限制的蓝牙设备的抢连方法,即,在蓝牙设备与终端设备A连接时,在接收到终端设备B的连接请求之后,中断与终端设备A的连接,实现对终端设备B的连接;此外,还存在连接过的设备在断开以后多次被动抢连的情况。
但是,上述蓝牙设备的抢连方法均存在抢占不合理,导致正常连接的蓝牙设备连接中断的问题。
发明内容
本申请实施例提供了一种设备连接切换方法、装置、电子设备和计算机可读存储介质,可以解决现有技术中终端抢占不合理的问题,同时还可以提高终端、蓝牙设备的数据安全性。
第一方面,提供一种设备连接切换方法,该方法包括:
在与第一终端设备建立蓝牙连接的情况下,接收第二终端设备发送的连接请求;
判断第二终端设备是否为最近一次与蓝牙设备断开连接的终端设备;
若第二终端设备为最近一次与蓝牙设备断开连接的终端设备,则不响应连接请求。
第二方面,提供一种蓝牙设备抢连装置,该装置包括:
接收模块,用于在与第一终端设备建立蓝牙连接的情况下,接收第二终端设备发送的连接请求;
判断模块,用于判断第二终端设备是否为最近一次与蓝牙设备断开连接的终端设备;
执行模块,用于若第二终端设备为最近一次与蓝牙设备断开连接的终端设备,则不响应连接请求。
第三方面,提供一种电子设备,包括存储器和处理器,所述存储器中储存有计算机程序;所述计算机程序被所述处理器执行时,使得所述处理器执行如第一方面所述的设备连接切换方法。
第四方面,提供一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现上述第一方面所述的设备连接切换方法。
上述设备连接切换方法、装置、电子设备和计算机可读存储介质,在与第一终端设备建立蓝牙连接的情况下,接收第二终端设备发送的连接请求,判断第二终端设备是否为最近一次与蓝牙设备断开连接的终端设备,若第二终端设备为最近一次与蓝牙设备断开连接的终端设备,则不响应连接请求。在本方法中,蓝牙设备可以在与第一终端设备建立蓝牙连接之后,在接收到第二终端设备的连接请求时,通过判断第二终端设备是否为最近一次与蓝牙设备断开连接的设备,在第二终端设备是最近一次与蓝牙设备断开连接的设备之后,不响应第二终端设备的连接请求,避免了第二客户端在与蓝牙设备断开连接之后,频 繁与蓝牙设备再次建立连接而影响当前连接的第一终端设备的业务交互的问题,从而保证了蓝牙设备与第一终端设备的业务交互,优化了其他客户端进行连接抢占的流程,进一步地优化了用户体验。
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为一个实施例中设备连接切换方法的应用环境图;
图2为一个实施例中设备连接切换方法的流程图;
图3为另一个实施例中设备连接切换方法的流程图;
图4为另一个实施例中设备连接切换方法的流程图;
图5为另一个实施例中设备连接切换方法的流程图;
图6为另一个实施例中设备连接切换方法的流程图;
图7为另一个实施例中设备连接切换方法的流程图;
图8为一个实施例中设备连接切换装置的结构框图;
图9为一个实施例中电子设备的结构示意图。
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
可以理解,本申请所使用的术语“第一”、“第二”等可在本文中用于描述各种元件,但这些元件不受这些术语限制。这些术语仅用于将第一个元件与另一个元件区分。举例来说,在不脱离本申请的范围的情况下,可以将第一客户端称为第二客户端,且类似地,可将第二客户端称为第一客户端。第一客户端和第二客户端两者都是客户端,但其不是同一客户端。
在蓝牙设备与第一终端设备连接过程中,可能存在第二终端设备向蓝牙设备发起建立连接请求的情况下。一般的,现有技术中蓝牙设备需要具有一对多连接功能,或者需要具有一对一连接场景下允许与其他终端设备进行切换连接的功能。在蓝牙设备具有一对一连接场景下允许与其他终端设备进行切换连接的功能的情况下,现有技术中的蓝牙设备要么是直接响应第二终端设备的连接请求,从而中断与第一终端设备的连接,影响第一客户端的业务执行,同时也对蓝牙设备的数据安全造成威胁;要么是不响应第二终端设备的连接请求,无法实现其他终端设备切换连接的效果。
目前蓝牙技术支持蓝牙设备与终端设备一对一连接,因此,在蓝牙设备已经与第一终端设备建立蓝牙连接的情况下,需要蓝牙设备支持抢连功能,以使蓝牙设备可以接收到其他终端设备发送的连接请求,从而根据连接请求执行相应的操作。例如,现有技术中,支持抢连功能的蓝牙设备大致分为两类,一类蓝牙设备是没有任何限制条件地支持抢连,即,当第一终端设备与蓝牙设备建立连接的情况下,若存在第二终端设备向蓝牙设备的发起连接请求,蓝牙设备会直接响应该连接请求,断开与第一终端设备的连接,建立与第二终端设备的连接,实现第二终端设备对蓝牙设备的抢连。另一类蓝牙设备是有一定限制条件地支持抢连,例如,蓝牙设备在接收到第二终端设备发起的连接请求之后,将第二终端设备的标识(例如,局域网地址(Media Access Control Address,MAC地址)、云端账号)发送至服务器,服务器根据第二终端设备的标识,对第二终端设备是否可执行抢连操作进行判别,从而蓝牙设备根据服务器返回的判别结果进行相应的连接切换操作。
上述无限制支持抢连的方法、或经由服务器进行合法判别的方法虽然都可以实现不同终端设备的切换使用蓝牙设备的目的,但是均存在一定的技术缺陷。示例性地,无论是在无限制支持抢连的场景下,还是经由服务器进行合法判别的场景下,已经与蓝牙设备连接过的终端设备均可以实现快捷回连的目的,例如,在蓝牙设备已经与第二终端设备建立连接的情况下,上次与蓝牙设备断开连接的第一终端设备可能会频繁地再与蓝牙设备进行回连,从而导致蓝牙设备无条件响应第一客户端的连接请求,中断与第二终端设备的连接,严重影响第二终端设备的用户体验。
基于此,本实施例提供一种设备连接切换方法来解决上述现有技术存在的问题。
图1为一个实施例中设备连接切换方法的应用环境示意图。如图1所示,该应用环境包括蓝牙设备1和至少两个终端设备2。其中,蓝牙设备可以为蓝牙耳机、真正无线立体声(True Wireless Stereo,TWS)耳机、蓝牙手表、手机、平板电脑、电脑、穿戴式设备、车载蓝牙设备等;终端设备可以为蓝牙手表、穿戴式设备、手机、平板电脑、电脑、服务器等。具体地,蓝牙耳机在与耳机建立蓝牙连接之后,可以通过开启蓝牙耳机的抢连功能,接收蓝牙手表发送的建立连接请求,从而根据以下实施例中提供的任意一种设备连接切换方法,实现蓝牙设备对于手机、蓝牙手表的切换连接。
图2为一个实施例中设备连接切换方法的流程图。本实施例中的设备连接切换方法,以运行于图1中的蓝牙设备上为例进行描述。如图2所示,设备连接切换方法包括步骤201至步骤203。
步骤201,在与第一终端设备建立蓝牙连接的情况下,接收第二终端设备发送的连接请求。
其中,蓝牙设备与第一终端设备建立蓝牙连接指的是蓝牙设备与第一终端设备已经完成蓝牙异步传输的逻辑链路(Asynchronous Connection-oriented,ACL)连接、蓝牙配对、蓝牙连接的过程而处于的状态。在建立蓝牙连接的情况下,第一终端设备可以与蓝牙设备进行业务交互,例如,在蓝牙设备为蓝牙耳机的情况下,第一终端设备可以通过蓝牙耳机进行音视频通话、音频播放等业务。
在蓝牙设备与第一终端设备建立蓝牙连接的情况下,蓝牙设备可以接收其他终端设备发送的连接请求。其中包括,蓝牙设备具备一对多连接功能,在与第一终端设备连接的情况下,可以直接接收第二终端设备发送的连接请求;或者,针对类似于蓝牙连接的场景,蓝牙设备需要开启允许抢连功能,从而接收第二终端设备发送的连接请求。
步骤202,判断第二终端设备是否为最近一次与蓝牙设备断开连接的终端设备。
其中,最近一次与蓝牙设备断开连接指的是基于时域维度确定的最后一次与蓝牙设备断开蓝牙连接的终端设备。蓝牙设备可以记录其与每一个终端设备建立蓝牙连接时刻和/或断开蓝牙连接的时刻,进一步地,蓝牙设备还可以基于上述记录的各终端设备建立蓝牙连接时刻与断开蓝牙连接的时刻生成记录表,该记录表中包括各个终端设备的设备标识和其对应的建立蓝牙连接时刻、断开蓝牙连接的时刻,以此,蓝牙设备在确定第二终端设备为第一终端设备的关联设备的情况下,获取第二终端设备的设备标识,基于该记录表中最后一次断开蓝牙连接的终端设备的设备标识和第二终端设备的设备标识,确定第二终端设备是否为最近一次与蓝牙设备断开连接的终端设备,示例性地,若最后一次断开蓝牙连接的终端设备的设备标识与第二终端设备的设备标识一致,则确定第二终端设备为最近一次与蓝牙设备断开连接的终端设备;若最后一次断开蓝牙连接的终端设备的设备标识与第二终端设备的设备标识不一致,则确定第二终端设备不是最近一次与蓝牙设备断开连接的终端设备。其中,示例性,终端设备的设备标识可以为终端设备的MAC地址、终端设备的设备序列号、终端设备的出厂序列号等,本实施例对此不做限定。
步骤203,若第二终端设备为最近一次与蓝牙设备断开连接的终端设备,则不响应连接请求。
在本实施例中,若蓝牙设备确定第二终端设备就是最近一次与蓝牙设备断开连接的终端设备,也即,在步骤202中,蓝牙设备确定最后一次断开蓝牙连接的终端设备的设备标识与第二终端设备的设备标识一致,在这种情况下,可以认为第二终端设备可能存在短期内自动触发与蓝牙设备发起建立连接的操作,也即,第二终端设备发起的建立连接请求并非实际需求,在这种情况下,为了保障蓝牙设备与第一终端设备的业务交互不被中断,蓝牙设备可以选择不响应第二客户端的连接请求,这里的不响应连接请求还可以包括向第二终端设备发送拒绝连接的响应,或者,蓝牙设备忽略该连接请求,不执行任何操作,本实施例对此不做限定。
上述备连接切换方法,在与第一终端设备建立蓝牙连接的情况下,接收第二终端设备发送的连接请求,判断第二终端设备是否为最近一次与蓝牙设备断开连接的终端设备,若第二终端设备为最近一次与蓝牙设备断开连接的终端设备,则不响应连接请求。在本方法中,蓝牙设备可以在与第一终端设备建立蓝牙连接之后,在接收到第二终端设备的连接请求时,通过判断第二终端设备是否为最近一次与蓝牙设备断开连接的设备,在第二终端设备是最近一次与蓝牙设备断开连接的设备之后,不响应第二终端设备的连接请求,避免了第二客户端在与蓝牙设备断开连接之后,频繁与蓝牙设备再次建立连接而影响当前连接的第一终端设备的业务交互的问题,从而保证了蓝牙设备与第一终端设备的业务交互,优化了其他客户端进行连接抢占的流程,进一步地优化了用户体验。
但是为了进一步的优化对第二终端设备的判断,确保第二终端设备不是短期内频繁与蓝牙设备发送连接请求,在其中一个可选的实施例中,如图3所示,该方法还包括:
步骤301,若第二终端设备为最近一次与蓝牙设备断开连接的终端设备,则获取最近一次与蓝牙设备断开连接的时刻与当前时刻之间的时间差。
在本实施例中,若蓝牙设备确定第二终端设备是最近一次与蓝牙设备断开连接的终端设备,为了避免第二终端设备在短时间内频繁向蓝牙设备发送连接请求的情况,蓝牙设备需要判断第二终端设备的最近一次断开连接的时刻与当前发起新的连接请求时刻直接的时间差值是否满足预设的条件。可选地,蓝牙设备可以基于上述实施例中的记录表获取最近一次与蓝牙设备断开连接的时刻,从本地时钟模块中获取当前时刻,从而计算最近一次与蓝牙设备断开连接的时刻与当前时刻之间的时间差。
步骤302,若时间差大于时间差阈值,则响应于连接请求,断开与第一终端设备的蓝牙连接,并建立与第二终端设备的蓝牙连接。
在本实施例中,时间差阈值可以为1个小时、3个小时、5个小时、1天等,若时间差大于时间差阈值,则说明第二终端设备虽然是上一次与蓝牙设备断开蓝牙连接的终端设备,但是其距离上一次断开蓝牙连接已经间隔较长时间,其向蓝牙设备发起的连接请求可以认为并不是自发的发起的请求,而是出于实际情况发起的,在这种情况下,排除了第二终端设备短期内多次向蓝牙设备自发向蓝牙设备发送连接请求的情况,响应该连接请求,断开与第一终端设备的蓝牙连接,并建立与第二终端设备的蓝牙连接。
步骤303,若时间差不大于时间差阈值,则不响应连接请求。
在本实施例中,若时间差不大于时间差阈值,可能存在第二终端设备自动触发连接的情况,也即,第二终端设备向蓝牙设备发送的连接请求,并非出于实际需求,在这种情况下,为了不影响蓝牙设备与第一终端设备的连接,蓝牙设备选择不响应第二终端设备的连接请求,与步骤203中类似的,蓝牙设备不响应连接请求可以为忽略连接请求,不做任何响应操作;也可以为向第二终端设备发送拒绝连接的响应,本实施例对此不做限定。
在本实施例中,蓝牙设备在确定第二终端设备为第一终端设备的关联设备之后,还可以根据最近一次与蓝牙设备断开连接的终端设备、最近一次与蓝牙设备断开连接时刻等参数确定第二终端设备是否为短期内频繁发起连接请求的终端设备,从而进一步地保证了第二客户端的连接为有效连接,使得连接切换更准确,优化用户体验。
在步骤203的另外一种情况下,若第二终端设备不是最近一次与蓝牙设备断开连接的设备,则排除第二终端设备为短期频繁与蓝牙设备发送连接请求的设备,在其中一个可选的实施例中,该方法还包括:
若第二终端设备不是最近一次与蓝牙设备断开连接的终端设备,则响应于连接请求,断开与第一终端设备的蓝牙连接,并建立与第二终端设备的蓝牙连接。
在本实施例中,蓝牙设备若确定第二终端设备不是最近一次与蓝牙设备断开连接的终端设备,也即,第二终端设备不是上一个与蓝牙设备建立蓝牙连接的终端设备,在这种情况下,排除了第二终端设备短期内多次向蓝牙设备自发向蓝牙设备发送连接请求的情况,在这种情况下,蓝牙设备响应该连接请求,断开与第一终端设备的蓝牙连接,并建立与第二终端设备的蓝牙连接。
在本实施例中,蓝牙设备在确定第二终端设备不是最近一次与蓝牙设备断开连接的终端设备的情况下,响应连接请求,断开与第一终端设备的蓝牙连接,并建立与第二终端设备的蓝牙连接,避免了第二终端设备短时间内频繁向蓝牙设备建立连接的情况下,进一步地优化了用户体验。
为了进一步确定第二客户端的合法性,如图4所示,在其中一个可选的实施例中,响应于连接请求之前,还包括:
步骤401,根据第一终端设备的第一关联设备信息,判断第二终端设备是否为第一终端设备的关联设备。
其中,第一关联设备信息中包括第一终端设备可以信任的其他终端设备的设备信息。需要说明的是,可以信任的其他终端设备可以为与第一终端设备连接过的终端设备、与第一终端设备类型相同的终端设备、与第一终端设备所属同一账号的终端设备、与第一终端设备处于同一局域网的终端设备等。
可选地,第一关联设备信息中可以包括与第一终端设备连接过的终端设备的设备信息,例如,在蓝牙设备为蓝牙设备、第一终端设备为手机的情况下,与第一终端设备连接过的终端设备可以为,在预设的历史时长内与手机连接过的智能手表、平板电脑、智能手环或其他具有蓝牙模块的终端设备,相应的,客户端的设备信息包括设备名称、设备类型、MAC地址、设备序列号、出厂序列号、业务类型等。预设的历史时长可以为过去一个月、过去半年等。在这种场景下,针对现有技术中终端设备若不具备账户登录的功能就无法实现连接切换的缺陷,通过本实施例提供的第一关联信息,可以实现将与第一终端设备连接过的终端设备确定为可以进行切换连接的合法设备,从而实现蓝牙设备的切换连接目的。
可选地,第一关联设备信息还可以包括与第一终端设备的类型相同的终端设备的设备信息。其中,示例性的,类型相同可以为与第一终端设备的品牌类型相同,例如,第一终端设备为品牌A手机的情况下,第一关联设备信息中可以包括品牌A的其他具有蓝牙模块的终端设备的设备信息,例如,品牌A的智能手表、品牌A的平板电脑;需要说明的是,这里品牌类型相同可以认为与第一终端设备的出厂序列号、设备序列号、或终端型号中指定字段相同,其中指定字段表示品牌类型。另外,示例性的,类型相同还可以为与第一终端设备的终端类型相同,例如,第一终端设备为手机的情况下,第一关联设备信息中包括终端类型为手机的其他终端设备的设备信息。
可选地,第一关联设备信息中还可以包括与第一终端设备所属同一账号的终端设备的设备信息。示例性的,第一终端设备的云端账号为用户A,那么第一关联设备信息中包括用户A所登录的其他终端设备的设备信息,例如,用户A登录的智能手表的设备信息、用户A登录的智能手环的设备信息、用户A登录的平板电脑的设备信息等,本实施例对此不做限定。
在本实施例中,第一关联设备信息可以为第一终端设备在与蓝牙设备建立蓝牙连接之后向蓝牙设备发送的信息;或者第一关联设备信息可以为第一终端设备更新其对应的关联 信息之后向蓝牙设备发送的信息。以此,蓝牙设备可以根据第一关联设备信息,将第二终端设备的设备标识与第一关联设备信息中的设备信息进行遍历查询,若第一关联设备信息中存在与第二终端设备的设备标识匹配的设备信息,则确定第二终端设备为第一终端设备的关联设备;若第一关联设备信息中不存在与第二终端设备的设备标识匹配的设备信息,则确定第二终端设备并非第一终端设备的关联设备。示例地,蓝牙设备可以根据第二终端设备的设备标识的字段与第一关联设备信息中的所有终端设备的设备标识字段进行比较,若存在终端设备的设备标识字段与第二终端设备的设备标识的字段一致,则确定第二终端设备为第一终端设备的关联设备;若第二终端设备的设备标识的字段与所有终端设备的设备标识字段均不一致,则确定第二终端设备不是第一终端设备的关联设备,本实施例对此不做限定。
步骤402,若第二终端设备为第一终端设备的关联设备,则执行响应于连接请求,断开与第一终端设备的蓝牙连接,并建立与第二终端设备的蓝牙连接的步骤。
在本实施例中,蓝牙设备在确定第二终端设备为第一终端设备的关联设备之后,也即,蓝牙设备确定第二终端设备为合法设备之后,响应第二终端设备发起的连接请求,断开与第一终端设备的蓝牙连接,而建立与第二终端设备的蓝牙连接。可选地,为了保证第一终端设备的用户使用蓝牙设备的用户体验,蓝牙设备还可以根据第一终端设备和第二终端设备的优先级,响应第二终端设备发起的连接请求,例如,蓝牙设备确定第二终端设备的优先级低于第一终端设备的优先级,在这种情况下,蓝牙设备可以向第二终端设备返回拒绝响应,若第二终端设备的优先级高于第一终端设备的优先级,蓝牙设备响应于第二终端设备的蓝牙连接请求,断开与第一终端设备的蓝牙连接,而建立与第二终端设备的蓝牙连接;其中,优先级可以为终端类型的优先级,也可以为终端发起业务的优先级;示例地,终端类型包括手机、手表、耳机、电脑等,其对应的优先级为手机>电脑>耳机>手表;终端类型还包括品牌A、品牌B、品牌C等,其对应的优先级为品牌A>品牌B>品牌C;业务包括通话业务、音频播放业务等,其对应的优先级为通话业务>音频播放业务,蓝牙设备可以根据预先设定的终端类型的优先级或业务的优先级,在确定第二终端设备的优先级大于第一终端设备的优先级的情况下,响应第二终端设备发起的连接请求,本实施例对此不做限定。
在本实施例中,蓝牙设备可以基于已建立蓝牙连接的第一终端设备的第一关联设备信息确定发送连接请求的第二终端设备是否为第一终端设备的关联设备,也即对发送连接请求的第二终端设备进行合法性判断,在确定第二终端设备为第一终端设备的关联设备的情况下,也即,在确定第二终端设备为合法设备的情况下,响应第二终端设备的连接请求,避免了非法客户端终端对蓝牙设备发起连接请求而导致的服务端终端当前业务中断的问题,进一步地,由于第二终端设备为第一终端设备的关联设备,也即第二终端设备是蓝牙设备默认的合法连接设备,在一定程度上保证蓝牙设备、第一终端设备、第二终端设备的数据安全性。
蓝牙设备与第二终端设备建立蓝牙连接之后,也即,蓝牙设备完成第二终端设备的切换连接之后,在其中一个可选的实施例中,该方法还包括:
在与第二终端设备建立蓝牙连接后,接收第二终端设备发送的第二关联设备信息。
在本实施例中,蓝牙设备在于第二终端设备建立蓝牙连接之后,需要接收第二终端设备的第二关联设备信息,第二关联设备信息可以为第二终端设备在确定与蓝牙设备建立连接之后触发执行的操作;也可以为蓝牙设备向第二终端设备发送关联设备信息请求,以使第二终端设备响应于该请求向蓝牙设备返回第二关联设备信息。与步骤401中第一关联设备信息类似的,第二关联设备信息中包括与第二终端设备关联的设备的信息,示例性地,第二关联设备信息中包括与第二终端设备连接过的终端设备的设备信息、与第二终端设备的类型相同的终端设备的设备信息、与第二终端设备所属同一账号的终端设备的设备信息 中至少一种信息。
在蓝牙设备接收到第二关联设备信息之后,可以将该第二关联设备信息存储至第一关联设备信息存储的存储空间中,也即,将第二关联设备信息与历史终端设备的关联信息合并保存,本实施例对此不做限定。
在本实施例中,蓝牙设备在与第二终端设备建立蓝牙连接之后,及时接收并存储第二终端设备发送的第二关联设备信息,并将第二关联设备信息存储至本地存储空间中,以为后续基于第二关联设备信息进行关联设备判断的步骤提供数据支撑。
但是,实际情况中,蓝牙设备的存储空间有限,在这种情况下,还包括:
将第二关联设备信息替换蓝牙设备保存的第一关联设备信息。
在本实施例中,蓝牙设备可以将第二关联设备信息覆盖至第一关联设备信息中,即,将第二关联设备信息作为蓝牙设备本地最终的关联设备信息;蓝牙设备也可以将第一关联设备信息与第二关联设备信息的并集作为本地最终的关联设备信息,并且减少了蓝牙设备存储空间的占用,本实施例对此不做限定。
在本实施例中,蓝牙设备在与第二终端设备建立蓝牙连接之后,及时接受第二终端设备发送的第二关联设备信息,以更新本地中的关联设备信息,为蓝牙设备基于关联设备信息进行关联设备判断提供了有效的数据支撑。
与接收第二终端设备的第二关联设备信息类似的,在其中一个可选的实施例中,该方法还包括:
在蓝牙设备与第一终端设备建立蓝牙连接的情况下,接收第一终端设备发送的第一关联设备信息。
在本实施例中,蓝牙设备在与第一终端设备建立蓝牙连接的情况下,可以接收第一终端设备的第一关联设备信息,第一关联设备信息可以为第一终端设备在确定与蓝牙设备建立连接之后触发执行的操作;也可以为蓝牙设备向第一终端设备发送关联设备信息请求,以使第一终端设备响应于该请求向蓝牙设备返回第一关联设备信息。
在本实施例中,每当蓝牙设备与新的终端设备建立蓝牙连接之后,蓝牙设备均需要接收当前新的终端设备发送的关联设备信息,以及时更新本地保存的关联设备信息,使得本地存储的关联设备信息更准确有效。
由于终端设备始终处于动态运行的状态,因此终端设备的关联设备也在实时更新中,也即,终端设备在与蓝牙设备建立连接之后,其对应的关联设备信息仍然会发生更新变化,在其中一个可选的实施例中,该方法还包括:
接收并保存第一终端设备发送的第三关联设备信息,第三关联设备信息指示第一终端设备的关联设备的变化更新。
在本实施例中,蓝牙设备可以随时接受第一终端设备发送的第三关联设备信息,这里第三关联设备信息指的是在第一终端设备与蓝牙设备建立蓝牙连接之后,第一终端设备的关联设备发生更新,从而确定的第一终端设备对应的更新得到的关联设备信息。可选地,第一终端设备可以在检测到关联设备发生变化时,生成第三关联设备信息,并将第三关联设备信息发送至蓝牙设备;或者,蓝牙设备还可以在基于关联设备信息执行第一终端设备的关联设备的判断操作之前,向第一终端设备发送关联设备的获取请求,以获取第一终端设备响应于获取请求而返回的第三关联设备信息,从而蓝牙设备根据第三关联设备信息来更新本地保存的关联设备信息。
在本实施例中,蓝牙设备可以接收第一终端设备发送的第三关联设备信息,并根据第三关联设备信息完成本地关联信息的更新,保证本地保存的关联设备信息为最新的关联设备信息,从而提高了基于关联设备信息判断关联设备的正确率。
示例性地,在蓝牙设备与第一终端设备建立蓝牙连接之后,若蓝牙设备想要接收其他终端设备发送的连接请求,蓝牙设备需要具备允许其他终端设备进行切换连接的功能,在 其中一个可选的实施例中,接收第二终端设备发送的蓝牙连接请求,包括:
在蓝牙设备使能抢连模式的情况下,接收第二终端设备发送的连接请求。
示例性地,蓝牙设备使能抢连模式指的是蓝牙设备在与第一终端设备建立蓝牙连接之后,仍可以接收到其他终端设备发送的连接请求。蓝牙设备处于允许抢连模式指的是蓝牙设备在与第一终端设备建立蓝牙连接之后,蓝牙设备仍以蓝牙搜索可见的状态存在,也即,其他终端设备在进行蓝牙搜索时,仍可以获取到该蓝牙设备的蓝牙信号,以此可以向该蓝牙设备发起蓝牙连接请求。
具体地,针对本实施例中的场景,抢连模式表示允许除最近一次与蓝牙设备断开连接的终端设备之外的其他终端设备抢占蓝牙设备与第一终端设备之间的蓝牙连接。
也即,蓝牙设备使能抢连模式接收第二终端设备发送的连接请求,在第二终端设备不是最近一次与蓝牙设备断开连接的终端设备的情况下,蓝牙设备的抢连模式表示允许第一终端设备的关联设备抢占蓝牙设备与第一终端设备之间的蓝牙连接。也即,蓝牙设备切断与第一终端设备的蓝牙连接,与第一终端设备的关联设备建立蓝牙连接,实现抢占连接切换。
在本实施例中,在蓝牙设备使能抢连模式的情况下,才可以接收第二终端设备发起的连接请求,通过基于蓝牙设备是否使能抢连模式的情况来确定是否可以接收第二终端设备的连接请求,一定程度上减少了发起连接请求的第二终端设备的数量,也避免了由于第二终端设备发起连接请求造成对第一终端设备的干扰,优化了用户使用蓝牙设备的用户体验。
那么相应地,如何控制蓝牙设备处于允许抢连模式,在其中一个可选的实施例中,如图5所示,该方法还包括:
步骤501,在与第一终端设备建立蓝牙连接的情况下,判断蓝牙设备是否正在执行第一终端设备的业务。
在本实施例中,蓝牙设备在确定与第一终端设备建立蓝牙连接的情况下,确定当前是否正在执行第一终端设备的业务,示例地,蓝牙设备可以获取当前运行的应用程序,从运行的应用程序中确定是否存在第一终端设备的业务;或者,蓝牙设备还可以监测与第一终端设备是否存在数据交互,若存在数据交互,则确定当前正在执行第一终端设备的业务。
步骤502,若蓝牙设备未执行第一终端设备的业务,则蓝牙设备使能抢连模式。
在本实施例中,蓝牙设备确定不存在与第一终端设备的业务匹配的当前运行的应用程序,或者,检测到当前不存在与第一终端设备的数据交互,在这种情况下,蓝牙设备确定未执行第一终端设备的业务,此时,由于当前蓝牙设备没有业务执行,其他终端设备进行切换连接也不会对蓝牙设备执行第一终端设备的业务造成业务中断等问题,基于此,蓝牙设备使能抢连模式,也即,蓝牙设备将抢连模式开启。
但是,实际情况上,在蓝牙设备正在执行第一终端设备的业务时,也存在进行第二终端设备切换连接的实际需求,在这种需求场景下,可以通过对第二终端设备进一步的条件判断,来确定是否开启蓝牙设备的允许抢连功能,从而实现实际需求中的切换连接目的。在其中一个可选的实施例中,如图6所示,该方法还包括:
步骤601,若蓝牙设备正在执行第一终端设备的业务,则判断第一终端设备是否存在关联设备。
其中,蓝牙设备正在执行第一终端设备的业务指的是蓝牙设备与第一终端设备正在进行业务交互,以蓝牙设备为蓝牙耳机、第一终端设备为手机来举例说明,蓝牙设备正在执行第一终端设备的业务可以为蓝牙耳机正在播放手机的音乐,还可以为手机正在通过蓝牙耳机进行语音通话等。
在本实施例中,蓝牙设备确定正在执行第一客户端的业务的情况下,为了避免一刀切无法进行第二终端设备的切换连接,蓝牙设备可以根据进一步的判断条件,来来确定蓝牙 设备是否使能抢连模式。这里进一步的判断条件可以为蓝牙设备确定第一终端设备是否存在关联设备,示例性地,蓝牙设备可以获取第一终端设备的第一关联设备信息,基于第一关联设备信息确定该第一终端设备是否存在关联设备,例如,若第一关联设备信息为空,则确定第一终端设备不存在关联设备;若第一关联设备信息不为空,则确定第一终端设备存在关联设备。
步骤602,若第一终端设备存在关联设备,则蓝牙设备使能抢连模式。
在本实施例中,若蓝牙设备确定第一终端设备存在关联设备,在这种情况下蓝牙设备使能抢连模式,目的在于允许蓝牙设备接收其他第二终端设备发送的连接请求,或者,设定蓝牙设备允许响应其他终端设备的连接请求,。
在本实施例中,特别针对于蓝牙设备正在执行第一终端设备的业务的情况下,蓝牙设备为了最大程度保护当前进行中的业务,在确定第一终端设备存在关联设备的情况下才控制蓝牙设备处于允许抢连模式,从根源上避免了一些不相关的设备对该蓝牙设备进行抢连的问题,增强了第一终端设备、蓝牙设备的数据安全性,同时也优化了用户体验。
可选地,上述步骤502和步骤602中蓝牙设备使能抢连模式的具体实现方式,包括:
开启蓝牙设备的寻呼扫描功能,或,使能蓝牙设备响应连接请求。
在本实施例中,蓝牙设备开启蓝牙设备的寻呼扫描功能指的是将蓝牙设备处于蓝牙搜索可见的状态,示例的,该蓝牙设备的相关信息可以显示于其蓝牙信号覆盖范围内的终端设备的蓝牙搜索列表中,其中,寻呼扫描功能可以通过设置参数Page scan来控制是否开启。示例性的,当Page scan的参数值为第一值时,表示蓝牙设备的寻呼扫描功能开启;当Page scan的参数值为第二值时,表示蓝牙设备的寻呼扫描功能关闭,其中,第一值可以为0或1,第二值可以为1或0;第一值和第二值也可以为其他指定的字符。蓝牙设备通过设定Page scan的值来开启寻呼扫描功能,从而在确定寻呼扫描功能开启的情况下,使能抢连模式,以此来接收第二终端设备发起的连接请求。
上述开启蓝牙设备的寻呼扫描功能是从蓝牙设备可以接收到其他终端设备的连接请求的角度描述;使能蓝牙设备响应连接请求指的是在蓝牙设备接收到其他终端设备的连接请求之后,允许响应其他终端设备的连接请求,也即,蓝牙设备一直处于蓝牙搜索可见的状态,一直可以接收其他终端设备发送的连接请求,但是只有使能蓝牙设备响应连接请求的状态下,也即只有在蓝牙设备使能抢连模式的情况下,才会响应终端设备发送的连接请求,否则即使接收到其他设备发送的连接请求,也不响应该连接请求,这里的不响应可以是蓝牙设备向第二终端设备发送拒绝响应或者直接忽略该连接请求。
在本实施例中,蓝牙设备在确定当前不存在正在执行的第一终端设备的业务和/或确定第一终端设备存在关联设备的情况下,通过开启寻呼扫描功能或者允许所述蓝牙设备响应连接请求的设定来使得蓝牙设备使能抢连模式,从而可以接收并响应其他第二终端设备发送的连接请求,由于没有第一终端设备的业务正在执行,其他终端设备发送连接请求也不会对第一终端设备或蓝牙设备造成业务中断的问题,或者,第一终端设备存在关联设备,其关联设备也即合法设备允许进行抢连操作,基于此,蓝牙设备实现不同终端设备的快速切换连接。
上述步骤602还存在另外一种场景,在其中一个可选的实施例中,该方法还包括:
若第一终端设备不存在关联设备,则蓝牙设备禁止抢连模式,蓝牙设备不响应第二终端设备发送的连接请求。
若蓝牙设备确定第一终端设备不存在关联设备,也即,第一关联设备信息为空,在这种情况下,其他所有终端设备均可认为是非法设备,为了避免其他陌生第二终端设备向蓝牙设备发送连接请求,蓝牙设备禁止抢连模式,若蓝牙设备处于禁止抢连模式下,蓝牙设备不会接收到其他终端设备发送的连接请求,或者,不响应其他终端设备的连接请求。即,不允许其他终端设备向蓝牙设备发送连接请求来影响第一终端设备的业务执行。
示例性地,蓝牙设备禁止抢连模式指的是蓝牙设备在与第一终端设备建立蓝牙连接之后,蓝牙设备处于蓝牙搜索不可见的状态,也即,其他终端设备在进行蓝牙搜索时,无法获取到该蓝牙设备的蓝牙信号,那么显然,其他终端设备也无法向该蓝牙设备发起蓝牙连接请求,相应地,蓝牙设备也无法接收到其他终端设备发送的蓝牙连接请求;或者,蓝牙设备可以接收其他终端设备发送的连接请求,但是不响应其他终端设备发送的连接请求,这里的不响应可以为向其他终端设备发送拒绝响应或者直接忽略该连接请求。
在本实施例中,在确定第一终端设备不存在关联设备之后,也即,确定除了第一终端设备之外,不存在其他抢连合法的终端设备之后,蓝牙设备禁止抢连模式,从而保证了当前执行的第一终端设备的业务运行,优化了用户的使用体验,并且一定程度上保护了第一终端设备和蓝牙设备的数据安全。
上述蓝牙设备禁止抢连模式的实现方式包括:
关闭蓝牙设备的寻呼扫描功能,或,禁止蓝牙设备响应连接请求。
在本实施例中,蓝牙设备关闭蓝牙设备的寻呼扫描功能指的是将蓝牙设备处于蓝牙搜索不可见的状态,示例的,该蓝牙设备的相关信息可以不会显示于其蓝牙信号覆盖范围内的终端设备的蓝牙搜索列表中。其中,与上述开启寻呼扫描功能类似的,可以通过设置参数Page scan来控制是否关闭寻呼扫描功能。示例性的,当Page scan的参数值为第一值时,表示蓝牙设备的寻呼扫描功能开启;当Page scan的参数值为第二值时,表示蓝牙设备的寻呼扫描功能关闭,其中,第一值可以为0或1,第二值可以为1或0;第一值和第二值也可以为其他指定的字符。蓝牙设备通过设定Page scan的值来关闭寻呼扫描功能,从而在确定寻呼扫描功能关闭的情况下,蓝牙设备禁止抢连模式,以此来拒绝接收任意一个第二终端设备发起的连接请求。
上述关闭蓝牙设备的寻呼扫描功能是从蓝牙设备接收不到其他终端设备的连接请求的角度描述;禁止蓝牙设备响应连接请求指的是蓝牙设备可以接收到的其他终端设备的连接请求,但是,蓝牙设备不响应其他终端设备的连接请求,也即,这里不响应连接请求可以是蓝牙设备向第二终端设备发送拒绝响应或者直接忽略该连接请求。
在本实施例中,蓝牙设备在确定第一终端设备不存在关联设备的情况下,通过关闭寻呼扫描功能或禁止所述蓝牙设备响应连接请求来使得蓝牙设备禁止抢连模式,从而不接收或者不响应其他第二终端设备发送的连接请求,由于第一终端设备不存在关联设备,也即不存在其他合法设备允许进行抢连操作,基于此,蓝牙设备关闭寻呼扫描功能来使得蓝牙设备处于禁止抢连模式下可以实现对终端设备、蓝牙设备的业务保持的目的,优化用户体验。
可选地,蓝牙设备在建立蓝牙连接的情况下,为了更好的适应于用户的需求,还可以根据本地的关联设备信息对向其发起连接请求的终端设备进行设备优先级判断,在其中一个可选的实施例中,该方法还包括:
在蓝牙设备未与任何终端设备建立蓝牙连接的情况下,若接收到至少两个第三终端设备发送的连接请求,则根据当前存储的第四关联设备信息确定优先级最高的第三终端设备,并响应优先级最高的第三终端设备的连接请求。
在本实施例中,在蓝牙设备未与任何终端设备建立连接的情况下,接收到至少两个第三终端设备发送的连接请求,蓝牙设备需要从至少两个第三终端设备中确定与其建立连接的一个目标终端设备,在确定目标终端设备的过程中,蓝牙设备可以基于本地存储的第四关联设备信息来确定目标终端设备。这里第四关联设备信息也可以为上述实施例中蓝牙设备更新后的最终存储至本地的关联设备信息。在确定目标终端设备的过程中,蓝牙设备可以根据预设的设备类型优先级、业务优先级等不同维度的优先级,确定设备类型优先级最高和/或业务优先级最高的第三终端设备作为目标终端设备;也可以根据预设的出厂序列号优先级,确定出厂序列号优先级最高的第三终端设备作为目标终端设备,本实施例对此不 做限定。
在本实施例中,蓝牙设备在与终端设备建立连接之后,都会同步该终终端设备的关联设备信息,也即,在与终端设备建立过蓝牙连接之后,蓝牙设备本地存储空间中始终存在关联设备信息,在出现多个终端设备发起蓝牙回连的情况下,蓝牙设备可以基于本地的关联设备信息确定优先级最高的终端设备建立蓝牙连接,一定程度上优化了终端设备与蓝牙设备回连的流程,提高终端设备的回连效率。
为了更好的说明上述方法,如图7所示,本实施例提供一种涉及蓝牙设备、第一终端设备、第二终端设备交互的设备连接切换方法,具体包括:
步骤101、在蓝牙设备与第一终端设备建立蓝牙连接的情况下,第一终端设备向蓝牙设备同步第一关联设备信息;
步骤102、蓝牙设备确定是否存在当前正在执行的业务;若不存在,则执行步骤103;若存在,则执行步骤104;
步骤103、蓝牙设备使能抢连模式,接收第二终端设备发送的连接请求,并响应于所述连接请求,断开与所述第一终端设备的蓝牙连接,并建立与所述第二终端设备的蓝牙连接;
步骤104、判断第一终端设备是否存在关联设备信息,若存在,则执行步骤105;若不存在,则执行步骤112;
步骤105、蓝牙设备使能抢连模式,接收第二终端设备发送的连接请求,并从第一终端设备更新第一关联设备信息,得到更新后的第一关联设备信息;
步骤106、根据设备标识和更新后的第一关联设备信息,确定第二终端设备是否为第一终端设备的关联设备;若为关联设备,则执行步骤107;若不是关联设备,则执行步骤112;
步骤107、在第二终端设备为第一终端设备的关联设备的情况下,判断第二终端设备是否为最近一次与蓝牙设备断开连接的终端设备;若不是,则执行步骤108;若是,则执行步骤109;
步骤108、响应连接请求,断开与第一终端设备的蓝牙连接,并建立与第二终端设备的蓝牙连接;
步骤109、获取最近一次与蓝牙设备断开连接的时刻与当前时刻之间的时间差;
步骤110、判断时间差是否大于时间差阈值,若大于,则执行步骤112;若不大于则执行步骤112;
步骤111、响应于连接请求,断开与第一终端设备的蓝牙连接,并建立与第二终端设备的蓝牙连接;
步骤112、蓝牙设备禁止抢连模式,不响应连接请求。
在本实施例中,在蓝牙设备与第一终端设备建立蓝牙连接之后,蓝牙设备确定当前没有执行第一终端设备的业务时,使得蓝牙设备处于允许抢连模式,从而接收第二终端设备的连接请求,进而根据第一终端设备发送的第一关联设备信息、蓝牙设备最近一次断开连接的终端设备信息等,确定是否响应第二终端设备的连接请求,多次条件判断,使得蓝牙设备在进行连接切换时,最大程度保证了与第一终端设备交互的完成性,也最大程度保证了第二终端设备的合法性,使得蓝牙设备可以在安全有效的场景下,实现合法终端设备的切换连接,优化了用户体验。
上述实施例提供的设备连接切换方法,其实现原理和技术效果与上述方法实施例类似,在此不再赘述。
应该理解的是,虽然图2-7的流程图中的各个步骤按照箭头的指示依次显示,但是这些步骤并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,这些步骤可以以其它的顺序执行。而且,图2-7中的至少一 部分步骤可以包括多个子步骤或者多个阶段,这些子步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些子步骤或者阶段的执行顺序也不必然是依次进行,而是可以与其它步骤或者其它步骤的子步骤或者阶段的至少一部分轮流或者交替地执行。
图8为一个实施例的设备连接切换装置的结构框图。如图8所示,该装置包括:
接收模块01,用于在与第一终端设备建立蓝牙连接的情况下,接收第二终端设备发送的连接请求;
判断模块02,用于判断第二终端设备是否为最近一次与蓝牙设备断开连接的终端设备;
执行模块03,用于若第二终端设备为最近一次与蓝牙设备断开连接的终端设备,则不响应连接请求。
在其中一个可选的实施例中,执行模块03,还用于若第二终端设备为最近一次与蓝牙设备断开连接的终端设备,则获取最近一次与蓝牙设备断开连接的时刻与当前时刻之间的时间差;若时间差大于时间差阈值,则响应于连接请求,断开与第一终端设备的蓝牙连接,并建立与第二终端设备的蓝牙连接;若时间差不大于时间差阈值,则不响应连接请求。
在其中一个可选的实施例中,执行模块03,还用于若第二终端设备不是最近一次与蓝牙设备断开连接的终端设备,则响应于连接请求,断开与第一终端设备的蓝牙连接,并建立与第二终端设备的蓝牙连接。
在其中一个可选的实施例中,执行模块03,还用于根据第一终端设备的第一关联设备信息,判断第二终端设备是否为第一终端设备的关联设备;若第二终端设备为第一终端设备的关联设备,则执行响应于连接请求,断开与第一终端设备的蓝牙连接,并建立与第二终端设备的蓝牙连接的步骤。
在其中一个可选的实施例中,接收模块01,还用于在与第二终端设备建立蓝牙连接后,接收第二终端设备发送的第二关联设备信息。
在其中一个可选的实施例中,接收模块01,还用于将第二关联设备信息替换蓝牙设备保存的第一关联设备信息。
在其中一个可选的实施例中,接收模块01,还用于在蓝牙设备与第一终端设备建立蓝牙连接的情况下,接收第一终端设备发送的第一关联设备信息。
在其中一个可选的实施例中,接收模块01,还用于接收并保存第一终端设备发送的第三关联设备信息,第三关联设备信息用于指示第一终端设备的关联设备的变化更新。
在其中一个可选的实施例中,接收模块01,还用于在蓝牙设备使能抢连模式的情况下,接收第二终端设备发送的连接请求;抢连模式表示允许除最近一次与蓝牙设备断开连接的终端设备之外的其他终端设备抢占蓝牙设备与第一终端设备之间的蓝牙连接。
在其中一个可选的实施例中,执行模块03,还用于在与第一终端设备建立蓝牙连接的情况下,判断蓝牙设备是否正在执行第一终端设备的业务;若蓝牙设备未执行第一终端设备的业务,则蓝牙设备使能抢连模式。
在其中一个可选的实施例中,执行模块03,还用于若蓝牙设备正在执行第一终端设备的业务,则判断第一终端设备是否存在关联设备;若第一终端设备存在关联设备,则蓝牙设备使能抢连模式。
在其中一个可选的实施例中,执行模块03,还用于启蓝牙设备的寻呼扫描功能;或,使能蓝牙设备响应连接请求。
在其中一个可选的实施例中,执行模块03,还用于若第一终端设备不存在关联设备,则蓝牙设备禁止抢连模式,蓝牙设备不响应第二终端设备发送的连接请求。
在其中一个可选的实施例中,执行模块03,还用于关闭蓝牙设备的寻呼扫描功能;或,禁止蓝牙设备响应连接请求。
在其中一个可选的实施例中,第一关联设备信息包括以下至少一种:
与第一终端设备连接过的终端设备的设备信息;
与第一终端设备的类型相同的终端设备的设备信息;
与第一终端设备所属同一账号的终端设备的设备信息。
上述蓝牙设备抢连装置中各个模块的划分仅仅用于举例说明,在其他实施例中,可将蓝牙设备抢连装置按照需要划分为不同的模块,以完成上述蓝牙设备抢连装置的全部或部分功能。
关于蓝牙设备抢连装置的具体限定可以参见上文中对于设备连接切换方法的限定,在此不再赘述。上述蓝牙设备抢连装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。
图9为一个实施例中电子设备的内部结构示意图。该电子设备可以是包括蓝牙模块的智能电子设备,例如,蓝牙耳机、手机、平板电脑、笔记本电脑、台式电脑、车载电脑、穿戴式设备等任意终端设备。该电子设备包括通过***总线连接的处理器和存储器。其中,该处理器可以包括一个或多个处理单元。处理器可为CPU(Central Processing Unit,中央处理单元)或DSP(Digital Signal Processing,数字信号处理器)等。存储器可包括非易失性存储介质及内存储器。非易失性存储介质存储有操作***和计算机程序。该计算机程序可被处理器所执行,以用于实现以下各个实施例所提供的一种设备连接切换方法。内存储器为非易失性存储介质中的操作***计算机程序提供高速缓存的运行环境。
本申请实施例中提供的设备连接切换装置中的各个模块的实现可为计算机程序的形式。该计算机程序可在终端或服务器上运行。该计算机程序构成的程序模块可存储在电子设备的存储器上。该计算机程序被处理器执行时,实现本申请实施例中所描述方法的步骤。
本申请实施例还提供了一种计算机可读存储介质。一个或多个包含计算机可执行指令的非易失性计算机可读存储介质,当所述计算机可执行指令被一个或多个处理器执行时,使得所述处理器执行设备连接切换方法的步骤。
本申请实施例还提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行设备连接切换方法。
本申请所使用的对存储器、存储、数据库或其它介质的任何引用可包括非易失性和/或易失性存储器。非易失性存储器可包括ROM(Read-Only Memory,只读存储器)、PROM(Programmable Read-only Memory,可编程只读存储器)、EPROM(Erasable Programmable Read-Only Memory,可擦除可编程只读存储器)、EEPROM(Electrically Erasable Programmable Read-only Memory,电可擦除可编程只读存储器)或闪存。易失性存储器可包括RAM(Random Access Memory,随机存取存储器),它用作外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如SRAM(Static Random Access Memory,静态随机存取存储器)、DRAM(Dynamic Random Access Memory,动态随机存取存储器)、SDRAM(Synchronous Dynamic Random Access Memory,同步动态随机存取存储器)、双数据率DDR SDRAM(Double Data Rate Synchronous Dynamic Random Access memory,双数据率同步动态随机存取存储器)、ESDRAM(Enhanced Synchronous Dynamic Random Access memory,增强型同步动态随机存取存储器)、SLDRAM(Sync Link Dynamic Random Access Memory,同步链路动态随机存取存储器)、RDRAM(Rambus Dynamic Random Access Memory,总线式动态随机存储器)、DRDRAM(Direct Rambus Dynamic Random Access Memory,接口动态随机存储器)。
以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对本申请专利范围的限制。应当指出的是,对于本领域的普通技术人员来说, 在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。
Claims (20)
- 一种设备连接切换方法,其特征在于,应用于蓝牙设备,所述方法包括:在与第一终端设备建立蓝牙连接的情况下,接收第二终端设备发送的连接请求;判断所述第二终端设备是否为最近一次与所述蓝牙设备断开连接的终端设备;若所述第二终端设备为最近一次与所述蓝牙设备断开连接的终端设备,则不响应所述连接请求。
- 根据权利要求1所述的方法,其特征在于,所述方法还包括:若所述第二终端设备为最近一次与所述蓝牙设备断开连接的终端设备,则获取最近一次与所述蓝牙设备断开连接的时刻与当前时刻之间的时间差;若所述时间差大于时间差阈值,则响应于所述连接请求,断开与所述第一终端设备的蓝牙连接,并建立与所述第二终端设备的蓝牙连接;若所述时间差不大于时间差阈值,则不响应所述连接请求。
- 根据权利要求1所述的方法,其特征在于,所述方法还包括:若所述第二终端设备不是最近一次与所述蓝牙设备断开连接的终端设备,则响应于所述连接请求,断开与所述第一终端设备的蓝牙连接,并建立与所述第二终端设备的蓝牙连接。
- 根据权利要求2或3所述的方法,其特征在于,所述响应于所述连接请求之前,还包括:根据所述第一终端设备的第一关联设备信息,判断所述第二终端设备是否为所述第一终端设备的关联设备;若所述第二终端设备为所述第一终端设备的关联设备,则执行所述响应于所述连接请求,断开与所述第一终端设备的蓝牙连接,并建立与所述第二终端设备的蓝牙连接的步骤。
- 根据权利要求4所述的方法,其特征在于,所述方法还包括:在与所述第二终端设备建立蓝牙连接后,接收所述第二终端设备发送的第二关联设备信息。
- 根据权利要求5所述的方法,其特征在于,所述方法还包括:将所述第二关联设备信息替换所述蓝牙设备保存的所述第一关联设备信息。
- 根据权利要求4所述的方法,其特征在于,所述方法还包括:在所述蓝牙设备与所述第一终端设备建立蓝牙连接的情况下,接收所述第一终端设备发送的所述第一关联设备信息。
- 根据权利要求7所述的方法,其特征在于,在所述接收所述第一终端设备发送的所述第一关联设备信息之后,还包括:接收并保存所述第一终端设备发送的第三关联设备信息,所述第三关联设备信息用于指示所述第一终端设备的关联设备的变化更新。
- 根据权利要求1所述的方法,其特征在于,所述接收第二终端设备发送的连接请求,包括:在所述蓝牙设备使能抢连模式的情况下,接收所述第二终端设备发送的连接请求;所述抢连模式表示允许除最近一次与蓝牙设备断开连接的终端设备之外的其他终端设备抢占所述蓝牙设备与所述第一终端设备之间的蓝牙连接。
- 根据权利要求9所述的方法,其特征在于,所述方法还包括:在与所述第一终端设备建立蓝牙连接的情况下,判断所述蓝牙设备是否正在执行所述第一终端设备的业务;若所述蓝牙设备未执行所述第一终端设备的业务,则所述蓝牙设备使能所述抢连模式。
- 根据权利要求10所述的方法,其特征在于,所述方法还包括:若所述蓝牙设备正在执行所述第一终端设备的业务,则判断所述第一终端设备是否存在关联设备;若所述第一终端设备存在关联设备,则所述蓝牙设备使能所述抢连模式。
- 根据权利要求10或11所述的方法,其特征在于,所述蓝牙设备所述使能抢连模式,包括:开启所述蓝牙设备的寻呼扫描功能;或,使能所述蓝牙设备响应连接请求。
- 根据权利要求11所述的方法,其特征在于,所述方法还包括:若所述第一终端设备不存在关联设备,则所述蓝牙设备禁止所述抢连模式,所述蓝牙设备不响应所述第二终端设备发送的连接请求。
- 根据权利要求13所述的方法,其特征在于,所述蓝牙设备禁止所述抢连模式,包括:关闭所述蓝牙设备的寻呼扫描功能;或,禁止所述蓝牙设备响应连接请求。
- 根据权利要求1所述的方法,其特征在于,所述第一关联设备信息包括以下至少一种:与所述第一终端设备连接过的终端设备的设备信息;与所述第一终端设备的类型相同的终端设备的设备信息;与所述第一终端设备所属同一账号的终端设备的设备信息。
- 根据权利要求1-3中任一项所述的方法,其特征在于,所述与第一终端设备建立蓝牙连接包括:与所述第一终端设备已完成蓝牙异步传输的逻辑链路ACL连接、蓝牙配对、蓝牙连接的过程。
- 根据权利要求2所述的方法,其特征在于,所述获取最近一次与所述蓝牙设备断开连接的时刻与当前时刻之间的时间差,包括:基于记录表获取最近一次与所述蓝牙设备断开连接的时刻,以及从本地时钟模块中获取所述当前时刻;其中,所述记录表中包括各个终端设备的设备标识,以及其对应的建立蓝牙连接时刻和断开蓝牙连接的时刻;计算最近一次与所述蓝牙设备断开连接的时刻与所述当前时刻之间的时间差。
- 一种设备连接切换装置,其特征在于,应用于蓝牙设备,包括:接收模块,用于在与第一终端设备建立蓝牙连接的情况下,接收第二终端设备发送的连接请求;判断模块,用于判断所述第二终端设备是否为最近一次与所述蓝牙设备断开连接的终端设备;执行模块,用于若所述第二终端设备为最近一次与所述蓝牙设备断开连接的终端设备,则不响应所述连接请求。
- 一种电子设备,包括存储器及处理器,所述存储器中储存有计算机程序,其特征在于,所述计算机程序被所述处理器执行时,使得所述处理器执行如权利要求1至17中任一项所述的方法的步骤。
- 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1至17中任一项所述的方法的步骤。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111448859.5A CN114125803A (zh) | 2021-11-30 | 2021-11-30 | 设备连接切换方法、装置、电子设备和计算机可读存储介质 |
CN202111448859.5 | 2021-11-30 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2023098235A1 true WO2023098235A1 (zh) | 2023-06-08 |
Family
ID=80368996
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2022/119666 WO2023098235A1 (zh) | 2021-11-30 | 2022-09-19 | 设备连接切换方法、装置、电子设备和计算机可读存储介质 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN114125803A (zh) |
WO (1) | WO2023098235A1 (zh) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113938971A (zh) * | 2021-11-30 | 2022-01-14 | Oppo广东移动通信有限公司 | 设备连接切换方法、装置、电子设备和计算机可读存储介质 |
CN114125803A (zh) * | 2021-11-30 | 2022-03-01 | Oppo广东移动通信有限公司 | 设备连接切换方法、装置、电子设备和计算机可读存储介质 |
CN117652166A (zh) * | 2022-05-24 | 2024-03-05 | 北京小米移动软件有限公司 | 蓝牙设备控制方法、装置、设备及存储介质 |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111246441A (zh) * | 2020-02-26 | 2020-06-05 | 深圳市岍丞技术有限公司 | 蓝牙耳机与终端的连接方法、***及存储介质 |
CN111741456A (zh) * | 2020-06-17 | 2020-10-02 | 成都极米科技股份有限公司 | 蓝牙设备及其蓝牙抢占方法和装置、计算机可读存储介质 |
CN112004173A (zh) * | 2020-08-27 | 2020-11-27 | 努比亚技术有限公司 | 蓝牙耳机的切换方法、移动终端及计算机可读存储介质 |
CN112040465A (zh) * | 2020-08-19 | 2020-12-04 | 泰州德川绿化养护有限公司 | 蓝牙音箱连接切换方法、蓝牙音箱、终端设备及*** |
CN114125803A (zh) * | 2021-11-30 | 2022-03-01 | Oppo广东移动通信有限公司 | 设备连接切换方法、装置、电子设备和计算机可读存储介质 |
-
2021
- 2021-11-30 CN CN202111448859.5A patent/CN114125803A/zh active Pending
-
2022
- 2022-09-19 WO PCT/CN2022/119666 patent/WO2023098235A1/zh unknown
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111246441A (zh) * | 2020-02-26 | 2020-06-05 | 深圳市岍丞技术有限公司 | 蓝牙耳机与终端的连接方法、***及存储介质 |
CN111741456A (zh) * | 2020-06-17 | 2020-10-02 | 成都极米科技股份有限公司 | 蓝牙设备及其蓝牙抢占方法和装置、计算机可读存储介质 |
CN112040465A (zh) * | 2020-08-19 | 2020-12-04 | 泰州德川绿化养护有限公司 | 蓝牙音箱连接切换方法、蓝牙音箱、终端设备及*** |
CN112004173A (zh) * | 2020-08-27 | 2020-11-27 | 努比亚技术有限公司 | 蓝牙耳机的切换方法、移动终端及计算机可读存储介质 |
CN114125803A (zh) * | 2021-11-30 | 2022-03-01 | Oppo广东移动通信有限公司 | 设备连接切换方法、装置、电子设备和计算机可读存储介质 |
Also Published As
Publication number | Publication date |
---|---|
CN114125803A (zh) | 2022-03-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2023098235A1 (zh) | 设备连接切换方法、装置、电子设备和计算机可读存储介质 | |
WO2023098234A1 (zh) | 设备连接切换方法、装置、电子设备和计算机可读存储介质 | |
EP3537734B1 (en) | Method and device for connecting a bluetooth device | |
WO2017097023A1 (zh) | 无感知认证方法***,基于该方法***的控制方法、*** | |
US20050235019A1 (en) | Method and system for transmitting data for data synchronization between server and client when data synchronization session was abnormally terminated | |
US11323492B2 (en) | Managing data communications based on phone calls between mobile computing devices | |
US10425318B2 (en) | Method for heartbeat packet processing by using proxy, apparatus, and communications system | |
WO2017177767A1 (zh) | 一种业务访问及其控制方法、装置 | |
CN115086481B (zh) | 一种来电提醒方法和电子设备 | |
CN111654415B (zh) | 基于区块链的信息处理方法、装置、设备及可读存储介质 | |
US9628567B2 (en) | Methods and systems for efficient discovery of devices in a peer-to-peer network | |
US11057475B2 (en) | Methods, apparatus and systems for resuming transmission link | |
JP2016033811A (ja) | セッション管理方法、セッション管理装置、セッション管理プログラム、および通話処理方法 | |
WO2023098233A1 (zh) | 设备连接切换方法、装置、电子设备和计算机可读存储介质 | |
WO2017219587A1 (zh) | 主从设备切换方法、从设备、管理服务器及存储介质 | |
CN113452770B (zh) | 数据同步方法、装置、计算机设备及存储介质 | |
CN106060031B (zh) | 一种多媒体通信控制的方法、服务器及*** | |
WO2021098015A1 (zh) | 耳机升级方法、耳机组件、升级装置和可读存储介质 | |
JP2015103862A (ja) | 通信端末、通信方法及びプログラム | |
WO2021239032A1 (zh) | 蓝牙协议连接方法、装置、存储介质及相关设备 | |
US10368210B2 (en) | Service processing method, terminal device, and service roaming network | |
WO2021134766A1 (zh) | 确定设备状态的方法、装置、设备及存储介质 | |
JP2002149465A (ja) | 情報共有システム | |
WO2018126483A1 (zh) | 一种网络服务的控制方法及装置 | |
WO2023202560A1 (zh) | 辅小区组信息发送方法、接收方法、终端、设备和介质 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 22900043 Country of ref document: EP Kind code of ref document: A1 |