CN115714967A - Method and device for realizing connection switching and electronic equipment - Google Patents

Method and device for realizing connection switching and electronic equipment Download PDF

Info

Publication number
CN115714967A
CN115714967A CN202211405836.0A CN202211405836A CN115714967A CN 115714967 A CN115714967 A CN 115714967A CN 202211405836 A CN202211405836 A CN 202211405836A CN 115714967 A CN115714967 A CN 115714967A
Authority
CN
China
Prior art keywords
near field
field communication
communication device
host
notification message
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211405836.0A
Other languages
Chinese (zh)
Inventor
陶宁
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
You Can See Beijing Technology Co ltd AS
Original Assignee
You Can See Beijing Technology Co ltd AS
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by You Can See Beijing Technology Co ltd AS filed Critical You Can See Beijing Technology Co ltd AS
Priority to CN202211405836.0A priority Critical patent/CN115714967A/en
Publication of CN115714967A publication Critical patent/CN115714967A/en
Pending legal-status Critical Current

Links

Images

Abstract

The embodiment of the disclosure discloses a method and a device for realizing connection switching and electronic equipment. The method is applied to a first host, and comprises the following steps: scanning a near field communication device list; screening target near field communication equipment from the near field communication equipment list; broadcasting a first notification message in case the target near field communication device is in a connected state; the first notification message is used for representing that the first host requests to be connected to the target near field communication equipment, so that the second host receiving the first notification message disconnects the first near field connection under the condition that the first near field connection is established between the second host and the target near field communication equipment; a second near field connection is established between the first host and the target near field communication device that has been switched to the unconnected state. The embodiment of the disclosure can reduce the cost for realizing connection switching.

Description

