Disclosure of Invention
The embodiment of the invention aims to solve the technical problem of providing a device switching method, a device, electronic equipment and a readable storage medium, so as to solve the problem of inconvenience in switching a keyboard and a mouse among a plurality of devices.
In order to solve the above problems, the present invention provides a device switching method, including:
receiving a current input instruction of input and output equipment;
detecting whether the current input instruction is a switching instruction or not;
If the current input instruction is a switching instruction, changing the current used equipment recorded on a first network device into the target network device according to the equipment identifier of the switched target network device carried by the switching instruction, so that the first network device forwards the input instruction to the target network device after receiving the input instruction of the input and output device; the first network device and the input/output device are connected through a connector.
Optionally, the plurality of network devices are connected to each other through a network switch, and the method further comprises:
And if the current input instruction is not a switching instruction, forwarding the current input instruction to the current using device by the first network device through the network switch.
Optionally, the device identifier includes a unique number, and before the 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; the unique identification is generated according to a unique number and a hardware address of the network equipment, and the unique number is allocated to each network equipment in advance;
resolving the unique identifier of each network device to obtain the unique number and the hardware address of each network device;
recording the unique number, hardware address and network address of each network device;
After the device identifier of the target network device after switching carried by the switching instruction changes the current used device recorded on the first network device into the target network device, forwarding the input instruction to the target network device includes:
Generating a protocol packet corresponding to the input instruction according to the unique number of the target network equipment; wherein, the protocol packet comprises a network address corresponding to the unique number and the input instruction;
and forwarding the protocol packet to the target network equipment according to the network address in the protocol packet.
Optionally, the changing the current used device recorded on the first network device to the target network device according to the device identifier of the target network device after switching carried by the switching instruction includes:
Searching the unique number, the hardware address and the record of the network address of the target network equipment according to the unique number of the target network equipment;
And if the record of the unique number, the hardware address and the network address of the target network device is searched, changing the current used device recorded on the first network device into the target network device.
Optionally, when the currently used device is the same device as the first network device, the method further comprises:
And if the current input instruction is a switching instruction, closing the function of the first network equipment for using the input and output equipment.
Optionally, after the current input instruction is the switching instruction, according to the device identifier of the switched target network device carried by the switching instruction, the current used device recorded on the first network device is changed to the target network device, where the method further includes:
when the target network equipment is not the same equipment as the first network equipment, establishing connection between the first network equipment and the target network equipment for transmitting the input instruction;
or when the target network device and the first network device are the same device, starting the function of the first network device for using the input/output device.
The invention also provides a device switching device, which comprises:
The instruction receiving module is used for receiving a current input instruction of the input and output equipment;
The instruction detection module is used for detecting whether the current input instruction is a switching instruction or not;
The device changing module is used for changing the current used device recorded on the first network device into the target network device according to the device identifier of the target network device after switching carried by the switching instruction if the current input instruction is the switching instruction, so that the first network device forwards the input instruction to the target network device after receiving the input instruction of the input and output device; the first network device and the input/output device are connected through a connector.
Optionally, the plurality of network devices are connected to each other through a network switch, and the apparatus further includes:
And the forwarding module is used for forwarding the current input instruction to the current using equipment through the network switch by the first network equipment if the current input instruction is not a switching instruction.
Optionally, the device identification includes a unique number, and the apparatus further includes:
The address receiving module is used for receiving the unique identifier and the network address sent by each network device before the current input instruction of the input/output device is received; the unique identification is generated according to a unique number and a hardware address of the network equipment, and the unique number is allocated to each network equipment in advance;
The analysis module is used for analyzing the unique identifier of each network device to obtain the unique number and the hardware address of each network device;
the recording module is used for recording the unique number, the hardware address and the network address of each network device;
The protocol packet generation module is used for generating a protocol packet corresponding to the input instruction according to the unique number of the target network equipment after the equipment identifier of the target network equipment after the switching carried by the switching instruction changes the current used equipment recorded on the first network equipment into the target network equipment; wherein, the protocol packet comprises a network address corresponding to the unique number and the input instruction;
And the instruction forwarding module is used for forwarding the protocol packet to the target network equipment according to the network address in the protocol packet.
Optionally, the device change module includes:
the record searching sub-module is used for searching the records of the unique number, the hardware address and the network address of the target network equipment according to the unique number of the target network equipment;
and the device changing sub-module is used for changing the current used device recorded on the first network device into the target network device if the unique number, the hardware address and the network address record of the target network device are searched.
Optionally, the apparatus further comprises:
And the function closing module is used for closing the function of the first network equipment for using the input and output equipment if the current input instruction is a switching instruction when the current equipment is the same equipment as the first network equipment.
Optionally, the apparatus further comprises:
A connection establishing module, configured to, when the current input instruction is a switching instruction, establish a connection between a first network device and a target network device for transmitting the input instruction when the target network device is not the same device as the first network device after changing a currently used device recorded on the first network device to the target network device according to a device identifier of the target network device after switching carried by the switching instruction;
Or a function starting module, configured to start a function of the input/output device used by the first network device when the target network device and the first network device are the same device.
The embodiment of the invention also discloses an electronic device which is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
and a processor for performing the method steps described above when executing the program stored on the memory.
The embodiment of the invention also discloses a readable storage medium, which enables the electronic device to execute one or more of the methods in the embodiment of the invention when the instructions in the storage medium are executed by the processor of the electronic device.
According to the embodiment of the invention, whether the current input instruction is a switching instruction is detected by receiving the current input instruction of the input/output equipment, if the current input instruction is the switching instruction, the current used equipment recorded on the first network equipment is changed into the target network equipment according to the equipment identifier of the switched target network equipment carried by the switching instruction, so that the first network equipment forwards the input instruction to the target network equipment after receiving the input instruction of the input/output equipment, wherein the first network equipment and the input/output equipment are connected through a connector, the connector only needs to be inserted into one network equipment, the input/output equipment can be switched and used among a plurality of network equipment, the input instruction can be forwarded to the target network equipment through a network, the complicated operation of re-plugging the receiver of the input/output equipment is avoided, and the convenient switching of the input/output equipment among the plurality of network equipment is realized.
Detailed Description
In order that the above-recited objects, features and advantages of the present invention will become more readily apparent, a more particular description of the invention will be rendered by reference to the appended drawings and appended detailed description.
Referring to fig. 1, a step flowchart of a device switching method provided by an embodiment of the present invention may specifically include the following steps:
step 101, receiving a current input instruction of an input/output device.
In the embodiment of the present invention, the network device performing step 101, step 102 and step 103 may be the first network device or the currently used device, which is not limited in this embodiment of the present invention.
In the embodiment of the present invention, the input/output device includes a mouse, a keyboard, a display with a touch function, etc., or any other applicable input/output device, which is not limited in this embodiment of the present invention. The user can input on the input-output device, and the input-output device generates a corresponding input instruction and sends the corresponding input instruction to the network device connected with the input-output device. The network device includes a server in a server room, a personal computer in a local area network, or any other suitable network device, which is not limited in this embodiment of the present invention.
For example, when the input output device is a keyboard, the input instruction may be a user pressing one or more keys on the keyboard, corresponding to the generated instruction. When the input/output device is a mouse, the input instruction may be a click operation performed by the user using the mouse, and the generated instruction corresponds to the input instruction.
Step 102, detecting whether the current input instruction is a switching instruction.
In the embodiment of the present invention, the 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 predetermined manner. For example, input instructions generated corresponding to a combination of a plurality of keys are appointed as switching instructions on a keyboard, or input instructions generated corresponding to a button set on control software is appointed as switching instructions when a mouse clicks, or any other applicable switching instructions, which the embodiments of the present invention do not limit.
In the embodiment of the invention, after receiving the current input instruction, whether the current input instruction is a switching instruction is detected. The currently input instruction is either a switch instruction or a non-switch instruction. Non-switching commands are typical operation commands, for example, input commands generated by various numbers and letters entered on a keyboard when a user types.
In the embodiment of the invention, the network equipment to which the switching instruction is to be switched is recorded as the target network equipment, so that the switching instruction carries the equipment identifier of the switched target network equipment. The device identifier includes a number customized by control software running on the network device for each network device, or a unique identifier of the network device, or any other suitable device identifier, which is not limited in this embodiment of the present invention.
Step 103, if the current input instruction is a switching instruction, changing the current used equipment recorded on a first network device into the target network device according to the equipment identifier of the switched target network device carried by the switching instruction, so that the first network device forwards the input instruction to the target network device after receiving the input instruction of the input and output device; the first network device and the input/output device are connected through a connector.
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 a keyboard, the connector is a wireless connector of the wireless mouse and the keyboard. The first network device is one of a plurality of network devices. When the input/output device is used, the connector of the input/output device is inserted into one 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 by a connector.
In the embodiment of the invention, the current used equipment of the input/output equipment is recorded on the first network equipment. The currently used device may be the first network device or may be other network devices 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 current use device is other network devices except 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 current use device, and the current use device receives the input instruction.
In the embodiment of the invention, if the current input instruction is a switching instruction, the device identifier of the target network device after switching is read from the switching instruction. And then changing the current used equipment recorded on the first network equipment into the target network equipment according to the equipment identification of the target network equipment after switching. And after receiving the input instruction of the input and output device again, the first network device forwards the input instruction to the target network device, namely, the current use device of the input and output device is switched to any network device.
In an optional embodiment of the present invention, the plurality of network devices are connected to each other through a network switch, where the currently used device is not the same device as the first network device, and in a specific implementation manner when the above steps are performed by the first network device, the method may further include: and if the current input instruction is not a switching instruction, forwarding the current input instruction to the current using device by the first network device through the network switch.
After receiving the current input instruction of the input and output equipment through the connector, the first network equipment is responsible for detecting whether the current input instruction is a switching instruction or not. If the current input instruction is not the switching instruction, the first network device continuously forwards the current input instruction to the current using device, namely other network devices, through the network switch, so that the function of using the input and output devices by the other network devices is realized.
In an optional embodiment of the present invention, the plurality of network devices are connected to each other through a network switch, where the currently used device is not the same device as the first network device, and when the step is performed by the currently used device, a specific implementation manner of receiving, by the currently used device, a current input instruction of the input/output device may include: a currently used device receives the currently entered instructions forwarded by the first network device via the network switch.
After receiving the current input instruction of the input and output device through the connector, the first network device forwards the current input instruction to the current using device through the network switch, and the current using device receives the current input instruction and then carries out the next processing.
Further, according to the device identifier of the target network device after switching carried by the switching instruction, the method for changing the current usage device recorded on the first network device into a specific implementation manner of the target network device by the current usage device may include: and the current use equipment sends a change request to the first network equipment through the network switch so as to change the current use equipment recorded on the first network equipment into the target network equipment, wherein the change request carries the equipment identifier of the target network equipment.
The current usage device changes the current usage device recorded on the first network device to the target network device. And sending a change request to the first network equipment through the network switch. After the first network device receives the change request, the recorded current use device is changed into the target network device according to the device identifier of the target network device carried by the change request.
In one example, a schematic diagram of a device switch is implemented with a mouse and keyboard as shown in FIG. 2. The network switch 21 and the servers 1, 2, 3, … …, n form a one-to-many network architecture in which the wireless mouse and the receiver of the keyboard 11 are inserted on the server 1. The instructions and codes sent by the wireless mouse and the keyboard 11 are forwarded through the server 1, so that the wireless mouse and the keyboard 11 can be operated on other devices. For example: to switch the wireless mouse and the keyboard 11 to the server 2, firstly, the server 1 receives a switching instruction, the wireless mouse and the keyboard 11 are connected with the server 2, after successful connection, the instruction sent by the wireless mouse and the keyboard 11 is forwarded to the network switch 21 through the server 1 and then is sent to the server 2, and after receiving the instruction, the server 2 performs corresponding mouse or keyboard actions.
According to the embodiment of the invention, whether the current input instruction is a switching instruction is detected by receiving the current input instruction of the input/output equipment, if the current input instruction is the switching instruction, the current used equipment recorded on the first network equipment is changed into the target network equipment according to the equipment identifier of the switched target network equipment carried by the switching instruction, so that the first network equipment forwards the input instruction to the target network equipment after receiving the input instruction of the input/output equipment, wherein the first network equipment and the input/output equipment are connected through a connector, the connector only needs to be inserted into one network equipment, the input/output equipment can be switched and used among a plurality of network equipment, the input instruction can be forwarded to the target network equipment through a network, the complicated operation of re-plugging the receiver of the input/output equipment is avoided, and the convenient switching of the input/output equipment among the plurality of network equipment is realized.
Referring to fig. 3, a step flowchart of a device switching method provided by an embodiment of the present invention may specifically include the following steps:
step 201, receiving unique identification and network address sent by each network device; wherein the unique identification is generated according to a unique number and a hardware address of the network device, and the unique number is pre-allocated to each network device.
In the embodiment of the present invention, since each network device may become the first network device or the currently used device, steps 201, 202 and 203 may be performed on each network device. Of course, it is also possible to perform steps 201, 202 and 203 only on the first network device or the currently used device.
In the embodiment of the invention, the equipment identifier comprises a unique number, and the unique number can facilitate the user to distinguish different network equipment. The unique number may be allocated at any time when each network device is allocated, or may be allocated sequentially, or any other suitable allocation manner, which is not limited in this embodiment of the present invention.
In the embodiment of the present invention, the hardware Address is a unique Address, such as a MAC (MEDIA ACCESS Control Address) Address, recorded on the network card by the manufacturer of the network device during production. For each network device, a unique identification of the network device is generated from the unique number and hardware address of the network device. The unique identification may uniquely identify the network device. For example, the code obtained by combining the unique number and the hardware address is used as a unique identifier, or any other applicable generation manner, which is not limited by the embodiment of the present invention.
In the embodiment of the invention, after the unique identifier of each network device is generated, the unique identifier and the network address of each network device are sent to each network device, so that each network device can be used as the first network device after being inserted into the connector of the input/output device, and has the capability of forwarding the input instruction to other network devices. Where the network address is a logical address that a node on the internet has in the network, the node may be addressed, for example, IP (Internet Protocol) addresses.
Step 202, resolving the unique identifier of each network device to obtain the unique number and hardware address of each network device.
In the embodiment of the invention, the unique identifier of each network device is respectively analyzed, that is, the inverse operation of the unique identifier is generated, so that the unique number and the hardware address of each network device are obtained.
Step 203, record the unique number, hardware address and network address of each network device.
In an embodiment of the present invention, a unique number, a hardware address, and a network address of each network device are recorded on the network device.
For example, a schematic diagram of a generation process of a random code table as shown in fig. 4. The generation of the unique random code (i.e., unique identification) for the network device may be generated by a set of custom algorithms. The algorithm needs to be deployed on each network device, and the random code is generated according to the MAC address of the network device and the assigned custom number. Then the random code of the network equipment and the corresponding IP address are sent to each network equipment (including the network equipment) through the network, after each network equipment receives the random code and the IP address, analysis is carried out, then a random code table is established according to the analyzed number, and the random code table comprises 3 parts: number, IP address, MAC address. In the server, the algorithm is set to be called once every preset period (for example, 1 minute), and the random code table is regenerated, so that the input and output equipment can still be normally used under the conditions of changing the IP address, increasing or decreasing the network equipment and the like.
Step 204, current input instructions of an input-output device are received.
In the embodiments of the present invention, the specific implementation manner of this step may be referred to the description in the foregoing embodiments, which is not repeated herein.
Step 205, detecting whether the current input instruction is a switching instruction.
In the embodiments of the present invention, the specific implementation manner of this step may be referred to the description in the foregoing embodiments, which is not repeated herein.
Step 206, if the current input instruction is a switching instruction, changing the current used device recorded on the first network device into the target network device according to the device identifier of the target network device after switching carried by the switching instruction.
In the embodiments of the present invention, the specific implementation manner of this step may be referred to the description in the foregoing embodiments, which is not repeated herein.
In an optional embodiment of the present invention, according to the device identifier of the target network device after switching carried by the switching instruction, a specific implementation manner of changing the current used device recorded on the first network device to the target network device may include: if the current input instruction is a switching instruction, searching the record of the unique number, the hardware address and the network address of the target network equipment according to the unique number of the target network equipment. And if the record of the unique number, the hardware address and the network address of the target network device is searched, changing the current used device recorded on the first network device into the target network device.
In the embodiment of the present invention, if the current input instruction is a switching instruction, it is necessary to check whether the unique number carried by the switching instruction has a corresponding network device. And searching the record of the unique number, the hardware address and the network address of the target network device in the record of the network device according to the unique number of the target network device.
In the embodiment of the invention, if the record of the unique number, the hardware address and the network address of the target network device is found, the existence of the target network device is indicated, and the first network device can acquire 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.
In an optional embodiment of the present invention, when the currently used device is a first network device, the method may further include: and if the current input instruction is a switching instruction, closing the function of the first network equipment for using the input and output equipment.
When the current using device is the first network device, the first network device can directly acquire the input instruction of the input/output device through the connector of the input/output device, which is equivalent to that the first network device can directly use the input/output device without forwarding through other network devices. When the switching instruction is from the first network device to other network devices, the function of the first network device for using the input/output device needs to be closed, so that the problem that the input/output device is used by the first network device and the target network device simultaneously is avoided because the first network device still executes the processing corresponding to the input instruction after receiving the input instruction of the input/output device after switching.
In an optional embodiment of the present invention, after the changing, according to the device identifier of the target network device after the switching carried by the switching instruction, the currently used device recorded on the first network device to the target network device if the currently input instruction is the switching instruction, the method further may include: when the target network equipment is not the same equipment as the first network equipment, establishing connection between the first network equipment and the target network equipment for transmitting the input instruction; or when the target network device and the first network device are the same device, starting the function of the first network device for using the input/output device.
When the target network device is not the same device as the first network device, after the currently used device recorded on the first network device is changed to the target network device, connection between the first network device and the target network device for transmitting an input instruction is required to be established, so that after the first network device receives the input instruction of the input and output device, the input instruction is sent to the target network device.
When the target network device and the first network device are the same device, the function of the first network device for using the input and output device is started, so that the first network device does not forward the input command to other network devices after receiving the input command of the input and output device, and directly executes the processing corresponding to the input command.
For example, a schematic diagram of a wireless mouse-to-keyboard switching network device is shown in fig. 5. Any one of the network devices is selected as the first network device. A unique random code is generated for each network device and sent to each network device and a random code table is generated from the received random code. A wireless connector of a wireless mouse and a keyboard is inserted on the first network device, so that the wireless mouse and the keyboard establish a connection with the first network device. After the keyboard is used for inputting or the mouse is moved, the first network device detects whether the received input instruction is a switching instruction. If the input instruction is a switching instruction, searching a unique number of the target network equipment in the random code table, and if the input instruction is not the switching instruction, continuing to judge whether the switching instruction is received or not. If the target network equipment is found, the function of the input and output equipment used by the first network equipment is closed, and if the target network equipment is not found, the connection of the wireless mouse and the keyboard with the first network equipment is continuously maintained. After the function of the first network device for using the input/output device is closed, changing the current used device recorded on the first network device into the target network device, and establishing connection between the wireless mouse and the keyboard and the target network device. And then the target network equipment receives input instructions of the wireless mouse and the keyboard and performs corresponding operations.
Step 207, after the first network device receives the input instruction of the input/output device, generating a protocol packet corresponding to the input instruction according to the unique number of the target network device; the protocol packet comprises a network address corresponding to the unique number and the input instruction.
In the embodiment of the invention, after the current use equipment is changed to the target network equipment, the unique number of the current use equipment, namely the unique number of the target network equipment, is recorded on the first network equipment. And after receiving the input instruction of the input and output equipment again, searching the corresponding network address according to the unique number of the target network equipment. And then generating a protocol packet corresponding to the input instruction. The format of the protocol packet is defined as the network address and input instruction corresponding to the unique number.
And step 208, forwarding the protocol packet to the target network device according to the network address in the protocol packet.
In the embodiment of the invention, the protocol packet is sent out by the first network device, and the protocol packet is forwarded to the target network device according to the network address in the protocol packet, so that the communication between the target network device and the first network device is realized, the communication between the input and output devices and the target network device is indirectly realized, and the switching to the target network device to use the input and output devices is realized.
A schematic diagram of a wireless mouse-keyboard communication process with a network device is shown in fig. 6. When the wireless mouse and the keyboard are switched to the network devices except 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 instructions of the wireless mouse and the keyboard, and after the protocol packet is sent out through the network switch, the protocol packet can reach the corresponding network device according to the IP address (network address) corresponding to the unique number. Then the network device analyzes the received protocol packet to obtain the input instructions of the wireless mouse and the keyboard, and then carries out corresponding operation.
According to the embodiment of the invention, the unique identification and the network address sent by each network device are received; the unique identification is information generated according to a unique number and a hardware address of network equipment, the unique number is information which is distributed to each network equipment in advance, the unique identification of each network equipment is analyzed to obtain the unique number and the hardware address of each network equipment, the unique number, the hardware address and the network address of each network equipment are recorded, a current input instruction of an input and output device is received, whether the current input instruction is a switching instruction or not is detected, if the current input instruction is the switching instruction, the current used equipment recorded on the first network equipment is changed into the target network equipment according to the equipment identification of the target network equipment after switching carried by the switching instruction, and a protocol packet corresponding to the input instruction is generated according to the unique number of the target network equipment; the protocol packet comprises a network address corresponding to the unique number and the input instruction, and the input instruction is forwarded to the target network device according to the network address in the protocol packet, so that the connector can be switched to use the input/output device only by inserting one network device, the input instruction can be forwarded to the target network device through a network, the complicated operation of re-plugging the receiver of the input/output device is avoided, and the convenient switching of the input/output device among the network devices is realized.
It should be noted that, for simplicity of description, the method embodiments are shown as a series of acts, but it should be understood by those skilled in the art that the embodiments are not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred embodiments, and that the acts are not necessarily required by the embodiments of the invention.
Referring to fig. 7, a block diagram of an embodiment of a device switching apparatus according to another embodiment of the present invention may specifically include the following modules:
An instruction receiving module 301, configured to receive a current input instruction of an input/output device;
an instruction detection module 302, configured to detect whether the current input instruction is a switching instruction;
The device changing module 303 is configured to change, if the current input instruction is a switching instruction, a current used device recorded on a first network device to the target network device according to a device identifier of a switched target network device carried by the switching instruction, so that the first network device receives an input instruction of the input/output device and forwards the input instruction to the target network device; the first network device and the input/output device are connected through a connector.
Optionally, the plurality of network devices are connected to each other through a network switch, the currently used device is not the first network device, and the apparatus further includes:
And the forwarding module is used for forwarding the current input instruction to the current using equipment through the network switch by the first network equipment if the current input instruction is not a switching instruction.
Optionally, the plurality of network devices are connected to each other through a network switch, the currently used device is not the first network device, and the instruction receiving module includes:
An instruction receiving sub-module, configured to receive the current input instruction forwarded by the first network device via the network switch;
The device change module includes:
And the request sending submodule is used for sending a change request to the first network equipment through the network switch so as to change the currently used equipment recorded on the first network equipment into the target network equipment, wherein the change request carries the equipment identifier of the target network equipment.
Optionally, the device identification includes a unique number, and the apparatus further includes:
The address receiving module is used for receiving the unique identifier and the network address sent by each network device before the current input instruction of the input/output device is received; the unique identification is generated according to a unique number and a hardware address of the network equipment, and the unique number is allocated to each network equipment in advance;
The analysis module is used for analyzing the unique identifier of each network device to obtain the unique number and the hardware address of each network device;
the recording module is used for recording the unique number, the hardware address and the network address of each network device;
The protocol packet generation module is used for generating a protocol packet corresponding to the input instruction according to the unique number of the target network equipment after the equipment identifier of the target network equipment after the switching carried by the switching instruction changes the current used equipment recorded on the first network equipment into the target network equipment; wherein, the protocol packet comprises a network address corresponding to the unique number and the input instruction;
And the instruction forwarding module is used for forwarding the protocol packet to the target network equipment according to the network address in the protocol packet.
In an alternative embodiment of the present invention, the device change module includes:
the record searching sub-module is used for searching the records of the unique number, the hardware address and the network address of the target network equipment according to the unique number of the target network equipment;
and the device changing sub-module is used for changing the current used device recorded on the first network device into the target network device if the unique number, the hardware address and the network address record of the target network device are searched.
In an alternative embodiment of the invention, the apparatus further comprises:
And the function closing module is used for closing the function of the first network equipment for using the input/output equipment if the current input instruction is a switching instruction when the current equipment is the first network equipment.
In an alternative embodiment of the invention, the apparatus further comprises:
a connection establishing module, configured to, after the current input instruction is a switching instruction, change a currently used device recorded on a first network device to the target network device according to a device identifier of a switched target network device carried by the switching instruction, and when the target network device is not the first network device, establish a connection between the first network device and the target network device for transmitting the input instruction;
or a function starting module, configured to start the function of the input/output device used by the first network device when the target network device is the first network device.
According to the embodiment of the invention, whether the current input instruction is a switching instruction is detected by receiving the current input instruction of the input/output equipment, if the current input instruction is the switching instruction, the current used equipment recorded on the first network equipment is changed into the target network equipment according to the equipment identifier of the switched target network equipment carried by the switching instruction, so that the first network equipment forwards the input instruction to the target network equipment after receiving the input instruction of the input/output equipment, wherein the first network equipment and the input/output equipment are connected through a connector, the connector only needs to be inserted into one network equipment, the input/output equipment can be switched and used among a plurality of network equipment, the input instruction can be forwarded to the target network equipment through a network, the complicated operation of re-plugging the receiver of the input/output equipment is avoided, and the convenient switching of the input/output equipment among the plurality of network equipment is realized.
For the device embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments for relevant points.
Fig. 8 is a block diagram illustrating a configuration of an electronic device 700 for device switching, according to an example embodiment. For example, the electronic device 700 may be a mobile phone, computer, digital broadcast terminal, messaging device, game console, tablet device, medical device, exercise device, personal digital assistant, or the like.
Referring to fig. 8, an 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.
The processing component 702 generally controls overall operation of the electronic device 700, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing element 702 may include one or more processors 720 to execute instructions to perform all or part of the steps of the methods described above. Further, the processing component 702 can include one or more modules that facilitate interaction between the processing component 702 and other components. For example, the processing component 702 may include a multimedia module to facilitate interaction between the multimedia component 708 and the processing component 702.
Memory 704 is configured to store various types of data to support operations at device 700. Examples of such data include instructions for any application or method operating on the electronic device 700, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 704 may be implemented by any type or combination of volatile or nonvolatile memory devices 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 or optical disk.
The power component 704 provides power to the various components of the electronic device 700. Power component 704 can include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for electronic device 700.
The multimedia component 708 includes a screen between the electronic device 700 and the user that provides an output interface. 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 a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may sense not only the boundary of a touch or slide action, but also the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 708 includes a front-facing camera and/or a rear-facing camera. When the electronic device 700 is in an operational 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 focal length and optical zoom capabilities.
The audio component 710 is configured to output and/or input audio signals. For example, the audio component 710 includes a Microphone (MIC) configured to receive external audio signals when the electronic device 700 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may be further stored in the memory 704 or transmitted via the communication component 716. In some embodiments, the audio component 710 further includes a speaker for outputting audio signals.
The I/O interface 712 provides an interface between the processing component 702 and peripheral interface modules, which may be a keyboard, click wheel, buttons, etc. These buttons may include, but are not limited to: homepage button, volume button, start button, and lock button.
The sensor assembly 714 includes one or more sensors for providing status assessment of various aspects of the electronic device 700. For example, the sensor assembly 714 may detect an on/off state of the device 700, a relative positioning of the components, such as a display and keypad of the electronic device 700, a change in position of the electronic device 700 or a component of the electronic device 700, the presence or absence of a user's contact with the electronic device 700, an orientation or acceleration/deceleration of the electronic device 700, and a change in temperature 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 a light 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 acceleration sensor, a gyroscopic sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 716 is configured to facilitate communication between the electronic device 700 and other devices, either wired or wireless. The electronic device 700 may access a wireless network based on a communication standard, such as WiFi,2G, or 3G, or a combination thereof. In one exemplary embodiment, the communication part 714 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communication component 714 further includes a Near Field Communication (NFC) module to facilitate short range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
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 elements for executing the methods described above.
In an exemplary embodiment, a non-transitory computer readable storage medium is also provided, such as memory 704, including instructions executable by processor 720 of electronic device 700 to perform the above-described method. For example, the non-transitory computer readable storage medium may be ROM, random Access Memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.
A non-transitory computer readable storage medium, which when executed by a processor of a terminal, causes the terminal to perform a device switching method, the method comprising:
receiving a current input instruction of input and output equipment;
detecting whether the current input instruction is a switching instruction or not;
If the current input instruction is a switching instruction, changing the current used equipment recorded on a first network device into the target network device according to the equipment identifier of the switched target network device carried by the switching instruction, so that the first network device forwards the input instruction to the target network device after receiving the input instruction of the input and output device; the first network device and the input/output device are connected through a connector.
Optionally, the plurality of network devices are connected to each other through a network switch, the currently used device is not the same device as the first network device, and the method further includes:
And if the current input instruction is not a switching instruction, forwarding the current input instruction to the current using device by the first network device through the network switch.
Optionally, the plurality of network devices are connected to each other through a network switch, the currently used device is not the first network device, and receiving the current input instruction of the input/output device includes:
receiving the current input instruction forwarded by the first network device through the network switch;
The changing the current used equipment recorded on the first network equipment into the target network equipment according to the equipment identifier of the target network equipment after switching carried by the switching instruction comprises the following steps:
And sending a change request to the first network equipment through the network switch so as to change the current used equipment recorded on the first network equipment into the target network equipment, wherein the change request carries the equipment identifier of the target network equipment.
Optionally, the device identifier includes a unique number, and before the 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; the unique identification is generated according to a unique number and a hardware address of the network equipment, and the unique number is allocated to each network equipment in advance;
resolving the unique identifier of each network device to obtain the unique number and the hardware address of each network device;
recording the unique number, hardware address and network address of each network device;
After the device identifier of the target network device after switching carried by the switching instruction changes the current used device recorded on the first network device into the target network device, forwarding the input instruction to the target network device includes:
Generating a protocol packet corresponding to the input instruction according to the unique number of the target network equipment; wherein, the protocol packet comprises a network address corresponding to the unique number and the input instruction;
and forwarding the protocol packet to the target network equipment according to the network address in the protocol packet.
Optionally, the changing the current used device recorded on the first network device to the target network device according to the device identifier of the target network device after switching carried by the switching instruction includes:
Searching the unique number, the hardware address and the record of the network address of the target network equipment according to the unique number of the target network equipment;
And if the record of the unique number, the hardware address and the network address of the target network device is searched, changing the current used device recorded on the first network device into the target network device.
Optionally, when the currently used device is the same device as the first network device, the method further comprises:
And if the current input instruction is a switching instruction, closing the function of the first network equipment for using the input and output equipment.
Optionally, after the current input instruction is the switching instruction, according to the device identifier of the switched target network device carried by the switching instruction, the current used device recorded on the first network device is changed to the target network device, where the method further includes:
when the target network equipment is not the same equipment as the first network equipment, establishing connection between the first network equipment and the target network equipment for transmitting the input instruction;
or when the target network device and the first network device are the same device, starting the function of the first network device for using the input/output device.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described by differences from other embodiments, and identical and similar parts between the embodiments are all enough to be referred to each other.
It will be apparent to those skilled in the art that embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the invention may take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiment and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or terminal device that comprises the element.
The above description of a device switching method, a device switching apparatus, an electronic device, and a readable storage medium provided by the present invention applies specific examples to illustrate the principles and embodiments of the present invention, and the above examples are only used to help understand the method and core ideas of the present invention; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in accordance with the ideas of the present invention, the present description should not be construed as limiting the present invention in view of the above.