Device connection method, data exchange method and related device
The method enhances device functionality and security by dynamically configuring network devices using scenario configuration information and descriptor sets, addressing fixed-function and security risk issues in connected devices.
Patent Information
- Application Number
- JP2025504767
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2022-08-08
- Filing Date
- 2023-08-03
- Publication Date
- 2025-09-02
AI Technical Summary
Current connected devices have fixed functions and high security risks due to the need for software rewriting and potential data leakage through packet capture by computer hosts.
A method for network devices that involves setting configuration information based on a preset policy, establishing communication connections using scenario configuration information, and defining device types through descriptor sets to enhance functionality and security.
Enriches device functions and ensures data security by preventing packet capture and malicious program intrusion, allowing dynamic configuration and secure communication.
Smart Images

Figure 2025528755000001_ABST
Abstract
Description
[Technical Field]
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS This application claims priority to a Chinese patent application, application number 20221092696.4, entitled "Device connection method, data exchange method, apparatus, device and storage medium," filed with the China Patent Office on August 8, 2022, all of which are incorporated herein by reference.
[0002] The present application relates to the field of communication and data security technology, and in particular to a device connection method, a data exchange method, an apparatus, a network device, a server side, and a computer-readable storage medium. [Background technology]
[0003] Currently, the device functions of some connected devices (such as Universal Serial Bus (USB) devices) are fixed at the factory and cannot be changed after shipping, or can only be changed by rewriting the software. Furthermore, if the connected device needs to be extended for various applications, control software such as a driver must be installed on the computer host. This makes it easy for the computer host to capture packets, which could leak actual data sources and network communication data. This also increases the risk of malicious programs cracking the connected device, increasing security risks. Summary of the Invention
[0004] To solve the technical problem that current connected devices have single functions and high security risks, the present application provides a device connection method, a data exchange method, an apparatus, a network device, a server side and a computer-readable storage medium.
[0005] In a first aspect, the present application provides a device connection method for a network device, the method comprising: setting configuration information of the network device based on a preset creation policy; reading the scenario configuration information in advance; Establishing a communication connection between the network device and the target device based on the loaded scenario configuration information to connect the network device to the target device.
[0006] The configuration information includes scenario configuration information of a network device in at least one application scenario, the scenario configuration information including at least one of a first descriptor set and a function command set, and data source configuration information, the first descriptor set for defining a device type of the network device, and the function command set including a descriptor command set.
[0007] In some embodiments of the first aspect, the pre-loading of the scenario configuration information includes: The scenario configuration information may be pre-loaded before connecting the network device to the target device, and the scenario configuration information may be stored on a server or the network device, where the server may be any electronic device that can establish a communication connection with the network device and load the scenario configuration information.
[0008] Note that the server side in this application may be an electronic device terminal that uses a network connection (such as a TCR / IP connection for long-distance communication) or a non-network connection (such as a point-to-point connection using Wi-Fi, Bluetooth, LoRA, etc. for short-range communication). For example, when a data interaction relationship is established between two terminals and the first terminal provides scenario configuration information or a data source to the second terminal (such as a network device or a connected device), the first terminal may be understood as the server side. Of course, the server side may also be understood as a server, virtual server, cloud server, server cluster, personal computer, embedded computer, mobile phone, tablet, smart wearable device, or even a client side, control side, etc. configured on the network side.
[0009] In some embodiments of the first aspect, the pre-loading of the scenario configuration information includes: When the network device is started up, the network device transmits to the server a request to acquire the scenario information, the request including an ID of the network device; the server responds to the scenario information acquisition request and filters, from the scenario configuration information, scenario configuration information that matches an ID of the network device as the scenario configuration information; and transmitting the scenario configuration information to the network device.
[0010] In some embodiments of the first aspect, setting the scenario configuration information of the network device includes: and setting at least one of the first descriptor set and the descriptor command set and data source configuration information according to a preset creation policy via a server side that has established a communication connection with the network device, a client side that has established a communication connection with the server side, or the network device, The preset creation policy includes at least one of a custom creation policy, a template creation policy, and an externally imported creation policy.
[0011] In some embodiments of the first aspect, establishing a communication connection with a target device based on the pre-loaded scenario configuration information includes: The method includes setting the network device to at least one of a master mode, a slave mode, and a peer-to-peer communication mode according to mode selection information in the scenario configuration information.
[0012] In some embodiments of the first aspect, setting the network device to a master mode and establishing a communication connection with a target device based on the descriptor command set includes: sending a handshake connection request to the target device; receiving a second set of descriptors sent by the target device in response to the handshake connection request; enumerating a plurality of descriptors in the second descriptor set based on a descriptor set of the function command set; determining that the handshake connection is successful if the plurality of descriptors of the second descriptor meets preset device requirements; If the plurality of descriptors do not meet the preset device requirements, determining that the handshake connection has failed, sending the acquired second descriptor set to a server side, downloading a corresponding third descriptor set from the server side, and performing enumeration again based on the descriptors in the third descriptor set.
[0013] In some embodiments of the first aspect, the descriptor command set includes a get device descriptor command, a get configuration descriptor command, a get interface descriptor command, a get endpoint descriptor command, a get string descriptor command, and a get BOS descriptor command.
[0014] In some embodiments of the first aspect, the method further comprises: and if the handshake connection based on the descriptors in the third set of descriptors is successful, setting a target data source for communication between the network device and the target device, the target data source being provided in the target device, the server side, a client side connected to the server side, or any one of electronic devices communicating with the network device.
[0015] In some embodiments of the first aspect, the function command set includes a data source command set, and configuring a target data source in communication between the network device and the target device includes: The method further includes determining a target data source when the network device communicates with the target device based on the data source command set and in accordance with the data source configuration information.
[0016] In some embodiments of the first aspect, the target data source includes at least one of a storage medium, an address range of storage space (such as a range of sector addresses), an image storage file, a specific folder, a database, and a data stream.
[0017] In some embodiments of the first aspect, the data source configuration information includes at least one of capacity information of the data source, a storage medium, an address range of storage space (e.g., a sector address range), a read / write status, an image storage file, a specific folder, a database, and a data stream, and the capacity information includes at least one of a last logical block address of the data source, a total number of formattable logical blocks, and a block capacity.
[0018] In some embodiments of the first aspect, the descriptor command set includes at least one of a first standard command set, a first special command set, and a configuration command set, wherein: the first standard command set is for sending commands to the target device to request descriptor data of the target device; The special command set is for obtaining data of a device type to which the target device belongs; The configuration command set is for transmitting configuration commands, where the configuration commands include at least one of commands such as set address, enable configuration, enable endpoint, and start peripheral module.
[0019] In some embodiments of the first aspect, when the network device is set to a master mode, establishing a communication connection with the target device based on the descriptor command set includes: sending a handshake connection request to the target device; Obtaining descriptor data for the target device in response to the first standard command set; Obtaining data of the target device in response to the special command set; Obtaining at least one of a setting status of an address of the target device, a configuration enabling status, an endpoint enabling status, and a peripheral module activation status in response to the setting command set; If it is determined that at least one of the descriptor data of the target device, the data of the target device, the address setting status of the target device, the configuration enabling status, the endpoint enabling status, or the peripheral module startup status does not satisfy the condition specified in the first connection status determination rule, determine that the handshake connection has failed, and send the descriptor data of the target device to the server side; receiving new scenario configuration information or a new descriptor command set sent from the server side; and establishing a communication connection between the network device and the target device in response to the new scenario configuration information or the new descriptor command set.
[0020] Here, the server side determines the new scenario configuration information or the new descriptor command set according to the descriptor data of the target device.
[0021] In some embodiments of the first aspect, when the network device is set to a slave mode, establishing a communication connection with a target device based on the first descriptor set includes: receiving a handshake connection request sent from the target device; responding to the handshake connection request, feeding back the first descriptor set to the target device so that the target device enumerates the first descriptor set; determining that the handshake connection is successful if the handshake connection request meets preset device requirements; If the handshake connection request does not meet preset device requirements, determine that the handshake connection has failed, send data of the handshake connection request to a server side, download a corresponding fourth descriptor set from the server side, and perform enumeration again based on the descriptors in the fourth descriptor set.
[0022] In some embodiments of the first aspect, the first set of descriptors includes at least one of a standard data set, a special data set, and an execution of a configuration command, wherein: The standard data set is used to feed back descriptor data according to the type and parameters of a standard command when sending the standard command to the target device.
[0023] The special data set is used to feed back data when sending a special command to the target device depending on the type and parameters of the special command and the type of the network device.
[0024] The execution of the configuration command is used to set at least one of an address of the network device, enable a configuration, enable an endpoint, and activate a peripheral module when the target device sends a configuration command.
[0025] In some embodiments of the first aspect, when the network device is set to a slave mode, establishing a communication connection with a target device based on the first descriptor set includes: receiving a handshake connection request sent from the target device; receiving at least one of a standard command, a special command, or a setting command sent from the target device; and determining that the handshake connection has failed and sending a descriptor command of the target device to a server side when the at least one of the standard command, the special command, or the setting command does not meet a condition specified in a second connection status judgment rule; receiving new scenario configuration information or a new first descriptor set sent from the server side; and establishing a communication connection between the network device and the target device according to the new scenario configuration information or the new first set of descriptors.
[0026] Here, the server side determines the new scenario configuration information or a new first descriptor set according to a descriptor command of the target device.
[0027] In some embodiments of the first aspect, the first set of descriptors includes at least one of a device descriptor, a configuration descriptor, an interface descriptor, an endpoint descriptor, a string descriptor, a BOS descriptor, and a preset custom descriptor.
[0028] In some embodiments of the first aspect, when the network device is configured in a peer-to-peer communication mode, establishing a communication connection with a target device based on the configuration information includes: setting a first interface of the network device as a sender and sending data to the target device via the first interface; and setting a second interface of the network device as a receiver and receiving data transmitted from the target device via the second interface.
[0029] In some embodiments of the first aspect, the configuration information includes at least one of a third mode, a third interface type, an interaction data set, a third status determination rule, and a third status response rule, wherein: The third mode is used to set the operation mode of the network device to a peer-to-peer mode.
[0030] The third interface type is used to configure the first interface as the sender and the second interface as the receiver.
[0031] The interaction data set is used to configure data to be sent from the network device to the target device.
[0032] The third status determination rule is used to determine whether the connection status of the network device is successful or failed according to the data sent from the target device.
[0033] The third status response rule is used to respond depending on the connection status of the network device.
[0034] In some embodiments of the first aspect, the target devices include at least one first target device and at least one second target device, and the network device functions as a master device that establishes a communication connection with the at least one first target device and a slave device that establishes a communication connection with the at least one second target device. Establishing a communication connection with a target device based on the target scenario descriptor information includes: enumerating a plurality of descriptors from a second descriptor set in at least one first target device based on a descriptor command set of the function command set; If the handshake connection of the plurality of descriptors in the second set of descriptors is successful, configuring a first target data source in communication between the network device and the at least one target device to complete communication between the network device and the at least one target device; receiving a handshake connection request sent from at least one second target device; Responding to the handshake connection request, feeding back the first descriptor set to the at least one second target device so that the at least one second target device enumerates the first descriptor set, and configuring a second target data source during communication between the network device and the at least one second target device according to configuration information of the data source after the handshake connection of the first descriptor set is successful.
[0035] In a second aspect, the present application provides a data exchange method applied to a network device, wherein the network device establishes a communication connection with a server side and a target device based on the above device connection method, and the method includes: Obtaining a data exchange request sent from a first target party; and responding to the data exchange request based on a preset processing policy and feeding back target data to the first target party, the target data being data sent from a second target party, where if the first target party is a server side, the second target party is the target device, or if the first target party is the target device, the second target party is the server side.
[0036] In some embodiments of the second aspect, the target devices include at least one first target device and at least one second target device, and the network device functions as a master device communicating with the first target device and as a slave device communicating with at least one second target device. Here, when the first target party is the server side, the second target party is the first target device or the second target device. When the first target party is the second target device, the second target party is the server side or the first target device.
[0037] In some embodiments of the second aspect, responding to the data exchange request and feeding back targeted data to the first targeted party based on the preset processing policy includes: In response to the data exchange request, forwarding the data exchange request to the second target party; receiving target data fed back by the second target party in response to the data exchange request, and forwarding the target data to the first target party.
[0038] In a third aspect, the present application provides a data exchange method applicable to a network device, the network device establishing a communication connection with a target device based on the device connection method described above, the method comprising: determining a target data source according to data source configuration information in the scenario configuration information; and realizing data interaction between the network device and the target device based on the target data source.
[0039] In some embodiments of the third aspect, the data source configuration information includes capacity information, storage medium, and read / write status of the data source, and the capacity information includes at least one of the last logical block address of the data source, the total number of formattable logical blocks, or block capacity.
[0040] In some embodiments of the third aspect, the target data source is provided on the target device, the network device, the server side, a client side connected to the server side, or any one of the electronic devices communicating with the network device.
[0041] In some embodiments of the third aspect, implementing data interaction between the network device and the target device based on the target data source includes: setting an auto-execution script when the network device communicates with the target device; Sending a first data exchange request to the target device based on the automatic execution script, and receiving first data sent by the target device in response to the first data exchange request; or receiving a second data exchange request sent from the target device based on the automatic execution script, and sending second data to the target device in response to the second data exchange request, wherein the first data or the second data is data at the target data source.
[0042] The scenario configuration information includes the automatic execution script.
[0043] In some embodiments of the third aspect, receiving data transmitted by the target device in response to the first data exchange request also includes: The method includes transmitting data sent from the target device to the server side, wherein the server side is any electronic device that can establish a communication connection with a network device and set configuration information.
[0044] In some embodiments of the third aspect, the method further comprises: receiving a first low-level command sent from the server side; sending the first low-level command to the target device; If the operation type of the first low-level command is a read operation, receiving data of a first sector address fed back by the target device in response to the first low-level command; If the operation type of the first low-level command is a read operation, writing the data in the data packet to the first sector address of the target device, where the first low-level command is sent from the client side to the server side, and the first low-level command includes an operation type, an operated storage space, an operation length, and a data packet, and the target device determines the first sector address according to the operated storage space and the operation length.
[0045] In some embodiments of the third aspect, the method also includes: receiving a search command sent from the server side; traversing and reading relevant storage space addresses (e.g., sector addresses) of the target device or network device, respectively, in response to the search command to search for corresponding storage data; and transmitting the stored data to the server side so as to transmit the file data from the server side to the client side.
[0046] The search command is sent from the client side to the server side, and the search command includes file information.
[0047] In some embodiments of the third aspect, the auto-execution script is a high-level command, and the high-level command includes a file creation command, a file deletion command, a file attribute change command, a file content read command, and a file content change command.
[0048] In a fourth aspect, the present application provides a device connection method applied to a server side, the method comprising: When communicating with a network device, transmitting target configuration information to the network device; Establishing a communication connection with a target device based on the target scenario configuration information to connect the network device to the target device.
[0049] The target configuration information is used to establish a communication connection between the network device and a target device. The target configuration information includes scenario configuration information of the network device in at least one application scenario, and the scenario configuration information includes at least one of a first descriptor set and a descriptor command set. The first descriptor set is used to define a device type of the network device. The scenario configuration information stored on the server side includes at least one of the first descriptor set and the descriptor command set of the network device and data source configuration information, which are generated according to a preset generation policy before pre-loading the target configuration information. The target scenario configuration information is one of the scenario configuration information.
[0050] In some embodiments of the fourth aspect, transmitting target configuration information to the network device comprises: receiving a scenario information acquisition request transmitted from the network device, responding to the scenario information acquisition request, and filtering, from the scenario configuration information, scenario configuration information that matches an ID of the network device in the scenario information acquisition request; and transmitting the scenario configuration information to the network device.
[0051] In some embodiments of the fourth aspect, the method further comprises: receiving a target device descriptor set transmitted from the network device; The server side determines new scenario configuration information according to a descriptor set of the target device and sends the new scenario configuration information to the network device so that the network device can establish a communication connection between the network device and the target device according to the new scenario configuration information.
[0052] Here, the descriptor set is received by the network device from the target device.
[0053] In a fifth aspect, the present application further provides a data exchange method applied to a server side, wherein the server side establishes a communication connection with a network device based on the device connection method described above, and the method includes: Sending a data exchange request to the network device and receiving target data fed back by the network device; and / or Sending target data to the network device in response to a data exchange request to which the network device responds based on a preset processing policy.
[0054] The data exchange request is used by the network device to respond to the data exchange request based on a preset processing policy, the target data is data sent from the target device, the target data is fed back from the network device to the target device, and the data exchange request is executed by the target device.
[0055] In some embodiments of the fifth aspect, the method further comprises: receiving a read operation command sent from the network device, determining data from the server-side data source in response to the read operation command, and sending the determined data to the network device; or The method includes receiving a write operation command and a write data packet sent from the network device, and writing the write data packet to the server-side data source in response to the write operation command.
[0056] In a sixth aspect, the present application further provides a server side comprising a processor and a memory, the server side being capable of realizing the above device connection method or the above data exchange method.
[0057] In a seventh aspect, the present application further provides a data exchange device applied to a network device, wherein the network device establishes a communication connection with a server side and a target device based on the above device connection method, and the device an acquisition module for acquiring the data exchange request sent from the first target party; and a response module for responding to the data exchange request based on a preset processing policy and feeding back target data to a first target party, the target data being data sent from a second target party, where if the first target party is the server side, the second target party is the target device, and if the first target party is the target device, the second target party is the server side.
[0058] In an eighth aspect, the present application further provides a network device comprising a processor and a memory, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, the above-mentioned device connection method or the above-mentioned data exchange method is implemented.
[0059] In a ninth aspect, the present application further provides a computer-readable storage medium having a computer program stored therein, the computer program implementing the above-mentioned device connection method or the above-mentioned data exchange method when executed by a processor.
[0060] In a tenth aspect, the present application further provides a device connection method for a network device, the method comprising: When communicating with the server side, it preloads target configuration information and Establishing a communication connection with a target device based on the target scenario configuration information to connect the network device to the target device.
[0061] The target configuration information is used to establish a communication connection between the network device and a target device. The target configuration information includes scenario configuration information of the network device in at least one application scenario, and the scenario configuration information includes at least one of a first descriptor set and a descriptor command set. The first descriptor set is used to define a device type of the network device. The scenario configuration information stored on the server side includes at least one of the first descriptor set and the descriptor command set of the network device and data source configuration information, which are generated according to a preset generation policy before pre-loading the target configuration information. The target scenario configuration information is one of the scenario configuration information.
[0062] In some embodiments of the tenth aspect, when communicating with the server side, pre-loading target configuration information includes: When communicating with a server side, sending a configuration acquisition request to the server side, the request including identification information of the network device; and receiving target configuration information corresponding to the identification information fed back from the server side.
[0063] In some embodiments of the tenth aspect, the network device acts as a master device that communicates with a target device, and the descriptor command set includes a plurality of function command sets, and the function command sets are used to control data exchange between the network device and the target device.
[0064] In some embodiments of the tenth aspect, establishing a communication connection with a target device based on the target scenario descriptor information includes: enumerating a plurality of descriptors in a second descriptor set for the target device based on a function command set in the descriptor command set; If the enumeration is successful, setting a target data source for communication between the network device and the target device, the target data source being provided on the target device.
[0065] In some embodiments of the tenth aspect, the function command set includes an acquisition command set and a verification command set, and enumerating a plurality of descriptors of a second descriptor set of the target device based on the function command set in the descriptor command set includes: reading a second descriptor set of the target device based on the obtain command set; verifying a plurality of descriptors in the second set of descriptors based on the verification command set; and determining that the enumeration is successful if a plurality of the descriptors meets preset device requirements.
[0066] In some embodiments of the tenth aspect, the function command set further includes a data source command set, and the target scenario configuration information further includes data source configuration information. Configuring a target data source during communication between the network device and the target device includes: The method further includes determining a target data source when the network device communicates with the target device based on the data source command set and in accordance with the data source configuration information.
[0067] In some embodiments of the tenth aspect, the network device is a network read / write control device, and establishing a communication connection with a target device based on the target scenario descriptor information includes: enumerating a plurality of descriptors in a second descriptor set for the target device based on a function command set in the descriptor command set; If the enumeration is successful, requesting the server side to send a driver command set corresponding to the target device to complete the communication connection, the driver command set being used to exchange data with the target device.
[0068] In some embodiments of the tenth aspect, the network device is a network proxy control device, and establishing a communication connection with a target device based on the target scenario descriptor information includes: enumerating a plurality of descriptors in a second descriptor set for the target device based on a function command set in the descriptor command set; If the enumeration is successful, the server side virtualizes the target device, generates a virtual device corresponding to the target device, and sends the second descriptor set to the server side to establish a communication connection with the target device.
[0069] In some embodiments of the tenth aspect, the network device functions as a slave device that establishes a communication connection with a target device based on the target scenario descriptor information, the establishing of the communication connection with the target device includes: receiving an enumeration request sent from the target device; In response to the enumeration request, feeding back the first descriptor set to the target device so that the target device enumerates the first descriptor set, and after the enumeration is successful, setting a target data source when communicating between the network device and the target device according to configuration information of the data source, wherein the target data source is provided on the server side.
[0070] In some embodiments of the tenth aspect, the data source configuration information includes capacity information of the data source, and the capacity information includes a last logical block address and a block capacity of the data source.
[0071] In certain embodiments of the tenth aspect, the descriptor set includes at least one of a device descriptor, a configuration descriptor, an interface descriptor, an endpoint descriptor, a string descriptor, and a preset custom descriptor.
[0072] In some embodiments of the tenth aspect, the target devices include at least one first target device and at least one second target device, and the network device functions as a master device that communicates with the first target device and as a slave device that establishes a communication connection with the second target device based on the target scenario descriptor information, the establishing a communication connection with the target device based on the target scenario descriptor information includes: enumerating a plurality of descriptors in a second descriptor set for the first target device based on a function command set in the descriptor command set; If the enumeration is successful, configuring a first target data source in communication between the network device and the first target device to complete a communication connection with the first target device; receiving an enumeration request sent from the second target device; In response to the enumeration request, feeding back the first descriptor set to the second target device so that the second target device enumerates the first descriptor set, and after the enumeration is successful, configuring a second target data source during communication between the network device and the second target device according to data source configuration information, wherein the first target data source is provided on the first target device and the second target data source is provided on the server side or the first target device.
[0073] In an eleventh aspect, the present application further provides a data exchange method applied to a network device, wherein the network device establishes a communication connection with a server side and a target device based on the above device connection method, and the method includes: Obtaining a data exchange request sent from a first target party; and responding to the data exchange request based on a preset processing policy and feeding back target data to the first target party, the target data being data sent from a second target party, where if the first target party is a server side, the second target party is the target device, or if the first target party is the target device, the second target party is the server side.
[0074] In some embodiments of the eleventh aspect, the target devices include at least one first target device and at least one second target device, and the network device functions as a master device communicating with the first target device and as a slave device communicating with at least one second target device. Here, when the first target party is the server side, the second target party is the first target device or the second target device. When the first target party is the second target device, the second target party is the server side or the first target device.
[0075] In some embodiments of the eleventh aspect, responding to the data exchange request and feeding back targeted data to the first targeted party based on the preset processing policy includes: In response to the data exchange request, forwarding the data exchange request to the second target party; receiving target data fed back by the second target party in response to the data exchange request, and forwarding the target data to the first target party.
[0076] In some embodiments of the eleventh aspect, the network device is a network USBkey device and the target device is a computer host, and in response to the data exchange request, forwarding the data exchange request to a second target party comprises: In response to a data exchange request sent from a computer host, forwarding the data exchange request to the server side, the data exchange request having authentication information of the network USBkey device so that the server side can verify against the authentication information.
[0077] In some embodiments of the eleventh aspect, responding to the data exchange request and feeding back targeted data to the first targeted party based on the preset processing policy includes: Processing data for the data exchange request based on a preset processing script, and obtaining a data processing result; sending a targeted data retrieval request to the second targeted party based on the processing result of the data; receiving target data corresponding to a result of processing the data fed back by the second target party in response to the data exchange request, and feeding back the target data to the first target party.
[0078] In a twelfth aspect, the present application further provides a device connection method applied to a server side, the method comprising: When communicating with a network device, transmitting target configuration information to the network device; Establishing a communication connection with a target device based on the target scenario configuration information to connect the network device to the target device.
[0079] The target configuration information is used to establish a communication connection between the network device and a target device. At least one preset configuration information is stored on the server side. The target configuration information is one of the preset configuration information, and the target configuration information includes scenario configuration information of the network device in at least one application scenario, and the scenario configuration information includes at least one of a first descriptor set and a descriptor command set. The first descriptor set is used to define a device type of the network device. The scenario configuration information stored on the server side is at least one of the first descriptor set and the descriptor command set of the network device and data source configuration information, which are generated according to a preset generation policy before pre-loading the target configuration information. The target scenario configuration information is one of the scenario configuration information.
[0080] In a thirteenth aspect, the present application further provides a data exchange method applied to a server side, wherein the server side establishes a communication connection with a network device based on the device connection method described above, and the method includes: Sending a data exchange request to the network device and receiving target data fed back by the network device; and / or Sending target data to the network device in response to a data exchange request to which the network device responds based on a preset processing policy.
[0081] The data exchange request is used by the network device to respond to the data exchange request based on a preset processing policy, the target data is data sent from the target device, the target data is fed back from the network device to the target device, and the data exchange request is executed by the target device.
[0082] In a fourteenth aspect, the present application further provides a device connection apparatus for applying to a network device, the apparatus comprising: A preload module for preloading target configuration information when communicating with the server side; and a first establishment module for establishing a communication connection with the target device based on target scenario configuration information to connect the network device to the target device.
[0083] At least one preset configuration information is stored on the server side, and the target configuration information is one of the preset configuration information, and the target configuration information includes scenario configuration information of the network device in at least one application scenario, and the scenario configuration information includes at least one of a first descriptor set and a descriptor command set. The descriptor set is used to define a device type of the network device. The scenario configuration information stored on the server side is at least one of the first descriptor set and the descriptor command set of the network device and data source configuration information, which are generated according to a preset generation policy before pre-loading the target configuration information. The target scenario configuration information is one of the scenario configuration information.
[0084] In a fifteenth aspect, the present application further provides a data exchange device applied to a network device, wherein the network device establishes a communication connection with a server side and a target device based on the above device connection method, and the device: an acquisition module for acquiring the data exchange request sent from the first target party; and a response module for responding to the data exchange request based on a preset processing policy and feeding back target data to a first target party, the target data being data sent from a second target party, where if the first target party is the server side, the second target party is the target device, and if the first target party is the target device, the second target party is the server side.
[0085] In a sixteenth aspect, the present application further provides a network device comprising a processor and a memory, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, the above-mentioned device connection method or the above-mentioned data exchange method is implemented.
[0086] In a seventeenth aspect, the present application further provides a server side comprising a processor and a memory, the server side being capable of realizing the above device connection method or the above data exchange method.
[0087] In an eighteenth aspect, the present application further provides a computer-readable storage medium having a computer program stored therein, the computer program implementing the above-mentioned device connection method or the above-mentioned data exchange method when executed by a processor.
[0088] The present application sets scenario configuration information for a network device and pre-loads the scenario configuration information, thereby redefining the device functions of the network device according to the target configuration information to further enrich the device functions. The scenario configuration information includes at least one of a first descriptor set and a descriptor command set, where the first descriptor set defines the device type of the network device. Furthermore, the present application further stores preset configuration information on a server side to facilitate real-time monitoring. If a network device is lost, the server side can cut off a communication connection with the network device, thereby ensuring the security of the data source of the network device. Finally, the method of obtaining configuration information on a server side and establishing a communication connection with the target device by establishing a communication connection with the target device based on the scenario configuration information and allowing the network device to connect to the target device effectively prevents packets from being captured by a computer host, which could leak actual data sources and network communication data, or be cracked by malicious programs, thereby ensuring the device security of the network device. [Brief explanation of the drawings]
[0089] [Figure 1] 1 is a schematic diagram of a flowchart of a device connection method in an embodiment of the present application; [Figure 2] FIG. 1 is a structural schematic diagram of a network device in an embodiment of the present application; [Figure 3A-3B] 1 is a schematic diagram of a network device as a portable device interacting with a control side in one embodiment of the present application; FIG. [Figure 3C] 1 is a schematic diagram of a network device as a mobile terminal interacting with a control party in one embodiment of the present application; FIG. [Figure 3D] FIG. 1 is a schematic diagram of a network device as a smartwatch interacting with a control party in one embodiment of the present application. [Figure 3E] 1 is a schematic diagram illustrating a network device as an in-vehicle terminal interacting with a control side in an embodiment of the present application; [Figure 3F] 1 is a schematic diagram of a network device as a device with multiple interfaces interacting with a control side in one embodiment of the present application; FIG. [Figure 4] FIG. 2 is an architecture diagram for setting target configuration information for a network device in one embodiment of the present application. [Figure 5A] FIG. 10 is a structural diagram of a network device according to another embodiment of the present application; [Figure 5B] FIG. 10 is a structural diagram of a network device according to another embodiment of the present application; [Figure 6] FIG. 10 is a schematic diagram of a flowchart of a device connection method provided in another embodiment of the present application. [Figure 7] FIG. 10 is a schematic diagram of a flowchart of a device connection method provided in another embodiment of the present application. [Figure 8] FIG. 10 is a schematic diagram of a flowchart of a device connection method provided in another embodiment of the present application. [Figure 9] FIG. 10 is a schematic diagram of a flowchart of a device connection method provided in another embodiment of the present application. [Figure 10] 1 is a schematic diagram of a flowchart of a data exchange method provided in an embodiment of the present application; [Figure 11] 4 is a flowchart of a data exchange method according to another embodiment of the present application; [Figure 12] 1 is a flowchart of a data exchange method in one embodiment of the present application; [Figure 13] 4 is a flowchart of a data exchange method according to another embodiment of the present application; [Figure 14A] FIG. 10 is a schematic diagram of controlling a sector address, data packet, or status of a "read command (read one sector)" from the perspective of a data processing process in one embodiment of the present application. [Figure 14B]FIG. 10 is a schematic diagram of sector addresses, data packets, or statuses of a "Read Command (Continuous Read of Multiple Sectors)" from the perspective of data exchange in one embodiment of the present application. [Figure 14C] FIG. 10 is a schematic diagram of a sector address, data packet, or status of a "write command (write one sector)" from the perspective of data exchange in one embodiment of the present application. [Figure 14D] FIG. 10 is a schematic diagram illustrating how a sector address, a data packet, or a status of a "write command (continuous writing of multiple sectors)" is controlled from the viewpoint of data exchange in an embodiment of the present application. [Figure 15] 4 is a flowchart of a data exchange method according to another embodiment of the present application; [Figure 16] 4 is a flowchart of a data exchange method according to another embodiment of the present application; [Figure 17] 4 is a flowchart of a data exchange method according to another embodiment of the present application; [Figure 18] 4 is a flowchart of a data exchange method according to another embodiment of the present application; [Figure 19] 4 is a flowchart of a data exchange method according to another embodiment of the present application; [Figure 20] 4 is a flowchart of a data exchange method according to another embodiment of the present application; [Figure 21] 4 is a flowchart of a data exchange method according to another embodiment of the present application; [Figure 22] FIG. 2 is a block diagram of a device connection apparatus provided in an embodiment of the present application; [Figure 23] FIG. 10 is a schematic diagram of a flowchart of a device connection method provided in another embodiment of the present application. [Figure 24] FIG. 10 is a block diagram of a device connection apparatus provided in another embodiment of the present application. [Figure 25] 1 is a block diagram of a data exchange device provided in an embodiment of the present application; [Figure 26] FIG. 10 is a block diagram of a data exchange device provided in another embodiment of the present application; [Figure 27] FIG. 1 is a structural schematic diagram of a network device provided in an embodiment of the present application; DETAILED DESCRIPTION OF THE INVENTION
[0090] Hereinafter, the technical solutions in the embodiments of the present application will be clearly and completely described with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all of the embodiments. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative work fall within the protection scope of the present application.
[0091] As described in the relevant technical description, the device functions of some connected devices are determined at the factory and cannot be changed after leaving the factory, or can only be changed by rewriting the software. For example, if a USB flash drive with a USB interface is specified to be used only as a storage device at the factory, in subsequent applications the USB flash drive can only store data locally. Some connected devices have multiple switchable device functions, but these functions are pre-set before leaving the factory, and the connected device can only be switched between the predetermined functions and cannot be changed after leaving the factory. In addition, some connected devices have relatively few connection interfaces, making it difficult to meet the needs of various functional scenarios. For example, in-vehicle devices have a limited number of USB communication interfaces (usually one), which can usually only be used to read USB flash drives.
[0092] Furthermore, due to the complexity of actual applications of connected devices, if hardware incompatibility occurs, such as a new model of the device not being supported or compatibility data for a particular model being omitted from the factory, the target device may not recognize the connection information of the connected device, resulting in connection failure for the connected device and increased error correction costs for the connected device. For example, if a connected device (in this case, the connected device is a slave device) cannot connect to a master device, or if a connected device (in this case, the connected device is a master device) cannot connect to a slave device, the receiving device will need to be recycled and its hardware updated again, resulting in wasted resources and increased costs.
[0093] Furthermore, storing data related to device functions or applications on the device itself is detrimental to data confidentiality and protection. Losing a device also means losing the data on the device. Because critical software, drivers, and other data are stored on the device, even if protected by software, they are vulnerable to reverse engineering. Furthermore, if a connected device needs to extend its application, it requires installing control software such as drivers on the computer host, which makes it easier for the computer host to capture packets, potentially exposing the actual data source and network communication data. Furthermore, connected devices can be potentially cracked by malicious programs, increasing security risks.
[0094] The above problems lead to single-function devices on the one hand, increased error correction costs on the other hand, and the inability to ensure local data security when connected to a computer host on the other hand.
[0095] Before introducing the embodiments of the present application, some technical terms used in this document will be briefly explained.
[0096] 1. Communication rules between master devices and slave devices. Divided into master mode and slave mode, the master device actively sends data interaction commands to the slave device, and the slave device passively responds according to the data interaction command. Taking the USB communication rules as an example, USB is divided into master devices (such as computer hosts) and slave devices (such as USB flash drives). The master device sends token packets (or token packets + data packets) to the slave device's endpoint, and the slave device responds according to the token packets (or token packets + data packets) received at the endpoint. Here, token packets include, but are not limited to:
[0097] SETUP token packet: For sending data packet commands from the master device to the slave device, for performing configuration, and for sending data packets to the slave device.
[0098] IN token packet: For the master device to obtain a data packet from the slave device. The slave device will feed back the data packet and an ACK status packet. If the slave device cannot feed back the corresponding data packet, it will feed back a NAK status packet.
[0099] OUT token packet: Used by the master device to send a data packet to a slave device and to guide the data packet to be sent. The slave device receives the data packet and feeds back a status packet such as ACK or NYET. If the slave device is unable to receive the data packet, it feeds back a NAK or STALL status packet. In some cases, before sending an OUT token packet, the master device may first send a PING token packet to test whether the slave device can receive the data packet. Taking USB as an example, the token packet also includes an SOF token packet and other status packets, the details of which will be omitted here.
[0100] 2. Principle of Enumeration (or Establishing a Handshake Connection). For a master device, enumeration (or establishing a handshake connection) is the process of reading the communication parameters of a slave device and further exchanging data. Taking a USB mass storage device as an example, the master device first reads basic parameters, such as the slave device's descriptor, including parameters for the hardware descriptor, configuration descriptor, port descriptor, and endpoint descriptor. Then, it reads driver information according to different parameters to obtain relevant information about the endpoints, enabling the hardware to connect and communicate. It also reads parameters of the mobile storage device, such as its capacity and whether it is read-only. It also reads file system information to display a drive letter to the computer's operating system. However, in the application of this application, it is not necessary to strictly follow the operating system's enumeration process; it is sufficient to read the data required for enumeration of the mobile storage device.
[0101] Therefore, an embodiment of the present application provides a device connection method. The method includes: setting configuration information of a network device based on a preset creation policy; pre-loading the scenario configuration information; and establishing a communication connection between the network device and a target device based on the loaded scenario configuration information to connect the network device to the target device. The configuration information includes scenario configuration information of a network device in at least one application scenario, and the scenario configuration information includes at least one of a first descriptor set and a function command set, as well as data source configuration information. The first descriptor set is for defining a device type of the network device. The function command set includes a descriptor command set.
[0102] Optionally, the configuration information is stored on the network device or on the server side or on the client side.
[0103] In an embodiment of the present application, a device connection method is provided. The method includes: setting target configuration information for a network device based on a preset generation policy; pre-loading the target configuration information when the network device communicates with a server; and simultaneously saving the target configuration information on the server to facilitate real-time monitoring of the network device. Based on the loaded at least one of a first descriptor set and a function command set, and data source configuration information, establishing a communication connection between the network device and a target device so that the network device can connect to the target device. The target configuration information includes scenario configuration information for the network device in at least one application scenario, and the scenario configuration information includes at least one of a first descriptor set and a function command set, and data source configuration information. The first descriptor set is for defining a device type of the network device. The function command set includes a descriptor command set, and the descriptor command set is for controlling data exchange between the network device and the target device. If the network device is lost, the server can cut off the communication connection with the network device to ensure security of the data source of the network device.
[0104] In an embodiment of the present application, a device connection method is provided. The method includes: pre-loading target configuration information when communicating with a server; and establishing a communication connection with the target device based on the target scenario configuration information so that the network device can connect to the target device. Multiple types of preset configuration information are stored on the server, and the target configuration information is one of the multiple types of preset configuration information. The target configuration information is scenario configuration information for the network device in at least one application scenario, and the scenario configuration information includes at least one of a first descriptor set and a descriptor command set. The first descriptor set defines a device type of the network device. The target scenario configuration information is one of the scenario configuration information.
[0105] Please refer to Fig. 1. Fig. 1 is a schematic diagram of a flow chart of a device connection method provided in an embodiment of the present application.
[0106] The method according to the embodiment of the present application is applicable to network devices, including devices such as a one-chip microcomputer or embedded device with a network function, terminal devices such as a smartphone or laptop, in-vehicle terminal devices, in-vehicle entertainment terminals, network USB key devices (e.g., bank USB keys, digital certificates, dongles, etc.), network proxy control devices (e.g., multi-port transponders), remote controllers (network read / write control devices, including but not limited to network controllers (e.g., routers, smart gateways, etc.)), communication devices (Communication Device Class, CDC, e.g., network cards, modems, ISDN (Integrated Services Digital Network) terminals), human interface devices (HID, e.g., keyboards or mice), mass storage devices (Mass Storage Device Class, MSC, e.g., USB flash drives, network USB flash drives, card readers, network card readers), printer devices (e.g., printers with USB interfaces), still imaging devices, video devices, audio / video devices, etc. This includes, but is not limited to, USB devices, smart card devices, Universal Serial Bus Hubs (USB hubs), and custom devices.
[0107] In one embodiment of the present application, the network device is connected to the server side via a wired network or a wireless network (such as an Ethernet interface, such as a twisted pair cable or an optical fiber, a Wi-Fi hotspot, an ultra-wideband UWB, Bluetooth, a 4G or 5G mobile cellular network, a LoRa long-distance radio wave, etc.), and the server side includes, but is not limited to, a personal computer, a mobile phone, a mobile terminal, a laptop, an embedded computer, a physical server, a virtual server, a server cluster, a cloud server, etc. During the networking between the network device and the server side, a virtual private network can be set up or a dedicated network line can be used to further enhance the network security.
[0108] In one embodiment of the present application, the server side is the control side. The control end includes the server side or the client side. The client side communicates with the network device. For example, the client side directly connects to the network device through P2P communication. The communication data between the client side and the network device is not forwarded by the server side, which can improve the transmission efficiency during data exchange.
[0109] In one embodiment of the present application, the control side is located locally on the network device and connected to the network device via short-range wireless communication such as Bluetooth. In another embodiment of the present application, the control side is located locally on the network device and connected to the network device via short-range wireless communication such as Bluetooth, and has functions such as creating a scenario, transmitting a scenario, and controlling data exchange. In another embodiment of the present application, the control side can also be located remotely on a terminal of the network device and perform remote communication via a TCP / IP network or the like. In another embodiment of the present application, the control side can be directly connected to the network device as a client terminal on the one hand, and has server-side functions such as creating a scenario, transmitting a scenario, and controlling data exchange on the other hand.
[0110] In an embodiment of the present application, the scenario may be created on the server side or by a network device.
[0111] Please refer to FIG. 2. FIG. 2 is a schematic diagram illustrating the structure of a network device in one embodiment of the present application. The network device includes, but is not limited to, a network unit 201, a storage unit 202, an interaction unit 203, a first interface 204, a second interface 205, and a main control module (not shown). Here, the network unit 201 is used for communication connection with the server side, the interaction unit 203 is used for interaction with a user, and the first interface 204 and the second interface 205 are for establishing communication connection with a target device. The first interface 204 can enable the network device to connect to the target device (master device) only as a slave device, and the second interface can enable the network device to connect to the target device (slave device) only as a master device. In addition, the first interface and the second interface can enable the network device to be both a master device and a slave device at the same time, and can be connected to different target devices, respectively. For example, by establishing a communication connection between a first interface and a computer device as a master device, and establishing a communication connection between a second interface and a storage device as a slave device, a communication connection is realized between the computer device, the network device (and the server side), and the storage device.
[0112] In one embodiment of the present application, the network unit 201 includes, but is not limited to, an Ethernet interface unit such as a twisted pair cable or optical fiber for realizing the above-mentioned wired connection, a Wi-Fi unit, a Bluetooth unit, an UWB unit, a 4G or 5G communication unit, a LoRa long-range wireless communication unit, etc. for realizing the above-mentioned wireless connection. The interaction unit 203 includes a display unit, a button, a switch, or a slide switch. The display unit may be a display screen or a touch screen. The main control module includes at least one of a microcontroller unit (MCU) chip and a host.
[0113] In one embodiment of the present application, the first interface 204 or the second interface 205 may be at least one of a USB interface, an HDMI (registered trademark) interface, a SCSI interface, an IEEE1394 interface, a SATA interface, an eMMC interface, an SDIO interface, an M.2 interface, a serial communication interface, etc.
[0114] Note that any device connected to a "network device" can be used as a "target device." Both a "network device" and a "target device" can be master devices or slave devices, and can also be peer-to-peer communication devices. A peer-to-peer communication device refers to a communication device that does not distinguish between master and slave devices. When a network device functions as a peer-to-peer communication device, it receives data sent from a target device at a first interface (the first interface is a receiving endpoint) and transmits data to the target device at a second interface (the second interface is a transmitting endpoint). Similarly, when a target device functions as a peer-to-peer communication device, it receives data sent from a network device at a receiving endpoint and transmits data to the network device at a transmitting endpoint.
[0115] In one embodiment of the present application, a user or a device manufacturer can pre-configure scenario configuration information for a network device on a server side. Before connecting to a target device, the network device reads a first descriptor set corresponding to the scenario configuration information from the server side, sets a physical communication interface, such as a first interface or a second interface, of the network device to master mode, slave mode, or peer-to-peer communication mode according to the first descriptor set, and connects to the target device, thereby establishing a connection relationship with the target device and exchanging data.
[0116] In one embodiment of the present application, when the network device is in slave mode, data required for the network device (e.g., when the network device functions as a USB flash drive) to communicate with a computer host can be stored on the server side. When the network device is used in master mode, data such as a communication protocol between the network device and a target device (e.g., when the target device is a USB flash drive) can be stored on the server side. When powered on, the network device obtains connection data such as the required first descriptor set from the server side to complete connection and data exchange with the target device.
[0117] Note that the terms "master device" and "master mode" described in the embodiments of the present application indicate a relative relationship in which device A is a master device relative to another device B, and do not necessarily mean that device A is only a "master device" or in "master mode." Furthermore, device A may also be a "slave device" or in "slave mode" relative to another device C. Similarly, the terms "slave device" and "slave mode" described in the embodiments of the present application indicate a relative relationship in which device A is a slave device relative to another device B, and a description thereof will be omitted here.
[0118] In one embodiment of the present application, the display unit displays multiple scenarios preset by the user, allowing the user to select between different device connection scenarios. Here, "*" indicates the currently selected scenario. The network device receives the scenario selected by the user and sends a configuration request to the server side or a client side communicating with the server side. The server side or the client side obtains scenario configuration information that matches the configuration request and sends the scenario configuration information to the network device via the server side communicating with the network device or the client side communicating with the server side. The network device configures the device functions of the network device according to the scenario configuration information.
[0119] For example, if you select a 64G USB flash drive, a 1024G USB flash drive, or a 16G USB flash drive, the network device will be formatted as a network USB flash drive, with the available storage capacity of the USB flash drive being 64G, 1024G, and 16G, respectively. The data stored will be different, and the corresponding formatted file system will be FAT32, ExFat, or CDFS, which will be used to store work materials, multimedia materials, or the operating system boot loader, respectively.
[0120] If you select the digital certificate scenario, the network device will be in the form of a USBkey, which can be used for identity authentication. For example, when you establish a communication connection with a computer host and the computer host needs to log in to a business system, you can use the USBkey to perform near-field or long-field identity authentication with the computer host.
[0121] If the proxy mode scenario is selected, the network device will be in network proxy control mode, and the device connected to the interface can be virtualized on the server side or the control side.
[0122] If you select the general read / write control mode, the network device will be a network read / write control device, and can perform read / write and other controls on the device connected to the second interface according to server-side commands or preset rules.
[0123] When the audio enhancement mode is selected, the network device takes the form of a network intermediate control device. The first interface is connected to a computer host, and the second interface is connected to an audio playback device. The audio data sent from the computer host can be sent to the server side in real time for calculation, or an enhancement script model can be downloaded from the server side to process the data on the network device, and the processed audio data can be sent to the audio playback device for audio playback.
[0124] Specifically, when a user selects one of the following scenarios via the display unit: 64G USB flash drive, 1024G USB flash drive, 16G USB flash drive, digital certificate, general read / write control mode, proxy mode, and audio enhancement mode, the network device receives the scenario selected by the user and sends a configuration request including that scenario to the server or a client communicating with the server. The server or client obtains the selected scenario configuration information and sends the scenario configuration information for the corresponding scenario to the network device via the server communicating with the network device or the client communicating with the server. The network device then configures the device functions of the network device to the functions or data sources (such as a data source in the form of a USB flash drive) of the selected scenario according to the scenario configuration information.
[0125] It should be understood that in other embodiments, the network device may have more or fewer components. For example, a network USB flash drive may have only a first interface and no second interface. If the first interface is a male interface and serves as a slave device interface, an interface converter converts the male interface to a female interface to function as a master device interface. For example, the network device may have multiple first or second interfaces for simultaneously connecting to multiple master or slave devices. The network device may not have a display unit, and the scenario switching operation may be completed on the server side. Alternatively, the network device may be controlled using another terminal via Wi-Fi, Bluetooth, NFC, a mobile cellular network (such as 4G or 5G), a satellite network, etc. The display unit may have more or fewer scenarios, but these will not be described here.
[0126] In one embodiment of the present application, the network device is connected to the control side via the network unit 201. The control side can be used as a server side or a combination of the server side and the client side. Exemplarily, FIGS. 3A to 3F show schematic diagrams of interactions between the network device and the control side. The control side may be a mobile terminal, a desktop computer, a server side (cloud server), etc. The control side pre-creates, edits, configures, or imports scenarios (or even selects scenarios) based on the server side (e.g., cloud server) or the control side itself. The control side may have all privileges or may have limited privileges. For example, User A (desktop display) has the privilege to create / configure / import scenarios and can create or edit scenarios. User B (mobile terminal) has the privilege to select scenarios and can make selections based on the scenarios created or edited by User A. The network device obtains scenario information (or even obtains selected scenario information) from the cloud server (e.g., via remote communication) or the control side (e.g., via short-range wireless communication) and enables the connection scenario of the corresponding network device according to the settings. A network device may have the authority to select a scenario, or may not have the authority to select a scenario, and the control side may pre-configure and select a scenario.
[0127] 3A and 3B show schematic diagrams of a network device as a portable device interacting with a control end. Here, the network device of FIG. 3A has a display screen and a second interface 205, and can obtain scenario information (or further obtain the scenario of a selected corresponding interface) via a cloud server (e.g., remote communication) or the control end (e.g., short-range wireless communication) and select a scenario to enable according to a list of scenarios on the display screen. Alternatively, the network device of FIG. 3B does not have a display screen but has a second interface 205, and can select a scenario to enable in numerical order by sliding a switch, thereby realizing switching between different scenarios (functions) of a single device in numerical order. FIG. 3C shows a schematic diagram of a network device interacting with a control end as a mobile terminal, which can receive or select scenario information from the server side, as well as create, edit, or import scenario information locally on the mobile terminal. 3D shows a schematic diagram of a network device as a smart wearable device (such as a smart watch) interacting with a control side, which can receive or select scenario information from a server side. The network device shown in FIGS. 3C and 3D includes a second interface 205. Furthermore, based on the second interface 205, the network device realizes conversion between a mobile phone line (e.g., a TYPE-C interface) and a USB male interface (male connector in slave mode) or a female interface (female connector in master mode) via a data cable or an interface conversion cable.
[0128] For example, FIG. 3E shows a schematic diagram of a network device as an in-vehicle terminal interacting with a control side. The network device includes a display screen and a second interface 205. By obtaining scenario information (or further obtaining scenarios for the selected corresponding interface) from a cloud server (e.g., via remote communication) or the control side (e.g., via short-range wireless communication), different scenarios (functions) can be expanded according to the scenario list on the display screen, effectively solving the problem of function expansion when the number of interfaces is limited. For example, the USB interface of the in-vehicle device can be used as a master device to connect to devices such as a USB flash drive or camera and store data locally, on the control side, or on a cloud server. Alternatively, it can be used as a slave device (e.g., a USB flash drive) to connect to a laptop computer or the like and store interaction data within the in-vehicle device or on a network.
[0129] 3F exemplarily shows a schematic diagram of a network device as a multi-interface device interacting with a control side. Here, the network device has multiple second interfaces 205. Scenarios are pre-created, configured, or imported according to different interfaces, or a scenario is further selected. The network device obtains scenario information from a cloud server (e.g., remote communication) or the control side (e.g., near-field communication), or further obtains scenes for the selected corresponding interface, and enables the scenario for the corresponding interface of the corresponding network device according to the settings. Furthermore, for each interface, the scenario to be enabled can also be selected by sliding a switch in the order of the scenario number. Different scenarios (functions) for multiple interfaces can be switched on a single device.
[0130] It should be noted that among the above 3A to 3F, the network unit 201 in FIG. 2 may also be added, but the explanation thereof will be omitted here.
[0131] Please refer to Fig. 1. As shown in Fig. 1, the device connection method of this embodiment includes the following steps:
[0132] Step S101: Set target configuration information of a network device based on a preset generation policy. The target configuration information includes scenario configuration information of the network device in at least one scenario, and the scenario configuration information includes at least one of a first descriptor set and a descriptor command set, and data source configuration information. The first descriptor set is for defining a device type of the network device.
[0133] In this step, the scenario configuration information is configuration information that defines the device type (or device function) of the network device, and the information includes, but is not limited to, a descriptor set, a descriptor command set, data source configuration information, a device role, etc. The descriptor set includes, but is not limited to, a device descriptor, a configuration descriptor, an interface descriptor, an endpoint descriptor, a string descriptor, a BOS descriptor, a custom descriptor, etc. The descriptor command set is a command set for realizing the master device function of the network device, and the descriptor command set includes multiple function command sets, including, but not limited to, an acquisition command set, a verification command set, a data source command set, an interaction command set, a custom command set, etc. The acquisition command set is used to acquire a descriptor set, and the verification command set is used to verify various descriptors in a descriptor set. The data source command set is used to acquire configuration parameters such as data source configuration information, and the interaction command set is used to realize data interactions between the network device and other devices, including, but not limited to, a read command, a write command, a create command, a modify command, a delete command, a set command, etc. The custom command set is used to define the required network device functions. Device roles include master role, slave role, and / or peer-to-peer role. When a network device functions as a master device, the device role is master. When a network device functions as a slave device, the device role is slave. When a network device functions as a peer-to-peer communication device, the device role is peer-to-peer.
[0134] Please refer to Figure 4. Figure 4 is an architecture diagram for setting target configuration information for a network device in one embodiment of the present application.
[0135] In one embodiment of the present application, scenario configuration information is set via a server side that communicates with a network device and a client side that communicates with the server side, and the preset creation policy includes at least one of a custom creation policy, a template creation policy, or an external import creation policy.
[0136] In one embodiment of the present application, if the preset creation policy is a custom creation policy, the client side creates scenario configuration information and sends the scenario configuration information to the server side. The network device determines a scenario and sends a request to the server side to acquire the scenario. The server side sends the scenario configuration information corresponding to the scenario to the network device in response to the scenario acquisition request sent from the network device.
[0137] Optionally, if the preset creation policy is a custom creation policy, a first descriptor set and data source configuration information of the network device are configured based on the device role of the network device selected by the user. Exemplarily, if the device role of the network device is selected as a master role (i.e., a master device that communicates with the target device), a functional command set used for master device enumeration, such as an acquisition command set, a verification command set, a configuration command set, an interaction command set, a data source command set, and a custom command set, is configured, and data source configuration information is configured to bind a data source during data exchange between the network device and the target device. Data sources include, but are not limited to, image storage files, specific folders, databases, and data streams. If the device role of the network device is selected as a slave role (i.e., a slave device that communicates with the target device), a descriptor parameter, a device type parameter, and data source configuration information for responding to the master device are configured. If the device role of the network device is selected as a peer-to-peer role, configuration information for data exchange of the device is configured. Configuring configuration information for data exchange of the device includes configuring a data sender or a data receiver of the network device. For example, interface 1 of the network device is configured as the data sender and interface 2 of the network device is configured as the receiver.
[0138] In one embodiment of the present application, if the preset generation policy is a template creation policy, at least one of the first descriptor set and the descriptor command set of the network device, and the data source configuration information are set based on the preset scenario template. Illustratively, if the network device functions as a slave device (e.g., a mass storage device, an AV device, etc.) in the application scenario, the manufacturer, identification information, and string information in the configuration descriptor, and the data source configuration information are set based on the preset scenario template corresponding to the application scenario.
[0139] In one embodiment of the present application, if the preset generation policy is an external import creation policy, at least one of a first descriptor set and a descriptor command set of the network device and data source configuration information is set based on the imported scenario template, or the data source configuration information is set based on the imported scenario information.
[0140] In this embodiment, configuration information corresponding to different application scenarios or device roles (device modes) is created, thereby enabling the network device to be applied to multiple application scenarios, thereby improving the applicability of the network device.
[0141] In one embodiment of the present application, a user can select a scenario on the display unit of the network device, including but not limited to a USB flash drive scenario, a USB key scenario, a network proxy control scenario, a network intermediate control scenario, etc.
[0142] In one embodiment of the present application, the scenario type may be a single device, such as a mass storage device such as a USB flash drive. Alternatively, devices in multiple scenarios, such as a USB flash drive and a camera, may be connected to the target device simultaneously. For example, a combination of multiple scenarios (USB flash drive scenario + camera scenario) may be connected.
[0143] In one embodiment of the present application, a device corresponding to one scenario may be a single device (e.g., one USB flash drive connected to a target device), a composite device (e.g., a USB flash drive, a camera, etc. connected to a target device at the same time), or a multi-function device (e.g., selecting either a USB flash drive or a camera to connect to a target device).
[0144] In one embodiment of the present application, when creating scenario configuration information, at least one of a first descriptor set and a descriptor command set of the network device and data source configuration information can be set based on the device role of the network device. Exemplarily, if the device role of the network device is a master device (e.g., a master device communicating with a target device), a descriptor command set for the master device to enumerate slave devices and / or data source configuration information for data exchange between the master device and the slave device are set. The data source configuration information is for binding a data source during data exchange between the network device and the target device. Data sources include, but are not limited to, storage media, address ranges of storage space (e.g., sector address ranges), image storage files, specific folders, databases, data streams, etc.
[0145] In one embodiment of the present application, the scenario configuration information further includes scenario basic information and a scenario switching policy. The scenario basic information includes one or more of a scenario identifier and a scenario name. The scenario identifier is for representing a unique ID of the scenario. For example, the unique ID may be a unique ID value of the scenario. The scenario name is for representing the name of the scenario. For example, the scenario name may be "USB Flash Drive (Work)", "USB Flash Drive (Life)", etc. The scenario switching policy is for representing a policy for the network device to select or switch between scenarios. The scenario switching policy includes at least a manual operation selection policy, an automatic operation selection policy, a permit or prohibit selection policy, a permit or prohibit connection policy, and an interface selection policy.
[0146] In one embodiment of the present application, the manual operation selection policy represents that a user selects a scenario for a network device in an interactive interface or physical interaction widget of a client-side, server-side, network device, control-side, or target device, for example, in a browser interface of a client-side app or web page.
[0147] Optionally, after the network device establishes a connection with the target device, the network device can send scenario information to the target device through a data exchange, and the target device selects a scenario for the network device.
[0148] Optionally, after establishing a connection between the network device and the target device, the network device can receive scenario information sent from the target device through data exchange. The target device, the network device, the server side, or the client side selects a scenario for the network device.
[0149] In another embodiment of the present application, the manual operation selection policy represents a scenario selection by a user in the interactive space of the network device. For example, the user selects a scenario using a button, switch, or slide switch on the network device. Optionally, the scenario can also be selected on a display unit of the network device. Exemplarily, the network device is provided with a display unit. The display unit displays options for the user to select an application scenario and determines the application scenario based on the user's selection. In this way, when the network device communicates with the server side, scenario configuration information based on the user's selection is preloaded. Similarly, the selection process on the network device may be a real-time process or a non-real-time process. Optionally, the preset application scenario can further be selected by a physical switch on the network device. Exemplarily, the network device is provided with a physical switch, and the scenario corresponding to the current switch pointer is selected by switching the physical switch. In this way, scenario configuration information based on the user's selection is preloaded during communication connection between the network device and the server side.
[0150] An automatic operation selection policy represents a preset scenario selection rule. If the client, server, network device, or target device meets the preset scenario selection rule, the scenario is automatically selected. The preset scenario selection rule selects a scenario based on a timer. For example, if the local timer or network timer on the client, server, or network device matches the preset clock, the corresponding scenario is selected.
[0151] In one embodiment of the present application, a scenario is selected according to data from a client side, a server side, or a peripheral module of a network device. For example, if the location information of a location module (e.g., a GPS positioning module, a Beidou positioning module) of the network device corresponds to a first preset location, or if the signal of a communication module (e.g., Wi-Fi, Bluetooth, etc.) of the network device satisfies a first preset condition (e.g., whether the signal carries a preset MAC address), or if the data of a sensor module of the network device corresponds to a first preset value (e.g., whether the temperature and humidity sensor corresponds to a corresponding first preset value), or if a near-field communication module (e.g., an NFC communication module) of the network device receives a specific signal, a corresponding scenario is selected.
[0152] In one embodiment of the present application, the network device automatically selects a corresponding application scenario based on preset interaction data (e.g., the content of a descriptor, a descriptor command, or the content of data communication (or data exchange)) of the target device.
[0153] The allow / prohibit selection policy allows or prohibits the selection of a network device's scenario based on the scenario's basic information, connection configuration, or data exchange configuration. It prohibits or allows the selection of a specific hardware type scenario according to preset rules for connection configuration information (such as device descriptors, configuration descriptors, interface descriptors, endpoint descriptors, string descriptors, and BOS descriptors) and data exchange configuration information. For example, it prohibits the selection of large-capacity device types (such as USB flash drives). It prohibits or allows the selection of a specific scenario according to preset rules for peripheral module data. For example, it allows or prohibits the selection of a corresponding scenario if the location information from the network device's location module (such as GPS or Beidou Positioning) corresponds to a second preset location, if the signal from a communication module (such as Wi-Fi or Bluetooth) meets a second preset condition (such as the presence or absence of a preset MAC address), if the data from the network device's sensor module corresponds to a second preset value (for example, if the temperature and humidity sensor corresponds to the corresponding second preset value), or if the network device's NFC communication module receives a specific signal.
[0154] In one embodiment of the present application, the network device allows or prohibits a corresponding application scenario based on preset interaction data of the target device (e.g., the content of a descriptor, a descriptor command, or the content of a data communication (or data exchange) sent from the target).
[0155] The allow / prohibit connection policy allows / prohibits a connection to a target device from a network device interface based on preset rules and data sent from the target device. If at least one of the descriptors (device vendor ID, device ID, device type (used type, subtype, interface instruction set, endpoint transmission mode), descriptor command, or data communication content sent from the target device meets the preset requirements, the connection to the target device is permitted / prohibited. For example, if the allow / prohibit connection policy prohibits a connection to a mass storage device, when the network device is in master mode and sends a descriptor command, if the target device's response data meets the characteristics of a mass storage device type (e.g., a USB flash drive), the connection to the network device is terminated to protect the security of the server or control side. For example, when the network device functions as a master, the network proxy control device reads the descriptor based on a preset script to determine the connected device's vendor ID, device ID, device type (used type, subtype, interface instruction set, endpoint transmission mode), etc. To protect server-side or control-side security, remote mapping is allowed only if the connected target device meets the manufacturer ID, device ID, or device type criteria.
[0156] The interface selection policy indicates that if a network device has only one interface, the selected scenario is enabled by default on that unique interface (e.g., the unique interface of a USB flash drive device). If a network device has multiple interfaces (e.g., multiple interfaces of a USB hub device), at least one interface to be enabled is further selected from the multiple interfaces based on the selected scenario. For example, if a network device has two interfaces, you can select Scenario A to enable Interface 1, Scenario B to enable Interface 2, or Scenario A to enable both Interface 1 and Interface 2 simultaneously. It should be understood that in other embodiments, the network device may have more or fewer components. For example, suppose there is only a first interface and no second interface. If the first interface is a male interface and serves as a slave device (e.g., in network USB flash drive mode), an interface converter (OTG adapter) converts the male interface to a female interface to function as the master device interface when it needs to be used as a master device (e.g., in read-write USB flash drive mode). For example, the network device may have multiple first or second interfaces for simultaneously connecting to multiple master or slave devices. The network device may not have a display unit, and the scenario switching operation may be completed on the server side, or the network device may be controlled using another terminal via Wi-Fi, Bluetooth, NFC, etc. The display unit may have more or fewer scenarios, but this will not be described here.
[0157] In one embodiment of the present application, when creating scenario configuration information, if the device role of the network device is a master role (i.e., a master device that communicates with the target device), first device connection configuration information is set, which includes a first mode, a first interface type, a standard command set, a special command set, a setting command set, a first connection status determination rule, and a first status response rule.
[0158] In the first mode, the network device is set to master mode. The first interface type is used to set the physical interface type of the network device, such as a USB interface, an HDMI interface, a SCSI interface, an IEEE 1394 interface, a SATA interface, an eMMC interface, an SDIO interface, an M.2 interface, or a serial communication interface. The first interface type can also be bound to communication protocol commands corresponding to the interface type, such as USB token packets (SETUP, IN, OUT, PING, etc.), status packets (ACK, NAK, NYET, etc.), transmission methods (transmission control, bulk transmission, transmission interruption, transmission synchronization, etc.), and standard communication protocols. The first standard command set includes a descriptor command set, which is used to send commands (such as get device descriptor, get configuration descriptor, get interface descriptor, get endpoint descriptor, get string descriptor, and get BOS descriptor) to a target device (slave device) to request corresponding descriptor data from the slave device and connect to the target device. The special command set includes a get device type data command set, which is used to obtain data for different device types. Note that different network devices support different special command sets. For example, the special command set for USB-related USB flash drives (USB Mass Storage Class) includes a descriptor for specifying MAXLUN to obtain the maximum number of logical units, the special command set for keyboard and mouse devices (Human Interface Device) includes a descriptor for obtaining HID, and the special command set for cameras (USB Video Class) includes a descriptor for specifying GET_RES to obtain resolution properties. The setting command set is for sending setting commands. Setting commands include at least one of commands such as setting an address, enabling a configuration (setting a configuration), enabling an endpoint, and starting a peripheral module.The first connection status determination rule is for determining whether the network device has successfully or unsuccessfully connected based on data fed back from the target device or a response status (response or no response). The data fed back from the target device includes data fed back from the target device during the connection phase or data exchange phase of the network device. The first status response rule is for responding according to the connection status of the network device. For example, if the network device determines that the connection has been successful, the network device sends a connection success message to the server side, and the server side notifies the client side that it can proceed to the next step. If the network device determines that the connection has been unsuccessful, the network device sends a connection failure message to the server side, obtains a new command set, and resends the command to the target device. Note that the command set may include at least one data exchange command or multiple data exchange commands.
[0159] In one embodiment of the present application, multiple preset scenarios can be pre-configured so that a scenario is automatically selected if a connection fails. For example, if a connection to a selected scenario A (e.g., a connection scenario to a USB flash drive) fails, the connection will be retried by switching to scenario B (e.g., a connection scenario to a camera device) or scenario C (a connection scenario to a keyboard device) until all preset scenarios have been tried or the connection is successful.
[0160] In one embodiment of the present application, based on the relevant connection data sent by the network device when the connection failed (e.g., data fed back from the target device to the network device (such as all or part of the descriptor, or related handshake data)), the server side further obtains, compares, analyzes, and judges the fed back data, confirms the device type of the target device, and sends a new set of descriptor obtainment commands to the network device or selects a new scenario, so as to cause the network device to reconnect to the target device.
[0161] In another embodiment of the present application, when creating scenario configuration information, if the device role of the network device is a slave role (i.e., a slave device that communicates with a target device), second device connection configuration information is set.
[0162] In one embodiment of the present application, the second device connection configuration information includes a second mode, a second interface type, a standard data set, a special data set, a setting command execution, a second connection status determination rule, and a second status response rule.
[0163] In the second mode, the network device is set to slave mode. The second interface type is for setting the type of physical communication interface of the network device, such as a USB interface, an HDMI interface, a SCSI interface, an IEEE 1394 interface, a SATA interface, an eMMC interface, an SDIO interface, an M.2 interface, or a serial communication interface. The first interface type can also be bound to a communication protocol command corresponding to the interface type. For example, it can respond to USB token packets (e.g., SETUP, IN, OUT, PING, etc.), status packets (e.g., ACK, NAK, NYET), transmission methods (e.g., transmission control, bulk transmission, transmission interruption, transmission synchronization, etc.), standard communication protocols, etc. The standard data set includes a first descriptor data set (e.g., a device descriptor, a configuration descriptor, an interface descriptor, an endpoint descriptor, a string descriptor, a BOS descriptor, etc.), which is used to feedback corresponding descriptor data according to the type and parameters of the command sent when the target device (the target device is the master device) sends a command to establish a communication connection with the network device. The special datasets include special datasets for device types (e.g., the maximum number of logical units for MAXLUN, the resolution property for GET_RES, etc.), which are used to feedback corresponding data according to the type and parameters of the command sent and the scenario configuration or device type of the network device when the target device sends a command. The execution of the setting command is used to perform operations such as setting the network device, the physical communication interface of the network device, or a peripheral module when the target device sends a setting command, according to the type and parameters of the setting command sent (e.g., setting an address, enabling a configuration (setting a configuration), enabling an endpoint, or starting a peripheral module).The second connection status determination rule is for determining whether the network device has successfully connected to the network or not, based on data sent from the target device (including data sent from the target device in the device connection phase or data exchange phase). For example, different commands are used to request a USB flash drive device and to request a camera device. The second status response rule is for responding based on the connection status (handshake or enumeration) of the network device. For example, if it is determined that the network device has successfully connected (or the handshake has succeeded, or the enumeration has succeeded), a connection success message is sent to the server, and the server notifies the client that it can proceed to the next step. If it is determined that the network device has failed to connect, a connection failure message is sent to the server, a new data set is obtained, and a signal to establish a connection (such as an enumeration signal) is resent to the target device. Note that the above data set may be feedback data for at least one data exchange command, or multiple feedback data for multiple data exchange commands.
[0164] In one embodiment of the present application, multiple preset scenarios can be pre-configured so that a scenario is automatically selected if a connection fails. For example, if a connection to the selected scenario A (a USB flash drive scenario) fails, the device will switch to scenario B (a camera device scenario) or scenario C (a keyboard device scenario) and retry the connection until all preset scenarios have been tried or the connection is successful.
[0165] In one embodiment of the present application, the server side further obtains, compares, analyzes, and determines the sent command data based on the related connection data sent by the network device when the connection fails (e.g., data sent from the target device to the network device (such as command data such as standard commands, special commands, setting commands, or other related handshake data)), and confirms the type of device the target device needs to connect to, thereby sending a new descriptor set to the network device or selecting a new scenario, so that the network device retries connecting to the target device.
[0166] Note that the interface of the network device in the embodiment of the present application can be switched between master mode and slave mode after shipping from the factory (for example, an interface with an OTG function), or can be set to master mode as a fixed value, or set to slave mode as a fixed value (for example, an interface without an OTG function, or an interface designed to be determined as a master device or a slave device by a hardware circuit). When the interface is determined to be in master mode or slave mode, the scenario corresponding to the interface can only be a different scenario in master mode or slave mode, and does not need to be set in the scenario configuration. At the same time, depending on the type of interface, a specific communication protocol can be set as a fixed value without needing to be set in the scenario configuration. For example, if the interface is a USB interface, the corresponding USB protocol is set as a fixed value.
[0167] In another embodiment of the present application, when creating the scenario configuration information, if the device role of the network device is a peer-to-peer communication mode, third device connection configuration information is set, which includes a third mode, a third interface type, an interaction data set, a configuration command set, a third status determination rule, and a third status response rule.
[0168] The third mode is for setting the network device to a peer-to-peer communication mode. The third interface type is for setting the type of physical communication interface of the network device. The interaction data set is for setting the data to be sent to the target device when the device is connected. The configuration command execution is for performing operations such as configuring the network device, its interface, or a peripheral module depending on the type and parameters of the configuration command (e.g., setting an address or starting a peripheral module) sent when the target device sends the configuration command. The third status determination rule is for determining whether the connection to the network device was successful or failed based on the data sent from the target device (including data sent from the target device during the data exchange phase). The third status response rule is for responding based on the connection status. For example, if the network device determines that the connection is successful, a connection success message is sent to the server, and the server notifies the client that it can proceed to the next step. If the network device determines that the connection is unsuccessful, a connection failure message is sent to the server, and at the same time, a new data transmission command or response data set is obtained, and data is resent to the target device or waits until data is received.
[0169] In one embodiment of the present application, the scenario configuration information further includes data exchange configuration information: when the device role of the network device is a master device (e.g., a master device communicating with a target device), the data exchange configuration information includes a data source command set, a data exchange command set, an automatic execution script of the command, a binding policy of a first interactive system or data source, and a first allow / prohibit exchange policy.
[0170] The data source command set is used to send commands to a target device to set data source information for the target device, such as its capacity information (e.g., maximum number of logical units, total number of formattable logical blocks, last logical block address, block capacity, total capacity, available space capacity, etc.) and read / write status (e.g., read-only status, write-only status, readable / writable status). The data exchange command set is used to send commands to a target device, causing the target device to execute preset commands or return data. For example, a write command and a data packet may be sent to the target device to write the data in the data packet to a specific location on the storage medium. Alternatively, a read command may be sent to the target device to return data to a specific location on the storage medium or to read specific data from a peripheral module or a sensor of the target device. Write and read commands include at least the storage space address (e.g., sector address) of the storage medium to be operated on and the number of storage spaces (e.g., number of sectors) to be operated on.
[0171] In one embodiment of the present application, the data exchange command set may be low-level commands. The data exchange commands include USB communication protocol commands. The USB communication protocol commands include sending an IN token packet to a specific endpoint (e.g., endpoint 1) of the target device (e.g., USB device) to obtain data fed back from the target device (i.e., an IN data command to endpoint 1) and / or sending an OUT token packet and a data packet to a specific endpoint (e.g., endpoint 2) of the target device (USB device) to send data to the target device (and an OUT data command to endpoint 2).
[0172] The data exchange commands (e.g., low-level commands) include Small Computer System Interface (SCSI) transparent command set commands that send a read command to a target device (e.g., a USB storage device) to instruct it to retrieve data at a specific sector address in the target device's storage space, and send a write command and data packet to the target device (e.g., a USB storage device) to instruct it to write data to a specific sector address in the target device's storage space.
[0173] In another embodiment of the present application, the data exchange command set includes an automatic command execution script. The automatic command execution script represents that interaction commands (including low-level commands, high-level commands, etc.) are automatically sent to the target device according to preset script rules to achieve automatic operation. The automatic command execution script includes automatically executing a file directory read script. For example, when a target device (such as a storage device) is successfully connected, an automatic operation rule is triggered, and the file directory read script is automatically executed to read file information, and the data of the read file information is converted and displayed in an interactive system (e.g., a client-side interface). Specifically, the automatically executed file directory read script automatically reads all file directory data according to file system protocol rules. The reading rule includes first reading the boot sector data (usually sector address 0x00) to analyze the boot sector address of the file system, then reading the boot sector data of the file system to analyze the sector address of the root folder (or the first directory) and related parameters such as cluster (block) size, after which reading the sector address data of the root folder to analyze file information, and further analyzing subdirectories, subfiles, etc. based on the file information.
[0174] Furthermore, the automatic command execution script can also include high-level commands. High-level commands are operation script commands based on multiple low-level commands (e.g., read and write commands for USB communication protocols or SCSI transparent command set commands) and are executed according to conditions such as user actions and timing. For example, file operation commands developed for different file system protocols (e.g., file systems such as exfat and fat32) automatically send multiple interaction commands (including multiple low-level commands and references between high-level commands) to the target device according to the parameters of the high-level command (e.g., file path and file name). Based on context analysis of the read and write data of the interaction commands, specific storage space data (e.g., sector address data) is read or written to the file system of the target device to realize specific file operation functions such as a "file creation command," "file deletion command," "file attribute change command," "file content read command," and "file content change command." High-level commands can be triggered by an operator on the client side, server side, or network device, and sent to network devices. Commands can also be triggered by peripheral modules such as timing devices and GPS to send commands to network devices. High-level commands can also be cross-referenced. For example, to "Create / Generate Content High-Level Commands", first execute a file creation command (the file name is the parameter of the file creation command), then execute a file content change command (the file name and file content are the parameters of the file content change command), to create a text file with a file name such as test.txt and file data of the test string.
[0175] In one embodiment of the present application, the high-level commands may be file operation commands developed according to different file system protocols, such as a file creation command, a file deletion command, a file attribute change command, a file content read command, a file content change command, etc.
[0176] In one embodiment of the present application, the automatic command execution script includes a data monitoring script. The data monitoring script automatically responds to the server side and the client side when the conditions of the preset rules are met. For example, a network device sends an IN token packet to an IN endpoint of a target device (e.g., a USB video source device, a USB camera) to detect whether the target device sends a data packet (a non-NAK status packet) to the network device through the IN endpoint. When the IN endpoint sends a data packet, the data packet received from the IN endpoint is forwarded to the client side or the server side.
[0177] In one embodiment of the present application, automatically executing a command script includes automatically executing a preset script (e.g., a high-level command or a low-level command) depending on data from a peripheral module (e.g., a positioning module GPS, a sensor), a timing device, or a network module. For example, if the location detected by a GPS positioning device is not at a preset location, or if the local IP address of a network device is not at a specific address, a command to delete file data or a data monitoring script is executed.
[0178] The binding policy of the first interactive system or data source is used for the network device to automatically convert commands sent by the client side and the server side into a preset data exchange command set (at least one command), and send the converted data exchange command set to the target device for execution. For example, the sent command can be for the client side to read or write a file or read or write a specific sector address.
[0179] In other embodiments of the present application, the binding policy of the first interactive system or data source is also used to automatically save data after performing an operation from the network device to the target device to any location, such as a storage medium (e.g., a memory chip, a hard disk, etc.), a storage space (e.g., a sector range), a specific database or folder or file (e.g., an image file), a storage space or a structured data string, within the network device, the client side, or the server side.
[0180] The first allow / prohibit exchange policy indicates whether the client or server is allowed or prohibited from sending a specific command to the target device via the network device, for example, prohibiting sending a data write command to the target device.
[0181] In one embodiment of the present application, the first allow / prohibit exchange policy may include a low-level command. The first allow / prohibit exchange policy may be a USB communication protocol command. For example, the first allow / prohibit exchange policy may be a command to allow / prohibit sending IN / OUT token packets to a specific endpoint. The first allow / prohibit exchange policy may also be a SCSI transparent instruction set command. For example, the first allow / prohibit exchange policy may be a command to allow / prohibit only sending reads / writes to a specific sector location.
[0182] In one embodiment of the present application, the first allow / prohibit exchange policy may include a high-level command, for example, the first allow / prohibit exchange policy may be a file operation command, such as only allowing / prohibiting the sending of a file deletion command.
[0183] The first allow / prohibit exchange policy performs control based on a data packet corresponding to a command, and indicates whether the target device is allowed or prohibited from transmitting specific data (e.g., a data packet having specific characteristics) to the network device. For example, if a data packet included in a write command meets specific characteristics, the write command is allowed or prohibited from being sent to the target device. Alternatively, if a data packet fed back from the target device in a read command meets specific characteristics, the read command is allowed or prohibited from being sent to the server side and the client side. The first allow / prohibit exchange policy may also indicate a policy that allows or prohibits data exchange depending on data from a peripheral module (e.g., a positioning module, a sensor, a network module, etc.).
[0184] In one embodiment of the present application, when the device role of the network device is a slave device (e.g., a slave device that communicates with a target device), the data exchange configuration information includes a command response operation, an automatic execution script for the command response operation, a binding policy for a second interactive system or data source, and a second allow / prohibit exchange policy.
[0185] The command response operation is for responding to a data exchange command sent from the target device, such as performing a preset operation or providing data feedback.
[0186] In one embodiment of the present application, the data exchange command set sent from the target device to the network device may be low-level commands such as USB communication protocol commands. The data exchange command set includes, when the target device (e.g., the master device of the USB device) sends an IN token packet to a specific endpoint (e.g., endpoint 1) of the network device, sending a response data packet back to endpoint 1, and when a specific endpoint (e.g., endpoint 2) of the target device sends an OUT token packet and data packet, receiving a data packet sent from the target device to endpoint 2's OUT.
[0187] In one embodiment of the present application, the data exchange command set sent from the target device to the network device may be a SCSI transparent command set command, which includes: feeding back data at a specific sector address in the data storage space to the target device when the target device (as a master device) sends a read command to read data at a specific sector address; and writing a data packet to a specific sector address in the data storage space when the target device (as a master device) sends a write command to the target device (the write command includes a specific sector address and a data packet).
[0188] In one embodiment of the present application, the data exchange command set sent from the target device to the network device may be high-level commands, such as file operation commands developed according to different file system protocols. The data exchange command set includes at least one of a file creation command, a file deletion command, a file attribute change command, a file content read command, and a file content change command. The data exchange command set may be operations based on multiple low-level commands (such as read / write commands of the USB communication protocol or a SCSI transparent command set), or may be an automated script for performing operations according to specific rules.
[0189] In one embodiment of the present application, objects operated by commands in the data exchange command set of the network device include storage-type objects and peripheral module-type objects. The storage-type objects include at least one of a database, folder, file (e.g., image file), or storage space (e.g., sector range) on the local memory chip, client side, or server side of the network device. The peripheral module-type objects include at least one of a positioning module, a sensor module, an audio / video source module, a human-computer interaction module, and an encryption module.
[0190] Automatic execution of command response operation scripts refers to the network device automatically feeding back data to the target device, performing data-related read and write operations, and controlling peripheral modules according to the rules of the preset script to achieve automatic operations. For example, if there is a need for backup and you have preset the data at a specific sector address to be protected, when the target device sends data to be written to the specific sector address, the data at the sector address will first be automatically read and written to the backup storage space, and then the data write operation will be performed on the target device.
[0191] In one embodiment of the present application, a network device automatically executes a command response operation script, including a data monitoring script. The data monitoring script includes low-level commands. If the conditions of a preset rule are met, the data monitoring script automatically responds to the server side, the client side, the control side, or an electronic device connected to the network device. For example, a target device sends an OUT token packet and a data packet to an OUT endpoint of the network device. If the network device detects that the endpoint number or the content of the data packet meets the conditions of the preset rule, it forwards the data packet to the client side or the server side or sends a reminder.
[0192] In one embodiment of the present application, automatically executing a command response operation script includes automatically executing a preset script (e.g., a high-level command or a low-level command) according to data from a peripheral module (e.g., a positioning module GPS, a sensor, etc.), a timing device, or a network module. For example, if the location detected by a GPS positioning device is not at a preset location, or if the local IP address of a network device is not at a specific address, a command to delete file data or a data monitoring script may be executed.
[0193] The second interactive system or data source is bound to the target device to automatically convert commands sent from the target device into preset command-response operations and execute them. For example, the command sent from the target device may be an operation command to read / write a file or read / write a specific sector address. The network device executes the corresponding operation according to the command and returns a data packet or a status packet. At the same time, the network device also responds with capacity information (such as the maximum number of logical units, the total number of formattable logical blocks, the last logical block address, block capacity, total capacity, and available space capacity) or read / write status (such as read-only status, write-only status, or read / write status) according to the command.
[0194] In other embodiments of the present application, the binding policy of the second interactive system or data source is also used to automatically associate the data source of a command-response operation with any location, such as a storage medium (e.g., memory chip, hard disk, etc.), a storage space (e.g., sector range), a specific database or folder or file (e.g., image file), a storage space or structured data string, on a network device, client side, or server side.
[0195] The second allow / deny exchange policy controls based on commands, allowing / denying a client, server, or network device from operating (or responding) to a specific command sent by a target device, for example, prohibiting an operation or response to a write data command sent by a target device.
[0196] In one embodiment of the present application, the second allow / prohibit data exchange policy includes a low-level command. The second allow / prohibit data exchange policy may be a USB communication protocol command. For example, the second allow / prohibit data exchange policy may allow / prohibit an operation (or response) in response to a token packet command sent by the target device to the endpoint IN / OUT of the network device. The second allow / prohibit data exchange policy may also be a SCSI transparent instruction set command. For example, the second allow / prohibit data exchange policy may allow / prohibit an operation (or response) in response to a read / write command sent by the target device to the network device to a specific sector location.
[0197] In another embodiment of the present application, the second allow / prohibit exchange policy may include a high-level command. For example, the second allow / prohibit exchange policy may be a file operation command. For example, the second allow / prohibit exchange policy may allow / prohibit an operation (or response) of a file delete command sent from the target device to the network device. The second allow / prohibit exchange policy may also perform control based on a data packet corresponding to the command and indicate whether to allow / prohibit an operation (or response) for specific data sent from the target device to the network device.
[0198] In another embodiment of the present application, when creating scenario configuration information, if the device role of the network device is a peer-to-peer communication device, data exchange configuration information for the device is configured. Configuring the data exchange configuration information for the device includes configuring the data sender or data receiver of the network device. For example, interface 1 of the network device is configured as the data sender, and data is sent to the receiver of the target device via interface 1. Interface 2 of the network device is configured as the receiver, and data sent from the target device is received via interface 2. In one embodiment of the present application, for details about configuring the data sender of the network device, see the data exchange configuration information for configuring the master device described above. For details about configuring the data receiver of the network device, see the data exchange configuration information for configuring the slave device described above.
[0199] Step S102: Read target configuration information in advance.
[0200] Optionally, create scenario configuration information locally on the network device and pre-load the scenario configuration information when the network device starts up (or before connecting).
[0201] Optionally, scenario configuration information is created on the server side, and the network device pre-loads the scenario configuration information obtained from the server side.
[0202] Optionally, scenario configuration information is set in advance on the server side, and the network device pre-loads the scenario configuration information obtained from the server side.
[0203] Optionally, step S102 further includes pre-loading target configuration information when communicating with a server side, the server side storing a plurality of preset configuration information, the target configuration information being one of the plurality of preset configuration information, and the target configuration information including scenario configuration information of a network device in at least one application scenario, the scenario configuration information including at least one of a first descriptor set and a descriptor command set, the first descriptor set for defining a device type of the network device.
[0204] Optionally, in step S102, the scenario configuration information stored on the server side is at least one of a first descriptor set and a descriptor command set of the network device, and data source configuration information, which are generated according to a preset generation policy before pre-loading target configuration information.
[0205] Optionally, before step S102, a first descriptor set and data source configuration information of the network device are set based on a preset creation policy, and the scenario configuration information is generated, wherein the preset creation policy includes at least one of a custom creation policy, a template creation policy, or an externally imported creation policy.
[0206] In one embodiment of the present application, when the network device is started up (or before it is connected), the network device establishes a communication connection with the server side and pre-loads the scenario configuration information stored on the server side. It should be understood that in other embodiments, the pre-loading can be performed at other times after the communication connection between the network device and the server side is established, and the communication establishment can be performed at other times after the network device is started up.
[0207] In one embodiment of the present application, the scenario configuration information is associated with the network device identification information. For example, the network device identification information may be S123456. A user or manufacturer associates scenario configuration information for one scenario or multiple scenarios with the network device identification information S123456 on the server side in advance. The network device sends a connection request to the server side, and the connection request includes the network device identification information. In response to the connection request sent from the network device, the server side transmits scenario configuration information corresponding to the network device identification information to the network device. The network device identification information may be set as a fixed value in data in the main control chip of the network device, data in a peripheral module (e.g., an encryption chip) of the network device, or the user's identification information. For example, after a user binds a device, the device stores the user's unique identification information. The network device identification information may be a character string, binary data, or the like. Furthermore, by associating the user's identification information with the scenario configuration information, permission control or sharing of scenarios among multiple users can be performed depending on the scenario configuration information associated with the user's identification information.
[0208] In one embodiment of the present application, all scenario configuration information corresponding to network devices stored on the server side can be pre-loaded. Also, scenario configuration information for network devices in a current application scenario can be pre-loaded. For example, based on a preset application scenario, scenario configuration information corresponding to the application scenario can be pre-loaded onto the server side.
[0209] In one embodiment of the present application, a network device presets a fixed scenario configuration template, acquires specific scenario configuration information from the server, and combines the specific information with the preset scenario configuration template to generate and load scenario configuration information. For example, a network device may be factory-set with a USB flash drive scenario template. When switching scenarios, the scenario configuration information acquired from the server includes only storage capacity information, read / write status, associated strings, vendor ID, product ID, and other configuration information related to the data source. This allows the device to switch between different USB flash drive data sources to change functionality.
[0210] In one embodiment of the present application, the power supply method for a network device includes, but is not limited to, the following: 1. When a network device is connected to a target device, the power supply of the target device supplies power to the network device. For example, when the network device functions as a slave device, it is connected to a target device (e.g., a computer host) and obtains power from the computer host. 2. The network device is equipped with a built-in power supply device, and the built-in power supply is used to supply power. 3. The network device is powered by an external power supply. For example, when the network device functions as a master device, it is connected to a mobile power supply or charger via a first interface to obtain power, and the second interface is connected to a target device (e.g., a slave device). When the network device functions as a slave device, it is connected to a mobile power supply or charger via a second interface to obtain power, and the first interface is connected to the master device.
[0211] Optionally, the process of establishing communication between the network device and the server side includes sending a communication connection request to the server side based on preset server-side configuration information, where the preset server-side configuration information can be stored in the network device, including, but not limited to, a server-side communication address (such as an IP address or a domain name address), a port, a user name, an access password, etc. Illustratively, when the network device is powered on and started up, the local preset server-side configuration information is read, and a communication connection request is sent to the server side based on the preset server-side configuration information, and a communication connection is established.
[0212] Optionally, the network devices are connected to the server side via a wired or wireless network (e.g., Ethernet interfaces such as twisted pair cables or optical fibers, Wi-Fi hotspots, ultra-wideband (UBW), Bluetooth, mobile cellular networks (e.g., 4G or 5G), satellite communications, and LoRa long-distance radio waves), where the server side includes, but is not limited to, devices with network service functions, such as personal computers, laptops, embedded computers, physical servers, cloud servers, or electronic products such as mobile phones and mobile terminals. During networking, network security can be further enhanced by setting up a virtual private network or using a dedicated network line.
[0213] In one embodiment of the present application, a preset application scenario can be selected on the server side. Illustratively, the server side is accessed via a client side (e.g., an app or a web page browser), and the user selects scenario configuration information that needs to be sent to the network device on the user side, and the scenario configuration information based on the user's selection is pre-loaded when the network device communicates with the server side.
[0214] It should be understood that the selection process on the server side may be a real-time process or a non-real-time process, i.e., when it is necessary to pre-load scenario configuration information, the application scenario corresponding to the scenario configuration information may be selected in real time on the server side; when it is necessary to pre-select the application scenario corresponding to the scenario configuration information and pre-load the scenario configuration information, the scenario configuration information may be pre-loaded based on the pre-selected application scenario.
[0215] In one embodiment of the present application, a preset application scenario can be selected by an interaction module of the network device. Exemplarily, the interaction module of the network device is provided with a display unit. The display unit displays options for a user to select an application scenario and determines the application scenario based on the user's selection. Thus, when the network device communicates with the server side, it pre-loads scenario configuration information based on the user's selection. Similarly, the selection process on the network device can be a real-time process or a non-real-time process.
[0216] In one embodiment of the present application, a preset application scenario can be selected using a physical switch on the network device. For example, the network device is provided with a physical switch, and the application scenario corresponding to the current switch pointer is selected by switching the physical switch. In this way, scenario configuration information based on the user's selection is preloaded during communication between the network device and the server side.
[0217] In one embodiment of the present application, the preset application scenario can also be automatically selected in the network device. Illustratively, the network device automatically selects a corresponding application scenario based on preset interaction data (e.g., descriptor content, descriptor command, or data communication content) of the target device. Alternatively, the network device automatically selects a corresponding application scenario at a specific location based on location information of a GPS module of the network device, or automatically selects a corresponding application scenario based on a local timer or a network timer of the network device.
[0218] After acquiring scenario information, the network device can store it locally. The next time the scenario information is executed, it can be used directly without acquiring it from the server. The scenario information can also be deleted if the network device cannot connect to the server or if the server sends a command to delete the scenario data. The target configuration information of the present application can be stored on the server. This prevents reverse engineering by malicious parties after the network device is lost and helps the server update the target configuration information in real time.
[0219] In one embodiment of the present application, the carrier of the scenario information includes at least one of the following, but is not limited to: (1) a transmitted binary data stream. For example, the network data stream may be a string, a structure, or the like. Here, the network device can directly read and set the application scenario information from the server side. (2) a binary file. For example, a file such as "Network USB Flash Drive.txt" (one scenario) or "USER123456.txt" (a user scenario set). Here, the network device imports and sets the application scenario information after downloading the file. (3) a link library file. For example, a dynamic link library such as "Network USB Flash Drive.so" (one scenario) or "USER123456.so" (a user scenario set). Here, the network device downloads the link library file and then uses a program to further call functions, variables, literals, and the like to set the application scenario information. Or, for example, a static link library such as "Network USB Flash Drive.a" (one scenario) or "USER123456.a" (a user scenario set). Here, after downloading the link library file, the network device further compiles it or directly calls functions, variables, literals, etc. to set application scenario information.
[0220] In one embodiment of the present application, after obtaining the scenario information, the network device enables the scenario information on the first interface or the second interface of the network device. If the network device has only one interface, the scenario will enable a unique communication interface, such as the first interface or the second interface, by default. If the network device has multiple interfaces (see FIG. 4), the interface will be enabled according to the interface number in the scenario configuration information. The activation method can be selected from the client side or the server side, the interaction module of the network device, or a data packet sent from the target device. For a network device with two or more interfaces, the scenario information can be flexibly enabled on multiple interfaces, allowing data source sharing and cooperative operation between interfaces.
[0221] Scenarios corresponding to the interface of a network device may include any of the following:
[0222] 1. Multiple scenarios or scenario device types can be the same. For example, interfaces of the same scenario device type (e.g., a scenario where the mass storage device device type is multiple USB flash drives) can be connected to different target devices.
[0223] 2. Multiple scenarios or scenario device types use the same scenario device type and data source (for example, a scenario where there are multiple USB flash drives in a network device of mass storage device type, and multiple USB flash drives share the same data source), and connect them to different target devices to enable data sharing and cooperative operations.
[0224] 3. Multiple scenarios or scenario device types are different scenario device types. For example, if interface 1 is a slave mode scenario device type (e.g., USB flash drive mode), it can be connected to target device 1 in USB flash drive mode (target device 1 is a computer host). If interface 2 is a master mode scenario device type (e.g., a network device has a command set for reading mass storage device types and can read target device 2), it can be connected to target device 2 (target device 2 is USB flash drive mode).
[0225] 4. Although there is only one scenario, it is composed of multiple interfaces, and data collaboration and coordination are performed between the interfaces. For example, in a network device (master mode + slave mode scenario), interface 1 of the network device is in master mode, the connected target device (e.g., a USB flash drive) is in slave mode, and interface 2 is in slave mode, with the connected target device being the master device (computer host). Furthermore, data sent by the master device (computer host) via interface 2 is forwarded by the network device to the slave device (e.g., a USB flash drive) via interface 1. The slave device's response data is sent via interface 1 and then forwarded by the network device to the master device (computer host) via interface 2. Because the data of the computer host and the USB flash drive is controlled by the network device, the network device can function as an intermediate control device, and the network device, either server or client, can control the data interaction commands of the computer host and the USB flash drive. For example, in peer-to-peer communication mode, interface 1 of the network device is the transmitter (TX) and interface 1 is connected to the receiver (RX) of the target device. Interface 2 of the network device is the receiving side (RX), and interface 2 is connected to the transmitting side (TX) of the target device. Interface 1 of the network device sends data to the target device, and interface 2 receives the data sent from the target device.
[0226] 5. Although there is only one scenario, it is composed of multiple network devices, and data work allocation, collaboration, and cooperation are performed between multiple network devices. For example, take Figure 5A as an example. The user selects Scenario A, and in Scenario A, Interface 1 and Physical Communication Interface 2 of Network Device A and Interface 1 and Interface 2 of Network Device B are respectively configured to realize work allocation, collaboration, and cooperation between two network devices and four interfaces.
[0227] 6. Executing task allocation, collaboration, and cooperation among multiple scenarios. As shown in Figure 5B, data sharing, task allocation, collaboration, and cooperation are executed among multiple network devices and multiple target devices controlled in multiple scenarios.
[0228] Step 103: Based on the loaded scenario configuration information, establish a communication connection between the network device and the target device, so that the network device can connect to the target device.
[0229] In one embodiment of the present application, the network device establishes a handshake connection with the target device via an interface according to the scenario configuration information. When the network device is in master mode, it identifies the type of the connected target device (in this case, the target device is a slave device). This allows it to load a driver program (e.g., a command set) for the target device and further operate the target device. When the network device is in slave mode, it responds to the target device with data such as a descriptor according to the command sent from the target device. This allows the target device to load a driver program for the network device and further operate the network device.
[0230] In this step, the target device may be a computer device that functions as a master device, such as a laptop, desktop computer, embedded host, industrial control device, in-vehicle device, mobile terminal, or physical server, or an electronic device that functions as a slave device, such as a USB memory (USB flash drive), mobile hard disk, hard disk, flash memory device reader, SD card, TF card, or external optical drive. When the target device functions as a master device, the network device communicates with the target device as a slave device. When the target device functions as a slave device, the network device communicates with the target device as a master device.
[0231] Optionally, if the pre-loaded target configuration information includes scenario configuration information for all application scenarios, determine target scenario configuration information corresponding to the current application scenario from the plurality of scenario configuration information based on the current application scenario selected by the user on the network device, define device functions of the network device based on the target scenario configuration information, and establish a communication connection with the target device.
[0232] Optionally, if the pre-loaded target configuration information only includes scenario configuration information for the current application scenario, define the device functions of the network device based on the scenario configuration information and establish a communication connection with the target device.
[0233] Optionally, the method for establishing communication between the network device and the target device can be realized based on a handshake communication method. Here, if the target device functions as a master device and the network device functions as a slave device, the target device sends a handshake request to the network device. The network device responds to the handshake request and feeds back communication parameters in target scenario configuration information (e.g., a descriptor such as a device descriptor) to the target device, thereby realizing a handshake protocol to establish a communication connection. If the target device functions as a slave device and the network device functions as a master device, the network device sends a handshake request. Optionally, during the implementation of the handshake protocol, the communication parameters can also be verified by enumeration.
[0234] In addition, in this embodiment, the device type of the network device is defined, and the network device can be used as a master device or a slave device, allowing it to be used in more application scenarios and expanding the application of the network device. In addition, communication data does not need to pass through the computer host, which effectively prevents the computer host from capturing packets and leaking the actual data source and network communication data, and effectively prevents the computer host from cracking the data by malicious programs, thereby ensuring the device security and data security of the network device. In addition, if the network device is sold or lost, the communication relationship with the network device can be approved or canceled through the server side, further ensuring the data source security of the network device.
[0235] Note that the process of establishing a handshake connection between a network device and a target device is essentially a data exchange, and the method of establishing a handshake connection between the network device and the target device differs depending on the mode of the network device (e.g., master mode, slave mode, peer-to-peer communication mode, etc.).
[0236] In one embodiment of the present application, when the device role of the network device is selected as a master mode (i.e., a master device that communicates with a target device), a functional command set (e.g., an acquisition command set, a verification command set, a configuration command set, an interaction command set, a data source command set, a custom command set, etc.) in a descriptor command set for master device enumeration is set, and data source configuration information is set to bind a data source during data exchange between the network device and the target device. Data sources include, but are not limited to, storage media, address ranges of storage space (e.g., sector address ranges), image storage files, specific folders, databases, and data streams. When the device role of the network device is selected as a slave mode (i.e., a slave device that communicates with a target device), a descriptor parameter, a device type parameter, and data source configuration information for responding to the master device are set.
[0237] In some embodiments, based on the embodiment shown in FIG. 1, step S102 includes: When communicating with a server side, sending a configuration acquisition request to the server side, the request including identification information of the network device; and receiving target configuration information corresponding to the identification information fed back from the server side.
[0238] In one embodiment of the present application, the server side can connect to multiple network devices simultaneously, so that the correspondence between the identification information of the network devices and the target configuration information ensures that the network devices accurately obtain the target configuration information.
[0239] In one embodiment of the present application, the identification information is identification information representing a network device, such as the device number of the network device, the user name (or user number, user session ID) of the user to which the network device belongs, etc. Optionally, a correspondence between the identification information and the target configuration information is established in advance, and the correspondence may be set to a fixed value when the network device is shipped from the factory, or the setting may be changed. It should be understood that all configuration information of the network device can be accessed from the user to the server side so that it can be set on the user's page. The following description is omitted.
[0240] In one embodiment of the present application, the configuration acquisition request also includes the current application scenario parameters of the network device, and based on the identification information and the current application scenario parameters, the target scenario configuration information corresponding to the current application scenario parameters can be accurately acquired.
[0241] When establishing a communication connection between devices, the master device performs a timeout determination (usually in milliseconds or microseconds) according to the communication protocol (e.g., handshake protocol or transmission control protocol). Therefore, to ensure that the communication connection is established within a preset time, the master device preloads the function command set and descriptor set into the network device. During data transmission between devices, the transmission protocol may be a bulk transmission protocol, an isochronous transmission protocol, or a transmission interruption protocol, which has a longer timeout interval. Therefore, data transmission during device interaction does not require preloading of related data. Furthermore, in a connection scenario with a long timeout determination, the function command set and descriptor set can be obtained in real time from the server.
[0242] In some embodiments, the network device acts as a master device that communicates with a target device, and the descriptor command set includes a plurality of function command sets, the function command sets for controlling data exchange between the network device and the target device.
[0243] Based on the embodiment shown in FIG. 1, step S103 includes: enumerating a plurality of descriptors in a second descriptor set for the target device based on a function command set in the descriptor command set; If the enumeration is successful, setting a target data source for communication between the network device and the target device, the target data source being provided on the target device.
[0244] If the enumeration fails, the acquired descriptor set is sent to the server side, and after identification by the server side, the corresponding descriptor set or function command set, etc. is downloaded from the server side, and the enumeration is performed again.
[0245] In this embodiment, when a network device functions as a master device, it needs to actively send requests. Therefore, in order to realize the master device function of the network device, a developed driver (i.e., a function command set) is pre-configured and stored on the server side, thereby protecting the security of the function command set data of the network device and preventing reverse engineering by malicious parties after the network device is lost.
[0246] In some embodiments, the enumeration process comprises: reading second descriptor data of the target device based on the acquisition command set; verifying a plurality of descriptors in the second set of descriptors based on the verification command set; and determining that the enumeration is successful if a plurality of the descriptors meets preset device requirements.
[0247] In one embodiment of the present application, when a network device is in master mode or in the master role, it selects a scenario after startup and then reads first device connection configuration information from the scenario configuration information. The network device sets an interface (e.g., the first interface or the second interface) of the network device to master mode according to the first mode of the first device connection configuration information. The network device sets a communication protocol according to the interface type. For example, it sets the communication protocol of the interface to the USB communication protocol. If the target device (slave device) sends an electrical signal indicating that it can be enumerated (connected), the network device sends an enumeration request (a request to establish a handshake connection) to the target device.
[0248] The network device sends at least one data interaction command (e.g., sending a standard request to the default endpoint 0 of the target device) to the target device through the configured (or default) interface according to the standard command set (e.g., the command set for obtaining descriptor data), the special command set (e.g., the command set for obtaining device type), and the setting command set in the first device connection configuration information, according to the communication protocol of the interface (e.g., the USB communication protocol), and receives data fed back from the target device. If the fed back data meets the connection success condition specified by the first connection status determination rule, the network device determines that the handshake connection has been successfully established and sends a connection success data packet to the server side according to the first status response rule. If the fed back data meets the connection failure condition specified by the first connection status determination rule, the network device determines that the handshake connection has failed and sends a connection failure data packet to the server side according to the first status response rule, to request new command set data from the server side, and reconnect to the target device.
[0249] The device connection method of this embodiment will be described below by taking a scenario in which a network device reads / writes to a USB flash drive as an example. Step S101 includes setting first device connection configuration information. Specifically, the first mode is set as master mode, the first interface type is set as USB interface, and one or more of the following standard command sets are set: acquire hardware descriptor, acquire configuration descriptor, acquire interface descriptor, acquire endpoint descriptor, and acquire string descriptor. One or more of the following special command sets are set: acquire total number of formattable logical blocks, acquire last logical block address, and set one or more of the following setting command sets: set device address, set device configuration (set enabled configuration), and set Bulk-Only Mass Storage Reset command. A first connection status determination rule is set as follows: determine whether the fed-back parameters such as interface descriptor, endpoint descriptor data, and capacity information meet the parameters of the mass storage device type, and if they do not meet the parameters of the mass storage device type, determine that the connection has failed. If the parameters of the large-capacity device type are met, the connection is determined to be successful, and the first status response rule is set as follows: If the connection fails, reconnect (enumerate) using the "second descriptor set." If the connection still fails, send a connection-failed status data packet to the server. If the connection is successful, send a connection-successful status data packet to the server.
[0250] The step S102 includes pre-loading the first device connection configuration information.
[0251] Step S103 includes connecting to the USB flash drive according to the first device connection configuration information when the network device interface detects that a device has been connected. Specifically, the interface of the network device is set to master mode according to the first mode of the first device connection configuration information. The communication protocol of the interface is set to the USB communication protocol according to the first interface type, and the communication address of the USB flash drive is set according to the "set device address" command. The descriptor of the USB flash drive is obtained according to at least one command of "get hardware descriptor," "get configuration descriptor," "get interface descriptor," "get endpoint descriptor," and "get string description." The capacity information of the USB flash drive is obtained according to at least one command of "get total number of formattable logical blocks" and "get last logical block address." The configuration of the USB flash drive (e.g., endpoint of the USB flash drive boot response) is enabled according to the "set device configuration" command. The mass storage function of the USB flash drive is enabled according to the "bulk-only mass storage reset" command. The device determines whether the USB flash drive has a successful connection or a failed connection according to a first connection status determination rule based on at least one of the USB flash drive's descriptor, the USB flash drive's capacity information, the USB flash drive's endpoint information, and the USB flash drive's mass storage capability. If the device determines that the connection to the USB flash drive has failed according to the first status response rule, it reconnects using a second descriptor set or reselects a preset alternative scenario and reconnects (e.g., a connection scenario to a camera). If the connection still fails, it sends a connection failure status data packet to the server side. If the connection is successful, it sends a connection success status data packet to the server side.
[0252] It should be noted that the steps in the above process of connecting to a USB flash drive according to the first device connection configuration information do not correspond one-to-one to the actual implementation process, and not all of them are required.
[0253] In this alternative embodiment, the descriptor set includes, but is not limited to, a device descriptor, a configuration descriptor, an interface descriptor, an endpoint descriptor, a string descriptor, a BOS descriptor, and a preset custom descriptor. The preset device requirements are protocol requirements in the communication protocol. Illustratively, Table 1 below shows examples of descriptors obtained by descriptor commands and settings by setting commands when a network device functions as a master device. It should be understood that the descriptor obtainment commands and setting commands shown in Table 1 below are used as examples only. Other embodiments may include more or fewer descriptors, but a description thereof will be omitted here.
[0254] By way of example, Table 1 below shows the descriptor commands that a network device sends when it is a master device or in master mode. JPEG2025528755000002.jpg175170
[0255] Illustratively, the network device reads the following information in the device descriptor, configuration descriptor, and string descriptor based on the descriptor command set: 1. Manufacturer, identification information, string, etc.; 2. Type of command, etc. used in the interface, for example, mass storage type; 3. Transmission endpoint, for example, Endpoint 1 indicates IN and Endpoint 2 indicates OUT; 4. Endpoint transmission mode, for example, bulk transmission mode. Based on the verification command set, it verifies whether the type of command, etc. used in the interface, endpoint, and endpoint transmission mode meet the application scenario requirements of the network device. If they meet, it is determined that the enumeration is successful (or the handshake connection is successfully established). If they do not meet, it is determined that the enumeration has failed (or the handshake connection establishment has failed), and the connection failure information is fed back to the server side.
[0256] Optionally, the functional command set further includes a configuration command set for sending a configuration command to the target device. For example, the network device sends a configuration command to the slave device to request the slave device to perform at least one of enabling a corresponding endpoint, setting a bus address, and enabling a configuration. Note that when the network device functions as a master device, connection to and enumeration of multiple slave devices is supported.
[0257] In this embodiment, the network device communicates with the target device as a master device. For an unknown connecting device (target device), the network device acquires data such as descriptors sent from the target device and sends them to the server side for identification, so that the network device can download the corresponding descriptor set or function command set from the server side or automatically select other alternative scenarios, thereby fully expanding the connection function of the network device to support different types of target devices.
[0258] In some embodiments, the configuration process for the target data source includes: determining a target data source for the network device based on the data source command set and in response to the data source configuration information;
[0259] In this alternative embodiment, a data source command set of the network device is configured based on an application scenario of the network device to operate the data source of the target device. For example, in an application scenario where the network device is connected to a mass storage device, a corresponding data source command set of the network device is configured to operate the data storage space of the target device. For example, in an application scenario where the network device is connected to a keyboard device, a corresponding data source command set of the network device is configured to read key values entered through the keyboard. The interaction data of the above operations on the data source of the target device can be synchronized to the server side in real time, or can be filtered (or transformed) by preset scripts or configuration rules before being synchronized to the server side.
[0260] Optionally, in an application scenario in which a network device is connected to a mass storage device, the data source configuration information includes, but is not limited to, capacity information of the data source. The capacity information includes the last logical block address of the data source, the total number of formattable logical blocks, and the block capacity, where (last logical block address + 1) x block capacity = capacity, (total number of formattable logical blocks) x block capacity = capacity. The data source configuration information includes the maximum number of logical units, read / write status (read-only status, write-only status, read / write status, etc.), and the maximum number of logical units indicates the number of partitions.
[0261] For example, in a scenario where a slave device is read in master mode (e.g., reading a USB flash drive), the network device is set to network read / write control device mode by the server or within the device before or after powering on the device. Specifically, the network device is powered on, a USB flash drive is inserted, and the network device interface detects the connection of the target device and performs enumeration using preset descriptor commands. If the enumeration is successful, the device type is acquired and enumeration success information (including the device type) is sent to the server to establish a communication connection. If the enumeration fails, the network device sends readable descriptor information to the server and requests the server to send a new function command set (such as a descriptor acquisition command set or a data exchange command set) or new scenario information. After receiving the new descriptor command or scenario information, the network device performs enumeration again. The server then loads the corresponding driver or operating software depending on the device type. The driver or operating software sends relevant commands (data source command sets) to the network device via the server side and performs calculations to obtain the maximum number of logical units, total space capacity, read / write status, available space capacity, related strings, vendor ID, and product ID of the target device (such as a USB flash drive), and then prepares for enumeration and operation. The server side or client side performs read and write operations via software. Users can operate target devices (such as USB flash drives) using server-side software, client-side apps, or apps such as web browsers. For example, users can write files on the client side to a USB flash drive, read files from a USB flash drive and save them on the client side, read data from a specified sector location on a USB flash drive, or write data to a specified sector location on a USB flash drive.
[0262] In a scenario where data from storage device A needs to be copied to storage device B (or data from a server needs to be downloaded to storage device A or B, or data from storage device A or B needs to be uploaded to the server), current technology requires connecting storage device A and storage device B to a computer to copy the data (or installing application software on the computer device before connecting to the server). As a result, packets may be captured by the computer device during the data copy, potentially resulting in data leakage. In this embodiment, the network device acts as a master device to communicate with the target device, thereby adequately solving the problems in the above scenario. This embodiment eliminates the need for a computer device (with an operating system), thereby preventing data theft by malicious programs during copying. Uploaded data is directly stored on the server, preventing data loss or leakage due to device loss. Because the network device is directly connected to the server, network traffic data does not need to pass through the computer device and the target device, reducing the possibility of network data capture and ensuring data security.
[0263] In some embodiments, the network device is a network read / write controlled device scenario, and establishing a communication connection with the target device based on the target scenario descriptor information includes: enumerating a plurality of descriptors in a second descriptor set for the target device based on a function command set in the descriptor command set; If the enumeration is successful, requesting the server side to send a driver command set corresponding to the target device to complete the communication connection, the driver command set being used to exchange data with the target device.
[0264] In this embodiment, the driver command set is a driver command set developed for a different device, including but not limited to an interaction command set and a custom command set. For the enumeration process for obtaining descriptors, etc., please refer to the relevant description when the network device functions as a master device, and the description will be omitted here.
[0265] In this embodiment, by requesting the server side to send a driver command set corresponding to the target device and identifying the device type of the target device based on the second descriptor set of the target device, driver command sets corresponding to different device types of the target device can be read from the server side and used for data exchange between the network device and the target device, thereby realizing connection and data exchange of multiple device types.
[0266] In addition, for a network-based read / write control device, the target data source may or may not be set according to the actual usage requirements.
[0267] In some embodiments, in a scenario where the network device is a network proxy control device, step S103 includes: enumerating a plurality of descriptors in a second descriptor set for the target device based on a function command set in the descriptor command set; If the enumeration is successful, the server side virtualizes the target device, generates a virtual device corresponding to the target device, and sends the second descriptor set to the server side to establish a communication connection with the target device.
[0268] In this embodiment, the descriptor enumeration process refers to the relevant description when the network device functions as a master device, and is not described here. Optionally, the virtualization process can be performed inside the server side or on the front end of a computer that controls the server side. Note that, for a network proxy control device, a target data source may or may not be set according to actual usage requirements.
[0269] Some application scenarios when using a network device as a master device are listed below, which are examples but not limited to:
[0270] 1. Use a network device as a remote controller. Instead of virtualizing the USB device, use a custom driver to control the program directly from the server side (it should be understood that USB devices can also be virtualized). Develop and control the program with a custom driver. In other words, develop your own driver instead of using a generic driver that comes with the operating system.
[0271] For example, a network read / write control device configured as a master (capable of performing protocol conversion according to customized interaction commands and scripts) can read and write handshake protocol data (e.g., descriptor sets) from interface devices such as USB, HDMI, SCSI, IEEE1394, SATA, eMMC, SDIO, M.2, and serial communication interfaces, enumerate the target devices based on the enumeration process described above, and establish a communication connection between the network read / write control device and the storage device. Then, based on the driver command set for read / write operations installed on the server side, the network read / write control device sends interaction commands to the network read / write control device, either controlled by the user or by pre-configuring commands on the server side. The network read / write control device then converts the interaction commands and sends them to the storage device, writing data from the server side to the storage device or uploading data from the storage device to the server side.
[0272] Similarly, a network-based read / write control device can establish a communication connection through sensor devices such as cameras and microphones, read data collected by the sensor devices and upload it to the server side, send server-side control commands (i.e., commands in a custom command set), control a camera to adjust its direction or angle, or control a microphone to adjust its power.
[0273] 2. Use a network device as a network proxy control device. By using a network device as a proxy device in combination with a native driver, the software virtualizes the target device as a local USB device (by registering information such as acquired descriptors on the USB bus, etc.), so that the server side or the computer front end that controls the server side recognizes the target device as a local USB device, allowing the target device to be successfully identified and used without secondary driver development. Optionally, if a master device is connected to multiple target devices at the same time, all target devices can be network mapped to the computer front end or server side, and the target devices can be virtualized as local USB devices on the computer front end or server side.
[0274] The prior art data implementation is USB device → computer host 1 → network share → computer host 2 → virtual USB device, which has the following problems: 1. Data must pass through computer host 1, which poses unknown risks to computer host 1. 2. Data passing through computer host 1 can easily have its packets captured, revealing the data source address and data interaction logic, creating security risks. 3. Computer host 1 is typically a PC or personal laptop, requiring the installation of an operating system and software. 4. The above data is implemented in the form of pure software. The network proxy control device of this application may also be in the form of independent hardware. Since data does not need to pass through a computer host, security risks are reduced.
[0275] For example, a network device uses a USB interface as a master device interface to read a basic descriptor set from a connected printer (target device) and enumerates the target device based on the enumeration process described above. If the enumeration is successful, the network device sends the printer's descriptor set to the server. The server uses the received descriptor set via a virtual bus or the like to create a virtual USB device on the local computer. The printer's native driver (functional command set) operates the virtual USB device to remotely control the mapped printer and perform printing. In other words, the communication relationship is server (printer driver → virtual USB device) → network USB device (master device) → printer. In another embodiment, by controlling the server side with a computer front end, the server-side virtualization process, waiting data to be printed, and the printer's printing progress can be visualized on the computer front end. A detailed description of this is omitted here.
[0276] Furthermore, when a network device is connected to a printer on-site, a native printer driver can be used via a remote server connected to the network device to directly identify the printer and control it to print, preventing data leakage caused by copying important files to unknown, risky computers.
[0277] The above application scenarios are used only as examples and are not limited to these. In other scenarios, multiple application scenarios can be combined. For example, Scenario 1 and Scenario 2 can be combined and developed and implemented simultaneously. This explanation is omitted here.
[0278] In some embodiments, based on the embodiment shown in FIG. 1 , the network device functions as a slave device that communicates with the target device, and step S103 includes: receiving an enumeration request sent from the target device; In response to the enumeration request, feeding back the first descriptor set to the target device so that the target device enumerates the first descriptor set, and after the enumeration is successful, setting a target data source when communicating between the network device and the target device according to configuration information of the data source, wherein the target data source is provided on the server side.
[0279] In this embodiment, similar to the communication connection process when the network device functions as a master device, when the network device of this embodiment functions as a slave device, the target device functions as the sender of the enumeration request, and the network device functions as the responder of the enumeration request. When the network device functions as a master device, the target device performs the enumeration action, and the network device responds to the enumeration action of the target device. When the network device functions as a slave device, it supports connection to multiple master devices and supports responding to the enumeration requests of multiple master devices. For details of the enumeration process, please refer to the embodiment when the network device functions as a master device. Here, the description will be omitted.
[0280] In one embodiment of the present application, when the network device is in slave mode, after selecting a scenario, the network device reads second device connection configuration information from the scenario configuration information. The network device sets an interface (e.g., the first interface or the second interface) of the network device to slave mode according to the first mode of the second device connection configuration information. Depending on the interface type, the network device sets the communication protocol of the interface to the USB communication protocol. After connecting to the target device (master device), the network device responds by transmitting an electrical signal indicating that it can be enumerated (connected).
[0281] The network device receives a data interaction command sent from the target device via the configured (or default) interface (e.g., the target device sends a standard request to endpoint 0 of the network device). If the data interaction command meets at least one corresponding data condition or rule condition among the standard data set (e.g., a descriptor acquisition data set), the special data set (e.g., a device type data set), the configuration command execution data set, the second connection status determination rule, and the second status response rule in the second device connection configuration information, the network device feeds back data to the target device. If the data exchange command includes data content in the configuration command execution data set, the network device performs a preset operation. If the data sent from the network device meets the connection success condition specified in the second connection status determination rule, the network device determines that the handshake connection has been successfully established and sends a connection success data packet to the server side according to the first status response rule. If the data fed back from the target device meets the connection failure condition specified by the first connection status determination rule, the network device determines that the handshake connection has failed, and sends a connection failure data packet to the server side according to the first status response rule to request new descriptor set data from the server side and reconnect to the target device.
[0282] The device connection method in this embodiment will be described below using a USB flash drive scenario as an example.
[0283] Step S101 includes setting second device connection configuration information. Specifically, the second mode is set as a slave mode, the second interface type is set as a USB interface, and one or more of the following standard data sets are set: a first hardware descriptor, a second hardware descriptor, a first descriptor, a second descriptor, a first interface descriptor, a second interface descriptor, a first endpoint descriptor, a second endpoint descriptor, a first string descriptor, and a second string descriptor. One or more of the following special data sets are set: a total number of formattable logical blocks, a last logical block address, a maximum number of logical units, a read / write status, etc. One or more of the following setting commands are set: a device address setting, a device configuration setting, and a bulk-only mass storage reset command. The second connection status determination rule is set as follows: Determine whether the commands sent from the network device, such as the get first hardware descriptor command, get first configuration descriptor command, get first interface descriptor command, get first endpoint descriptor command, get first string descriptor command, get total number of formattable logical blocks command, get last logical block address command, and get read / write status command, match the read parameters of the mass storage device type. If they do not match the mass storage device type parameters, determine that the connection has failed. If they match the mass storage device type parameters, determine that the connection has been successful. The second status response rule is set as follows: If the connection has failed, reconnect (enumerate) using the second hardware descriptor, second configuration descriptor, second interface descriptor, second endpoint descriptor, and second string descriptor in the descriptor set. If the connection still fails, send a connection failure status data packet to the server. If the connection is successful, send a connection success status data packet to the server.
[0284] The step S102 includes pre-loading second device connection configuration information.
[0285] Step S103 includes connecting a network device (in a USB flash drive scenario) to the target device in accordance with the second device connection configuration information. Specifically, an electrical signal indicating that the network device can be enumerated through the interface is sent to the target device. When the target device responds to the enumeration electrical signal and sends a data interaction command, the network device's interface is set to slave mode in accordance with the second mode of the second device connection configuration information. The interface's communication protocol is set to USB communication protocol in accordance with the second interface type. In response to executing device address setting, the network device sets a USB communication address. The network device responds to at least one of commands such as a get first hardware descriptor command, a get first configuration descriptor command, a get first interface descriptor command, a get first endpoint descriptor command, and a get first string descriptor command. In response to executing the set device configuration command, endpoints and functions corresponding to the network device's interface are enabled. In response to executing a Bulk-Only Mass Storage Reset command, the network device performs a self-test of the mass storage device type functions and sends back an execution status packet. According to the second connection status determination rule, it is determined whether commands such as a get first hardware descriptor command, a get first configuration descriptor command, a get first interface descriptor command, a get first endpoint descriptor command, a get first string descriptor command, a get total number of formattable logical blocks command, a get last logical block address command, and a get read / write status command are mass storage device type commands. If they do not correspond to the get mass storage device type commands, it is determined that the connection has failed. If they correspond to the mass storage device type parameters, it is determined that the connection has succeeded.If the connection fails, reconnect using the second hardware descriptor, second configuration descriptor, second interface descriptor, second endpoint descriptor, and second string descriptor in the descriptor set.If the connection fails, send a connection failure status data packet to the server side, or switch to an alternative scenario such as a camera scenario.If the connection is successful, send connection success status information to the server side.
[0286] By way of example, Table 1 below shows the descriptors that a network device responds to when it is a slave device or in slave mode. JPEG2025528755000003.jpg213170JPEG2025528755000004.jpg74170
[0287] In some embodiments, the target devices include at least one first target device and at least one second target device, and the network device functions as a master device communicating with the first target device and as a slave device communicating with the second target device. Establishing a communication connection with the target device based on the target scenario descriptor information includes: enumerating a plurality of descriptors in a second descriptor set for the first target device based on a function command set in the descriptor command set; If the enumeration is successful, configuring a first target data source in communication between the network device and the first target device to complete a communication connection with the first target device; receiving an enumeration request sent from the second target device; In response to the enumeration request, feeding back the first descriptor set to the second target device so that the second target device enumerates the first descriptor set, and after the enumeration is successful, configuring a second target data source during communication between the network device and the second target device according to data source configuration information, wherein the first target data source is provided on the first target device and the second target data source is provided on the server side or the first target device.
[0288] In this embodiment, the descriptor enumeration process and the target data source configuration process refer to the relevant description when the network device functions as a master device or a slave device. Here, the description is omitted. The network device in this embodiment has at least two physical interfaces and simultaneously exists as a "host device + slave device." The network device obtains a second descriptor set of the first target device (slave device) to complete the enumeration of the first target device. When the second target device (master device) sends an enumeration request, the network device transfers the first descriptor set to the second target device and completes the enumeration on the second target device, thereby realizing multi-device interaction between the first target device, the network device (and the server side), and the second target device.
[0289] Optionally, the network device can also forward the descriptor command sent from the second target device directly to the first target device and forward the response data of the first target device directly to the second target device to complete the enumeration.
[0290] Optionally, the server side logs data exchange between the first target device and the second target device for auditing the first target device and the second target device. In the case of data exchange, the network device or the server side may also perform operations such as data modification, replacement, etc., to protect data security of the first target device and the second target device.
[0291] As an example, the network device may be a network USB hub (e.g., USB HUB), and in this embodiment, the network device may monitor the connected first target device and detect descriptor parameters and communication data. Specifically, when the first target device connects to the network device, it uploads a descriptor set of the first target device (such as vendor ID, product ID, or device type (used type, subtype, interface command set, endpoint transmission mode)) to the server side. Only after the server side determines that the first target device meets the vendor ID, product ID, or device type requirements can the first target device exchange data with the network device or the second target device.
[0292] Optionally, when the network device functions as a slave device of a mass storage device, the data source configuration information includes, but is not limited to, capacity information of the data source. The capacity information includes the last logical block address and block capacity of the data source, where (last logical block address + 1) × block capacity = capacity, and the data source configuration information further includes the maximum number of logical units, where the maximum number of logical units indicates the number of partitions. In another embodiment of the present application, the capacity information includes the total number of formattable logical blocks and block capacity of the data source, where (total number of formattable logical blocks) × block capacity = capacity.
[0293] Currently, all connected devices have a single function, such as a single storage device or external device. When used as a storage device, data can only be stored within the storage device. The storage capacity is limited by the hardware, and the data storage space can be easily identified by a computer device, creating a risk of data theft. In this embodiment, a network device is used as a slave device to communicate with a target device, and multiple functionalities of one device can be realized through scenario switching, thereby successfully overcoming the storage capacity limitations and the risk of data storage space being easily identified, thereby improving the security of the data source.
[0294] Some application scenarios when using a network device as a slave device are listed below, which are examples but not limited to:
[0295] 1. A network device functions as a network USB flash drive or other storage medium. The network device is configured as a USB flash drive (e.g., a mass storage device type, a bulk transfer endpoint, etc.), or as an SD card, a TF card, or a hard disk. A computer host obtains a descriptor set for the network device and enumerates the descriptor set to establish a communication connection between the network device and the computer host. In one embodiment, the computer host sends a read or write command to the network device, and the network device sends the read or write command to the server side, the client side, or the control side. The following description will focus on the server side as an example. The network device establishes an association with the computer host based on an image file (e.g., a disk image file of partition.dd or an optical disk image file of partition.ISO) established on the server side, the client side, or the control side, and performs reading or writing to the target data source of the network device. In the data writing scenario, the computer host writes interaction data to the network USB flash drive, network SD card, network TF card, or network hard disk, and the network USB flash drive, network SD card, network TF card, or network hard disk uploads the interaction data to the server side, and the server side writes the interaction data to a specified offset position in the image file.In the data reading scenario, the server side reads the specified offset data from the image file and feeds it back to the computer host.
[0296] The data in the image file is stored sequentially in the storage space. For example, after analyzing the file system, the image file A.dd is assigned the sector range of sector addresses 0x1000 to 0x1007. The size of the sector range of sector addresses 0x1000 to 0x1007 in the image file is only an example, and the sector range of the actual storage medium will be larger than the above sector range.
[0297] Taking the FAT32 file system as an example, the file information for an image file includes the first cluster address. The FAT32 file system finds all cluster addresses based on the first cluster address and the FAT (File Allocation Table) and converts them all to sector addresses. For example, the A.dd file above is converted to sectors 0x1000 to 0x1007. The specified offset indicates the offset of the operation address for read and write commands for the image file. For example, when using the above image file A.dd as a data source, if the target device's read / write target sector address (i.e., the specified offset) is 0, it is converted to sector 0 (the first sector address) of image file A.dd, i.e., 0x1000. If the target device's read / write target sector address is 1, it is converted to sector address (0+1) of image file A.dd. Similarly, the specified offset is mapped to a specific sector address. Different data sources correspond to different sector addresses. For example, the storage sectors of image file A.dd are 0x1000-0x1007, and the storage sectors of image file B.dd are 0x2000-0x2007. To switch the data source from image file A.dd to image file B.dd, simply change the read and write address to sectors 0x2000-0x2007. The data source is different depending on the sector address corresponding to the data source. This allows for data source switching. Furthermore, the data sources use different physical storage media, directly physically separating the different data sources. JPEG2025528755000005.jpg65170
[0298] See Table 3. Taking the FAT32 file system as an example (file information for A.txt, mirror file as well), the first cluster number is 0x1d, and the first sector (first sector address) can be obtained based on file system calculations. The corresponding cluster chain can be obtained from the FAT table, and the sector address set for the file content data can be obtained by calculation based on the cluster chain. The data in the sector address set is the content data of the A.txt file. For example, it is binary data with a string of 123456 characters. In the case of an image file, it is the corresponding sector data.
[0299] It should also be understood that different data sources may have different capacity information (including the last logical block address, the total number of formattable block capacities, block capacity, total space capacity, usable space capacity, and the maximum number of logical units), read / write status (e.g., read-only status, write-only status, readable / writable status, etc.), associated strings, manufacturer (Vender ID), device ID (Product ID), etc. Therefore, although the device type in multiple different scenarios is the same (e.g., a USB flash drive device of mass storage device type), different data source configurations and switching between data sources actually change the device's functionality.
[0300] Furthermore, when a network device interacts with a computer host, it can directly manage storage space ranges (sector address ranges) rather than files. For example, the sector range 0x1000-0x1007 is assigned to a USB flash drive (say, the first USB flash drive), and the sector range 0x2000-0x2007 is assigned to another USB flash drive (say, the second USB flash drive).
[0301] For USB flash drives (USB interface), SD cards (eMMC and other interfaces), TF cards (eMMC and other interfaces), or hard disks (SATA, M.2 and other interfaces), it is essentially just a data source (sector address) or capacity information (optional). The network device actually acts as a remote mapper for read and write commands (i.e., converting server-side data to USB flash drives with USB interface, SD cards or TF cards with eMMC or SDIO interfaces, hard disks with SATA or M.2 interfaces, etc.).
[0302] In one embodiment of the present application, the data source includes, but is not limited to, a storage medium, an address range of storage space (e.g., a sector address range), an image storage file, a specific folder, a database, and a data stream. A specific file is a file pre-selected by a user, permitted to be read and written by a computer device, and displayed to the user on the computer device. Mapping a specific file to a target address refers to mapping the sector address of a specific file in a storage device to a target address. An image file can be connected to a computer host as a storage data source. A network device communicates with a server side via wired or wireless communication, and the server side has multiple image files. Optionally, based on distributed storage technology, optimized storage, and CDN network acceleration, the image file can be database data or a combination, merge, or mapping of multiple files.
[0303] In one embodiment of the present application, a network device is connected to a server side and transmits an identification number to the server side. The server side associates a corresponding image file according to the identification number of the network device. When a computer host sends a data interaction command, the server side transmits the read and write requirements of the data interaction command (e.g., read or write operation, the address of the first sector to be operated, and the length of the operated sector) to the server side. After receiving the read and write requirements sent from the network device, the server side feeds back the data block address of the sector file corresponding to the image file to realize data space expansion of the network device. In one embodiment of the present application, the server side switches and controls the target image file corresponding to the network device according to the identification number of the network device, thereby connecting the target image file to the computer host. For example, three image files, "Partition1.dd," "Partition2.dd," and "Partition3.dd," are bound according to the identification number of the network device (or the user's identification number (bound by account login)), and the three image files are switched between and connected to the data source of the computer host.
[0304] In one embodiment of the present application, a target device is connected to a server side and an image file of "Partition1.dd" stored on the server side is connected to a computer host. The computer host sends a data interaction command with a sector size of 512 bytes. To use the data interaction command to read data from sector address 0 and write data to sector address 1, a request is sent to the server side via a network device. The server side converts sector 0 to the first address of "Partition1.dd" and converts sector 1 to the offset address of 512 bytes of "Partition1.dd." The server side feeds back data from 0 to the next 511 bytes of the first address of the image file "Partition1.dd" according to the converted addresses. Data from 512 bytes to the next 511 bytes of "Partition1.dd" is written as the offset address, and the network device feeds back the feedback result from the server side to the computer host. The above sector size of 512 bytes is merely an example and is not a limitation of the present application. For example, the size of one sector may be 1024, 2048, or 4096 bytes.
[0305] In an embodiment of the present application, a network device can freely switch between different storage data sources without installing software tools on the computer host (e.g., a USB flash drive read / write driver included with the operating system). The actual addresses of the data sources are hidden from the computer host. The data sources are stored in the cloud. If the network device is lost, the data source can be remotely canceled, improving data security for the data storage device. In addition, this embodiment directly reads and writes specific offset address data (or sector address data corresponding to the file) associated with the server side, and transfers data directly to the server side or the computer host using a transfer method, which is not limited by the storage space of the storage device itself, improving efficiency and increasing the applicable scenarios.
[0306] The present embodiment differs from existing network USB flash drives in that, in related technologies, files on the server side are first downloaded to the network USB flash drive's storage device, and then the computer reads and downloads the files from the storage device's file system. Alternatively, a computer first writes files to the USB flash drive's file system, and then uploads them from the network USB flash drive to the server-side terminal. In this case, the network USB flash drive's own storage capacity is used. For example, a 16GB network USB flash drive cannot transfer a 32GB file. Or, a network USB flash drive with less than 4GB of free space cannot transfer a file larger than 4GB. The present invention transfers data using a buffer zone (e.g., 512 bytes per sector), eliminating file limitations. However, data on the entire storage partition cannot be swapped. In the present invention, partition 1.dd can be formatted as a FAT32 file system and files A.txt and B.txt can be created based on sector address reading and writing. Partition 2.dd can be formatted as an ExFAT file system and files C.txt and D.txt can be created, or they can be directly connected to a computer for viewing. For existing networked USB flash drives, only specific files can be selected and copied. Furthermore, based on distributed storage technology, optimized storage, and CDN network acceleration, image files such as "Partition1.dd" mapped to the server side can be database data or a combination, merge, or map of multiple files.
[0307] In one embodiment of the present application, if the network device is an SD card or a TF card, the network device can send or receive data packets through an eMMC interface or an SDIO interface and the corresponding communication protocol, for example, by sending read / write commands on the SDIO_CMD line and using the SDIO_D line to send or receive data packets.
[0308] In one embodiment of the present application, if the network device is a hard disk, the network device can send or receive data packets via a SATA interface or an M.2 interface and corresponding communication protocol.
[0309] 2. The network device functions as a network USBkey device (such as a bank USB key, digital certificate, or dongle). The network device is configured as a USBkey and connected to a computer host. The network USBkey device contains: 1. a PIN password (the password is entered by the user or data collected and converted by a sensor), 2. an algorithm, and 3. a key. For a PIN password, the data entered by the user or collected and converted by a sensor can be sent to the server via the network to verify the PIN. For an algorithm, it can be remotely downloaded from the server using a script, meaning the algorithm can be updated or selected at any time. For a key, data on the key or its components (e.g., an encryption method combining a local key and a server-side key) can be stored on the server to improve security. Optionally, during interaction between the network device and the server, the server performs logging and behavior analysis, immediately blocking suspicious behavior and raising an alarm to prevent misuse of the USBkey.
[0310] 1. Important data such as PINs, algorithms, and keys do not need to be stored on the USBkey itself. Important data is downloaded from the server to the USBkey's memory during operation. For enhanced security, important data is deleted when the USBkey is powered off. 2. The server can log each time a user uses the USBkey to prevent misuse. For example, USB device virtualization technology allows USBkey data to be shared among multiple computers. 3. A lost USBkey can be remotely locked to prevent theft. 4. A satellite positioning module such as GPS or Beidou can be installed. The USBkey's geographic location is reported when a request is sent to the server. The USBkey can only be used if preset geographic location conditions are met. 5. The USBkey's data source is stored on the server, eliminating the need for a network communication link to pass through the host, ensuring data source security. 5. USBkey password input validation can be performed remotely via the client or server when used.
[0311] 3. A network device acts as an intermediate device (for example, a storage device with network capabilities). The computer host sends a read / write interaction command to the intermediate device. For example, it sends a command to read data from address 0, with the read data length being 512 bytes. It also sends a command to write data from address 1, with the write data being 0x1212... (512 bytes), with the data length being 512 bytes. After receiving the command, the intermediate device calculates the address, the number of bytes in one sector (for example, 512 bytes), and the data length, and converts the sector address of the data interaction command operation into an address corresponding to the server-side data (or the server side modifies it according to a preset rule based on the transferred data interaction command). For example, it converts it into a read / write operation for the U.dd file data on the server side. For example, it converts address 0 into the sector 0 address of the U.dd file data on the server side, and converts address 1 into the sector 1 address of the U.dd file data on the server side. After the conversion, it operates on the U.dd file data on the server side. For example, the data at address 0 of the U.dd file data on the server side is fed back, and data 0x1212... (512 bytes) is written to sector address 1.
[0312] It should be noted that the above application scenarios are used only as examples and are not limiting. In other scenarios, other hardware formats, such as input devices such as keyboards, may be used. The description here is omitted.
[0313] Please refer to FIG. 6. FIG. 6 is a schematic flowchart of a device connection method provided in one embodiment of the present application. Here, communication between a network device and a slave device employs the USB communication protocol. The device connection method of this embodiment is described using an example in which a network device (master mode) reads data from a slave device (e.g., a USB flash drive) via a USB interface. Note that this example and related data are not limiting. For example, the other target device (slave device) may be another device type, such as a USB camera. A detailed description is omitted here.
[0314] The client side creates (or saves) scenario configuration information for the "USB flash drive reading scenario" via the server side, or selects existing scenario configuration information for the "USB flash drive reading scenario." When the network device sends a request to the server side, the server side sends the scenario configuration information for the "USB flash drive reading scenario" to the network device.
[0315] In another embodiment of the present application, scenario configuration information can be created on the server side. The network device sends a configuration acquisition request to the server side. In response to the configuration acquisition request, the server side acquires scenario configuration information for the USB flash drive reading scenario from the server side and sends the acquired scenario configuration information for the USB flash drive reading scenario to the network device.
[0316] When a target device (i.e., a USB flash drive) is plugged into the interface of a network device, the USB flash drive sends an enumeration request (e.g., an electrical signal indicating that it can be enumerated) to the network device. The network device then sends a Get Hardware Descriptor command to the USB flash drive and sends an IN token packet to a specific endpoint of the USB flash drive to feed back the search data. For example, the network device sends a Hardware Descriptor command to endpoint 0 of the USB flash drive via a SETUP token packet.
[0317] In this embodiment, the network device, acting as a master device, actively sends a data interaction command to a slave device (e.g., a USB flash drive), and the slave device passively responds according to the data interaction command. Taking the USB communication rule as an example, the network device sends a token packet (or a token packet plus a data packet) to the slave device's endpoint, and the slave device responds (e.g., sends a data packet or a status packet back to the master device) according to the token packet (or the token packet plus a data packet) received at the endpoint. When the network device functions as a slave device, it receives a token packet (or a token packet plus a data packet) sent from the master device and responds according to the received token packet (or the token packet plus a data packet). Here, the token packet includes, but is not limited to, at least one of a SETUP token packet, an IN token packet, an OUT token packet, a PING token packet, and a SOF token packet. The status packet includes, but is not limited to, at least one of an ACK, a NAK, a NYET, and a STALL status packet. The handshake packet includes a token packet and a status packet. Table 4 is a parameter table for the command format of the SETUP token packet, where 0x in this application represents a hexadecimal coded value. JPEG2025528755000006.jpg25170
[0318] See Table 4. In one embodiment of the present application, the command format of the SETUP token packet includes a first type field of command (SETUP), a first address field (ADDR), a first endpoint field (ENDP), a first data field (DATA), and a first status field (ACK or NAK). Recording a SETUP command identifier in the first command type field indicates that the first command type is a SETUP token packet, and 0x2D is the identifier value. The first address field is for recording address information of the receiver of the SETUP token packet (i.e., the USB flash drive). For example, the USB bus address information of the recorded USB flash drive is 0x25. The first endpoint field is for recording endpoint information of the receiver of the SETUP token packet. For example, the endpoint information of the recorded USB flash drive is 0x00. The first data field (DATA) is for recording data packet data of the SETUP token packet. For example, the data in the DATA field is a command for obtaining a device descriptor. The first status field is for recording the status of the receiver (i.e., the USB flash drive) of the SETUP token packet. The status field includes an ACK status packet, a NAK status packet, etc., where the ACK status packet indicates the success status of the receiver, and the NAK status packet indicates the failure status of the receiver.
[0319] See Tables 5 and 6. In one embodiment of the present application, after receiving the ACK status packet sent by the USB flash drive in response to the SETUP token packet, the network device subsequently sends an IN token packet to the USB flash drive. In response to the IN token packet, the USB flash drive feeds back a hardware descriptor data packet of the USB flash drive to the network device.
[0320] If the network device sends an IN token packet to a specific endpoint of the slave device (USB flash drive) and receives a NAK status packet (0x5A) fed back from the USB flash drive, this indicates that the slave device (USB flash drive) cannot provide data, as shown in Table 5. As shown in Table 6, the network device repeatedly sends IN token packets to the USB flash drive (within the timeout determination period) until the USB flash drive feeds back the first ACK status packet. This description is omitted in this application. JPEG2025528755000007.jpg24170JPEG2025528755000008.jpg23170
[0321] See Table 6. In one embodiment of the present application, the command format of the IN token packet includes a second command type field (IN), a second address field (ADDR), a second endpoint field (ENDP), a second data field (DATA), and a second status field (such as ACK or NAK). The second command type field records an IN command identifier, which can take a value of 0x69 to indicate that the command type is an IN token packet. The second address field is for recording address information of the receiver of the IN token packet. For example, the USB bus address information of the recorded USB flash drive is 0x25. The second endpoint field is for recording endpoint information of the receiver of the IN token packet. For example, the endpoint information of the recorded USB flash drive is 0x00. The second data field is for recording data fed back from the receiver of the IN token packet (i.e., the USB flash drive). For example, the data in the DATA field is a device descriptor. The second status field is for recording the status of the receiver of the IN token packet. The second status field includes an ACK status packet, a NAK status packet, etc., where the ACK status packet indicates the success status of the receiver, and the NAK status packet indicates the failure status of the receiver.In one embodiment of the present application, the hardware descriptor data for the target device (slave device, e.g., a USB flash drive) includes at least a descriptor length indicator (e.g., 0x12), a device descriptor indicator (e.g., 0x01), a USB protocol version indicator (e.g., 0x00 0x02), a type code indicator (e.g., 0x00), a subtype code indicator (e.g., 0x00), a protocol indicator used by the device (e.g., 0x00), a maximum packet length indicator for endpoint 0 (e.g., 0x40), a manufacturer ID indicator (e.g., 0xff 0xff), a product ID indicator (e.g., 0x78 0x56), a device version number indicator (e.g., 0x00 0x02), a manufacturer string index indicator (e.g., 0x01), a product string index indicator (e.g., 0x02), a product serial number string index indicator (e.g., 0x03), and a configuration number indicator (e.g., 0x01).
[0322] After the network device receives the hardware descriptor data sent from the target device (slave device, such as a USB flash drive), it must send an OUT token packet to the target device according to the rules (e.g., rules controlling transmission) corresponding to the SETUP token packet, and then guide an empty data packet (see Table 7) to notify the target device (slave device) that the data has been successfully received. This description is omitted in this application. JPEG2025528755000009.jpg22170
[0323] See Table 7. In one embodiment of the present application, the command format of the OUT token packet includes a third command type field (OUT), a third address field (ADDR), a third endpoint field (ENDP), a third data field (DATA0 or DATA1), and a third status field (ACK, NAK, or NETY). The third command type field records an OUT command identifier, which can take a value of 0xE1 to indicate that the command type is an OUT token packet. The third address field is for recording address information of the receiver of the OUT token packet. For example, the USB bus address information of the recorded USB flash drive is 0x25. The third endpoint field is for recording endpoint information of the receiver of the OUT token packet. For example, the endpoint information of the recorded USB flash drive is 0x00. The third data field is for recording data fed back from the receiver of the OUT token packet. For example, the recorded data is empty. The third status field is for recording the status of the receiver of the OUT token packet. The third status field includes an ACK status packet, a NAK status packet, etc., where the ACK status packet indicates the success status of the receiver, and the NAK status packet indicates the failure status of the receiver.
[0324] See Table 8. The network device assigns an address to a slave device (such as a USB flash drive) by sending a device address setting command to the USB flash drive, and feeds back search data by sending an IN token packet to a specific endpoint of the slave device (such as a USB flash drive). For example, the network device sends a device address setting command to endpoint 0 of the USB flash drive via a SETUP token packet. In response to the device address setting command and the IN token packet, the USB flash drive feeds back a first ACK status packet of the USB flash drive to the network device. For example, the USB flash drive feeds back the first ACK status packet to the network device via endpoint 0. For example, the network device sends a SETUP token packet to endpoint 0 of the USB flash drive, and the data of the SETUP token packet (see the data in the DATA field in Table 9) is for setting the address. When the network device receives the first ACK status packet fed back from the USB flash drive, it indicates that the address of the USB flash drive has been successfully set. JPEG2025528755000010.jpg21170
[0325] The network device sends a get string descriptor command to the USB flash drive and an IN token packet to a specific endpoint of the USB flash drive to feed back the search data. For example, the network device sends a string descriptor command to endpoint 0 of the USB flash drive via a SETUP token packet. In response to the get string descriptor command and the IN token packet, the USB flash drive feeds back a string descriptor data packet of the USB flash drive to the network device.
[0326] For example, for data of handshake packets and data packets related to related descriptor acquisition commands, setting commands, descriptors, token packets, status packets, etc., refer to the above table, or refer to Table 1, Table 2, or other examples. Explanations thereof will be omitted in this application.
[0327] The network device sends a get configuration descriptor command to the USB flash drive and an IN token packet to a specific endpoint of the USB flash drive to feed back the search data. For example, the network device sends a get configuration descriptor command to endpoint 0 of the USB flash drive via a SETUP token packet. In response to the get configuration descriptor command and the IN token packet, the USB flash drive feeds back a configuration descriptor data packet of the USB flash drive to the network device. For example, the USB flash drive feeds back a configuration descriptor data packet to the network device via endpoint 0 (the configuration descriptor data packet typically includes a configuration descriptor, an interface descriptor, and an endpoint descriptor).
[0328] The network device sends a set configuration command to the USB flash drive to set configuration information of the USB flash drive, and sends an IN token packet to a specific endpoint of the USB flash drive to feed back search data. For example, the network device sends a set configuration command to endpoint 0 of the USB flash drive via a SETUP token packet. In response to the set configuration command and the IN token packet, the USB flash drive feeds back a second ACK status packet of the USB flash drive to the network device.
[0329] The network device determines whether the network device and the target device are successfully connected (or linked) based on the descriptor data fed back from the USB flash drive. If the network device determines that the USB flash drive connection has failed based on the first status response rule and the descriptor data fed back from the USB flash drive, it requests a new scenario configuration or a new command set from the server and reconnects. If the connection is successful, it proceeds to send a special request and exchanges data with the special request according to the acquired descriptor information. Furthermore, the network device analyzes and obtains the USB flash drive's descriptor information (such as interface descriptor and endpoint descriptor) to obtain the specific endpoint number and transmission mode for data transmission from the USB flash drive, and then continues sending commands to the USB flash drive. For example, based on the analysis of the acquired endpoint descriptor, it determines that endpoint 1 is an OUT endpoint and its transmission mode is bulk transmission. It sets endpoint 2 of the network device to an IN endpoint and its transmission mode to bulk transmission. Note that the endpoint numbers and endpoint functions of each device are different and are usually obtained through endpoint descriptors. The above endpoints 1 and 2 are examples and do not constitute limitations on the target device.
[0330] It determines whether the connection (or linkage, or handshake) between the network device (master device) and the target device (slave device), or between the network device (slave device) and the target device (as a slave device) is successful. This can be performed in the handshake phase (get descriptor command, setting configuration, etc.) or in the data exchange phase (read / write sector address command that meets preset, sending TEST detection command, etc.), but the description thereof will be omitted in this application.
[0331] The network device sends a Get MAXLUN Descriptor command (special command set) to the USB flash drive and sends an IN token packet to a specific endpoint of the USB flash drive to feed back the search data. For example, the network device sends a Get MAXLUN Descriptor command to endpoint 0 of the USB flash drive via a SETUP token packet. The USB flash drive feeds back the MAXLUN data packet of the USB flash drive to the network device in response to the MAXLUN descriptor command and the IN token packet. The USB flash drive feeds back MAXLUN data, such as 0x00, to the network device based on the IN token packet. For example, the USB flash drive feeds back the MAXLUN data to the network device via endpoint 0. Here, the MAXLUN data includes the maximum number of logical units.
[0332] The network device sends an INquiry command to the USB flash drive and an IN token packet to a specific endpoint of the USB flash drive to feed back the search data. For example, the network device sends an INquiry command to endpoint 1 of the USB flash drive via an OUT token packet and an IN token packet to endpoint 2. The USB flash drive feeds back the device information data packet of the USB flash drive to the network device in response to the get device information descriptor command and the IN token packet.
[0333] For example, the network device may send a command (e.g., a SCSI or SATA command such as a CBW data packet) to endpoint 1 of the target device to request device information (INquiry) data from the target device according to a preset scenario configuration. The target device responds to the "INquiry" read request and feeds back a first data packet (INquiry data packet) and a status packet (e.g., a SCSI or SATA command such as a CBW packet) to the network device.
[0334] See Table 9. The CBW packet includes information such as the CBW packet identifier, the CBW packet number, the number of transmitted bytes, the transmission direction, the logical unit of the operation, the length of the command block, the operation command code, and the operation command parameters. Here, the operation command code being 0x12 indicates that the network device (master mode) sends an "INquiry" data request command to the target device (slave device). JPEG2025528755000011.jpg32170
[0335] See Table 10. The first data packet (INQUIRY data) contains the following information: JPEG2025528755000012.jpg69170
[0336] See Table 11. The CSW status includes the CSW identifier, the CBW packet number, the number of remaining bytes, and the error code. JPEG2025528755000013.jpg23170
[0337] In the above, the data structures of the CBW command packet and the CSW status packet are explained based on the SCSI communication protocol, and explanations of other related contents of the present application will be omitted here.
[0338] The network device sends a get command for capacity information (e.g., maximum number of logical units, total number of formattable logical blocks, last logical block address, block capacity, etc.) or a get command for read / write status (MODESENCE6) to a specific OUT endpoint of the USB flash drive, and then sends an IN token packet to a specific IN endpoint of the USB flash drive to feed back the retrieved data. For example, the network device sends a get command for capacity information or a get command for read / write status to endpoint 1 of the USB flash drive via an OUT token packet, and sends an IN token packet to endpoint 2. The USB flash drive feeds back a data packet of the USB flash drive's capacity information or read / write status via endpoint 2.
[0339] In one embodiment of the present application, a network device sends a request to read the "total number of formattable logical blocks" (READ_FORMAT_CAPACITIES) to a specific OUT endpoint of a target device. For example, the network device sends a CBW packet to the target device (e.g., a USB flash drive), where the operation command code is 0x23, requesting to obtain the "total number of formattable logical blocks" of the target device (e.g., a USB flash drive). In response to the request to read the "total number of formattable logical blocks," the target device (e.g., a USB flash drive) feeds back a first data packet (e.g., Table 12) and a CSW status packet to the network device.
[0340] See Table 12. The first data packet (total number of formattable logical blocks) contains the following information: JPEG2025528755000014.jpg86170
[0341] In one embodiment of the present application, a network device sends a request to read the "last logical block address" (READ_CAPACITY) to a specific OUT endpoint of a target device. For example, the network device sends a CBW packet to the target device (e.g., a USB flash drive). The operation command code is 0x25, requesting to obtain the "last logical block address" data of the target device (e.g., a USB flash drive). In response to the request to read the "last logical block address," the target device (e.g., a USB flash drive) feeds back a first data packet (e.g., Table 13) and a CSW status packet to the network device.
[0342] See Table 13. The first data packet (last logical block address) contains the following information: JPEG2025528755000015.jpg64170
[0343] Note that the network device (master mode) can calculate capacity information using the "total number of formattable logical blocks" and the "last logical address block" separately, so there is no need to obtain both data simultaneously.
[0344] In one embodiment of the present application, a network device sends a request to read the "read-write status" (MODESENCE6) of a specific OUT endpoint of a target device. For example, the network device sends a CBW packet to the target device (e.g., a USB flash drive). The operation command code is 0x2A, requesting to obtain the "MODESENCE6" data of the target device (e.g., a USB flash drive). In response to the request to read "MODESENCE6," the target device (e.g., a USB flash drive) returns a first data packet (e.g., Table 14) and a CSW status packet to the network device. See Table 14. The first data packet (MODESENCE6) contains the following information: JPEG2025528755000016.jpg45170
[0345] The network device determines whether the network device is successfully connected to (or linked to) the target device based on at least one of the MAXLUN data packet, the device information data packet, the capacity information data packet, and the read / write status (MODESENCE6) data packet fed back from the USB flash drive. According to the first status response rule, the network device determines that the connection of the USB flash drive has failed and requests a new command set from the server side to reconnect. If the connection is successful, the network device sends a connection success status data packet to the server side and sends a connection success status data packet to the client side via the server side.
[0346] Please refer to Figure 7. Figure 7 is a schematic flowchart of a device connection method provided in another embodiment of the present application, where the communication between the network device and the slave device adopts the USB communication protocol, and for the network device (slave mode), the device connection method of this embodiment is described using the scenario of a USB flash drive as an example.
[0347] Note that this example and related data are not limiting, and other network devices (slave devices, slave mode) may be other device types, such as a USB camera scenario. A detailed description is omitted here. The data contents of the token packet, CBW packet, CSW packet, operation command, data packet, etc., related to this embodiment are similar to those in the embodiment in which the network device (master mode) reads a USB flash drive. In other words, in the master role and slave role, the device exchanges command data and response data and sets the response in the scenario configuration. A detailed description is omitted in this embodiment.
[0348] The client side creates scenario configuration information for a USB flash drive scenario, or selects existing scenario configuration information for a USB flash drive scenario. The network device sends a configuration acquisition request to the server side. Here, the configuration acquisition request includes the USB flash drive scenario. The server side acquires the scenario configuration information for the USB flash drive scenario from the client side in response to the configuration acquisition request, and sends the acquired scenario configuration information for the USB flash drive scenario to the network device (i.e., the USB flash drive).
[0349] The network device is set to slave mode according to the scenario configuration information, with the default endpoint 0 enabled and configured to control transmission.
[0350] When a target device (master device) is plugged into the interface of a network device (eg, a USB flash drive), an enumeration request (eg, an electrical signal indicating that it can be enumerated) is sent to the target device.
[0351] The target device sends a get hardware descriptor command to a specific endpoint of the network device and sends an IN token packet to the specific endpoint of the network device to feed back the search data. For example, the target device sends a hardware descriptor command to endpoint 0 of the network device via a SETUP token packet. In response to the get hardware descriptor command and the IN token packet, the network device feeds back a hardware descriptor data packet of the USB flash drive to the specific endpoint of the target device. For example, the network device feeds back a hardware descriptor data packet of the network device (e.g., a USB flash drive) to the target device via endpoint 0. The hardware descriptor data packet of the network device (e.g., a USB flash drive) includes at least the device type and device functions of the USB flash drive.
[0352] The target device assigns an address to the network device by sending a device address setting command to a specific endpoint of the network device, and feeds back the search data by sending an IN token packet to the specific endpoint of the network device. For example, the target device sends a device address setting command to endpoint 0 of the network device via a SETUP token packet. The network device performs the address setting operation in response to the device address setting command, and feeds back a third ACK status packet of the USB flash drive to the target device in response to the IN token packet. For example, the network device feeds back a first ACK status packet to the target device via endpoint 0. The first ACK status packet indicates whether the address of the network device has been successfully assigned.
[0353] The target device sends a get string descriptor command to a specific endpoint of the network device, and sends an IN token packet to the specific endpoint of the network device to feed back the search data. For example, the target device sends a string descriptor command to endpoint 0 of the network device via a SETUP token packet. In response to the get string descriptor command and the IN token packet, the network device feeds back a string descriptor data packet of the USB flash drive to the target device. For example, the network device feeds back the string descriptor data packet to the network device via endpoint 0.
[0354] The target device sends a get configuration descriptor command to a specific endpoint of the network device and an IN token packet to feed back the search data. For example, the target device sends a get configuration descriptor command to endpoint 0 of the network device via a SETUP token packet. In response to the get configuration descriptor command and the IN token packet, the network device feeds back a configuration descriptor data packet for the USB flash drive to the target device. For example, the network device feeds back the configuration descriptor data packet to the target device via endpoint 0.
[0355] The target device sends a configuration setting command to a specific endpoint of the network device to set configuration information for the network device, and sends an IN token packet to the specific endpoint of the network device to feed back search data. For example, the target device sends a configuration setting command to endpoint 0 of the network device via a SETUP token packet. The network device performs a setting operation according to the configuration setting command. For example, it enables the corresponding transmission endpoint according to the descriptor data selected in the setting command, and feeds back a second ACK status packet of the USB flash drive to the target device in response to the IN token packet. For example, the network device feeds back a second ACK status packet to the network device via endpoint 0. The network device performs configuration enablement according to the above command or scenario configuration. For example, it enables a specific endpoint (e.g., endpoint 1) in the network device and sets it as an OUT endpoint, and sets the transmission mode of OUT endpoint 1 to bulk transmission. It sets a specific endpoint (e.g., endpoint 2) in the network device as an IN endpoint, and sets the transmission mode of IN endpoint 2 to bulk transmission.
[0356] The network device determines whether the network device and the target device are successfully connected (or linked) according to the command fed back from the target device and the second status response rule. If the command sent from the target device does not meet the preset device requirements specified in the second status response rule, it determines that the network device connection has failed and requests a new descriptor set from the server side to reconnect. If the command fed back from the target device meets the preset device requirements specified in the second status response rule, it determines that the connection has succeeded and proceeds to the data exchange process of the special request.
[0357] In the data exchange process of the special request, the target device sends a MAXLUN descriptor acquisition command to a specific endpoint of the network device, and sends an IN token packet to the specific endpoint of the network device to feed back the search data. For example, the target device sends a MAXLUN descriptor command to endpoint 0 of the network device via a SETUP token packet. In response to the MAXLUN descriptor command and the IN token packet, the network device feeds back a MAXLUN data packet of the network device (e.g., a USB flash drive) to the target device.
[0358] The target device sends a get device information descriptor command to the network device and sends an IN token packet to a specific endpoint of the network device to feed back the search data. For example, the target device sends a get capacity information descriptor command to endpoint 1 of the USB flash drive via an OUT token packet. The network device feeds back a capacity information data packet of the USB flash drive via endpoint 2 in response to the get capacity information descriptor command and IN token packet. The target device sends a get capacity information descriptor command to a specific endpoint of the network device and sends an IN token packet to a specific endpoint (e.g., endpoint 2) of the network device to feed back the search data. For example, the target device sends a get capacity information command (such as the maximum number of logical units, the total number of formattable logical blocks, the last logical block address, and block capacity) or a read / write status to endpoint 1 of the USB flash drive via an OUT token packet. The network device feeds back a capacity information or read / write status data packet of the network USB flash drive via endpoint 2 in response to the capacity information command and IN token packet.
[0359] The target device sends a get read / write status (MODESENCE6) command to the network device and sends an IN token packet to a specific endpoint of the network device to feed back the search data. For example, the target device sends a get MODESENCE6 command to endpoint 1 of the network device via an OUT token packet. In response to the MODESENCE6 command and IN token packet, the network device feeds back a MODESENCE6 data packet of the network device (USB flash drive) via endpoint 2.
[0360] The network device determines whether the network device and the target device are successfully connected (or coupled) according to the command sent from the target device and the second interface status rule. According to the first status response rule, the network device determines that the target device has failed to connect to the network device (USB flash drive), and requests a new descriptor set from the server side to reconnect. If the connection is successful, the network device sends a connection success status data packet to the server side, and sends a connection success status data packet to the client side via the server side.
[0361] Note that the data such as descriptors, capacity information, read / write status, etc. that the network device above feeds back to the target device (master device) as a slave device are set in advance in the scenario configuration (USB flash drive).
[0362] In one embodiment of the present application, when the network device functions in a peer-to-peer communication mode, after starting up the network device and selecting a scenario, the third device connection configuration information is read from the scenario configuration information.
[0363] After starting up the network device and selecting a scenario, the third mode, third interface type, interaction data set, third status determination rule, and third status response rule of the third device connection configuration information field are obtained. According to the third mode, the operation mode of the network device is set to a peer-to-peer communication mode. According to the third interface type, two physical communication interfaces of the network device are selected as a transmitting data interface and a data receiving interface. Here, the transmitting data interface of the network device is connected to the data receiving interface of the target device, and the receiving data interface of the network device is connected to the data transmitting interface of the target device.
[0364] The network device transmits data to the target device through a data transmission interface (TX) based on the rules of the interaction data set, receives data fed back from the target device through a data receiving interface, and receives data sent from the target device through a data receiving interface (RX) based on the rules of the interaction data set, and feeds back data to the target device through a transmission data interface.
[0365] If the data sent from the target device meets the preset connection success condition specified in the third connection status determination rule, the network device determines that the handshake connection has been successfully established and sends a connection success data packet to the server side according to the third status response rule.If the data fed back from the target device meets the preset connection failure condition specified in the third connection status determination rule, the network device determines that the handshake connection has failed and sends a connection failure data packet to the server side according to the third status response rule to request data such as a new interaction data set, and reconnect or wait for the target device to connect.
[0366] Please refer to Figure 8. Figure 8 is a schematic diagram of a flowchart of a device connection method provided in an embodiment of the present application. The method according to the embodiment of the present application is applicable to a network device, which stores scenario configuration information for at least one application scenario. Examples of the network device include devices such as a single-chip microcomputer or embedded device with a network function, an in-vehicle device, a terminal device such as a smartphone, a tablet, or a laptop, a network USB key device (e.g., a bank USB key, a digital certificate, a dongle, etc.), a network proxy control device (e.g., a multi-port transponder), a remote controller (a network read / write control device, including but not limited to a network controller (e.g., a router, a smart gateway, etc.)), a communication device (Communication Device Class, CDC, e.g., a network card, a modem, an ISDN (Integrated Services Digital Network) terminal), a human interface device (HID, e.g., a keyboard, a mouse, etc.), a mass storage device (Mass Storage Device Class, MSC, e.g., a USB flash drive, a network USB flash drive, a card reader, a network card reader), a printer device (e.g., a printer with a USB interface), a still imaging device, a video device, etc. This includes, but is not limited to, USB devices, Audio / Video devices, Smart Card devices, Universal Serial Bus Hubs, and custom devices.
[0367] As shown in FIG. 8, the device connection method of this embodiment includes steps S301 and S302. In step S301, when communicating with a server side, target configuration information is pre-loaded, and the server side stores a plurality of preset configuration information, the target configuration information being one of the plurality of preset configuration information, and the target configuration information includes scenario configuration information of a network device in at least one application scenario, the scenario configuration information including at least one of a first descriptor set and a descriptor command set, and the first descriptor set is for defining a device type of the network device.
[0368] In step S302, to connect the network device to a target device, a communication connection with the target device is established based on target scenario configuration information, where the target scenario configuration information is one of the scenario configuration information.
[0369] In one embodiment of the present application, the scenario configuration information is scenario configuration information generated after the network device sets at least one of the first descriptor set and the descriptor command set, and data source configuration information, in accordance with a preset generation policy, and the preset generation policy includes at least one of a custom creation policy, a template creation policy, or a creation policy imported from outside.
[0370] Please refer to Figure 9. Figure 9 is a schematic flowchart of a device connection method provided in an embodiment of the present application. As shown in Figure 9, the device connection method of this embodiment includes step S701: In step S701, to connect the network device to a target device, a communication connection with the target device is established based on target scenario configuration information, the target scenario configuration information being one of the scenario configuration information, the scenario configuration information including at least one of a first descriptor set and a descriptor command set, the first descriptor set for defining a device type of the network device.
[0371] In this embodiment, the device connection process is the same as that of the embodiment shown in Figure 1, and for the description of this step, please refer to the relevant description of the embodiment shown in Figure 1. Here, the description will be omitted. Note that in this embodiment, the target scenario configuration information is stored in the local storage space of the network device without being obtained from the server side, which further improves the device connection efficiency and limits the functional scope of the network device.
[0372] Please refer to Figure 10. Figure 10 is a schematic diagram of a flowchart of a data exchange method provided in an embodiment of the present application. The method according to the embodiment of the present application is applicable to a network device, which establishes a communication connection between a server side and a target device by the above-mentioned device connection method. The network device may be a device such as a one-chip microcomputer or an embedded device having a network function, a terminal device such as a smartphone or a laptop, a network USB key device (e.g., a bank USB key, a digital certificate, a dongle, etc.), a network proxy control device (e.g., a multi-port transponder, etc.), a remote controller (a network read / write control device, including but not limited to a network controller (e.g., a router, a smart gateway, etc.)), a communication device (Communication Device Class, CDC, e.g., a network card, a modem, an ISDN (Integrated Services Digital Network) terminal), a human interface device (HID, e.g., a keyboard, a mouse), a mass storage device (Mass Storage Device Class, MSC, e.g., a USB flash drive, a network USB flash drive, a card reader, a network card reader), a printer device (e.g., a printer with a USB interface), a still imaging device, a video device, etc. This includes, but is not limited to, USB devices, Audio / Video devices, Smart Card devices, Universal Serial Bus Hubs, and custom devices. 10 shows the data exchange method of this embodiment. The method includes steps S801 to S802, which will be described in detail below.
[0373] Step S801: Obtain a data exchange request sent from a first target party.
[0374] Step S802: Respond to the data exchange request according to a preset processing policy, and feed back target data to a first target party. The target data is data sent from a second target party. Wherein, if the first target party is a server side, the second target party is the target device. If the first target party is the target device, the second target party is the server side.
[0375] In one embodiment of the present application, the data exchange request is a request for data exchange between a network device and a target device, and includes a first exchange request sent from the network device and a second exchange request sent from the target device. The preset processing policy is a policy for processing the data exchange request, including, but not limited to, a first policy based on processing locally on the network device and a second policy based on forwarding the data exchange request to a server side.
[0376] In one embodiment of the present application, when a network device functions as a master device, it supports connection to multiple slave devices and further supports data exchange with multiple slave devices. When a network device functions as a slave device, it supports connection to multiple master devices and further supports data exchange with multiple master devices. This embodiment connects the network device, the server side, and the target device via the device connection method of the embodiment shown in FIG. 1, FIG. 8, or FIG. 9, so that the network device takes on different interaction roles and interaction processes in different data exchange scenarios. This enables the network device to exchange data in multiple application scenarios, improving the scenario applicability of the network device.
[0377] In one embodiment of the present application, the network device functions in master mode and obtains the endpoint information (e.g., endpoint 1 is IN and endpoint 2 is OUT) of the target device (USB slave device) using a descriptor get command. The network device sends a command request for a command search operation to the server side via the network interface and waits for the server side to send an interaction command. When the interaction command is searched, the network device downloads an interaction command set for the interaction operation. For example, suppose you need to send data A1 to the target device and receive data fed back from the target device. The network device sends the A1 data to endpoint 2 (OUT) of the target device and sends an IN token packet to endpoint 1 (IN) to feed back the searched data. After receiving a DATA data packet A2 from endpoint 1, the network device uploads it to the server side.
[0378] In one embodiment of the present application, the network device operates in slave mode and enables the endpoint number, transmission direction, and transmission mode of the corresponding endpoint (e.g., endpoint 1 is an IN endpoint and bulk transmission mode, and endpoint 2 is an OUT endpoint and bulk transmission mode) based on endpoint-related information (e.g., interface descriptor, endpoint descriptor, etc.) in the scenario configuration, and waits for the computer host to send interaction command data to the above two ports. The network device receives A1 data sent from the computer host to endpoint 2 (OUT). The network device uploads the A1 data to the server side through the network interface. The server side analyzes the A1 data and waits for the network device to download the A2 data. The network device downloads the A2 data through the network interface. When the computer host sends an IN token packet to endpoint 1 (IN) of the network device, a DATA data packet A2 is fed back to the computer host.
[0379] In one embodiment of the present application, the network device has both a slave mode and a master mode. The target device includes at least one first target device and at least one second target device, and the network device functions as a master device communicating with the first target device and as a slave device communicating with at least one second target device. Here, when the first target party is the server side, the second target party is the first target device or the second target device. When the first target party is the second target device, the second target party is the server side or the first target device.
[0380] Specifically, in slave mode (e.g., interface 1), the network device enables a first endpoint (e.g., endpoint 1) as IN and a second endpoint (e.g., endpoint 2) as OUT based on endpoint-related information (e.g., interface descriptor, endpoint descriptor, etc.) in the scenario configuration, and waits for target device 1 (computer host) to send interaction command data to the above two ports via interface 1. Meanwhile, in master mode (e.g., interface 2), the network device sends a get descriptor command via interface 2 to obtain endpoint information (e.g., endpoint 1 is IN, endpoint 2 is OUT) of target device 2 (USB device). Interface 1 of the network device receives A1 data sent from target device 1 to endpoint 2 (OUT) of the network device. The network device sends A1 data to endpoint 2 (OUT) of target device 2 via interface 2 and sends an IN token packet to endpoint 1 (IN) to feed back the search data. When interface 2 of the network device receives DATA data packet A2 from endpoint 1 of target device 2, the DATA data packet A2 is fed back to target device 1 via endpoint 1 of interface 1 of the network device. The network device downloads preset rules from the server side via the network interface, and detects interactions between the A1 data and the A2 data, thereby uploading the data to the server side, downloading data from the server side to replace or modify the A1 data or the A2 data, or blocking communication of the target device 1 or the target device 2.
[0381] In addition, the embodiment of the present application can solve at least the following problems.
[0382] Capacity issue: Take the network USB flash drive scenario (slave device) as an example, in the existing data exchange, all files on the server side (for example, a 4GB file called test.avi) are first downloaded to the USB flash drive, and then the computer reads the test.avi data from the USB flash drive.
[0383] The data exchange method of the present application directly transfers request or corresponding data packets during the download process, requiring only a small amount of data buffer storage space. For example, if each sector is 512 bytes, a single 512-byte memory buffer is configured. When the computer host reads the first sector address data of the file test.avi, the network device transmits a read command to the server, downloads the first sector address data from the server, stores it in the memory buffer, and transfers the data in the memory buffer zone to the computer host. As the computer host continues to read the second and even last sector addresses of the file test.avi, the memory buffer is continuously updated, and data is exchanged between the server and the computer host, enabling the transfer of a 4GB file with a 512-byte storage capacity. The size of the transferred file is not limited by the storage capacity of the network device itself. Conversely, for example, if the network device uses a network read / write control device to read and write test.avi from a USB flash drive, it can upload test.avi to the server using a 512-byte memory buffer zone.
[0384] The above is just an example. Different file systems may have different read and write methods, or may manage multiple sectors as a cluster, but these all apply to these basic data exchange rules. In the actual exchange process, requests for multiple sectors may be consolidated and processed to improve transfer efficiency. For example, the cache space may be 128 x 512 bytes, and data may be exchanged in 128 sectors at the same time. We will not go into detail here.
[0385] Problems with function expansion: Taking a network read / write control device (master device) as an example, with existing technology, a device acting as a master device can only first install program software (e.g., drivers, analysis programs, etc.) with interaction commands on the device. Only when there is a local device with a driver can it control a connected device. Therefore, to control the target device, the driver must be installed in advance, preventing device functions from being easily expanded.
[0386] Using the network device data exchange technology of the present application, interaction commands can be downloaded in real time by the server. Take, for example, a network device connecting a standard USB flash drive (with software installed) and a special camera (without software installed). When the USB flash drive is connected, the device itself has the USB flash drive read / write program (functional command set) installed, allowing it to directly read and write to the USB flash drive. When a camera is connected, the device does not have the special camera's functional command set, so it cannot identify the acquired descriptor and cannot complete enumeration. Therefore, the acquired descriptor is sent to the server. After the server identifies the camera, it sends the relevant functional command set (such as obtaining the descriptor and verifying the command), and the device re-enumerates the camera and establishes a connection according to the functional command set. The server then directly sends a command to read data from the special camera to the network device, which then forwards the command to the special camera. After the camera returns data, the network device can either directly display the camera's screen or forward the screen data to the server, where it can be saved or shared.
[0387] Security issues: The data buffer zone of the network device and downloaded function command data can be stored in memory. There is no need to store data in the device itself, and data will be lost after power is turned off. This can protect important data from theft.
[0388] In some embodiments, based on the embodiment shown in FIG. 10, step S802 includes: In response to the data exchange request, forwarding the data exchange request to a second target party; receiving target data fed back by the second target party in response to the data exchange request, and forwarding the target data to the first target party.
[0389] In one embodiment of the present application, the network device forwards and processes the data exchange request based on a second policy for forwarding the data exchange request to the server side.
[0390] In one embodiment of the present application, when a network device receives a data exchange request sent from a target device, the network device forwards the data exchange request to a server side, and the server side analyzes and processes the data exchange request and feeds back the target data to the network device, which then feeds back the target data to the target device.
[0391] In one embodiment of the present application, the network device is a network USBkey device, the target device is a computer host, and the response to the data exchange request is to forward the data exchange request to a second target party, including forwarding the data exchange request to a server side in response to the data exchange request sent by the computer host. The data exchange request includes authentication information of the USBkey device (the authentication information can be obtained from user input or sensor collection and conversion) so that the server side can verify the authentication information. Here, the authentication information includes, but is not limited to, a PIN text password and biometric information. The biometric information includes, but is not limited to, fingerprint information, iris information, face information, voiceprint information, etc. Note that for a description of the implementation principle of the network USBkey device, please refer to the relevant description of the network USBkey device in the device connection method above. A detailed description is omitted here.
[0392] In one embodiment of the present application, when a user operates a network device to send a data exchange request, the data exchange request is first sent to the server side for analysis and processing. The server side then feeds back the target data to the network device, and the network device feeds back the target data to the target device. Exemplarily, the network device functions as a keyboard device, and the keyboard device is connected to a computer host in a slave role. When a user presses a key (e.g., key A) on the keyboard device at the front end or server side of the computer to input "A" on the computer host, the data exchange request triggered by pressing key A is sent to the server side. The server side identifies the key value "A" corresponding to key A and feeds back the key value "A" to the keyboard device. When the target device (computer) scans the keyboard input, the keyboard device sends the key value "A" to the computer host. This can be used as a remote keyboard input scenario. When a user remotely inputs a confidential string (e.g., a password) into a computer host, security is improved because there is no need to communicate the confidential string to on-site personnel for input. It should be understood that the above key values are used only as examples and are not limiting, and the keyboard device can also be applied to a scenario in which a process is performed using a preset process script, and the description thereof will be omitted here.
[0393] In one embodiment of the present application, the network device functions as a network proxy control device, is connected to the printer via a master roll, and receives print-ready data sent from a computer host. If the print-ready data needs to be optimized (for example, to enhance the image data to improve the print quality of the image), the network device sends the print-ready data to the server side for optimization processing, receives optimization data fed back from the server side, and sends the optimized data to the printer for printing. It should be understood that the above image data is used only as an example and is not limited thereto, and other data may be used in other embodiments.
[0394] In one embodiment of the present application, data processing is performed on the server side via request forwarding, thereby reducing the hardware load on the network device, thereby enabling some network devices with low computing power to process data with high computing power, realizing high-level functionality in network devices with low-level functions, and improving the advanced application extension of network devices, while at the same time preventing high-level function programs from being reverse-engineered, cracked, or exploited locally.
[0395] In one embodiment of the present application, based on the embodiment shown in FIG. 10, the step S802: Processing data for the data exchange request based on a preset processing script, and obtaining a data processing result; sending a targeted data retrieval request to the second targeted party based on the processing result of the data; receiving target data corresponding to a result of processing the data fed back by the second target party in response to the data exchange request, and feeding back the target data to the first target party.
[0396] In one embodiment of the present application, the preset processing script is a script program that integrates data processing logic, allowing the network device to process data locally and execute data logic without transferring all data to the server side for execution, and interact with the server side only when a specific condition is triggered, thereby improving the efficiency of data processing.
[0397] In one embodiment of the present application, the network device functions as a mass storage device (slave role) and processes data exchange requests based on a preset processing script. For example, if the network device identifies that the data exchange request sent from the computer host indicates that the file name to be read is test.txt (i.e., the data processing result), it requests the server side to read the test.txt file data, downloads the test.txt file data (i.e., the target data) sent from the server side, and feeds the test.txt file data back to the computer host. Similarly, in a data writing process, when the computer host writes the test.txt file, the network device uploads and stores the test.txt file to the server side, while other files are normally stored locally.
[0398] In one embodiment of the present application, a network device functions as a network read / write control device (master role) with built-in storage media. It stores and executes common or open-source interaction command processing logic on the local storage media, thereby improving data exchange speed. Special commands are stored on the server side and remotely loaded from the server side according to actual needs, preventing the special command interaction logic from being reverse-analyzed on the local terminal and ensuring data exchange security. Based on a preset script, the device searches for data on connected mass storage devices (e.g., USB flash drives). For example, it searches for files named test.txt or files whose first byte in the first sector is 0xFF, and automatically uploads the searched file data to the server side.
[0399] In one embodiment of the present application, when a network device functions as a master, the network proxy control device reads the descriptor based on a preset script to identify the vendor ID, product ID, device type (used type, subtype, interface instruction set, endpoint transmission mode), etc. of the connected device. To protect the security of the server or control side, remote mapping is permitted only if the connected target device meets the vendor ID, product ID, or device type conditions.
[0400] In one embodiment of the present application, a network device functions as a master network intermediate control device based on a preset script or a downloaded script. The script is a set of AI models or algorithms. When the device is connected to an audio device and a computer host, an audio optimization enhancement algorithm is switched to optimize the audio data sent from the computer host to the audio device and enhance the sound playback effect of the audio device. When the device is connected to a camera and a computer host, an AI image recognition model is switched to process the image data sent from the camera to the computer host, enabling object marking and other functions.
[0401] In one embodiment of the present application, the mass storage device, the network read / write control device, the network proxy control device, and the network intermediate control device are also applicable to a request forwarding scenario, rather than being processed locally using a preset processing script. For data exchange between other types of devices, please refer to the description of the relevant example of the device connection method above. Here, the description is omitted.
[0402] Please refer to Figure 11. Figure 11 is a flowchart of a data interaction method in another embodiment of the present application. The data interaction method includes steps S1101 and S1102, In step S1101, scenario configuration information for communication between a network device and a target device is set, and the scenario configuration information includes an automatic execution script.
[0403] In step S1102, a first data exchange request is sent to the target device based on the automatic execution script, and data sent from the target device in response to the first data exchange request is received, or a second data exchange request is received from the target device based on the automatic execution script, and data is sent to the target device in response to the second data exchange request.
[0404] In one embodiment of the present application, when the network device receives the data transmitted by the target device in response to the first data exchange request, the network device transmits the data transmitted from the target device to the server side.
[0405] In one embodiment of the present application, during the process of exchanging data with the target device, the network device can exchange data with the target device based on a local data module (e.g., a memory chip module, a camera module) of the network device, or exchange data with the target device based on a data source provided by the client side or the server side, according to the preset configuration of the data exchange configuration information.
[0406] The following describes the data exchange method in this embodiment when the network device is in master mode.
[0407] After starting up the network device and selecting a scenario, the network device is configured according to the data exchange configuration information in the scenario configuration information. If the data exchange configuration information includes an automatic command execution script (e.g., an automatic data interaction command transmission script), the network device automatically sends a command to the target device according to the contents of the automatic command execution script. If the data exchange configuration information includes a data source command set and a data exchange command set, the network device sends a command to the target device according to the data source command set and the data exchange command set. After sending the command to the target device, the network device waits for and receives data in response from the target device.
[0408] In one embodiment of the present application, the data to which the target device responds may be a data packet of a command request or a status packet of the command execution result. After receiving the response data from the target device, if it is determined that the command has not been executed and that the command is a high-level command, for example, if the command is a combination of multiple low-level commands or an automatic execution script of the command (e.g., an automatic transmission script of a data interaction command), the response data is identified according to the rules of the high-level command and a preset command in the high-level command is subsequently sent. If it is determined that the command has been executed, the response data can be stored in a local storage medium (e.g., a memory chip, a hard disk, etc.) of the network device, or the response data of the target device can be sent to the server side and the client side according to the preset rules of the command.
[0409] In one embodiment of the present application, the network device feeds back data to the server side and the client side according to at least one of the data source command set, the data exchange command set, the bound interactive system or the data source in the data exchange configuration information. The data fed back from the network device may be the original data (e.g., the original data packet) responded by the target device, or may be the data processed according to the preset rule of the command in the data exchange configuration information (e.g., converting the status packet into a specific mark).
[0410] In one embodiment of the present application, based on the permitted / prohibited data exchange policy in the data exchange configuration information, the network device identifies the parameter contents of commands sent from the client side and the server side. For example, the network device identifies the operation type (e.g., read / write type) and operation target (e.g., specific sector address) in the commands sent from the client side and the server side to the network device. In addition, the network device can restrict commands with specific parameter contents, such as commands that prohibit write operations or commands that prohibit operations with a sector address of 0x00.
[0411] In one embodiment of the present application, according to the allow / prohibit data exchange policy, the network device can identify the contents of the data packets of the received command or response command, for example, the write data packets in the write command sent from the client side and the server side, or the data packets fed back in response to the read command, are determined and identified according to the hash value of the data packet or the byte value at a specific position.
[0412] In another embodiment of the present application, the peripheral module data and the command parameters or data packet contents can be combined for identification and determination. For example, the peripheral module data can be the specific location area of a GPS positioning module or the IP address of a network module. If the command or response data meets a preset rule, the network device operates the command or response data according to an allow / prohibit exchange policy (e.g., whether the network device forwards or does not forward a command sent from the client or server side, or whether the network device forwards or does not forward a data packet in which the target device responds to the client or server side).
[0413] Furthermore, in one embodiment of the present application, the data and command parameters of the peripheral module or the contents of the data packet can be combined and determined, for example, a command to read a sector at a specific location can be executed on the target device only if the GPS position of the GPS positioning module is at a specific location.
[0414] The data exchange method in this embodiment will be described below by taking reading and writing to a USB flash drive (scenario) by a network device (master mode) as an example.
[0415] Step S1101 further includes setting data exchange configuration information for a scenario in which a USB flash drive is read. Specifically, when setting the data exchange configuration information, one or more commands in a data source command set are set, such as the maximum number of logical units, obtaining the number of formattable blocks, obtaining the last logical block address, obtaining block capacity, and read / write status. One or more commands in a data exchange command set, such as a USB communication protocol command, a SCSI transparent command set command, and a file operation command, are set. One or more commands in a binding policy of an interactive system or a data source, such as a binding relationship between an operation command on the server side or client side and a preset command of a network device, are set. One or more commands in a binding policy of an interactive system or a data source are set. For example, if the location data in the positioning module is not located in a specific location area, the client side and the server side are prohibited from sending a "file operation command" command to the target device to delete the "test.txt" file under the root directory.
[0416] In one embodiment of the present application, after the network device and the target device are successfully enumerated, step S1102 includes the network device executing a "file directory reading script" to automatically read the boot sector data (usually sector address 0x00) of the target device and analyze the boot sector address of the file system, reading the file system boot sector address data and analyzing related parameters such as the sector address and cluster (block) size of the root folder (or first directory), and reading the sector address data of the root folder to analyze file information. The network device processes the file information data according to the rules of "interactive system or data source binding" and sends the processing result to the client side or server side. As a result, the corresponding file information is displayed in the interactive interface of the client side or server side (similar to the display of the root directory when a USB flash drive is connected to a computer).
[0417] In one embodiment of the present application, the network device reads addresses of multiple sectors according to the protocol rules of the file system based on the automatic execution script of commands in the interaction command set, analyzes the file directory and file data based on the read data, and stores the file directory and file data locally, on the server side, or on the client side of the network device. For example, as shown in FIGS. 12 and 13, the network device sends sector address read command data to a specific endpoint of the target device and a specific endpoint data obtain command. For example, the network device sends sector address read command data (e.g., a SCSI or SATA CBW packet) to endpoint 1 of the target device via an OUT token packet and a endpoint data obtain command to endpoint 2 of the target device via an IN token packet. The target device feeds back a data packet corresponding to the sector address to the network device in accordance with the sector address read command data and the endpoint data obtain command. The network device analyzes the file directory and file data based on the read data. Here, the file directory includes at least one of a file name, a file attribute, and a starting address of the file. The network device then sends the file directory and file data to the server side. The server side transmits the file directory and file data to the client side, so that the file directory and file data are displayed on the interactive interface of the client side.
[0418] In one embodiment of the present application, a network device is set to master mode based on scenario (connection) configuration information and performs data interaction with a target device according to the automatic execution script of a command in the data exchange configuration information. The network device obtains data interaction endpoint information of the target device (USB device) by obtaining a descriptor command from the scenario (connection) configuration information. The network device sends a command request for a command search operation to the server side via the interface and waits for the server side to send an interaction command. Once the interaction command is searched, the network device downloads an interaction command set for the interaction operation. After receiving the interaction command set, the network device sends command data to the target device (within a timeout determination period) based on the automatic execution script of the command in the interaction command set in accordance with the USB communication protocol and mass storage device rules, and continuously sends token packets to request data from the IN endpoint until the IN endpoint returns data or returns an ACK status packet.
[0419] For example, as shown in FIG. 12, the network device sends command data and a get endpoint data command to the target device. For example, the network device sends command data to endpoint 1 of the target device via an OUT token packet and sends a get endpoint data command to endpoint 2 of the target device via an IN token packet. If no data is fed back or if preparations for feeding back data are not complete, the target device feeds back a NAK status packet to the network device in response to the command data and the get endpoint data command. Here, the NAK status packet indicates that there is no data. The network device repeatedly sends the get endpoint data command to the target device in response to the NAK status packet until it receives sector data and an ACK status packet fed back from the target device.
[0420] In one embodiment of the present application, the network device and the target device can interact with each other through sector read and write operations.
[0421] Specifically, the client and server send sector read / write operation commands (e.g., read or write commands for specific sector addresses in SCSI, SATA, etc., CBW packets, etc.) to the network device. The network device then analyzes the sector read / write operation commands sent by the client and server according to the "interactive system or data source binding" command rules and sends sector read / write operation commands to the target device according to preset commands in the "data exchange command set" (e.g., SCSI transparent instruction set commands). The sector read / write operation commands include: when a read command is sent to the target device (e.g., to read data from a specific sector), the target device returns a data packet and a status packet at a specific sector address in the data storage space; when a write command is sent to the target device (e.g., to write a command and data packet for a specific sector), the target device writes a data packet to a specific sector address in the target device's data storage space, and the target device returns a status packet. After receiving the data packet or status packet, the network device responds to the client or server according to the "interactive system or data source binding" command rules.
[0422] Specifically, as shown in FIG. 14A, a network device (master device) sends a command (including a token packet and a CBW packet) to a target device (slave device, e.g., a USB flash drive). Taking the SCSI protocol as an example, 0x28 represents a READ (10) command requesting the reading of sector address data. The command further includes an operation sector address of 0x00000000 and an operation sector count of 0x0001. Upon receiving the command, the target device (slave device) responds to the master device with a data packet (DATA packet) and a status packet (CSW packet). See FIG. 14B. As shown in FIG. 14B, this is a multiple sector continuous read command, and the operation sector count of the network device (master device) is 0x0002. Upon receiving the command, the target device (slave device) responds to the master device with two data packets (DATA packet) and a status packet (CSW packet).
[0423] Specifically, as shown in FIG. 14C, a network device (master device) sends a command (including a token packet and a CBW packet) to a target device (slave device, for example, a USB flash drive). Taking the SCSI protocol as an example, 0x2A represents a WRITE (10) command requesting data to be written to a sector address. The command further includes a data packet (DATA packet). After receiving the command and data packet, the target device (slave device) performs the operation and responds to the master device with a status packet (CSW packet). See FIG. 14D. As shown in FIG. 14D, this is a continuous write command for multiple sectors. The number of operation sectors of the network device (master device) is 0x0002. The command also includes two data packets (DATA packets). After receiving the command and two data packets, the target device (slave device) performs the operation and responds to the master device with a status packet (CSW packet).
[0424] Note that to avoid duplication, the relevant parameters of the read and write commands are abbreviated elsewhere in this application.
[0425] Please refer to FIG. 15. As shown in FIG. 15, in one embodiment of the present application, the client side transmits sector address read command data to the server side. The server side transmits the received sector address read command data to the network device. The network device transmits the sector address read command data (e.g., a SCSI CBW packet) to a specific OUT endpoint (e.g., endpoint 1) of the target device via an OUT token packet, and transmits an endpoint data obtain command to a specific IN endpoint (e.g., endpoint 2) of the target device via an IN token packet. Based on the sector address read command data and the IN token packet, the target device feeds back a data packet of the corresponding sector address and a status packet of the execution command (e.g., a SCSI CSW packet) to the network device. The network device transmits the data packet and the status packet (or status data) to the server side and transfers the sector data packet and the status packet (or status data) to the client side via the server side.
[0426] Please refer to FIG. 15. As shown in FIG. 15, in one embodiment of the present application, the client side (or control side) sends sector address write command data and a data packet to the server side. The server side transmits the received sector address write command and data packet to the network device. The network device transmits the sector address write command (e.g., a SCSI CBW packet) and a data packet to a specific OUT endpoint (e.g., endpoint 1) of the target device via an OUT token packet, and transmits an IN acquire token packet to a specific IN endpoint (e.g., endpoint 2) of the target device via an IN token packet. The target device performs an operation according to the sector address command and data packet and feeds back to the network device with a status packet (e.g., a SCSI CSW packet or a USB ACK or NAK packet). The network device transmits the status packet (or status data) to the server side, and transfers the status packet (or status data) to the client side via the server side.
[0427] In one embodiment of the present application, a network device and a target device can interact with each other through file read and write operations. Specifically, a file operation command (e.g., a file creation command, a file deletion command, a file attribute change command, a file content read command, a file content change command, etc.) is sent to the network device via the client side or the server side. The network device then analyzes the file operation command sent from the client side or the server side according to the command rules of the "interactive system or data source binding" and sends the file operation command to the target device according to the preset commands of the data exchange command set. If the file operation command is a command to write data to the target device, such as a file creation command, a file deletion command, a file attribute change command, or a file content change command, the file operation command becomes a write command that writes a data packet, and the target device feedbacks status packet data according to the file operation command. If the file operation command is a command to read data from the target device, such as a file content read command, the file operation command becomes a read command, and the target device feedbacks data packets and status packets according to the file operation command. After receiving the data of the data packet or the status packet, the network device responds to the client side or the server side based on the "binding of the interactive system or data source" command rule.
[0428] Please refer to FIG. 16. As shown in FIG. 16, in another embodiment of the present application, the client side sends a file creation command to the server side. The server side sends the file creation command to the network device, and the network device writes the data of the created file to a specific sector address according to the protocol rules of the file system and the preset file directory. For example, the network device sends sector address write command data and file creation data to endpoint 1 of the target device via an OUT token packet in accordance with the file creation command. The target device writes the file creation data to a specific sector address in accordance with the sector address write command data and the file creation data, and feeds back the sector data packet to the network device. For example, the target device feeds back the sector data packet to the network device via endpoint 2. The network device determines the creation result data from the sector data packet and feeds back the creation result data to the server side. The server side feeds back the creation result data to the client side.
[0429] In one embodiment of the present application, when the client or server side sends a command or executes an automatic command execution script, the network device follows the rules of the "permit / prohibit exchange policy" when sending the data interaction command to the target device. For example, according to the above CBW packet command, it permits / prohibits reading / writing of specific sector data. If prohibited, the CBW command is not sent to the target device.
[0430] As shown in FIG. 17 , in one embodiment of the present application, the client side sends a file search command to the server side. The server side sends the file search command to the network device, and the network device automatically reads multiple storage space addresses (e.g., sector addresses) according to the protocol rules of the file system, determines the found file data, and analyzes the file directory. For example, the network device sends sector address read command data to endpoint 1 of the target device via an OUT token packet in accordance with the search file command, and sends an endpoint data obtain command to endpoint 2 of the target device via an IN token packet. The target device feeds back sector data packets (e.g., file contents) or search result (e.g., file information) data packets to the network device in accordance with the sector address read command data and the endpoint data obtain command. For example, the target device feeds back the sector data packets to the network device via endpoint 2. The network device determines the found file data from the sector data packets or search result data packets, analyzes the file directory, and feeds back the search result or file data to the server side. The server side feeds back the found file data to the client side.
[0431] The methods for creating and searching for files differ depending on the file system protocol. The same applies to file operations such as deleting files, changing file attributes, and changing file contents. Depending on the rules of different file systems, these can be set in the scenario using scripts or high-level commands. A detailed explanation is omitted here.
[0432] The following describes the data exchange method in this embodiment when the network device is in slave mode.
[0433] After starting up (or before connecting) the network device and selecting a scenario, the network device is configured according to the data exchange configuration information in the scenario configuration information. For example, the network device may set a command-response operation, automatic execution of a command-response operation script, a binding policy for a second interactive system or data source, and a second permission / prohibition exchange policy in the data exchange configuration information. The network device receives, processes, and responds to commands from the target device according to the set command-response operation, automatic execution of a command-response operation script, a binding policy for a second interactive system or data source, and the second permission / prohibition exchange policy. The objects operated by the network device according to the received command include at least one of the following: 1. A specific database, folder, file (e.g., image file), or storage space (e.g., sector range) on the local memory chip, client side, or server side of the network device; 2. A local peripheral module such as a positioning module, sensor module, audio / video source module, or human-computer interaction module.
[0434] In one embodiment of the present application, the network device responds to commands or data sent from the target device according to commands such as command-response operations, binding policies of the second interactive system, or data source. For example, the network device receives a data packet from the OUT endpoint in response to a USB token packet sent from the target device, writes the data packet to a storage space, and uploads the data to the storage space of the IN endpoint. The network device responds to commands or data sent from the target device in an automatic response manner. For example, it automatically reads / writes to the bound data source according to the target device's commands. No human intervention is required during the read / write process.
[0435] In another embodiment of the present application, the network device performs command-response operations on the client-side and server-side interactive interfaces according to commands such as command-response operations, binding policies of a second interactive system or a data source, etc. For example, if the network device is a keyboard device, when the target device sends a USB token packet (e.g., an IN token) to request, the user can input the letter "A" on the client-side interactive interface, and the network device feeds back the data packet of the letter "A" to the target device at the IN endpoint, thereby realizing manual interaction with the target device.
[0436] The data exchange method according to this embodiment will be described below using the case where the network device (slave mode) is a USB flash drive as an example.
[0437] Step S1101 further includes setting data exchange configuration information for the USB flash drive. Specifically, when setting the data exchange configuration information,...
Claims
1. A device connection method applied to a network device, comprising: setting configuration information of the network device based on a preset creation policy; reading the scenario configuration information in advance; Establishing a communication connection between the network device and the target device based on the loaded scenario configuration information to connect the network device to the target device. The configuration information includes scenario configuration information of a network device in at least one application scenario, the scenario configuration information including at least one of a first descriptor set and a function command set, and data source configuration information, the first descriptor set is used to define a device type of the network device, and the function command set includes a descriptor command set.
2. The step of reading the scenario configuration information in advance includes:
2. The device connection method of claim 1, further comprising: pre-loading the scenario configuration information before connecting the network device to the target device; the scenario configuration information being stored on a server side or the network device; and the server side being any electronic device that can establish a communication connection with the network device and load the scenario configuration information.
3. The step of reading the scenario configuration information in advance includes: When the network device is started up, the network device transmits to the server a request to acquire the scenario information, the request including an ID of the network device; the server responds to the scenario information acquisition request and filters, from the scenario configuration information, scenario configuration information that matches the ID of the network device as the scenario configuration information; The device connection method according to claim 2 , further comprising transmitting the scenario configuration information to the network device.
4. setting scenario configuration information of the network device, 2. The device connection method according to claim 1, further comprising: setting at least one of the first descriptor set and the descriptor command set, and data source configuration information, in accordance with a preset creation policy via a server side that has established a communication connection with the network device, or a client side that has established a communication connection with the server side, or via the network device, wherein the preset creation policy includes at least one of a custom creation policy, a template creation policy, and a creation policy that is imported from an external device.
5. Establishing a communication connection with a target device based on the read scenario configuration information The device connection method according to claim 1 , further comprising setting the network device to at least one of a master mode, a slave mode, and a peer-to-peer communication mode in accordance with mode selection information in the scenario configuration information.
6. When the network device is set to a master mode, establishing a communication connection with a target device based on the descriptor command set includes: sending a handshake connection request to the target device; receiving a second set of descriptors sent by the target device in response to the handshake connection request; enumerating a plurality of descriptors in the second descriptor set based on a descriptor set of the function command set; determining that the handshake connection is successful if the plurality of descriptors of the second descriptor meets preset device requirements; 2. The device connection method of claim 1, further comprising: if the plurality of descriptors do not meet preset device requirements, determining that the handshake connection has failed, sending the acquired second descriptor set to a server side, downloading a corresponding third descriptor set from the server side, and performing enumeration again based on the descriptors in the third descriptor set.
7. 7. The device connection method according to claim 6, wherein the descriptor command set includes a get command for a device descriptor, a get command for a configuration descriptor, a get command for an interface descriptor, a get command for an endpoint descriptor, a get command for a string descriptor, and a get command for a BOS descriptor.
8. The method further comprises:
7. The device connection method of claim 6, further comprising setting a target data source for communication between the network device and the target device when the handshake connection based on a descriptor in the third descriptor set is successful, wherein the target data source is provided in the target device, the server side, a client side connected to the server side, or any one of electronic devices communicating with the network device.
9. The function command set includes a data source command set, and setting a target data source during communication between the network device and the target device includes:
9. The device connection method according to claim 8, further comprising determining a target data source when communicating between the network device and the target device in accordance with the data source configuration information based on the data source command set.
10. The device connection method of claim 8, wherein the target data source includes at least one of a storage medium, an address range of a storage space, an image storage file, a specific folder, a database, and a data stream.
11. 10. The device connection method of claim 9, wherein the data source configuration information includes at least one of capacity information of the data source, a storage medium, an address range of the storage space, a read / write status, an image storage file, a specific folder, a database, and a data stream, and the capacity information includes at least one of the last logical block address of the data source, the total number of formattable logical blocks, and a block capacity.
12. the descriptor command set includes at least one of a first standard command set, a first special command set, and a configuration command set; the first standard command set is used to send commands to the target device to request descriptor data of the target device; The special command set is for obtaining data of a device type to which the target device belongs; 2. The device connection method of claim 1, wherein the configuration command set is used to send configuration commands, and the configuration commands include at least one of commands such as setting an address, enabling a configuration, enabling an endpoint, and starting a peripheral module.
13. When the network device is set to a master mode, establishing a communication connection with a target device based on the descriptor command set includes: sending a handshake connection request to the target device; Obtaining descriptor data for the target device in response to the first standard command set; Obtaining data of the target device in response to the special command set; Obtaining at least one of a setting status of an address of the target device, a configuration enabling status, an endpoint enabling status, and a peripheral module activation status in response to the setting command set; When it is determined that at least one of the descriptor data of the target device, the data of the target device, the address setting status of the target device, the configuration enabling status, the endpoint enabling status, or the peripheral module startup status does not satisfy the condition specified in the first connection status determination rule, determining that the handshake connection has failed and sending the descriptor data of the target device to the server side; receiving new scenario configuration information or a new descriptor command set sent from the server side; establishing a communication connection between the network device and the target device in response to the new scenario configuration information or the new descriptor command set; The device connection method of claim 12, wherein the server side determines the new scenario configuration information or the new descriptor command set according to the descriptor data of the target device.
14. When the network device is set to a slave mode, establishing a communication connection with a target device based on the first descriptor command set includes: receiving a handshake connection request sent from the target device; responding to the handshake connection request, feeding back the first descriptor set to the target device so that the target device enumerates the first descriptor set; determining that the handshake connection is successful if the handshake connection request meets preset device requirements; 2. The device connection method of claim 1, further comprising: if the handshake connection request does not satisfy preset device requirements, determining that the handshake connection has failed, sending data of the handshake connection request to a server side, downloading a corresponding fourth descriptor set from the server side, and performing enumeration again based on descriptors in the fourth descriptor set.
15. the descriptor command set includes at least one of a standard command set, a special command set, and an execution of a configuration command; The standard data set is used to feed back descriptor data according to the type and parameters of a standard command when sending the standard command to the target device; The special data set is used to feed back data according to the type and parameters of the special command and the type of the network device when sending a special command to the target device; 2. The device connection method according to claim 1, wherein the execution of the setting command is used to set at least one of an address of the network device, enabling a configuration, enabling an endpoint, and activating a peripheral module when the target device sends the setting command.
16. When the network device is set to a slave mode, establishing a communication connection with a target device based on the first descriptor command set includes: receiving a handshake connection request sent from the target device; receiving at least one of a standard command, a special command, or a setting command sent from the target device; and determining that the handshake connection has failed and sending a descriptor command of the target device to a server side when the at least one of the standard command, the special command, or the setting command does not meet a condition specified in a second connection status judgment rule; receiving new scenario configuration information or a new first descriptor set sent from the server side; establishing a communication connection between the network device and the target device in response to the new scenario configuration information or the new first set of descriptors; The device connection method according to claim 15, wherein the server side determines the new scenario configuration information or the new first descriptor set according to a descriptor command of the target device.
17. 17. The device connection method of claim 1 or 16, wherein the first set of descriptors includes at least one of a device descriptor, a configuration descriptor, an interface descriptor, an endpoint descriptor, a string descriptor, a BOS descriptor, and a preset custom descriptor.
18. When the network device is configured in a peer-to-peer communication mode, establishing a communication connection with a target device based on the configuration information includes: setting a first interface of the network device as a sender and sending data to the target device via the first interface; 2. The device connection method according to claim 1, further comprising: setting a second interface of the network device as a receiving side; and receiving data transmitted from the target device via the second interface.
19. the configuration information includes at least one of a third mode, a third interface type, an interaction data set, a third status determination rule, and a third status response rule; the third mode is used to set the operation mode of the network device to a peer-to-peer mode; the third interface type is used to configure the first interface as the sender and the second interface as the receiver; the interaction data set is used to configure data to be sent from the network device to the target device; the third status determination rule is used to determine whether the connection status of the network device is successful or failed according to the data sent from the target device; 20. The device connection method according to claim 18, wherein the third status response rule is used to respond depending on the connection status of the network device.
20. The target devices include at least one first target device and at least one second target device, and the network device functions as a master device that establishes a communication connection with the at least one first target device and as a slave device that establishes a communication connection with the at least one second target device, and establishing a communication connection with the target devices based on the target scenario descriptor information includes: enumerating a plurality of descriptors from a second descriptor set in at least one first target device based on a descriptor command set of the function command set; If the handshake connection of the plurality of descriptors in the second set of descriptors is successful, configuring a first target data source in communication between the network device and the at least one target device to complete communication between the network device and the at least one target device; receiving a handshake connection request sent from at least one second target device; 2. The device connection method of claim 1, further comprising: responding to the handshake connection request, feeding back the first descriptor set to the at least one second target device so that the at least one second target device enumerates the first descriptor set; and configuring a second target data source in communication between the network device and the at least one second target device according to configuration information of the data source after the handshake connection of the first descriptor set is successful.
21. A data exchange method applied to a network device, the network device establishing a communication connection with a server side and a target device based on the device connection method according to any one of claims 1 to 18, the method comprising: Obtaining a data exchange request sent from a first target party; and responding to the data exchange request based on a preset processing policy and feeding back target data to a first target party, wherein the target data is data sent from a second target party, and when the first target party is the server side, the second target party becomes the target device, and when the first target party is the target device, the second target party becomes the server side.
22. 22. The data exchange method of claim 21, wherein the target devices include at least one first target device and at least one second target device, the network device functions as a master device communicating with the first target device and as a slave device communicating with the second target device, and when the first target party is the server side, the second target party is the first target device or the second target device, and when the first target party is the second target device, the second target party is the server side or the first target device.
23. Responding to the data exchange request and feeding back targeted data to the first targeted party based on the preset processing policy includes: in response to the data exchange request, forwarding the data exchange request to the second target party; 23. The data exchange method according to claim 21 or 22, further comprising receiving target data fed back by the second target party in response to the data exchange request, and transferring the target data to the first target party.
24. A data exchange method applied to a network device, the network device establishing a communication connection with a target device based on the device connection method according to any one of claims 1 to 18, the method comprising: determining a target data source according to data source configuration information in the scenario configuration information; and realizing data interaction between the network device and the target device based on the target data source.
25. 25. The data exchange method of claim 24, wherein the data source configuration information includes capacity information, storage medium, and read / write status of the data source, and the capacity information includes at least one of the last logical block address of the data source, the total number of formattable logical blocks, or block capacity.
26. 25. The data exchange method according to claim 24, wherein the target data source is provided in any one of the target device, the server side, a client side connected to the server side, or an electronic device communicating with the network device.
27. realizing data interaction between the network device and the target device based on the target data source, setting an auto-execution script when the network device communicates with the target device; Sending a first data exchange request to the target device based on the automatic execution script, and receiving first data sent by the target device in response to the first data exchange request; or 27. The data exchange method of claim 26, further comprising receiving a second data exchange request sent from the target device based on the automatic execution script, and sending second data to the target device in response to the second data exchange request, wherein the first data or the second data is data in the target data source, and the scenario configuration information includes the automatic execution script.
28. Receiving data transmitted by the target device in response to the first data exchange request further comprises:
28. The data exchange method of claim 27, further comprising transmitting data sent from the target device to the server side, wherein the server side is any electronic device that can establish a communication connection with a network device and set configuration information.
29. The method further comprises: receiving a first low-level command sent from the server side; sending the first low-level command to the target device; If the operation type of the first low-level command is a read operation, receiving data of a first sector address fed back by the target device in response to the first low-level command; if the operation type of the first low-level command is a read operation, writing the data in the data packet to the first sector address of the target device; The data exchange method of any one of claims 24 to 28, characterized in that the first low-level command is sent from a client side to a server side, the first low-level command includes an operation type, an operated storage space, an operation length, and a data packet, and the target device determines the first sector address according to the operated storage space and the operation length.
30. The method further comprises: receiving a search command sent from the server side; traversing and reading relevant storage space addresses of the target device or network device, respectively, in response to the search command to search for corresponding storage data; transmitting the stored data to the server side so as to transmit the file data from the server side to the client side; 28. The data exchange method according to claim 27, wherein the search command is sent from a client side to the server side, and the search command includes file information.
31. 28. The data exchange method of claim 27, wherein the auto-execution script is a high-level command, and the high-level command includes a file creation command, a file deletion command, a file attribute change command, a file content read command, and a file content change command.
32. A device connection method applied to a server side, the method comprising: When communicating with a network device, transmitting target configuration information to the network device; establishing a communication connection with a target device based on the target scenario configuration information to connect the network device to the target device; A device connection method, characterized in that the target configuration information is used to establish a communication connection between the network device and a target device, the target configuration information includes scenario configuration information of the network device in at least one application scenario, the scenario configuration information includes at least one of a first descriptor set and a descriptor command set, the first descriptor set is used to define a device type of the network device, and the scenario configuration information stored on the server side is at least one of the first descriptor set and the descriptor command set of the network device, and data source configuration information, which are generated according to a preset generation policy before pre-loading the target configuration information, and the target scenario configuration information is one of the scenario configuration information.
33. transmitting target configuration information to the network device; receiving a scenario information acquisition request transmitted from the network device, responding to the scenario information acquisition request, and filtering, from the scenario configuration information, scenario configuration information that matches an ID of the network device in the scenario information acquisition request; and transmitting the scenario configuration information to the network device.
34. The method further comprises: receiving a target device descriptor set transmitted from the network device; The server side determines new scenario configuration information according to a descriptor set of the target device, and sends the new scenario configuration information to the network device, so that the network device establishes a communication connection between the network device and the target device according to the new scenario configuration information; 33. The device connection method of claim 32, wherein the descriptor set is received by the network device from the target device.
35. A data exchange method applied to a server side, the server side establishing a communication connection with a network device based on the device connection method according to any one of claims 30 to 32, the method comprising: Sending a data exchange request to the network device and receiving target data fed back by the network device; and / or transmitting target data to the network device in response to a data exchange request to which the network device has responded based on a preset processing policy; A data exchange method, characterized in that the data exchange request is used by the network device to respond to the data exchange request based on a preset processing policy, the target data is data sent from the target device, the target data is fed back from the network device to the target device, and the data exchange request is executed by the target device.
36. The method further comprises: receiving a read operation command sent from the network device, determining data from the server-side data source in response to the read operation command, and sending the determined data to the network device; or 36. The data exchange method of claim 35, further comprising receiving a write operation command and a write data packet sent from the network device, and writing the write data packet to the server-side data source in response to the write operation command.
37. The server side is characterized in that it comprises a processor and a memory, and the server side is capable of realizing the device connection method described in any one of claims 32 to 34 or the data exchange method described in any one of claims 35 to 36.
38. A data exchange apparatus applied to a network device, the network device establishing a communication connection with a server side and a target device based on the device connection method according to any one of claims 1 to 20, the apparatus comprising: an acquisition module for acquiring a data exchange request sent from a first target party; and a response module for responding to the data exchange request based on a preset processing policy and feeding back target data to a first target party, the target data being data sent from a second target party, where if the first target party is the server side, the second target party is the target device, and if the first target party is the target device, the second target party is the server side.
39. A network device comprising a processor and a memory, wherein the memory is used to store a computer program, and the computer program, when executed by the processor, implements the device connection method of any one of claims 1 to 20 or the data exchange method of any one of claims 21 to 31.
40. A computer-readable storage medium having a computer program stored thereon, the computer program, when executed by a processor, performing the device connection method according to any one of claims 1 to 20, 32 to 34, or the data exchange method according to any one of claims 21 to 31, 35 to 36.
41. 1. A device connection method for a network device, the method comprising: When communicating with the server side, it preloads target configuration information and establishing a communication connection with a target device based on the target scenario configuration information to connect the network device to the target device; A device connection method, characterized in that the target configuration information is used to establish a communication connection between the network device and a target device, the target configuration information includes scenario configuration information of the network device in at least one application scenario, the scenario configuration information includes at least one of a first descriptor set and a descriptor command set, the first descriptor set is used to define a device type of the network device, and the scenario configuration information stored on the server side is at least one of the first descriptor set and the descriptor command set of the network device, and data source configuration information, which are generated according to a preset generation policy before pre-loading the target configuration information, and the target scenario configuration information is one of the scenario configuration information.
42. When communicating with the server side, pre-loading the target configuration information When communicating with a server side, sending a configuration acquisition request to the server side, the request including identification information of the network device; The device connection method of claim 41, further comprising receiving target configuration information corresponding to the identification information fed back from the server side.
43. 42. The device connection method of claim 41, wherein the network device acts as a master device that communicates with a target device, and the descriptor command set includes a plurality of function command sets, the function command sets for controlling data exchange between the network device and the target device.
44. Establishing a communication connection with the target device based on the target scenario descriptor information enumerating a plurality of descriptors in a second descriptor set for the target device based on a function command set in the descriptor command set; 44. The device connection method of claim 43, further comprising: if the enumeration is successful, setting a target data source for communication between the network device and the target device, the target data source being provided in the target device.
45. The function command set includes an acquisition command set and a verification command set, and enumerating a plurality of descriptors in a second descriptor set of the target device based on the function command set in the descriptor command set includes: reading a second descriptor set of the target device based on the obtain command set; verifying a plurality of descriptors in the second set of descriptors based on the verification command set; and determining that the enumeration is successful if a plurality of the descriptors meet preset device requirements.
46. The function command set further includes a data source command set, and setting a target data source when the network device communicates with the target device includes:
45. The device connection method of claim 44, further comprising determining a target data source when communicating between the network device and the target device according to the data source configuration information based on the data source command set.
47. The network device is a device for controlling reading and writing by the network device, and establishing a communication connection with the target device based on the target scenario descriptor information includes: enumerating a plurality of descriptors in a second descriptor set for the target device based on a function command set in the descriptor command set; 44. The device connection method of claim 43, further comprising: if the enumeration is successful, requesting the server side to send a driver command set corresponding to the target device to complete the communication connection, the driver command set being used to exchange data with the target device.
48. The network device is a network device proxy control device, and establishing a communication connection with a target device based on the target scenario descriptor information includes: enumerating a plurality of descriptors in a second descriptor set for the target device based on a function command set in the descriptor command set; 44. The device connection method of claim 43, further comprising: if the enumeration is successful, transmitting the second descriptor set to the server side so that the server side virtualizes the target device, generates a virtual device corresponding to the target device, and establishes a communication connection with the target device.
49. The network device functions as a slave device that communicates with a target device, and establishing a communication connection with the target device based on the target scenario descriptor information includes: receiving an enumeration request sent from the target device; 42. The device connection method of claim 41, further comprising: responding to the enumeration request, feeding back the first descriptor set to the target device so that the target device enumerates the first descriptor set; and after the enumeration is successful, setting a target data source for communication between the network device and the target device according to configuration information of the data source, wherein the target data source is provided on the server side.
50. 50. A device connection method according to claim 46 or 49, wherein the data source configuration information includes capacity information of the data source, and the capacity information includes the last logical block address and block capacity of the data source.
51. 50. The device connection method of claim 44 or 49, wherein the descriptor set includes at least one of a device descriptor, a configuration descriptor, an interface descriptor, an endpoint descriptor, a string descriptor, and a preset custom descriptor.
52. The target devices include at least one first target device and at least one second target device, and the network device functions as a master device that establishes a communication connection with the first target device and as a slave device that establishes a communication connection with the second target device, and establishing a communication connection with the target device based on the target scenario descriptor information includes: enumerating a plurality of descriptors in a second descriptor set for the first target device based on a function command set in the descriptor command set; If the enumeration is successful, configuring a first target data source in communication between the network device and the first target device to complete a communication connection with the first target device; receiving an enumeration request sent from the second target device; 42. The device connection method of claim 41, further comprising: responding to the enumeration request, feeding back the first descriptor set to the second target device so that the second target device enumerates the first descriptor set; and after the enumeration is successful, configuring a second target data source during communication between the network device and the second target device according to data source configuration information, wherein the first target data source is provided in the first target device, and the second target data source is provided on the server side or the first target device.
53. A data exchange method applied to a network device, wherein the network device establishes a communication connection with a server side and a target device based on the device connection method according to any one of claims 41 to 52, the method comprising: Obtaining a data exchange request sent from a first target party; and responding to the data exchange request based on a preset processing policy and feeding back target data to a first target party, wherein the target data is data sent from a second target party, and when the first target party is the server side, the second target party becomes the target device, and when the first target party is the target device, the second target party becomes the server side.
54. 54. The data exchange method of claim 53, wherein the target devices include at least one first target device and at least one second target device, the network device functions as a master device communicating with the first target device and as a slave device communicating with the second target device, and when the first target party is the server side, the second target party is the first target device or the second target device, and when the first target party is the second target device, the second target party is the server side or the first target device.
55. Responding to the data exchange request and feeding back targeted data to the first targeted party based on the preset processing policy includes: in response to the data exchange request, forwarding the data exchange request to the second target party; 55. A data exchange method according to claim 53 or 54, further comprising receiving target data fed back by the second target party in response to the data exchange request, and forwarding the target data to the first target party.
56. the network device is a network USBkey device and the target device is a computer host, and in response to the data exchange request, forwarding the data exchange request to a second target party comprises:
56. The data exchange method of claim 55, further comprising: in response to a data exchange request sent from a computer host, forwarding the data exchange request to the server side, the data exchange request having authentication information of the network USBkey device so that the server side can verify the authentication information.
57. Responding to the data exchange request and feeding back targeted data to the first targeted party based on the preset processing policy includes: Processing data for the data exchange request based on a preset processing script, and obtaining a data processing result; sending a targeted data acquisition request to the second targeted party based on the processing result of the data; 55. A data exchange method as described in claim 53 or 54, characterized in that it includes receiving target data corresponding to the data processing result fed back by the second target party in response to the data exchange request, and feeding back the target data to the first target party.
58. A device connection method applied to a server side, the method comprising: When communicating with a network device, transmitting target configuration information to the network device; establishing a communication connection with a target device based on the target scenario configuration information to connect the network device to the target device; A device connection method, characterized in that the target configuration information is used to establish a communication connection between the network device and a target device, the target configuration information includes scenario configuration information of the network device in at least one application scenario, the scenario configuration information includes at least one of a first descriptor set and a descriptor command set, the first descriptor set is used to define a device type of the network device, and the scenario configuration information stored on the server side is at least one of the first descriptor set and the descriptor command set of the network device, and data source configuration information, which are generated according to a preset generation policy before pre-loading the target configuration information, and the target scenario configuration information is one of the scenario configuration information.
59. 59. A data exchange method applied to a server side, wherein the server side establishes a communication connection with a network device based on the device connection method of claim 58, the method comprising: Sending a data exchange request to the network device and receiving target data fed back by the network device; and / or transmitting target data to the network device in response to a data exchange request to which the network device has responded based on a preset processing policy; A data exchange method, characterized in that the data exchange request is used by the network device to respond to the data exchange request based on a preset processing policy, the target data is data sent from the target device, the target data is fed back from the network device to the target device, and the data exchange request is executed by the target device.
60. A device connection apparatus for use with a network device, the apparatus comprising: A preload module for preloading target configuration information when communicating with the server side; and a first establishing module for establishing a communication connection with a target device based on target scenario configuration information to connect the network device to the target device. At least one preset configuration information is stored on the server side, and the target configuration information is one of the preset configuration information, and the target configuration information includes scenario configuration information of the network device in at least one application scenario, and the scenario configuration information includes at least one of a first descriptor set and a descriptor command set, and the descriptor set is used to define a device type of the network device. The scenario configuration information stored on the server side includes at least one of a first descriptor set and a descriptor command set of the network device, and data source configuration information, which are generated according to a preset generation policy before pre-loading target configuration information, and the target scenario configuration information is one of the scenario configuration information.
61. A data exchange apparatus applied to a network device, the network device establishing a communication connection with a server side and a target device based on the device connection method according to any one of claims 41 to 52, the apparatus comprising: an acquisition module for acquiring a data exchange request sent from a first target party; and a response module for responding to the data exchange request based on a preset processing policy and feeding back target data to a first target party, the target data being data sent from a second target party, where if the first target party is the server side, the second target party is the target device, and if the first target party is the target device, the second target party is the server side.
62. A network device comprising a processor and a memory, wherein the memory is used to store a computer program, and the computer program, when executed by the processor, implements a device connection method according to any one of claims 41 to 52 or a data exchange method according to any one of claims 53 to 57.
63. The server side comprises a processor and a memory, and is capable of implementing the device connection method of claim 58 or the data exchange method of claim 59.
64. A computer-readable storage medium having a computer program stored thereon, the computer program, when executed by a processor, performing the device connection method according to any one of claims 41 to 52 or the data exchange method according to any one of claims 53 to 57.