Method and device for realizing connection switching and electronic equipment
Technical Field
The present disclosure relates to the field of communications technologies, and in particular, to a method and an apparatus for implementing connection switching, and an electronic device.
Background
In some scenarios, the device with near field communication function needs to be connected to different hosts of multiple hosts near itself at different times, for example, in a scenario of using a stylus pen, the stylus pen is connected to the host 1 at a certain time, and the stylus pen needs to be connected to the host 2 at the next time. In order to realize the switching of the host connected with the reading pen, the hardware of the reading pen needs to be modified greatly, so that the reading pen supports the complicated connection switching operation, which results in higher cost for realizing the connection switching.
Disclosure of Invention
The present disclosure is proposed to solve the above technical problems. The embodiment of the disclosure provides a method and a device for realizing connection switching and electronic equipment.
According to an aspect of the embodiments of the present disclosure, there is provided a method for implementing connection switching, applied to a first host, the method including:
scanning a near field communication device list;
screening target near field communication equipment from the near field communication equipment list;
broadcasting a first notification message in case the target near field communication device is in a connected state; wherein the first notification message is used for representing that the first host requests to connect to the target near field communication device, so that a second host receiving the first notification message disconnects a first near field connection when the first near field connection is established between the second host and the target near field communication device;
establishing a second near field connection between the first host and the target near field communication device that has been switched to an unconnected state.
In one optional example, before the broadcasting the first notification message, the method further comprises:
determining a first sequence of characters for identifying the target near field communication device;
generating a first notification message; the first character sequence is stored in a first preset position in the first notification message, and the connection request identifier is stored in a second preset position in the second notification message.
In one optional example, the determining a first sequence of characters for identifying the target near field communication device comprises:
determining a first MAC address of the target near field communication device based on a device name of the target near field communication device;
-intercepting a first sequence of characters identifying the target near field communication device from the first MAC address.
In one optional example, said establishing a second near field connection between said first host and said target near field communication device that has switched to an unconnected state comprises:
determining that the target near field communication device has switched to the unconnected state and establishing a second near field connection between the first host and the target near field communication device, in the event of receiving a second notification message broadcast by a second host;
wherein the second notification message is used to characterize that the second host has disconnected the first near field connection.
According to another aspect of the embodiments of the present disclosure, there is provided a method for implementing connection switching, applied to a second host, the method including:
receiving a first notification message broadcast by a first host, wherein the first notification message is used for representing that the first host requests to be connected to a target near field communication device;
disconnecting the first near field connection if the first near field connection is established between the second host and the target near field communication device.
In one optional example, before disconnecting the first near field connection in a case where the first near field connection is established between the second host and the target near field communication device, the method further comprises:
determining a second MAC address of a connected near field communication device of the second host based on a device name of the connected near field communication device if the second host is in a connected state;
intercepting a second sequence of characters identifying the connected near field communication device from the second MAC address;
determining a first sequence of characters for identifying the target near field communication device based on the first notification message;
determining that the connected near field communication device is the target near field communication device if the first character sequence matches the second character sequence.
In one optional example, after said disconnecting the first near field connection, the method further comprises:
determining a first sequence of characters for identifying the target near field communication device based on the first notification message;
generating a second notification message, wherein a first preset position in the second notification message stores the first character sequence, and a second preset position in the second notification message stores a connection disconnection identifier;
broadcasting the second notification message.
In one optional example, after said disconnecting said first near field connection, said method comprises:
starting timing from the moment when the first near-field connection is disconnected;
and under the condition that the timing duration reaches a preset duration and the target near field communication equipment is in an unconnected state, establishing a third near field connection between the second host and the target near field communication equipment.
According to still another aspect of the embodiments of the present disclosure, there is provided an apparatus for implementing connection switching, applied to a first host, the apparatus including:
a scanning module for scanning a near field communication device list;
the screening module is used for screening target near field communication equipment from the near field communication equipment list;
a first broadcasting module for broadcasting a first notification message in case the target near field communication device is in a connected state; wherein the first notification message is used to characterize that the first host requests to connect to the target near field communication device, so that a second host receiving the first notification message disconnects a first near field connection if the first near field connection is established between itself and the target near field communication device;
a first connection module for establishing a second near field connection between the first host and the target near field communication device that has been switched to an unconnected state.
In one optional example, the apparatus further comprises:
a first determination module for determining a first sequence of characters for identifying the target near field communication device before broadcasting a first notification message;
the first generating module is used for generating a first notification message; the first character sequence is stored in a first preset position in the first notification message, and the connection request identifier is stored in a second preset position in the second notification message.
In one optional example, the first determining module comprises:
a determining submodule, configured to determine a first MAC address of the target near field communication device based on a device name of the target near field communication device;
and the intercepting submodule is used for intercepting a first character sequence used for identifying the target near field communication equipment from the first MAC address.
In an optional example, the first connection module is specifically configured to:
determining that the target near field communication device has switched to the unconnected state and establishing a second near field connection between the first host and the target near field communication device, in the event of receiving a second notification message broadcast by a second host;
wherein the second notification message is used to characterize that the second host has disconnected the first near field connection.
According to another aspect of the embodiments of the present disclosure, there is provided an apparatus for implementing connection switching, applied to a second host, the apparatus including:
a receiving module, configured to receive a first notification message broadcasted by a first host, where the first notification message is used to characterize that the first host requests to connect to a target near field communication device;
a disconnection module configured to disconnect a first near field connection when the first near field connection is established between the second host and the target near field communication device.
In one optional example, the apparatus further comprises:
a second determining module, configured to determine, when a first near-field connection is established between the second host and the target near-field communication device, a second MAC address of a connected near-field communication device of the second host based on a device name of the connected near-field communication device before the first near-field connection is disconnected and when the second host is in a connected state;
an intercepting module for intercepting a second sequence of characters identifying the connected near field communication device from the second MAC address;
a third determination module for determining a first sequence of characters for identifying the target near field communication device based on the first notification message;
a fourth determining module, configured to determine that the connected near field communication device is the target near field communication device when the first character sequence matches the second character sequence.
In one optional example, the apparatus further comprises:
a fifth determination module for determining a first sequence of characters for identifying the target near field communication device based on the first notification message after disconnecting the first near field connection;
a second generating module, configured to generate a second notification message, where a first predetermined location in the second notification message stores the first character sequence, and a second predetermined location in the second notification message stores a connection disconnection identifier;
and the second broadcasting module is used for broadcasting the second notification message.
In one optional example, the apparatus further comprises:
the timing module is used for starting timing from the moment when the first near field connection is disconnected after the first near field connection is disconnected;
and the second connection module is used for establishing a third near field connection between the second host and the target near field communication equipment under the condition that the timing duration reaches a preset duration and the target near field communication equipment is in an unconnected state.
According to still another aspect of an embodiment of the present disclosure, there is provided an electronic apparatus including:
a memory for storing a computer program product;
and a processor for executing the computer program product stored in the memory, and when the computer program product is executed, implementing the method for implementing connection switching applied to the first host or the second host.
According to another aspect of the embodiments of the present disclosure, there is provided a computer-readable storage medium having computer program instructions stored thereon, wherein the computer program instructions, when executed by a processor, implement the above method for implementing connection switching applied to a first host or a second host.
According to yet another aspect of an embodiment of the present disclosure, there is provided a computer program product comprising computer program instructions which, when executed by a processor, implement the above-mentioned method for implementing a connection handover applied to a first host or a second host.
In the embodiment of the disclosure, the first host may scan the near field communication device list, and determine the target near field communication device to be connected through screening of the near field communication device list, and then, the first host may actively disconnect the near field connection with the target near field communication device by the second host connected to the target near field communication device through broadcasting of the first notification message under the condition that the target near field communication device is in a connected state, so as to ensure that the near field connection can be successfully established between the first host and the target near field communication device. Therefore, in the embodiment of the disclosure, on the premise of not modifying the hardware of the near field communication device, the switching of the host connected with the near field communication device can be conveniently and quickly realized through the communication between the hosts, and therefore, the embodiment of the disclosure can reduce the cost for realizing the connection switching.
The technical solution of the present disclosure is further described in detail by the accompanying drawings and examples.
Drawings
The above and other objects, features and advantages of the present disclosure will become more apparent by describing in more detail embodiments of the present disclosure with reference to the attached drawings. The accompanying drawings are included to provide a further understanding of the embodiments of the disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the description serve to explain the principles of the disclosure and not to limit the disclosure. In the drawings, like reference numbers generally represent like parts or steps.
Fig. 1 is a flowchart illustrating a method for implementing connection handover according to an exemplary embodiment of the present disclosure.
Fig. 2 is a flowchart illustrating a method for implementing connection handover according to another exemplary embodiment of the present disclosure.
Fig. 3 is a flowchart illustrating a method for implementing connection handover according to still another exemplary embodiment of the present disclosure.
Fig. 4 is a flowchart illustrating a method for implementing connection handover according to yet another exemplary embodiment of the present disclosure.
Fig. 5 is a flowchart illustrating a method for implementing connection switching according to still another exemplary embodiment of the present disclosure.
Fig. 6 is a flowchart illustrating a method for implementing connection switching according to still another exemplary embodiment of the present disclosure.
Fig. 7 is a schematic structural diagram of an apparatus for implementing connection switching according to an exemplary embodiment of the present disclosure.
Fig. 8 is a schematic structural diagram of an apparatus for implementing connection switching according to another exemplary embodiment of the present disclosure.
Fig. 9 is a block diagram of an electronic device provided in an exemplary embodiment of the present disclosure.
Detailed Description
Hereinafter, example embodiments according to the present disclosure will be described in detail with reference to the accompanying drawings. It should be understood that the described embodiments are only some of the embodiments of the present disclosure, and not all of the embodiments of the present disclosure, and it is to be understood that the present disclosure is not limited by the example embodiments described herein.
It should be noted that: the relative arrangement of parts and steps, numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present disclosure unless specifically stated otherwise.
It will be understood by those of skill in the art that the terms "first," "second," and the like in the embodiments of the present disclosure are used merely to distinguish one element from another, and are not intended to imply any particular technical meaning, nor is the necessary logical order between them.
It is also understood that in embodiments of the present disclosure, "a plurality" may refer to two or more and "at least one" may refer to one, two or more.
It is also to be understood that any reference to any component, data, or structure in the embodiments of the disclosure, may be generally understood as one or more, unless explicitly defined otherwise or stated otherwise.
In addition, the term "and/or" in the present disclosure is only one kind of association relationship describing an associated object, and means that three kinds of relationships may exist, for example, a and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" in the present disclosure generally indicates that the former and latter associated objects are in an "or" relationship.
It should also be understood that the description of the various embodiments of the present disclosure emphasizes the differences between the various embodiments, and the same or similar parts may be referred to each other, so that the descriptions thereof are omitted for brevity.
Meanwhile, it should be understood that the sizes of the respective portions shown in the drawings are not drawn in an actual proportional relationship for the convenience of description.
The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the disclosure, its application, or uses.
Techniques, methods, and apparatus known to those of ordinary skill in the relevant art may not be discussed in detail but are intended to be part of the specification where appropriate.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, further discussion thereof is not required in subsequent figures.
The disclosed embodiments may be applied to electronic devices such as terminal devices, computer systems, servers, etc., which are operational with numerous other general purpose or special purpose computing system environments or configurations. Examples of well known terminal devices, computing systems, environments, and/or configurations that may be suitable for use with electronic devices, such as terminal devices, computer systems, servers, and the like, include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, hand-held or laptop devices, microprocessor-based systems, set top boxes, programmable consumer electronics, network pcs, minicomputer systems, mainframe computer systems, distributed cloud computing environments that include any of the above systems, and the like.
Electronic devices such as terminal devices, computer systems, servers, etc. may be described in the general context of computer system-executable instructions, such as program modules, being executed by a computer system. Generally, program modules may include routines, programs, objects, components, logic, data structures, etc. that perform particular tasks or implement particular abstract data types. The computer system/server may be practiced in distributed cloud computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed cloud computing environment, program modules may be located in both local and remote computer system storage media including memory storage devices.
Exemplary method
In order to solve the problems in the prior art, the present disclosure provides a method for implementing connection switching from the perspective of a first host and a second host, respectively, and first introduces the method for implementing connection switching provided by the present disclosure from the perspective of a first host.
Fig. 1 is a flowchart illustrating a method for implementing connection handover according to an exemplary embodiment of the present disclosure. The method shown in fig. 1 is applied to the first host, and the method shown in fig. 1 includes step 110, step 120, step 130 and step 140, which are described below.
Step 110, a list of near field communication devices is scanned.
It should be noted that the Near Field Communication technology involved in the embodiments of the present disclosure includes, but is not limited to, bluetooth (Bluetooth) technology, near Field Communication (NFC) technology, and the like. For convenience of understanding, the following description will be given by taking a case where the near field communication technology is a bluetooth technology as an example, so that the near field communication device referred to hereinafter may be a bluetooth device, and the near field connection referred to hereinafter may be a bluetooth connection; wherein, under some reading pen usage scenarios, bluetooth equipment can be for some reading pen, under other usage scenarios, bluetooth equipment can be mouse, intelligent camera etc..
The first host may have a bluetooth function, and in step 110, on the premise that the bluetooth function of the first host is turned on, by scanning and searching for each bluetooth device near the first host, based on a search result, a near field communication device list may be obtained; at least one near field communication device may be included in the near field communication device list, and each near field communication device in the near field communication device list may be a bluetooth device in the vicinity of the first host.
Step 120, the target near field communication device is screened from the near field communication device list.
Optionally, the signal strengths corresponding to all the near field communication devices in the near field communication device list may be determined, and the near field communication device with the highest corresponding signal strength is selected from the near field communication device list as the target near field communication device; or, randomly screening one near field communication device from the near field communication device list as a target near field communication device; or, the near field communication device list may be presented to the user, and the user selects one near field communication device in the near field communication device list in a voice mode or a touch mode, and the near field communication device selected by the user may be used as the target near field communication device.
Step 130, broadcasting a first notification message under the condition that the target near field communication device is in a connected state; the first notification message is used for representing that the first host requests to be connected to the target near field communication equipment, so that the second host receiving the first notification message disconnects the first near field connection under the condition that the first near field connection is established between the second host and the target near field communication equipment.
Optionally, the near field communication device list may further record respective states of each included near field communication device, where the state of any near field communication device may have two possible situations, namely a connected state and an unconnected state; the connected state indicates that the near field communication equipment currently establishes near field connection with a certain host, and the unconnected state indicates that the near field communication equipment currently does not establish near field connection with any host.
After the target near field communication device has been screened out by performing step 120, the status of the target near field communication device may be determined from the information recorded in the near field communication device list.
If the state of the target near field communication equipment is in an unconnected state, the first host can directly establish near field connection between the first host and the target near field communication equipment according to a standard Bluetooth protocol; the standard Bluetooth protocol may be a Bluetooth Low Energy (BLE) protocol.
If the state of the target near field communication device is a connected state, the first host may generate a first notification message for requesting connection to the target near field communication device according to a standard bluetooth protocol, and broadcast the first notification message, so that each host near the first host can receive the first notification message; the communication distance between each host near the first host and the first host is within the communication range supported by the standard Bluetooth protocol; the first notification message may be in the form of BLE broadcast data.
Assuming that the second host receives the first notification message, the second host may then determine whether a first near field connection is established between itself and the target near field communication device. If a first near-field connection is established between the second host and the target near-field communication equipment, the second host can actively disconnect the first near-field connection; if the first near field connection is not established between the second host and the target near field communication device, the second host does not need to perform a disconnection operation.
A second near field connection is established between the first host and the target near field communication device that has been switched to the unconnected state, step 140.
As described above, the second host may disconnect the first near field connection according to the first notification message, so that the target near field communication device may be switched from a connected state to an unconnected state, and when the target near field communication device is switched to the unconnected state, the second host may establish a second near field connection between itself and the target near field communication device according to a standard bluetooth protocol.
In the embodiment of the disclosure, the first host may scan the near field communication device list, and determine the target near field communication device to be connected through screening of the near field communication device list, and then, the first host may actively disconnect the near field connection with the target near field communication device by the second host connected to the target near field communication device through broadcasting of the first notification message under the condition that the target near field communication device is in a connected state, so as to ensure that the near field connection can be successfully established between the first host and the target near field communication device. Therefore, in the embodiment of the disclosure, on the premise of not modifying the hardware of the near field communication device, the switching of the host connected with the near field communication device can be conveniently and quickly realized through the communication between the hosts, and therefore, the embodiment of the disclosure can reduce the cost for realizing the connection switching.
On the basis of the embodiment shown in fig. 1, as shown in fig. 2, the method further comprises a step 121 and a step 123 before the step 130.
In step 121 a first sequence of characters for identifying a target near field communication device is determined.
In one embodiment, step 121 includes:
determining a first MAC address of a target near field communication device based on a device name of the target near field communication device;
from the first MAC address, a first sequence of characters identifying the target near field communication device is intercepted.
Optionally, the near field communication device list may record respective device names of the included near field communication devices, and the device name of any near field communication device may be composed of two parts, which are respectively an agreed prefix and an MAC address of the near field communication device; wherein, the appointed prefix can include any character; the English corresponding to the MAC Address is called Media Access Control Address, and the Chinese corresponding to the MAC Address means Media Access Control Address.
In step 121, the device name of the target near field communication device may be extracted from the near field communication device list, and the MAC address may be extracted from the device name of the target near field communication device as the first MAC address, and then several characters capable of serving as device identification may be intercepted from the first MAC address, and a sequence of the intercepted several characters may be taken as the first character sequence.
In one example, the device name of the target near field communication device is RSDPP _ ABCDEF, RSDPP _ is the agreed prefix, ABCDEF is the first MAC address of the target near field communication device, then CDEF may be truncated from ABCDEF as the first character sequence. Of course, BCDEF may also be truncated from ABCDEF as the first character sequence, depending on the actual situation.
In this embodiment, the first MAC address of the target near field communication device is determined based on the device name of the target near field communication device, and the first MAC address is intercepted, so that the first character sequence for identifying the target near field communication device can be obtained efficiently and reliably.
Of course, the specific implementation of step 121 is not limited to this, for example, the first MAC address itself may be used as the first character sequence, and for example, ABCDEF may be used as the first character sequence.
Step 123, generating a first notification message; the first character sequence is stored in a first preset position in the first notification message, and the connection request identifier is stored in a second preset position in the first notification message.
Alternatively, the request connection identifier may be represented by a first preset character, and the first preset character may be 1 or other characters.
It should be noted that any notification message involved in the embodiments of the present disclosure may include 20 bytes for storing a broadcast Universal Unique Identifier (UUID); the 16 th, 17 th, 18 th, 19 th and 20 th bytes are usable parts, and then the four bytes 16, 17 th, 18 th and 19 th bytes can be used as the first predetermined position, and the 20 th byte position can be used as the second predetermined position.
In generating the first notification message, C may be placed in the 16 th byte, D in the 17 th byte, E in the 18 th byte, F in the 19 th byte, and 1 in the 20 th byte, whereby the first notification message storing the first character sequence and the request connection identification may be generated.
In this way, after receiving the first notification message, according to the connection request identifier stored in the second predetermined location in the first notification message, the second host can determine that the first host has a need to connect to a certain near field communication device, and according to the first character sequence stored in the first predetermined location in the first notification message, the second host can efficiently and reliably determine which near field communication device the first host needs to connect to, and accordingly, the second host can determine whether it needs to perform a disconnection operation.
In one optional example, establishing a second near field connection between the first host and the target near field communication device that has switched to an unconnected state comprises:
under the condition of receiving a second notification message broadcasted by a second host, determining that the target near field communication equipment is switched to an unconnected state, and establishing a second near field connection between the first host and the target near field communication equipment;
wherein the second notification message is used to characterize that the second host has disconnected the first near field connection.
Optionally, after the second host successfully disconnects the first near-field connection according to the first notification message, the second host may generate a second notification message for indicating that the second host has disconnected the first near-field connection according to a standard bluetooth protocol, and broadcast the second notification message, so that each host (including the first host) near the second host can receive the second notification message; wherein the second notification message may be in the form of BLE broadcast data.
In case of receiving the second notification message, the first host may determine that the target near field communication device has switched to an unconnected state, and the second host may immediately establish a second near field connection between itself and the target near field communication device according to the standard bluetooth protocol. In this way, by using the reception of the second notification message as a trigger condition for establishing the near field connection, it is possible to efficiently and reliably determine the timing suitable for establishing the second near field connection between the first host and the target near field communication device.
Of course, in specific implementation, the first host may not receive the second notification message as a trigger condition for establishing the near field connection, for example, the first host may periodically scan the near field communication device list, and if it is determined that the device of the target near field communication device is in an unconnected state based on information recorded in the near field communication device list obtained by scanning at a certain time, the first host may establish the second near field connection between itself and the target near field communication device, which is also feasible.
The following describes a method for implementing connection switching provided by the present disclosure from the perspective of the second host.
Fig. 3 is a flowchart illustrating a method for implementing connection switching according to an exemplary embodiment of the present disclosure. The method shown in fig. 3 is applied to the second host, and the method shown in fig. 3 includes steps 310 and 320, which are described below.
Step 310, receiving a first notification message broadcasted by the first host, wherein the first notification message is used for representing that the first host requests to connect to the target near field communication device.
The second host may have a bluetooth function, and in step 310, the first notification message broadcasted by the first host may be received on the premise that the bluetooth function of the second host is turned on.
In step 320, in case a first near field connection is established between the second host and the target near field communication device, the first near field connection is disconnected.
In the embodiment of the disclosure, after receiving the first notification message broadcast by the first host, the second host may actively disconnect the first near-field connection under the condition that the first near-field connection is established between the second host and the target near-field communication device, so as to ensure that the near-field connection can be successfully established between the first host and the target near-field communication device. Therefore, on the premise of not modifying the hardware of the near field communication equipment, the switching of the host connected with the near field communication equipment can be conveniently and quickly realized through the communication between the hosts, and therefore, the cost for realizing the connection switching can be reduced by the embodiment of the disclosure.
On the basis of the embodiment shown in fig. 3, as shown in fig. 4, the method further includes step 311, step 313, step 315, and step 317 before step 320.
In step 311, in the case that the second host is in the connected state, a second MAC address of the connected near field communication device is determined based on the device name of the connected near field communication device of the second host.
Alternatively, the MAC address may be extracted from the device name of the connected near field communication device of the second host as the second MAC address.
Step 313, a second sequence of characters identifying the connected near field communication device is intercepted from the second MAC address.
It should be noted that, in the specific implementation of step 313, reference may be made to the above description of the manner of obtaining the first character sequence, and details are not described herein again.
A first sequence of characters for identifying the target near field communication device is determined based on the first notification message, step 315.
In step 315, a first sequence of characters can be extracted from a first predetermined location of the first notification message.
In step 317, the connected near field communication device is determined to be the target near field communication device in case the first character sequence matches the second character sequence.
In step 317, it may be determined whether the first character sequence is the same as the second character sequence. If the first character sequence is the same as the second character sequence, the first character sequence can be considered to be matched with the second character sequence, and then the connected near field communication equipment can be determined to be target near field communication equipment, namely, a first near field connection is established between the second host and the target near field communication equipment; if the first character sequence is different from the second character sequence it may be determined that the connected near field communication device is not the target near field communication device, i.e. the first near field connection is not established between the second host and the target near field communication device.
In the embodiment of the disclosure, by comparing the second character sequence obtained for the connected nfc device of the second host with the first character sequence obtained based on the first notification message, whether the first nfc is established between the second host and the target nfc device can be efficiently and reliably determined, so as to determine whether the second host needs to perform a disconnection operation.
On the basis of the embodiment shown in fig. 3, as shown in fig. 5, after step 320, the method further comprises step 330, step 340 and step 350.
Based on the first notification message, a first sequence of characters for identifying the target near field communication device is determined, step 330.
In step 330, a first sequence of characters may be extracted from a first predetermined location of the first notification message.
Step 340, generating a second notification message, where a first character sequence is stored in a first predetermined location in the second notification message, and a connection disconnection identifier is stored in a second predetermined location in the second notification message.
Alternatively, the disconnection indication may be represented by a second preset character, and the second preset character may be 2 or another character.
In step 340, a second notification message may be generated according to the standard bluetooth protocol, and assuming that the first predetermined location in the first notification message stores a CDEF and the second predetermined location in the first notification message stores a 1, the first predetermined location in the second notification message may store a CDEF and the second predetermined location in the second notification message may store a 2.
Step 350, broadcasting a second notification message.
In the embodiment of the disclosure, after the first near field connection is successfully disconnected, the second host may timely notify the first host that the first near field connection is disconnected through generation and broadcast of the second notification message, so that the first host establishes the second near field connection at a proper time.
On the basis of the embodiment shown in fig. 3, as shown in fig. 6, after step 320, the method further comprises step 360 and step 370.
And step 360, starting timing from the moment when the first near field connection is disconnected.
Alternatively, a timer may be set and controlled to start counting from the moment when the first near-field connection is disconnected.
And step 370, establishing a third near field connection between the second host and the target near field communication device when the timing duration reaches a preset duration and the target near field communication device is in an unconnected state.
Alternatively, the preset time period may be 3 seconds, 4 seconds, 5 seconds, 6 seconds or other time periods, which are not listed here.
In the embodiment of the disclosure, when the timing duration of the timer reaches the preset duration, the second host may scan the near field communication device list, and determine the current state of the target near field communication device based on information recorded in the scanned near field communication device list. If the current state of the target near field communication device is an unconnected state, this indicates that the second host has reserved enough connection time for the first host, but the first host has not successfully connected to the target near field communication device, which is likely caused by a failure of the first host, so the second host may actively establish a third near field connection with the target near field communication device, and thus the second host may re-provide service for the user, for example, the user may read a pen through an operating point, so that the second host plays a video that is interesting to the user.
Any of the methods for implementing a connection switch provided by embodiments of the present disclosure may be performed by any suitable device having data processing capabilities, including but not limited to: terminal equipment, a server and the like. Alternatively, any of the methods for implementing connection switching provided by the embodiments of the present disclosure may be executed by a processor, for example, the processor executes any of the methods for implementing connection switching mentioned by the embodiments of the present disclosure by calling a corresponding instruction stored in a memory. And will not be described in detail below.
Exemplary devices
The present disclosure provides an apparatus for implementing connection switching from the perspective of a first host and a second host, respectively, and the apparatus for implementing connection switching provided by the present disclosure from the perspective of a first host is first described below.
Fig. 7 is a schematic structural diagram of an apparatus for implementing connection switching according to an exemplary embodiment of the present disclosure, where the apparatus shown in fig. 7 is applied to a first host, and the apparatus shown in fig. 7 includes a scanning module 710, a screening module 720, a first broadcasting module 730, and a first connection module 740.
A scanning module 710 for scanning a near field communication device list;
a screening module 720, configured to screen a target near field communication device from the near field communication device list;
a first broadcasting module 730, configured to broadcast a first notification message if the target near field communication device is in a connected state; wherein the first notification message is used for representing that the first host requests to connect to the target near field communication device, so that a second host receiving the first notification message disconnects a first near field connection when the first near field connection is established between the second host and the target near field communication device;
a first connection module 740, configured to establish a second near field connection between the first host and the target near field communication device that has been switched to an unconnected state.
In one optional example, the apparatus further comprises:
a first determining module for determining a first sequence of characters for identifying a target near field communication device prior to broadcasting a first notification message;
the first generating module is used for generating a first notification message; the first character sequence is stored in a first preset position in the first notification message, and the connection request identifier is stored in a second preset position in the second notification message.
In one optional example, the first determining module comprises:
a determining submodule, configured to determine a first MAC address of a target near field communication device based on a device name of the target near field communication device;
and the intercepting submodule is used for intercepting a first character sequence used for identifying the target near field communication equipment from the first MAC address.
In an optional example, the first connection module 740 is specifically configured to:
under the condition of receiving a second notification message broadcasted by a second host, determining that the target near field communication equipment is switched to an unconnected state, and establishing a second near field connection between the first host and the target near field communication equipment;
wherein the second notification message is used to characterize that the second host has disconnected the first near field connection.
The following describes an apparatus for implementing connection switching provided by the present disclosure from the perspective of the second host.
Fig. 8 is a schematic structural diagram of an apparatus for implementing connection switching according to an exemplary embodiment of the present disclosure, where the apparatus shown in fig. 8 is applied to a second host, and the apparatus shown in fig. 8 includes a receiving module 810 and a disconnection module 820.
A receiving module 810, configured to receive a first notification message broadcasted by a first host, where the first notification message is used to characterize that the first host requests to connect to a target near field communication device;
a disconnection module 820 configured to disconnect the first near-field connection if the first near-field connection is established between the second host and the target near-field communication device.
In one optional example, the apparatus further comprises:
a second determining module, configured to determine, when a first near-field connection is established between a second host and a target near-field communication device, a second MAC address of a connected near-field communication device based on a device name of the connected near-field communication device of the second host, before the first near-field connection is disconnected, and when the second host is in a connected state;
an intercepting module, configured to intercept a second character sequence for identifying the connected near field communication device from the second MAC address;
a third determining module for determining a first sequence of characters for identifying a target near field communication device based on the first notification message;
and the fourth determining module is used for determining the connected near field communication equipment as the target near field communication equipment under the condition that the first character sequence is matched with the second character sequence.
In one optional example, the apparatus further comprises:
a fifth determining module for determining a first sequence of characters for identifying the target near field communication device based on the first notification message after the first near field connection is disconnected;
the second generation module is used for generating a second notification message, a first character sequence is stored in a first preset position in the second notification message, and a connection disconnection identifier is stored in a second preset position in the second notification message;
and the second broadcasting module is used for broadcasting the second notification message.
In one optional example, the apparatus further comprises:
the timing module is used for starting timing from the moment when the first near field connection is disconnected after the first near field connection is disconnected;
and the second connection module is used for establishing a third near field connection between the second host and the target near field communication equipment when the timing reaches the preset duration and the target near field communication equipment is in an unconnected state.
Exemplary electronic device
Next, an electronic apparatus according to an embodiment of the present disclosure is described with reference to fig. 9. The electronic device may be either or both of the first device and the second device, or a stand-alone device separate from them, which stand-alone device may communicate with the first device and the second device to receive the acquired input signals therefrom.
Fig. 9 illustrates a block diagram of an electronic device 900 in accordance with an embodiment of the disclosure.
As shown in fig. 9, the electronic device 900 includes one or more processors 910 and memory 920.
The processor 910 may be a Central Processing Unit (CPU) or other form of processing unit having data processing capabilities and/or instruction execution capabilities, and may control other components in the electronic device 900 to perform desired functions.
Memory 920 may store one or more computer program products, and memory 920 may include various forms of computer-readable storage media, such as volatile memory and/or non-volatile memory. The volatile memory may include, for example, random Access Memory (RAM), cache memory (cache), and/or the like. The non-volatile memory may include, for example, read Only Memory (ROM), hard disk, flash memory, etc. One or more computer program products may be stored on the computer-readable storage medium and executed by the processor 910 to implement the method for implementing connection switching applied to the first host or the second host of the various embodiments of the present disclosure described above and/or other desired functions. The computer readable storage medium may also store various content such as an input signal, a signal component, a noise component, and the like.
In one example, the electronic device 900 may further include: an input device 930 and an output device 940, which are interconnected by a bus system and/or other form of connection mechanism (not shown).
For example, when the electronic device 900 is a first device or a second device, the input 930 may be a microphone or an array of microphones. When the electronic device 900 is a stand-alone device, the input 930 may be a communication network connector for receiving the acquired input signals from the first device and the second device.
The input device 930 may also include, for example, a keyboard, a mouse, and the like.
The output device 940 may output various information to the outside. The output devices 940 may include, for example, a display, speakers, a printer, and a communication network and remote output devices connected thereto, among others.
Of course, for simplicity, only some of the components of the electronic device 900 relevant to the present disclosure are shown in fig. 9, omitting components such as buses, input/output interfaces, and so forth. In addition, electronic device 900 may include any other suitable components depending on the particular application.
Exemplary computer program product and computer-readable storage Medium
In addition to the above-described methods and apparatus, embodiments of the present disclosure may also be a computer program product comprising computer program instructions that, when executed by a processor, cause the processor to perform the steps in the method for implementing a connection switch applied to a first host or a second host according to various embodiments of the present disclosure described in the "exemplary methods" section above in this specification.
The computer program product may write program code for carrying out operations for embodiments of the present disclosure in any combination of one or more programming languages, including an object oriented programming language such as Java, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device, or entirely on the remote computing device or server.
Furthermore, embodiments of the present disclosure may also be a computer-readable storage medium having stored thereon computer program instructions that, when executed by a processor, cause the processor to perform steps in a method for implementing a connection switch applied to a first host or a second host according to various embodiments of the present disclosure described in the "exemplary methods" section above in this specification.
The computer-readable storage medium may take any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may include, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The foregoing describes the general principles of the present disclosure in conjunction with specific embodiments, however, it is noted that the advantages, effects, etc. mentioned in the present disclosure are merely examples and are not limiting, and they should not be considered essential to the various embodiments of the present disclosure. Furthermore, the foregoing disclosure of specific details is for the purpose of illustration and description and is not intended to be limiting, since the disclosure is not intended to be limited to the specific details so described.
In the present specification, the embodiments are described in a progressive manner, and each embodiment focuses on differences from other embodiments, and the same or similar parts in each embodiment are referred to each other. For the system embodiment, since it basically corresponds to the method embodiment, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The block diagrams of devices, apparatuses, systems referred to in this disclosure are only given as illustrative examples and are not intended to require or imply that the connections, arrangements, configurations, etc. must be made in the manner shown in the block diagrams. These devices, apparatuses, devices, systems may be connected, arranged, configured in any manner, as will be appreciated by one skilled in the art. Words such as "including," "comprising," "having," and the like are open-ended words that mean "including, but not limited to," and are used interchangeably therewith. The words "or" and "as used herein mean, and are used interchangeably with, the word" and/or, "unless the context clearly dictates otherwise. The word "such as" is used herein to mean, and is used interchangeably with, the phrase "such as but not limited to".
The methods and apparatus of the present disclosure may be implemented in a number of ways. For example, the methods and apparatus of the present disclosure may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above-described order for the steps of the method is for illustration only, and the steps of the method of the present disclosure are not limited to the order specifically described above unless specifically stated otherwise. Further, in some embodiments, the present disclosure may also be embodied as programs recorded in a recording medium, the programs including machine-readable instructions for implementing the methods according to the present disclosure. Thus, the present disclosure also covers a recording medium storing a program for executing the method according to the present disclosure.
It is also noted that in the devices, apparatuses, and methods of the present disclosure, each component or step can be decomposed and/or recombined. These decompositions and/or recombinations are to be considered equivalents of the present disclosure.
The previous description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other aspects without departing from the scope of the disclosure. Thus, the present disclosure is not intended to be limited to the aspects shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
The foregoing description has been presented for purposes of illustration and description. Furthermore, this description is not intended to limit embodiments of the disclosure to the form disclosed herein. While a number of example aspects and embodiments have been discussed above, those of skill in the art will recognize certain variations, modifications, alterations, additions and sub-combinations thereof.

