Device switching method, device, electronic device and storage medium
By detecting input commands and switching network devices based on device identifiers, the problem of inconvenience in switching between multiple devices in a server room using keyboards and mice has been solved, achieving seamless device switching.
Patent Information
- Application Number
- CN202111604249.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-24
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2041-12-24
AI Technical Summary
In server rooms, switching between multiple devices with a keyboard and mouse requires unplugging and replugging the wireless receiver, which is inconvenient.
By receiving the current input command from the input/output device, detecting whether it is a switching command, and changing the current device of the first network device to the target network device according to the device identifier of the target network device carried in the switching command, the input command is forwarded to the target device through the connector and network, thereby achieving seamless switching between multiple network devices.
It avoids the tedious operation of re-plugging and unplugging input/output device receivers, and enables convenient device switching between multiple network devices.
Smart Images

Figure CN114553935B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a device switching method, a device switching apparatus, an electronic device and a readable storage medium. Background Art
[0002] With the rapid development of science and technology, there are more and more electronic products, and many electronic products are inseparable from servers, so there are many server rooms. In the server room, there are usually 1 or 2 sets of keyboards and mice for debugging. There are many servers in the server room. The keyboard and mouse are on one server. When you need to debug another server, you have to re-plug the keyboard and mouse, which is very inconvenient.
[0003] In the prior art, the wireless mouse and keyboard can be used to switch between different server devices, providing many conveniences for users. However, when using other devices, the wireless receivers of the mouse and keyboard still need to be re-plugged. In short, it is inconvenient to switch between multiple devices. Summary of the invention
[0004] The technical problem to be solved by the embodiments of the present invention is to provide a device switching method, apparatus, electronic device and readable storage medium, so as to solve the problem of the inconvenience of keyboard and mouse switching between multiple devices.
[0005] In order to solve the above problem, the present invention provides a device switching method, comprising:
[0006] Receive current input instructions from input and output devices;
[0007] Detecting whether the current input instruction is a switching instruction;
[0008] If the current input instruction is a switching instruction, the currently used device recorded on the first network device is changed to the target network device according to the device identifier of the switched target network device carried by the switching instruction, so that after the first network device receives the input instruction of the input-output device, the input instruction is forwarded to the target network device; wherein the first network device and the input-output device are connected via a connector.
[0009] Optionally, the plurality of network devices are interconnected via a network switch, and the method further comprises:
[0010] If the current input instruction is not a switching instruction, the first network device forwards the current input instruction to the currently used device via the network switch.
[0011] Optionally, the device identification includes a unique number, and before receiving the current input instruction of the input / output device, the method further includes:
[0012] Receiving a unique identifier and a network address sent by each network device; wherein the unique identifier is generated based on a unique number and a hardware address of the network device, and the unique number is pre-assigned to each network device;
[0013] Parse the unique identifier of each network device to obtain the unique number and hardware address of each network device;
[0014] Record the unique number, hardware address and network address of each network device;
[0015] After changing the currently used device recorded on the first network device to the target network device according to the device identification of the switched target network device carried in the switching instruction, forwarding the input instruction to the target network device includes:
[0016] Generate a protocol packet corresponding to the input instruction according to the unique number of the target network device; wherein the protocol packet includes the network address corresponding to the unique number and the input instruction;
[0017] According to the network address in the protocol packet, the protocol packet is forwarded to the target network device.
[0018] Optionally, the changing the currently used device recorded on the first network device to the target network device according to the device identifier of the switched target network device carried in the switching instruction comprises:
[0019] According to the unique number of the target network device, searching for the record of the unique number, hardware address and network address of the target network device;
[0020] If the records of the unique number, hardware address and network address of the target network device are found, the currently used device recorded on the first network device is changed to the target network device.
[0021] Optionally, when the currently used device and the first network device are the same device, the method further includes:
[0022] If the current input instruction is a switching instruction, the function of the first network device using the input and output device is disabled.
[0023] Optionally, if the current input instruction is a switching instruction, after changing the currently used device recorded on the first network device to the target network device according to the device identifier of the switched target network device carried in the switching instruction, the method further includes:
[0024] When the target network device and the first network device are not the same device, establishing a connection between the first network device and the target network device for transmitting the input instruction;
[0025] Alternatively, when the target network device and the first network device are the same device, a function of the first network device using the input and output device is enabled.
[0026] The present invention also provides a device switching apparatus, comprising:
[0027] An instruction receiving module, used for receiving current input instructions of an input and output device;
[0028] An instruction detection module, used to detect whether the current input instruction is a switching instruction;
[0029] A device change module is used to change the currently used device recorded on the first network device to the target network device according to the device identifier of the switched target network device carried by the switching instruction if the current input instruction is a switching instruction, so that after the first network device receives the input instruction of the input-output device, the input instruction is forwarded to the target network device; wherein the first network device and the input-output device are connected via a connector.
[0030] Optionally, the plurality of network devices are interconnected via a network switch, and the apparatus further comprises:
[0031] The forwarding module is used for, if the current input instruction is not a switching instruction, causing the first network device to forward the current input instruction to the currently used device via the network switch.
[0032] Optionally, the device identifier includes a unique number, and the apparatus further includes:
[0033] An address receiving module, used for receiving a unique identifier and a network address sent by each network device before receiving the current input instruction of the input / output device; wherein the unique identifier is generated according to a unique number and a hardware address of the network device, and the unique number is pre-assigned to each network device;
[0034] A parsing module is used to parse the unique identification of each network device to obtain the unique number and hardware address of each network device;
[0035] A recording module, used to record the unique number, hardware address and network address of each network device;
[0036] A protocol packet generation module, configured to generate a protocol packet corresponding to the input instruction according to the unique number of the target network device after the device identification of the switched target network device carried by the switching instruction is changed from the currently used device recorded on the first network device to the target network device; wherein the protocol packet includes the network address corresponding to the unique number and the input instruction;
[0037] The instruction forwarding module is used to forward the protocol packet to the target network device according to the network address in the protocol packet.
[0038] Optionally, the device change module includes:
[0039] A record search submodule, used to search for the record of the unique number, hardware address and network address of the target network device according to the unique number of the target network device;
[0040] The device changing submodule is used to change the currently used device recorded on the first network device to the target network device if the record of the unique number, hardware address and network address of the target network device is found.
[0041] Optionally, the device further comprises:
[0042] The function closing module is used to close the function of the first network device using the input and output device when the currently used device and the first network device are the same device and if the current input instruction is a switching instruction.
[0043] Optionally, the device further comprises:
[0044] a connection establishing module, configured to, if the current input instruction is a switching instruction, after changing the currently used device recorded on the first network device to the target network device according to the device identifier of the switched target network device carried in the switching instruction, establish a connection between the first network device and the target network device for transmitting the input instruction when the target network device and the first network device are not the same device;
[0045] Alternatively, the function enabling module is used to enable the function of the first network device to use the input and output device when the target network device and the first network device are the same device.
[0046] The embodiment of the present invention further discloses an electronic device, characterized in that it includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0047] Memory, used to store computer programs;
[0048] The processor is used to implement the above-mentioned method steps when executing the program stored in the memory.
[0049] The embodiment of the present invention further discloses a readable storage medium. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute one or more methods described in the embodiment of the present invention.
[0050] According to an embodiment of the present invention, by receiving the current input instruction of an input / output device, it is detected whether the current input instruction is a switching instruction. If the current input instruction is a switching instruction, the currently used device recorded on the first network device is changed to the target network device according to the device identifier of the switched target network device carried by the switching instruction, so that after the first network device receives the input instruction of the input / output device, the input instruction is forwarded to the target network device. The first network device and the input / output device are connected via a connector, so that the connector only needs to be inserted into one network device, and the input / output device can be switched between multiple network devices. The input instruction can be forwarded to the target network device via the network, avoiding the tedious operation of re-plugging and re-plugging the receiver of the input / output device, and realizing convenient switching of the input / output device between multiple network devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 A flowchart of a device switching method provided by an embodiment of the present invention is shown;
[0052] Figure 2 A schematic diagram showing device switching using a mouse and keyboard is shown;
[0053] Figure 3 A flowchart of a device switching method provided by another embodiment of the present invention is shown;
[0054] Figure 4 A schematic diagram showing a process of generating a random code table is shown;
[0055] Figure 5 A schematic diagram showing a wireless mouse and keyboard switching network device is shown;
[0056] Figure 6 A schematic diagram showing the communication process between a wireless mouse and keyboard and a network device;
[0057] Figure 7 A structural block diagram of an embodiment of a device switching apparatus provided by another embodiment of the present invention is shown;
[0058] Figure 8 A structural block diagram of an electronic device for device switching according to an exemplary embodiment is shown. DETAILED DESCRIPTION
[0059] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0060] Reference Figure 1 , shows a flow chart of a device switching method provided by an embodiment of the present invention, which may specifically include the following steps:
[0061] Step 101, receiving the current input instruction of the input / output device.
[0062] In the embodiment of the present invention, the network device that executes step 101, step 102 and step 103 may be the first network device or the currently used device, which is not limited in the embodiment of the present invention.
[0063] In the embodiment of the present invention, the input and output devices include a mouse, a keyboard, a display with a touch function, etc., or any other applicable input and output devices, which are not limited in the embodiment of the present invention. The user can input on the input and output device, and the input and output device generates corresponding input instructions and sends them to the network device connected to the input and output device. Among them, the network device includes a server in a server room, a personal computer in a local area network, etc., or any other applicable network device, which is not limited in the embodiment of the present invention.
[0064] For example, when the input / output device is a keyboard, the input instruction may be a command generated by a user pressing one or more keys on the keyboard. When the input / output device is a mouse, the input instruction may be a click operation performed by the user using the mouse, and a command generated accordingly.
[0065] Step 102: Detect whether the current input instruction is a switching instruction.
[0066] In the embodiment of the present invention, a switching instruction refers to an instruction for switching a network device using an input / output device from one network device to another network device in a pre-agreed manner. For example, an input instruction generated by a combination of multiple keys on a keyboard is agreed upon as a switching instruction, or an input instruction generated by clicking a button set on a control software with a mouse is agreed upon as a switching instruction, or any other applicable switching instruction is agreed upon, and the embodiment of the present invention does not limit this.
[0067] In the embodiment of the present invention, after receiving the current input instruction, it is detected whether the current input instruction is a switching instruction. The current input instruction is either a switching instruction or a non-switching instruction. A non-switching instruction is a common operation instruction, for example, when a user types, various numbers and letters entered on the keyboard correspond to the generated input instructions.
[0068] In the embodiment of the present invention, the network device to which the switching instruction is to be switched is recorded as the target network device, so the switching instruction carries the device identification of the target network device after the switching. The device identification includes a number customized for each network device by the control software running on the network device, or a unique identification of the network device, or any other applicable device identification, which is not limited in the embodiment of the present invention.
[0069] Step 103: If the current input instruction is a switching instruction, the currently used device recorded on the first network device is changed to the target network device according to the device identifier of the switched target network device carried by the switching instruction, so that after the first network device receives the input instruction of the input-output device, the input instruction is forwarded to the target network device; wherein the first network device and the input-output device are connected via a connector.
[0070] In an embodiment of the present invention, the connector of the input-output device is used to connect the input-output device to a certain network device. For example, when the input-output device is a wireless mouse and keyboard, the connector is a wireless connector of the wireless mouse and keyboard. The first network device is one of the plurality of network devices. When the input-output device is used, the connector of the input-output device is inserted into a network device, and the network device into which the connector is inserted is the first network device. The first network device and the input-output device are connected via the connector.
[0071] In an embodiment of the present invention, the first network device records the currently used device of the input / output device. The currently used device may be the first network device or another network device other than the first network device. When the currently used device is the first network device, the input instruction of the input / output device directly reaches the first network device through the connector, and the first network device receives the input instruction without forwarding the input instruction to other network devices. When the currently used device is another network device other than the first network device, after the input instruction of the input / output device reaches the first network device through the connector, the first network device needs to forward the input instruction to the currently used device, and the currently used device receives the input instruction.
[0072] In the embodiment of the present invention, if the current input instruction is a switching instruction, the device identification of the target network device after switching is read from the switching instruction. Then, according to the device identification of the target network device after switching, the currently used device recorded on the first network device is changed to the target network device. Thereafter, when the first network device receives the input instruction of the input / output device again, it forwards the input instruction to the target network device, that is, the currently used device of the input / output device is switched to any network device.
[0073] In an optional embodiment of the present invention, multiple network devices are interconnected through a network switch, and the currently used device is not the same device as the first network device. The above steps are a specific implementation method when executed by the first network device, and may also include: if the current input instruction is not a switching instruction, the first network device forwards the current input instruction to the currently used device via the network switch.
[0074] After the first network device receives the current input instruction of the input / output device through the connector, it is responsible for detecting whether the current input instruction is a switching instruction. If the current input instruction is not a switching instruction, the first network device continues to forward the current input instruction to the currently used device, that is, other network devices, via the network switch, thereby realizing the function of other network devices using the input / output device.
[0075] In an optional embodiment of the present invention, multiple network devices are interconnected via a network switch, and the currently used device is not the same device as the first network device. When the above steps are performed by the currently used device, a specific implementation method in which the currently used device receives the current input instructions of the input and output devices may include: the currently used device receives the current input instructions forwarded by the first network device via the network switch.
[0076] After receiving the current input instruction of the input-output device through the connector, the first network device forwards the current input instruction to the currently used device via the network switch. The currently used device receives the current input instruction and then performs the next step of processing.
[0077] Further, according to the device identification of the switched target network device carried by the switching instruction, a specific implementation method in which the currently used device changes the currently used device recorded on the first network device to the target network device may include: the currently used device sends a change request to the first network device through the network switch to change the currently used device recorded on the first network device to the target network device, wherein the change request carries the device identification of the target network device.
[0078] The currently used device changes the currently used device recorded on the first network device to the target network device. The network switch sends a change request to the first network device. After receiving the change request, the first network device changes the currently used device recorded to the target network device according to the device identifier of the target network device carried in the change request.
[0079] In one example, if Figure 2 The schematic diagram of the mouse and keyboard for implementing device switching is shown. The network switch 21 and servers 1, 2, 3, ..., n form a one-to-many network structure, in which the receiver of the wireless mouse and keyboard 11 is inserted into the server 1. The instructions and codes sent by the wireless mouse and keyboard 11 are forwarded through the server 1, so as to realize the operation of the wireless mouse and keyboard 11 on other devices. For example: to realize the switching of the wireless mouse and keyboard 11 to the server 2, first the server 1 receives the switching instruction, the wireless mouse and keyboard 11 establishes a connection with the server 2, and after the successful connection, the instructions sent by the wireless mouse and keyboard 11 are forwarded to the network switch 21 through the server 1, and then sent to the server 2. After receiving the instruction, the server 2 performs the corresponding mouse or keyboard action.
[0080] According to an embodiment of the present invention, by receiving the current input instruction of an input / output device, it is detected whether the current input instruction is a switching instruction. If the current input instruction is a switching instruction, the currently used device recorded on the first network device is changed to the target network device according to the device identifier of the switched target network device carried by the switching instruction, so that after the first network device receives the input instruction of the input / output device, the input instruction is forwarded to the target network device. The first network device and the input / output device are connected via a connector, so that the connector only needs to be inserted into one network device, and the input / output device can be switched between multiple network devices. The input instruction can be forwarded to the target network device via the network, avoiding the tedious operation of re-plugging and re-plugging the receiver of the input / output device, and realizing convenient switching of the input / output device between multiple network devices.
[0081] Reference Figure 3 , shows a flow chart of a device switching method provided by an embodiment of the present invention, which may specifically include the following steps:
[0082] Step 201, receiving a unique identifier and a network address sent by each network device; wherein the unique identifier is generated based on a unique number and a hardware address of the network device, and the unique number is pre-assigned to each network device.
[0083] In the embodiment of the present invention, since each network device may become the first network device or the currently used device, step 201, step 202 and step 203 may be performed on each network device. Of course, it is also possible to perform step 201, step 202 and step 203 only on the first network device or the currently used device.
[0084] In the embodiment of the present invention, the device identification includes a unique number, which can facilitate users to distinguish different network devices. When assigning a unique number to each network device, it can be assigned at any time, sequentially, or in any other applicable assignment manner, which is not limited in the embodiment of the present invention.
[0085] In the embodiment of the present invention, the hardware address is a unique address burned into the network card by the network device manufacturer during production, for example, MAC (Media Access Control Address). For each network device, a unique identifier of the network device is generated based on the unique number and hardware address of the network device. The unique identifier can uniquely identify the network device. For example, the unique number and the hardware address are combined to obtain a code as the unique identifier, or any other applicable generation method is used, which is not limited by the embodiment of the present invention.
[0086] In the embodiment of the present invention, after generating the unique identifier of each network device, the unique identifier and network address of each network device are sent to each network device, so that each network device can be used as a first network device after being inserted into the connector of the input and output device, and has the ability to forward input instructions to other network devices. The network address is a logical address that a node on the Internet has in the network, which can be used to address the node, for example, an IP (Internet Protocol) address.
[0087] Step 202: parse the unique identifier of each network device to obtain the unique number and hardware address of each network device.
[0088] In the embodiment of the present invention, the unique identification of each network device is parsed respectively, that is, the inverse operation of generating the unique identification is performed, so as to obtain the unique number and hardware address of each network device.
[0089] Step 203, record the unique number, hardware address and network address of each network device.
[0090] In the embodiment of the present invention, the unique number, hardware address and network address of each network device are recorded on the network device.
[0091] For example, Figure 4Schematic diagram of the random code table generation process shown. The unique random code (i.e., unique identification) of a network device can be generated by a set of custom algorithms. The algorithm needs to be deployed on each network device to generate the random code based on the MAC address of the network device and the assigned custom number. Then the random code and the corresponding IP address of the network device are sent to each network device (including the network device itself) through the network. After each network device receives the random code and IP address, it parses them and then establishes a random code table based on the parsed number. The random code table contains 3 parts: number, IP address, and MAC address. In the server, it is set to call the algorithm once every preset period (such as 1 minute) to regenerate the random code table, so that the input and output devices can still be used normally when the IP address changes, the network devices increase or decrease, etc.
[0092] Step 204: Receive the current input instruction of the input / output device.
[0093] In the embodiment of the present invention, the specific implementation method of this step can refer to the description in the above embodiment and will not be repeated here.
[0094] Step 205: Detect whether the current input instruction is a switching instruction.
[0095] In the embodiment of the present invention, the specific implementation method of this step can refer to the description in the above embodiment and will not be repeated here.
[0096] Step 206: If the current input instruction is a switching instruction, then according to the device identifier of the switched target network device carried in the switching instruction, the currently used device recorded on the first network device is changed to the target network device.
[0097] In the embodiment of the present invention, the specific implementation method of this step can refer to the description in the above embodiment and will not be repeated here.
[0098] In an optional embodiment of the present invention, according to the device identification of the switched target network device carried by the switching instruction, a specific implementation method of changing the currently used device recorded on the first network device to the target network device may include: if the current input instruction is a switching instruction, then according to the unique number of the target network device, searching for the record of the unique number, hardware address and network address of the target network device. If the record of the unique number, hardware address and network address of the target network device is found, then changing the currently used device recorded on the first network device to the target network device.
[0099] In the embodiment of the present invention, if the current input instruction is a switching instruction, it is necessary to first check whether the unique number carried by the switching instruction has a corresponding network device. According to the unique number of the target network device, the unique number, hardware address and network address of the target network device are searched in the network device record.
[0100] In the embodiment of the present invention, if the record of the unique number, hardware address and network address of the target network device is found, it indicates that the target network device exists and the first network device can obtain the network address of the target network device. At this time, the currently used device recorded on the first network device is changed to the target network device. For example, the number of the currently used device recorded on the first network device is changed to the target network device.
[0101] In an optional embodiment of the present invention, when the currently used device is a first network device, the method may further include: if the current input instruction is a switching instruction, shutting down the function of the first network device using the input and output device.
[0102] When the currently used device is the first network device, the first network device can directly obtain the input instruction of the input-output device through the connector of the input-output device, which is equivalent to the first network device being able to directly use the input-output device without being forwarded by other network devices. When the switching instruction is to switch from the first network device to other network devices, it is necessary to turn off the function of the first network device to use the input-output device, so as to avoid the problem that after the switching, the first network device still executes the processing corresponding to the input instruction after receiving the input instruction of the input-output device, and avoids the problem that the input-output device is used by the first network device and the target network device at the same time.
[0103] In an optional embodiment of the present invention, if the current input instruction is a switching instruction, then according to the device identifier of the switched target network device carried by the switching instruction, after the currently used device recorded on the first network device is changed to the target network device, it may also include: when the target network device and the first network device are not the same device, establishing a connection between the first network device and the target network device for transmitting the input instruction; or, when the target network device and the first network device are the same device, enabling the function of the first network device to use the input and output devices.
[0104] When the target network device and the first network device are not the same device, after the currently used device recorded on the first network device is changed to the target network device, it is necessary to establish a connection between the first network device and the target network device for transmitting input instructions, so that after the first network device receives the input instruction from the input-output device, it sends the input instruction to the target network device.
[0105] When the target network device and the first network device are the same device, the function of the first network device using the input and output devices is enabled, so that after receiving the input instruction of the input and output device, the first network device does not forward the input instruction to other network devices, but directly executes the processing corresponding to the input instruction.
[0106] For example, Figure 5 The schematic diagram of the wireless mouse and keyboard switching network device shown in the figure. Among all the network devices, any one network device is selected as the first network device. A unique random code is generated for each network device, and the random code is sent to each network device, and a random code table is generated from the received random code. The wireless connector of the wireless mouse and keyboard is inserted into the first network device, so that the wireless mouse and keyboard are connected to the first network device. After inputting with the keyboard or moving the mouse, the first network device will detect whether the received input instruction is a switching instruction. If the input instruction is a switching instruction, the unique number of the target network device is searched in the random code table. If the input instruction is not a switching instruction, it continues to determine whether the switching instruction is received. If the target network device is found, the function of the first network device using the input and output device is turned off. If the target network device is not found, the connection between the wireless mouse and keyboard and the first network device is maintained. After the function of the first network device using the input and output device is turned off, the currently used device recorded on the first network device is changed to the target network device, and a connection between the wireless mouse and keyboard and the target network device is established. Then the target network device receives the input instruction of the wireless mouse and keyboard and performs corresponding operations.
[0107] Step 207, after the first network device receives the input instruction from the input-output device, it generates a protocol packet corresponding to the input instruction according to the unique number of the target network device; wherein the protocol packet includes the network address corresponding to the unique number and the input instruction.
[0108] In the embodiment of the present invention, after the currently used device is changed to the target network device, the first network device records the unique number of the currently used device, that is, the unique number of the target network device. After receiving the input instruction of the input / output device again, the corresponding network address is first found according to the unique number of the target network device. Then, a protocol packet corresponding to the input instruction is generated. The format of the protocol packet is defined as the network address corresponding to the unique number and the input instruction.
[0109] Step 208: forward the protocol packet to the target network device according to the network address in the protocol packet.
[0110] In an embodiment of the present invention, a protocol packet is sent by a first network device, and the protocol packet is forwarded to a target network device according to a network address in the protocol packet, thereby realizing communication between the target network device and the first network device, thereby indirectly realizing communication between an input / output device and the target network device, and realizing switching to the target network device to use the input / output device.
[0111] like Figure 6 Schematic diagram of the communication process between the wireless mouse and keyboard and the network device shown in FIG. When the wireless mouse and keyboard are switched to a network device other than the first network device, the first network device communicates with the target network device through the set network protocol. The protocol packet contains the unique number of the device and the input instruction of the wireless mouse and keyboard. After the protocol packet is sent out through the network switch, it can reach the corresponding network device according to the IP address (network address) corresponding to the unique number. Then the network device will parse the received protocol packet, obtain the input instruction of the wireless mouse and keyboard, and then perform the corresponding operation.
[0112] According to an embodiment of the present invention, by receiving a unique identifier and a network address sent by each network device; wherein the unique identifier is information generated according to a unique number and a hardware address of the network device, and the unique number is information pre-assigned to each network device, parsing the unique identifier of each network device, obtaining a unique number and a hardware address of each network device, recording the unique number, hardware address and network address of each network device, receiving a current input instruction of an input / output device, detecting whether the current input instruction is a switching instruction, and if the current input instruction is a switching instruction, changing the currently used device recorded on the first network device to the target network device according to the device identifier of the switched target network device carried by the switching instruction, and generating a protocol packet corresponding to the input instruction according to the unique number of the target network device; wherein the protocol packet includes a network address corresponding to the unique number and the input instruction, and forwarding the input instruction to the target network device according to the network address in the protocol packet, so that the connector only needs to be inserted into one network device, and the input / output device can be switched between multiple network devices, and the input instruction can be forwarded to the target network device through the network, avoiding the tedious operation of re-plugging the receiver of the input / output device, and realizing convenient switching of the input / output device between multiple network devices.
[0113] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0114] Reference Figure 7 , shows a structural block diagram of an embodiment of a device switching device provided by another embodiment of the present invention, which may specifically include the following modules:
[0115] The instruction receiving module 301 is used to receive the current input instruction of the input and output device;
[0116] The instruction detection module 302 is used to detect whether the current input instruction is a switching instruction;
[0117] The device change module 303 is used to change the currently used device recorded on the first network device to the target network device according to the device identifier of the switched target network device carried by the switching instruction if the current input instruction is a switching instruction, so that after the first network device receives the input instruction of the input-output device, it forwards the input instruction to the target network device; wherein the first network device and the input-output device are connected via a connector.
[0118] Optionally, a plurality of network devices are interconnected via a network switch, the currently used device is not the first network device, and the apparatus further comprises:
[0119] The forwarding module is used for, if the current input instruction is not a switching instruction, causing the first network device to forward the current input instruction to the currently used device via the network switch.
[0120] Optionally, a plurality of network devices are interconnected via a network switch, the currently used device is not the first network device, and the instruction receiving module includes:
[0121] An instruction receiving submodule, configured to receive the current input instruction forwarded by the first network device via the network switch;
[0122] The equipment change module includes:
[0123] The request sending submodule is used to send a change request to the first network device through the network switch to change the currently used device recorded on the first network device to the target network device, wherein the change request carries the device identification of the target network device.
[0124] Optionally, the device identifier includes a unique number, and the apparatus further includes:
[0125] An address receiving module, used for receiving a unique identifier and a network address sent by each network device before receiving the current input instruction of the input / output device; wherein the unique identifier is generated according to a unique number and a hardware address of the network device, and the unique number is pre-assigned to each network device;
[0126] A parsing module is used to parse the unique identification of each network device to obtain the unique number and hardware address of each network device;
[0127] A recording module, used to record the unique number, hardware address and network address of each network device;
[0128] A protocol packet generation module, configured to generate a protocol packet corresponding to the input instruction according to the unique number of the target network device after the device identification of the switched target network device carried by the switching instruction is changed from the currently used device recorded on the first network device to the target network device; wherein the protocol packet includes the network address corresponding to the unique number and the input instruction;
[0129] The instruction forwarding module is used to forward the protocol packet to the target network device according to the network address in the protocol packet.
[0130] In an optional embodiment of the present invention, the device change module includes:
[0131] A record search submodule, used to search for the record of the unique number, hardware address and network address of the target network device according to the unique number of the target network device;
[0132] The device changing submodule is used to change the currently used device recorded on the first network device to the target network device if the record of the unique number, hardware address and network address of the target network device is found.
[0133] In an optional embodiment of the present invention, the device further comprises:
[0134] The function closing module is used to close the function of the first network device using the input and output device when the currently used device is the first network device and if the current input instruction is a switching instruction.
[0135] In an optional embodiment of the present invention, the device further comprises:
[0136] a connection establishing module, configured to, if the current input instruction is a switching instruction, after changing the currently used device recorded on the first network device to the target network device according to the device identifier of the switched target network device carried in the switching instruction, establish a connection between the first network device and the target network device for transmitting the input instruction when the target network device is not the first network device;
[0137] Alternatively, the function enabling module is used to enable the function of the first network device to use the input and output device when the target network device is the first network device.
[0138] According to an embodiment of the present invention, by receiving the current input instruction of an input / output device, it is detected whether the current input instruction is a switching instruction. If the current input instruction is a switching instruction, the currently used device recorded on the first network device is changed to the target network device according to the device identifier of the switched target network device carried by the switching instruction, so that after the first network device receives the input instruction of the input / output device, the input instruction is forwarded to the target network device. The first network device and the input / output device are connected via a connector, so that the connector only needs to be inserted into one network device, and the input / output device can be switched between multiple network devices. The input instruction can be forwarded to the target network device via the network, avoiding the tedious operation of re-plugging and re-plugging the receiver of the input / output device, and realizing convenient switching of the input / output device between multiple network devices.
[0139] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0140] Figure 8 1 is a block diagram of an electronic device 700 for device switching according to an exemplary embodiment. For example, the electronic device 700 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0141] Reference Figure 8 , the electronic device 700 may include one or more of the following components: a processing component 702 , a memory 704 , a power component 706 , a multimedia component 708 , an audio component 710 , an input / output (I / O) interface 712 , a sensor component 714 , and a communication component 716 .
[0142] The processing component 702 generally controls the overall operation of the electronic device 700, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 702 may include one or more processors 720 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 702 may include one or more modules to facilitate the interaction between the processing component 702 and other components. For example, the processing component 702 may include a multimedia module to facilitate the interaction between the multimedia component 708 and the processing component 702.
[0143] The memory 704 is configured to store various types of data to support operations on the device 700. Examples of such data include instructions for any application or method operating on the electronic device 700, contact data, phone book data, messages, pictures, videos, etc. The memory 704 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0144] The power component 704 provides power to various components of the electronic device 700. The power component 704 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 700.
[0145] The multimedia component 708 includes a screen that provides an output interface between the electronic device 700 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 708 includes a front camera and / or a rear camera. When the electronic device 700 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0146] The audio component 710 is configured to output and / or input audio signals. For example, the audio component 710 includes a microphone (MIC), and when the electronic device 700 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 704 or sent via the communication component 716. In some embodiments, the audio component 710 also includes a speaker for outputting audio signals.
[0147] I / O interface 712 provides an interface between processing component 702 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0148] The sensor assembly 714 includes one or more sensors for providing various aspects of status assessment for the electronic device 700. For example, the sensor assembly 714 can detect the open / closed state of the device 700, the relative positioning of components, such as the display and keypad of the electronic device 700, and the sensor assembly 714 can also detect the position change of the electronic device 700 or a component of the electronic device 700, the presence or absence of contact between the user and the electronic device 700, the orientation or acceleration / deceleration of the electronic device 700, and the temperature change of the electronic device 700. The sensor assembly 714 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 714 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 714 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0149] The communication component 716 is configured to facilitate wired or wireless communication between the electronic device 700 and other devices. The electronic device 700 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 714 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 714 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0150] In an exemplary embodiment, the electronic device 700 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0151] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 704 including instructions, and the instructions can be executed by a processor 720 of an electronic device 700 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0152] A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of a terminal, enables the terminal to perform a device switching method, the method comprising:
[0153] Receive current input instructions from input and output devices;
[0154] Detecting whether the current input instruction is a switching instruction;
[0155] If the current input instruction is a switching instruction, the currently used device recorded on the first network device is changed to the target network device according to the device identifier of the switched target network device carried by the switching instruction, so that after the first network device receives the input instruction of the input-output device, the input instruction is forwarded to the target network device; wherein the first network device and the input-output device are connected via a connector.
[0156] Optionally, a plurality of network devices are interconnected via a network switch, the currently used device is not the same device as the first network device, and the method further includes:
[0157] If the current input instruction is not a switching instruction, the first network device forwards the current input instruction to the currently used device via the network switch.
[0158] Optionally, a plurality of network devices are interconnected via a network switch, the currently used device is not the first network device, and receiving a current input instruction of an input / output device comprises:
[0159] receiving the current input instruction forwarded by the first network device via the network switch;
[0160] The step of changing the currently used device recorded on the first network device to the target network device according to the device identifier of the switched target network device carried in the switching instruction comprises:
[0161] A change request is sent to the first network device through the network switch, so that the currently used device recorded on the first network device is changed to the target network device, wherein the change request carries the device identifier of the target network device.
[0162] Optionally, the device identification includes a unique number, and before receiving the current input instruction of the input / output device, the method further includes:
[0163] Receiving a unique identifier and a network address sent by each network device; wherein the unique identifier is generated based on a unique number and a hardware address of the network device, and the unique number is pre-assigned to each network device;
[0164] Parse the unique identifier of each network device to obtain the unique number and hardware address of each network device;
[0165] Record the unique number, hardware address and network address of each network device;
[0166] After changing the currently used device recorded on the first network device to the target network device according to the device identification of the switched target network device carried in the switching instruction, forwarding the input instruction to the target network device includes:
[0167] Generate a protocol packet corresponding to the input instruction according to the unique number of the target network device; wherein the protocol packet includes the network address corresponding to the unique number and the input instruction;
[0168] According to the network address in the protocol packet, the protocol packet is forwarded to the target network device.
[0169] Optionally, the changing the currently used device recorded on the first network device to the target network device according to the device identifier of the switched target network device carried in the switching instruction comprises:
[0170] According to the unique number of the target network device, searching for the record of the unique number, hardware address and network address of the target network device;
[0171] If the records of the unique number, hardware address and network address of the target network device are found, the currently used device recorded on the first network device is changed to the target network device.
[0172] Optionally, when the currently used device and the first network device are the same device, the method further includes:
[0173] If the current input instruction is a switching instruction, the function of the first network device using the input and output device is disabled.
[0174] Optionally, if the current input instruction is a switching instruction, after changing the currently used device recorded on the first network device to the target network device according to the device identifier of the switched target network device carried in the switching instruction, the method further includes:
[0175] When the target network device and the first network device are not the same device, establishing a connection between the first network device and the target network device for transmitting the input instruction;
[0176] Alternatively, when the target network device and the first network device are the same device, a function of the first network device using the input and output device is enabled.
[0177] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0178] It will be appreciated by those skilled in the art that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0179] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0180] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0181] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0182] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0183] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0184] The above is a detailed introduction to a device switching method, a device switching apparatus, an electronic device, and a readable storage medium provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for a person skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A device switching method, It is characterized in that include: Receive current input instructions from input and output devices; Detecting whether the current input instruction is a switching instruction; If the current input instruction is a switching instruction, then according to the device identifier of the switched target network device carried in the switching instruction, the currently used device recorded on the first network device is changed to the target network device, so that after the first network device receives the input instruction of the input-output device again, it forwards the input instruction received again to the target network device; wherein the first network device and the input-output device are connected via a connector; When the currently used device and the first network device are the same device, the method further includes: If the current input instruction is a switching instruction, the function of the first network device using the input and output device is disabled.
2. The method according to claim 1, It is characterized in that A plurality of network devices are connected to each other via a network switch, and the method further comprises: If the current input instruction is not a switching instruction, the first network device forwards the current input instruction to the currently used device via the network switch.
3. The method according to claim 1, It is characterized in that The device identification includes a unique number. Before receiving the current input instruction of the input / output device, the method further includes: Receiving a unique identifier and a network address sent by each network device; wherein the unique identifier is generated based on a unique number and a hardware address of the network device, and the unique number is pre-assigned to each network device; Parse the unique identifier of each network device to obtain the unique number and hardware address of each network device; Record the unique number, hardware address and network address of each network device; After changing the currently used device recorded on the first network device to the target network device according to the device identifier of the switched target network device carried in the switching instruction, forwarding the input instruction received again to the target network device includes: Generate a protocol packet corresponding to the input instruction received again according to the unique number of the target network device; wherein the protocol packet includes the network address corresponding to the unique number and the input instruction received again; According to the network address in the protocol packet, the protocol packet is forwarded to the target network device.
4. The method according to claim 3, It is characterized in that The step of changing the currently used device recorded on the first network device to the target network device according to the device identifier of the switched target network device carried in the switching instruction comprises: According to the unique number of the target network device, searching for the record of the unique number, hardware address and network address of the target network device; If the records of the unique number, hardware address and network address of the target network device are found, the currently used device recorded on the first network device is changed to the target network device.
5. The method according to any one of claims 1 to 4, It is characterized in that If the current input instruction is a switching instruction, after changing the currently used device recorded on the first network device to the target network device according to the device identifier of the switched target network device carried in the switching instruction, the method further includes: When the target network device and the first network device are not the same device, establishing a connection between the first network device and the target network device for transmitting the input instruction received again; Alternatively, when the target network device and the first network device are the same device, a function of the first network device using the input and output device is enabled.
6. A device switching device, It is characterized in that include: An instruction receiving module, used for receiving current input instructions of an input and output device; An instruction detection module, used to detect whether the current input instruction is a switching instruction; a device changing module, configured to change the currently used device recorded on the first network device to the target network device according to the device identifier of the switched target network device carried in the switching instruction if the current input instruction is a switching instruction, so that after the first network device receives the input instruction of the input-output device again, it forwards the input instruction received again to the target network device; wherein the first network device and the input-output device are connected via a connector; The device also includes: The function closing module is used to close the function of the first network device using the input and output device when the currently used device and the first network device are the same device and if the current input instruction is a switching instruction.
7. The device according to claim 6, It is characterized in that A plurality of network devices are connected to each other via a network switch, and the apparatus further comprises: The forwarding module is used for, if the current input instruction is not a switching instruction, causing the first network device to forward the current input instruction to the currently used device via the network switch.
8. The device according to claim 6, It is characterized in that The device identification includes a unique number, and the apparatus further includes: An address receiving module, used for receiving a unique identifier and a network address sent by each network device before receiving the current input instruction of the input / output device; wherein the unique identifier is generated according to a unique number and a hardware address of the network device, and the unique number is pre-assigned to each network device; A parsing module is used to parse the unique identification of each network device to obtain the unique number and hardware address of each network device; A recording module, used to record the unique number, hardware address and network address of each network device; A protocol packet generation module, configured to generate a protocol packet corresponding to the input instruction received again according to the unique number of the target network device, after changing the currently used device recorded on the first network device to the target network device according to the device identification of the switched target network device carried by the switching instruction; wherein the protocol packet includes the network address corresponding to the unique number and the input instruction received again; The instruction forwarding module is used to forward the protocol packet to the target network device according to the network address in the protocol packet.
9. The device according to claim 8, It is characterized in that The equipment change module includes: A record search submodule, used to search for the record of the unique number, hardware address and network address of the target network device according to the unique number of the target network device; The device changing submodule is used to change the currently used device recorded on the first network device to the target network device if the record of the unique number, hardware address and network address of the target network device is found.
10. The device according to any one of claims 6 to 9, It is characterized in that The device also includes: a connection establishing module, configured to, if the current input instruction is a switching instruction, after changing the currently used device recorded on the first network device to the target network device according to the device identifier of the switched target network device carried in the switching instruction, establish a connection between the first network device and the target network device for transmitting the input instruction received again when the target network device and the first network device are not the same device; Alternatively, the function enabling module is used to enable the function of the first network device to use the input and output device when the target network device and the first network device are the same device.
11. An electronic device, It is characterized in that It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 5 when executing a program stored in a memory.
12. A readable storage medium, It is characterized in that When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the device switching method as described in one or more of method claims 1-5.