Claims (11)

1. A method for implementing connection switching, applied to a first host, the method comprising:
scanning a near field communication device list;
screening target near field communication equipment from the near field communication equipment list;
broadcasting a first notification message if the target near field communication device is in a connected state; wherein the first notification message is used for representing that the first host requests to connect to the target near field communication device, so that a second host receiving the first notification message disconnects a first near field connection when the first near field connection is established between the second host and the target near field communication device;
establishing a second near field connection between the first host and the target near field communication device that has been switched to an unconnected state.
2. The method of claim 1, wherein prior to broadcasting the first notification message, the method further comprises:
determining a first sequence of characters for identifying the target near field communication device;
generating a first notification message; the first character sequence is stored in a first preset position in the first notification message, and the connection request identifier is stored in a second preset position in the second notification message.
3. The method of claim 2, wherein determining the first sequence of characters for identifying the target near field communication device comprises:
determining a first MAC address of the target near field communication device based on a device name of the target near field communication device;
-intercepting a first sequence of characters identifying the target near field communication device from the first MAC address.
4. The method of claim 1, wherein establishing a second near field connection between the first host and the target near field communication device that has been switched to an unconnected state comprises:
determining that the target near field communication device has switched to the unconnected state and establishing a second near field connection between the first host and the target near field communication device, in the event of receiving a second notification message broadcast by a second host;
wherein the second notification message is used to characterize that the second host has disconnected the first near field connection.
5. A method for implementing connection switching, applied to a second host, the method comprising:
receiving a first notification message broadcast by a first host, wherein the first notification message is used for representing that the first host requests to be connected to a target near field communication device;
disconnecting the first near field connection if the first near field connection is established between the second host and the target near field communication device.
6. The method of claim 5, wherein before disconnecting the first near field connection in the case where the first near field connection is established between the second host and the target near field communication device, the method further comprises:
determining a second MAC address of a connected near field communication device of the second host based on a device name of the connected near field communication device if the second host is in a connected state;
intercepting a second sequence of characters identifying the connected near field communication device from the second MAC address;
determining a first sequence of characters for identifying the target near field communication device based on the first notification message;
determining that the connected near field communication device is the target near field communication device if the first character sequence matches the second character sequence.
7. The method of claim 5, wherein after said disconnecting the first near field connection, the method further comprises:
determining a first sequence of characters for identifying the target near field communication device based on the first notification message;
generating a second notification message, wherein a first preset position in the second notification message stores the first character sequence, and a second preset position in the second notification message stores a connection disconnection identifier;
broadcasting the second notification message.
8. The method of claim 5, wherein after said disconnecting the first near field connection, the method further comprises:
starting timing from the moment when the first near-field connection is disconnected;
and under the condition that the timing duration reaches a preset duration and the target near field communication equipment is in an unconnected state, establishing a third near field connection between the second host and the target near field communication equipment.
9. An apparatus for implementing connection switching, applied to a first host, the apparatus comprising:
a scanning module for scanning a near field communication device list;
the screening module is used for screening target near field communication equipment from the near field communication equipment list;
a first broadcasting module for broadcasting a first notification message in case the target near field communication device is in a connected state; wherein the first notification message is used for representing that the first host requests to connect to the target near field communication device, so that a second host receiving the first notification message disconnects a first near field connection when the first near field connection is established between the second host and the target near field communication device;
a first connection module for establishing a second near field connection between the first host and the target near field communication device that has been switched to an unconnected state.
10. An apparatus for implementing connection switching, applied to a second host, the apparatus comprising:
a receiving module, configured to receive a first notification message broadcasted by a first host, where the first notification message is used to characterize that the first host requests to connect to a target near field communication device;
a disconnection module configured to disconnect a first near field connection when the first near field connection is established between the second host and the target near field communication device.
11. An electronic device, comprising:
a memory for storing a computer program product;
a processor configured to execute the computer program product stored in the memory, and when the computer program product is executed, the method for implementing connection switching according to any one of the preceding claims 1 to 8 is implemented.
CN202211405836.0A 2022-11-10 2022-11-10 Method and device for realizing connection switching and electronic equipment Pending CN115714967A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211405836.0A CN115714967A (en) 2022-11-10 2022-11-10 Method and device for realizing connection switching and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211405836.0A CN115714967A (en) 2022-11-10 2022-11-10 Method and device for realizing connection switching and electronic equipment

Publications (1)

Publication Number Publication Date
CN115714967A true CN115714967A (en) 2023-02-24

Family

ID=85232729

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211405836.0A Pending CN115714967A (en) 2022-11-10 2022-11-10 Method and device for realizing connection switching and electronic equipment

Country Status (1)

Country Link
CN (1) CN115714967A (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120083209A1 (en) * 2010-09-30 2012-04-05 Apple Inc. Wireless accessory device pairing determination for multiple host devices
CN105812906A (en) * 2016-03-22 2016-07-27 广东欧珀移动通信有限公司 Communication control method and device for playing device
CN108184225A (en) * 2017-12-29 2018-06-19 飞天诚信科技股份有限公司 Cancel the method and intelligent terminal of bluetooth connection in a kind of Bluetooth connection process in real time
CN109379773A (en) * 2018-09-30 2019-02-22 联想(北京)有限公司 A kind of switching method, the first output equipment and the second output equipment
CN110191442A (en) * 2019-04-18 2019-08-30 华为技术有限公司 A kind of Bluetooth connecting method, equipment and system
CN113473435A (en) * 2021-08-19 2021-10-01 Oppo广东移动通信有限公司 Bluetooth-based equipment connection method and device, electronic equipment and storage medium
CN113965895A (en) * 2021-12-16 2022-01-21 深圳市晨北科技有限公司 Bluetooth connection switching method, equipment and storage medium
WO2022055415A1 (en) * 2020-09-14 2022-03-17 Razer (Asia-Pacific) Pte. Ltd. Seamless bluetooth switching system
CN114513773A (en) * 2022-01-25 2022-05-17 深圳市飞科笛系统开发有限公司 Audio playing method, system, audio playing device and storage medium

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120083209A1 (en) * 2010-09-30 2012-04-05 Apple Inc. Wireless accessory device pairing determination for multiple host devices
CN105812906A (en) * 2016-03-22 2016-07-27 广东欧珀移动通信有限公司 Communication control method and device for playing device
CN108184225A (en) * 2017-12-29 2018-06-19 飞天诚信科技股份有限公司 Cancel the method and intelligent terminal of bluetooth connection in a kind of Bluetooth connection process in real time
CN109379773A (en) * 2018-09-30 2019-02-22 联想(北京)有限公司 A kind of switching method, the first output equipment and the second output equipment
CN110191442A (en) * 2019-04-18 2019-08-30 华为技术有限公司 A kind of Bluetooth connecting method, equipment and system
WO2022055415A1 (en) * 2020-09-14 2022-03-17 Razer (Asia-Pacific) Pte. Ltd. Seamless bluetooth switching system
CN113473435A (en) * 2021-08-19 2021-10-01 Oppo广东移动通信有限公司 Bluetooth-based equipment connection method and device, electronic equipment and storage medium
CN113965895A (en) * 2021-12-16 2022-01-21 深圳市晨北科技有限公司 Bluetooth connection switching method, equipment and storage medium
CN114513773A (en) * 2022-01-25 2022-05-17 深圳市飞科笛系统开发有限公司 Audio playing method, system, audio playing device and storage medium

Similar Documents

Publication Publication Date Title
US10142425B2 (en) Session reliability for a redirected USB device
EP3654591B1 (en) Method and device for transmitting multimedia message, storage medium, and electronic apparatus
US20220391489A1 (en) Data processing method and apparatus, computer device, and storage medium
EP3163946A1 (en) Information transmission method and apparatus, device, computer program and recording medium
US10554831B2 (en) Remote maintenance system for image processing apparatus, capable of reducing user's time and effort, communication establishment method, and storage medium
CN113438527A (en) Video screen projection method, device, equipment and storage medium
CN112346751B (en) Application program installation method and device, electronic equipment and storage medium
CN114338650A (en) File transmission method and device, electronic equipment and readable storage medium
CN111246238A (en) Live broadcast method, device, storage medium and live broadcast system
JP2021028819A (en) Smart service method, apparatus, and device
EP3174244B1 (en) Video communication ending method and apparatus, computer program and recording medium
US11706301B2 (en) Server node selection method and terminal device
CN107707939B (en) Video access method, access balance server, central server and system
CN113079588A (en) Control method, control device, control equipment and storage medium
CN115714967A (en) Method and device for realizing connection switching and electronic equipment
CN111787054A (en) Cloud game input method, device, equipment and medium
CN107566215B (en) Wireless network cutout detection method, device, storage medium and mobile terminal
CN112291788B (en) Data processing method, device, storage medium, terminal and network access point equipment
CN113242314B (en) Cross-terminal resource access method and device, storage medium and electronic equipment
WO2022078119A1 (en) Cross-device data sharing method and related device
CN114880018A (en) Request processing method and device, storage medium and electronic equipment
CN114630323A (en) Voice call service processing method and device and computer readable storage medium
CN113518107A (en) File transmission method, computing device and computer storage medium
CN112398919A (en) Message pushing method, device, equipment and storage medium
CN112261051B (en) User registration method, device and system

Legal Events

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