Data communication method, apparatus, device, storage medium, and program product
By establishing port mapping and network socket protocol connection between the host computer and the slave computer, and combining Android debug bridge service and backup wireless network, the stability and compatibility issues in traditional USB communication methods are solved, realizing stable bidirectional communication and parallel debugging between the host computer and the slave computer, thus improving the stability and reliability of the system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA MOBILEHANGZHOUINFORMATION TECH CO LTD
- Filing Date
- 2026-05-13
- Publication Date
- 2026-06-09
AI Technical Summary
In existing technologies, traditional USB communication methods cannot simultaneously guarantee stable communication between the host computer and the slave computer and meet the needs of development, debugging and remote operation and maintenance, resulting in control and management conflicts and a lack of disaster recovery mechanisms.
By establishing port mapping rules and network socket protocol connections between the host computer and the slave computer, and combining Android debug bridge service and backup wireless network, a stable and efficient bidirectional encrypted communication link is built to achieve isolation of logical layer communication resources.
It achieves stable bidirectional communication between the host computer and the slave computer, avoids conflicts between debugging and operation and maintenance, improves the stability and reliability of the system, and eliminates the dependence on OTG Host mode.
Smart Images

Figure CN122179487A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of data transmission technology, and in particular relates to a data communication method, apparatus, device, storage medium and program product. Background Technology
[0002] With the increasing demand for intelligent and remote operation and maintenance of industrial equipment, higher requirements are being placed on the communication solutions between host computers and slave computers.
[0003] In equipment development and maintenance scenarios, host computers and slave computers often communicate using the traditional Universal Serial Bus (USB). However, this communication method cannot guarantee stable data exchange, nor can it meet the dual needs of development debugging and remote maintenance, thus causing conflicts in control and management and hindering efficient communication between the two.
[0004] Therefore, a communication optimization scheme that can simultaneously ensure communication stability is needed. Summary of the Invention
[0005] This application provides a data communication method, apparatus, device, storage medium, and program product that can improve the stability and mode adaptability of communication.
[0006] In a first aspect, embodiments of this application provide a data communication method applied to a host computer, the method comprising: Determine the first transmission control protocol port corresponding to the host computer. The host computer and the slave computer are connected by a universal serial bus. The working mode of the host computer includes slave mode or master mode. After receiving the port forwarding instruction initiated by the lower-level machine, a port mapping rule is established between the first transmission control protocol port and the second transmission control protocol port corresponding to the lower-level machine. After the host computer and the slave computer perform a network socket protocol handshake, a network socket protocol connection is established between the host computer and the slave computer based on the port mapping rules and the universal serial bus connection. When the Android debugging bridge service is running normally, the system sends first data to the lower-level device and / or receives second data sent by the lower-level device through the network socket protocol connection.
[0007] In one feasible implementation, before sending the first data to the lower-level machine via the network socket protocol connection, the method further includes: Establish a backup wireless network between the host computer and the slave computer; Determine the first connection state corresponding to the network socket protocol connection and the second connection state of the backup wireless network; When the first connection state is normal, the system sends first data to the lower-level device and / or receives second data sent by the lower-level device through the network socket protocol connection. If the first connection status is abnormal and the second connection status is normal, the system sends first data to the lower-level device and / or receives second data sent by the lower-level device through the backup wireless network.
[0008] In one feasible implementation, sending first data to the lower-level machine via the network socket protocol connection includes: Write the first data to the network socket protocol server deployed in the host computer; The first data is sent to the socket client corresponding to the debug bridge daemon process via the network socket protocol server. The debug bridge daemon encapsulates the first data according to a preset debug bridge protocol to obtain the first data packet of the debug bridge protocol. The first data packet is sent to the lower-level machine via a corresponding batch channel connected through a universal serial bus. The debug bridge server of the lower-level machine decapsulates the first data packet to obtain the first data. The debug bridge server then sends the first data to a proxy service deployed in the lower-level machine through a socket server maintained within the debug bridge server. The proxy service then sends the first data to the application in the lower-level machine.
[0009] In one feasible implementation, the second data sent by the lower-level machine is received via the network socket protocol connection, including: The second data packet is decapsulated by debugging the bridge daemon process to obtain the second data, which is obtained by the lower-level machine from the encapsulation of the second data. After decapsulating the second data packet through the debug bridge daemon to obtain the second data, the method further includes: The second data is sent to the socket server maintained within the debug bridge daemon process; The second data is sent to the network socket protocol server through the socket server maintained within the debug bridge daemon process; The second data is sent to the application corresponding to the host computer through the network socket protocol server, so that the application corresponding to the host computer can process the second data.
[0010] In one feasible implementation, sending first data to the lower-level machine via the network socket protocol connection includes: Determine the first sub-data corresponding to different business types in the first data; Allocate a corresponding transmission channel for each of the first sub-data items; Each of the first sub-data items is sent to the lower-level machine according to its corresponding transmission channel.
[0011] In one feasible implementation, before sending the first data to the lower-level machine via the network socket protocol connection, the method further includes: The first data is encrypted using a pre-negotiated symmetric key, and the encrypted first data is then sent to the lower-level machine as the first data. Before encrypting the first data using a pre-negotiated symmetric key, the method further includes: Receive the asymmetric public key sent by the lower-level machine; A symmetric key is generated, and the symmetric key is encrypted using the asymmetric public key to obtain the symmetric key to be transmitted; The symmetric key to be transmitted is sent to the lower-level machine, so that the lower-level machine can decrypt the symmetric key to be transmitted based on the asymmetric private key corresponding to the asymmetric public key to obtain the symmetric key.
[0012] Secondly, embodiments of this application provide a data communication method applied to a lower-level machine, the method comprising: Determine the second transmission control protocol port corresponding to the lower-level machine, and the upper-level machine and the lower-level machine are connected by a universal serial bus; A port forwarding command is sent to the host computer, which triggers the host computer to establish a port mapping rule between the first transmission control protocol port and the second transmission control protocol port corresponding to the host computer. After the host computer and the slave computer perform a network socket protocol handshake, a network socket protocol connection is established between the host computer and the slave computer based on the port mapping rules and the universal serial bus connection. When the Android debugging bridge service is running normally, the system sends second data to the host computer and / or receives first data sent by the host computer through the network socket protocol connection.
[0013] In one feasible implementation, the port forwarding command is an Android debug bridge forwarding command, which initiates a port forwarding command to the host computer, including: The Android debug bridge forwarding command is executed and sent to the host computer. The Android debug bridge forwarding command includes at least the first transmission control protocol port and the second transmission control protocol port.
[0014] In one feasible implementation, the network socket protocol handshake is performed in the following manner: A proxy service is deployed within the lower-level machine, and the proxy service includes a proxy network socket protocol client. The proxy network socket protocol client sends a network socket protocol connection request to the host computer based on the second transmission control protocol port; When the host computer starts the Network Socket Protocol (NSP) server, the NSP handshake is performed by proxying the NSP client based on the NSP connection response sent by the host computer. If the network socket protocol server on the host computer is not started, the proxy network socket protocol client will resend the network socket protocol connection request to the host computer based on the second transmission control protocol port until the network socket protocol handshake is successful.
[0015] In one feasible implementation, the proxy service further includes a proxy network socket protocol server, which sends second data to the host computer via the network socket protocol connection, including: The proxy network socket protocol server receives the second data sent by the socket client and sends the second data back to the proxy network socket protocol client. The second data is transmission control protocol bearer data. The second data is sent to the socket server maintained in the debug bridge server through the proxy network socket protocol client. The proxy network socket protocol client and the socket server maintained in the debug bridge server have a transmission control protocol connection. The second data is encapsulated according to the preset debug bridge protocol through the debug bridge server to obtain the second data packet of the debug bridge protocol; The second data packet is sent to the host computer via a general serial bus connection to the corresponding batch logic channel, so that the debug bridge daemon of the host computer can decapsulate the second data packet to obtain the second data, and send the second data to the socket server maintained within the debug bridge daemon.
[0016] In one feasible implementation, the proxy service further includes a proxy network socket protocol server, which receives first data sent by the host computer via the network socket protocol connection, including: The first data packet is decapsulated by the debugging bridge server to obtain the first data; the first data packet is obtained by the host computer from the first data. The first data is sent to the proxy network socket protocol client by debugging the socket server maintained in the bridge server. The first data is sent to the proxy network socket protocol server through the proxy network socket protocol client; The first data is sent to the application corresponding to the lower-level machine through the proxy network socket protocol server, so that the application corresponding to the lower-level machine can process the first data.
[0017] Thirdly, embodiments of this application provide a data communication device, the device comprising: The first determining module is used to determine the first transmission control protocol port corresponding to the host computer. The host computer and the slave computer are connected by a universal serial bus. The working mode of the host computer includes slave mode or master mode. The first port mapping rule establishment module is used to establish a port mapping rule between the first transmission control protocol port and the second transmission control protocol port corresponding to the lower-level machine after receiving the port forwarding instruction initiated by the lower-level machine. The network socket protocol connection establishment module is used to establish a network socket protocol connection between the host computer and the slave computer based on the port mapping rules and the universal serial bus connection after the host computer and the slave computer have performed a network socket protocol handshake. The data transceiver module is used to send first data to the lower-level device and / or receive second data sent by the lower-level device through the network socket protocol connection when the Android debug bridge service is running normally.
[0018] Fourthly, embodiments of this application provide a data communication device, the device comprising: The second determining module is used to determine the second transmission control protocol port corresponding to the lower-level machine, and the upper-level machine and the lower-level machine are connected by a universal serial bus. The second port mapping rule establishment module is used to send a port forwarding instruction to the host computer. The port forwarding instruction is used to trigger the host computer to establish a port mapping rule between the first transmission control protocol port and the second transmission control protocol port corresponding to the host computer. The network socket protocol connection establishment module is used to establish a network socket protocol connection between the host computer and the slave computer based on the port mapping and the universal serial bus connection after the host computer and the slave computer have performed a network socket protocol handshake. The data transceiver module is used to send second data to the host computer and / or receive first data sent by the host computer via the network socket protocol connection when the Android debug bridge service is running normally.
[0019] Fifthly, embodiments of this application provide a data communication device, the device comprising: The device includes: a processor, and a memory storing computer program instructions; the processor reads and executes the computer program instructions to implement the methods described in the first aspect and / or the second aspect.
[0020] In a sixth aspect, embodiments of this application provide a computer storage medium storing computer program instructions, which, when executed by a processor, implement the methods described in the first and / or second aspects.
[0021] In a seventh aspect, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the methods described in the first and / or second aspects.
[0022] The data communication method, apparatus, device, storage medium, and program product of this application embodiment can establish port mapping rules between the first transmission control protocol port corresponding to the host computer and the second transmission control protocol port corresponding to the slave computer. After the host computer and the slave computer perform a network socket protocol handshake, a network socket protocol connection is established between the host computer and the slave computer based on the port mapping rules and the universal serial bus connection. Through the network socket protocol connection, bidirectional communication between the host computer and the slave computer is realized. With the construction of the transmission control protocol port mapping rules, complete isolation of communication resources can be achieved at the logic layer. Even if the host computer is in host mode, it can coexist stably with the Android debugging bridge service, thereby ensuring the stable realization of bidirectional communication between the host computer and the slave computer, and enabling communication and debugging to be performed in parallel. Attached Figure Description
[0023] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0024] Figure 1 A flowchart illustrating a data communication method provided in one embodiment of this application is shown; Figure 2 A flowchart illustrating a data communication method provided in another embodiment of this application is shown; Figure 3This illustration shows a schematic diagram of a data communication system architecture provided in one embodiment of this application; Figure 4 This illustration shows a flowchart of sending first data to a lower-level machine according to an embodiment of this application; Figure 5 A flowchart illustrating a data communication method provided in another embodiment of this application is shown; Figure 6 A flowchart illustrating a data communication method according to yet another embodiment of this application is shown; Figure 7 A schematic diagram of another data communication system architecture provided by another embodiment of this application is shown; Figure 8 This illustration shows a schematic diagram of the structure of a data communication device according to an embodiment of this application; Figure 9 A schematic diagram of another data communication device provided in another embodiment of this application is shown; Figure 10 A schematic diagram of the hardware structure of the data communication device provided in an embodiment of this application is shown. Detailed Implementation
[0025] The features and exemplary embodiments of various aspects of this application will be described in detail below. To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain this application and not to limit it. For those skilled in the art, this application can be implemented without some of these specific details. The following description of the embodiments is merely to provide a better understanding of this application by illustrating examples.
[0026] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes said element.
[0027] In existing technologies, traditional Universal Serial Bus (USB) communication architectures typically require Android devices to operate in Plug and Play (OTG Host) mode. The Android device → Ubuntu device (download channel) can include: the Android device, acting as a USB slave, sends control commands through its own USB virtual serial port interface (e.g., / dev / ttyGS0); the control commands are encapsulated into data packets using the standard USB protocol and transmitted to the Ubuntu device, acting as the USB host, via the OTG data cable; the Ubuntu device parses the data packet and executes the corresponding control actions. The Ubuntu → Android (upload channel) can include: when the Ubuntu device experiences a state change or triggers an event, it writes the status information or event result to the corresponding USB virtual serial port; the Android device then periodically polls and reads the data through this USB virtual serial port interface, thereby achieving real-time monitoring and response to the Ubuntu device's status.
[0028] However, many Android tablets or terminal devices on the market lack the corresponding functions or operational capabilities of this Host mode, or are constrained by hardware specifications and power management strategies, resulting in unstable operation of the USB OTG Host mode. This problem severely restricts the universality and feasibility of this communication architecture in practical application scenarios. Therefore, Android devices rely heavily on the OTG Host mode.
[0029] When an Android device is configured as a USB Host, its built-in Android Debug Bridge daemon (ADBD service) is forced to terminate due to the default adaptation to Universal Serial Bus Slave (USB Device) mode. In this state, the Ubuntu system cannot access the Android device through the Android Debug Bridge (ADB) channel, making it difficult to simultaneously meet the dual needs of development debugging and remote operation and maintenance. This leads to a functional conflict between device control and operation and maintenance management; that is, the ADB service cannot coexist with USB Host.
[0030] In communication based on Universal Serial Bus (USB) plug-and-play technology, if the physical connection of the USB bus is lost or the master device malfunctions (such as a loose interface or insufficient power supply), the communication link will be immediately interrupted and will not have automatic recovery capabilities. The existing architecture lacks both redundant communication channels and a self-recovery mechanism for downtime, making it highly susceptible to the risk of business task interruption or equipment malfunction. Therefore, the communication link lacks a disaster recovery mechanism.
[0031] To address the problems of existing technologies, embodiments of this application provide a data communication method, apparatus, device, storage medium, and program product. This enables Android devices to operate in slave mode via a USB OTG interface, and Ubuntu devices to operate in host mode. Within this architecture, by combining ADB port forwarding mechanism and WebSocket multi-channel communication technology, a stable, efficient, and bidirectionally encrypted communication link is constructed.
[0032] The data communication method provided in the embodiments of this application will be described below.
[0033] Figure 1 A flowchart illustrating a data communication method according to an embodiment of this application is shown. As shown, the method is applied to a host computer and may include the following steps: S101 to S104.
[0034] S101. Determine the first transmission control protocol port corresponding to the host computer. The host computer and the slave computer are connected by a universal serial bus. The working mode of the host computer includes slave mode or master mode.
[0035] In this embodiment, the host computer is the initiator of debugging commands, the receiver of status data, and the carrier of human-computer interaction. In some embodiments, the host computer is an Android system device. The slave computer is the executor of debugging tasks, the collector of underlying data, and the bearer of hardware drivers. In some embodiments, the slave computer is an Ubuntu system device. It is easy to understand that the slave computer can access and debug the host computer. Moreover, the host computer and the slave computer have a Universal Serial Bus connection, that is, the host computer and the slave computer can be connected via a USB cable. The first Transmission Control Protocol port is a Transmission Control Protocol (TCP) port established within the host computer.
[0036] In the master-slave communication architecture of Universal Serial Bus (USB), master mode (USB Host) and slave mode (USB Device) are two working modes or states based on the ownership of bus control. The core difference lies in who controls the establishment of the communication link and resource scheduling. In slave mode (USB Device), the host computer deploying the Android system acts as a passive responder on the USB bus, receiving instructions or data sent by the other end of the USB bus and responding accordingly. In master mode (USB Host), the host computer acts as the active controller of the USB bus, possessing management rights over the bus. It can actively identify, enumerate, and manage external USB slave devices. Therefore, it can actively scan slave devices, send instructions or data to them, and allocate communication resources.
[0037] Therefore, the S101 is a dedicated TCP port assigned or selected by the Android host computer. This lays the foundation for establishing port mapping and enabling bidirectional communication with the Ubuntu system's slave computer.
[0038] S102. After receiving the port forwarding instruction initiated by the lower-level machine, establish port mapping rules between the first transmission control protocol port and the corresponding second transmission control protocol port of the lower-level machine.
[0039] In this embodiment, the second Transmission Control Protocol (TCP) port refers to the Transmission Control Protocol (TCP) port located within the lower-level device. The port forwarding command refers to the TCP port forwarding command executed by the lower-level device; specifically, it is an ADB-specific command initiated by the lower-level device based on a USB connection, used to establish a bidirectional TCP data logical forwarding channel between the lower-level device's second TCP port and the upper-level device's first TCP port. For example, the port forwarding command could be `adbforward tcp:6001 tcp:6000`. `adb forward` is a fixed command segment used to identify that the ADB port forwarding function is being executed, and to inform the ADB service that a TCP port forwarding link needs to be established between the host and device (upper-level and lower-level devices); it is the functional identifier of the entire command. `tcp:6001` represents a second TCP port of the lower-level device, and `tcp:6000` represents a first TCP port of the upper-level device.
[0040] In this embodiment, after receiving the port forwarding instruction initiated by the lower-level machine, the upper-level machine can know what the second transmission control protocol port of the lower-level machine is, so that the port mapping rule between the first transmission control protocol port and the second transmission control protocol port can be established.
[0041] In this embodiment, establishing port mapping rules between the first and second Transmission Control Protocol (TCP) ports essentially involves creating a mapping between the two ports. In other words, it binds these two TCP ports, thereby establishing a bidirectional dedicated transmission channel between them. The port mapping rules refer to the specific rules governing the mapping or binding between the first and second TCP ports; that is, the port mapping rules clearly define the mapping, binding, and pairing relationship between the first and second TCP ports. This allows data transmission between the host computer and the slave computer through these two bound or mapped TCP ports, with transparent forwarding achieved via the ADB underlying channel and USB connection.
[0042] S103. After the host computer and the slave computer perform a network socket protocol handshake, a network socket protocol connection is established between the host computer and the slave computer based on port mapping rules and universal serial bus connection.
[0043] In this embodiment, the WebSocket handshake is a protocol upgrade request and confirmation process based on the HTTP protocol. After establishing port mapping rules between the first transmission control protocol port and the second transmission control protocol port, the WebSocket handshake can be completed through the first transmission control protocol port and the second transmission control protocol port, that is, the handshake request and handshake response are transmitted through the first transmission control protocol port and the second transmission control protocol port.
[0044] After a successful WebSocket handshake, a WebSocket connection is established between the host and slave devices via the USB physical connection (Universal Serial Bus connection). This WebSocket connection is a long-lived connection bound to the USB physical layer and port mapping rules (between the first and second Transmission Control Protocol ports). In this embodiment, the USB physical connection between the host and slave devices is the hardware foundation for data transmission, and the WebSocket connection is the bidirectional communication channel between them. After this establishment, the USB physical connection is used only as the physical transmission carrier, not the core of communication control. This means that the Android system's host device does not need to be in USB Host mode to achieve data transmission, completely eliminating the rigid requirement of OTG Host mode. Instead, the core of communication is transformed into the WebSocket connection, significantly improving its universality and feasibility across various Android terminals.
[0045] Since the ADB service cannot coexist with USB Host mode, it can cause conflicts in debugging and maintenance between the host computer and the slave computer. By using port mapping and establishing a WebSocket connection, and this WebSocket connection can communicate with the ADB service, the bidirectional communication mechanism of the WebSocket connection can be used to achieve bidirectional communication between the host computer and the slave computer, thus avoiding debugging and maintenance conflicts.
[0046] S104. When the Android debug bridge service is running normally, the system connects via network socket protocol to send first data to the lower-level device and / or receive second data sent by the lower-level device.
[0047] In this embodiment, with the Android Debug Bridge (ADB) service running normally, the host computer can use the established network socket protocol connection to send and receive data with the slave computer, regardless of whether it is in host mode or slave mode. This frees the Android system's host computer from its dependence on OTG Host mode. The first data refers to the data sent from the host computer to the slave computer, and the second data refers to the data sent from the slave computer to the host computer.
[0048] Figure 2 A flowchart illustrating a data communication method according to another embodiment of this application is shown. As shown, in some embodiments, before sending first data to a lower-level machine via a network socket protocol connection, the method further includes steps S201 to S204.
[0049] S201. Establish a backup wireless network between the host computer and the slave computer.
[0050] In this embodiment, before data transmission, a wireless network needs to be established between the host computer and the slave computer. This wireless network is referred to as the backup wireless network. The backup wireless network can be WiFi. The backup wireless network can be automatically or manually switched on in the event of a failure in the Universal Serial Bus connection or Network Socket Protocol connection, signal interruption, bandwidth overload, or planned maintenance, so that data communication or interaction between the host computer and the slave computer can still occur.
[0051] In some embodiments, once the Network Sockets Protocol (NAT) connection is established and stable, a backup WiFi channel, i.e., a backup wireless network, can be pre-established using a proxy service deployed in the lower-level machine to shorten the switching latency between the backup wireless network and the NAT connection. The NAT connection can be referred to as the USB master channel or USB master link.
[0052] In some embodiments, establishing a backup wireless network between the host computer and the slave computer may include: on the basis of an enabled AES-GCM (Advanced Encryption Standard-Galois / Counter Mode) encrypted channel, the host computer (Android device) connects to a proxy service deployed in the slave computer via a network socket protocol and sends network configuration parameters, including SSID (Service Set Identifier), password, and device IP, to the proxy service; subsequently, the proxy service calls the nmcli or wpa_cli tool to complete the network access operation for the SSID based on the network configuration parameters.
[0053] In this embodiment, the AES-GCM encrypted channel is a dedicated data transmission link with confidentiality, integrity, and authenticity guarantees established by the host computer and the slave computer after negotiating a key and configuring parameters based on the AES-GCM algorithm. SSID is the unique name identifier of the wireless local area network (WLAN) where the host computer is located; its core function is to distinguish different wireless networks. nmcli and wpa_cli are command-line wireless network management tools natively pre-installed on Linux systems (including Ubuntu). Their core function is to configure, authenticate, and connect to wireless networks. After receiving network configuration parameters including the SSID, password, and device IP, the nmcli and wpa_cli tools can automatically connect to the wireless network where the host computer is located.
[0054] S202. Determine the first connection state corresponding to the network socket protocol connection and the second connection state of the backup wireless network.
[0055] In this embodiment, the first connection state refers to the connection state of the Network Sockets Protocol (NAT) connection, used to indicate whether the NAT connection or the Universal Serial Bus (USB) connection is disconnected. The second connection state refers to the connection state of the backup wireless network, used to indicate whether the backup wireless network is disconnected.
[0056] In some embodiments, a proxy service deployed within the lower-level machine can continuously monitor the connection status of a Network Sockets Protocol (NAT) connection or a Universal Serial Bus (USB) connection to determine the first connection status. The proxy service refers to a network proxy service, which is an intermediate network node that can forward or process network requests and responses between the two ends. In this embodiment, the proxy service is deployed within the lower-level machine to handle data transmission between the upper-level machine and the lower-level machine.
[0057] In some embodiments, the health status of the USB channel (a universal serial bus connection between a host computer and a slave computer) can be continuously monitored through a proxy service. In other words, link monitoring can be achieved through the proxy service. When the initial connection state is disconnected, the indicators of the USB channel's health status include, but are not limited to, USB channel heartbeat loss, / sys / class / android_usb / android0 / state=DISCONNECTED, and adb forward port mapping failure.
[0058] In the field of communication technology, a heartbeat is a software-level active keep-alive and status detection mechanism, not a physiological heartbeat. It is a core means of ensuring the reliability of communication between devices and links. One party in a communication sends a small, dedicated detection data packet (called a heartbeat packet) to the other party at preset fixed time intervals (such as 100ms or 1s). After receiving the packet, the receiving end must return a corresponding heartbeat response packet within a specified time to confirm the link connectivity and the device's liveness. Heartbeat loss in a USB channel means that the heartbeat initiator does not receive a response packet from the receiving end within a preset time window, i.e., the sending and receiving of heartbeat packets between the host computer and the slave computer is not completed. ` / sys / class / android_usb / android0 / state=DISCONNECTED` is a core parameter in the Android kernel or embedded devices running the Android system, used to characterize the connection status of the Android USB interface. Specifically, it indicates that the physical link or logical connection of the current Android USB interface has been interrupted. If / sys / class / android_usb / android0 / state=DISCONNECTED is detected, it means that the Universal Serial Bus connection between the host computer and the slave computer has been disconnected, and the Network Socket Protocol connection has also been disconnected.
[0059] adb stands for Android Debug Bridge, a toolset used to establish debugging communication between a host computer and an Android device (or embedded Android device). adb forward is one of the core commands of the adb tool, its function being to establish a bidirectional port forwarding mapping relationship between a "host port" and an "Android device port," allowing the host and Android device to transmit data (such as debugging commands, business data packets, log information, etc.) through the specified port. In this embodiment, adb forward is used to establish a bidirectional port forwarding mapping relationship, i.e., a port mapping rule, between a first Transmission Control Protocol (TCP) port and a second TCP port. an adb forward port mapping failure means that the bidirectional port forwarding mapping or relationship established by the adb forward command between the first and second TCP ports is broken, making data forwarding and transmission impossible.
[0060] S203. When the first connection is normal, the lower-level device is connected via the network socket protocol to send the first data and / or receive the second data sent by the lower-level device.
[0061] In this embodiment, when the first connection state is normal, it indicates that the corresponding network socket protocol connection has the conditions for stable operation, and the host computer can transmit the first data to the slave computer based on this network socket protocol connection. It should be noted that the above-mentioned network socket protocol connection is established based on the Universal Serial Bus (USB) connection between the host computer and the slave computer. Therefore, compared with the mode of data transmission only through a wireless network, the data transmission process based on this socket connection can achieve high-speed data transmission by taking advantage of the transmission characteristics of the USB physical link.
[0062] Furthermore, because the WebSocket protocol has a bidirectional communication mechanism, the host computer and the slave computer can achieve bidirectional communication through a WebSocket connection. The host computer can both send first data to the slave computer and receive second data sent by the slave computer, and simultaneously send the first data and receive the second data. The method provided in this embodiment enables the Android system's host computer to establish a USB-based bidirectional communication mechanism while operating in slave mode via the USB OTG interface and with the ADB service running normally. This allows communication and debugging to proceed in parallel, avoiding the incompatibility between the ADB service and the USB host, and achieving coexistence of bidirectional communication and the ADB service.
[0063] S204. If the first connection status is abnormal and the second connection status is normal, send the first data to the lower-level device through the backup wireless network, and / or receive the second data sent by the lower-level device.
[0064] In this embodiment, the first connection state is abnormal and the second connection state means that the Universal Serial Bus connection and the Network Socket Protocol connection between the host computer and the slave computer are both disconnected. However, the backup wireless network between the host computer and the slave computer can still operate normally. Therefore, the communication link between the host computer and the slave computer can be switched to the backup wireless network to ensure that communication is not interrupted, thereby improving the stability and reliability of the overall system.
[0065] In this embodiment, dual-link monitoring and automatic switching can be performed on the two communication links: the Network Socket Protocol (NAT) connection and the backup wireless network. It should be noted that the NAT connection and the backup wireless network need to be established first, and then the link switching is implemented based on connection status and other information; that is, a "build first, then switch" approach is adopted.
[0066] In some embodiments, when a USB channel disconnection is detected between the host computer and the slave computer, the proxy service will immediately trigger a channel switching process. Specifically, the network socket protocol connection will be switched to a backup wireless network. Subsequently, the proxy deployed in the slave computer will actively connect to the address ws: / / via the WebSocket client module.<ANDROID_IP> The server (6000) establishes a WiFi-based WebSocket communication link and configures this link as the currently active communication channel. ws: / / <ANDROID_IP> :6000 is the dedicated network access address of the Android host computer's WebSocket server. It is the unique target address for the proxy's WebSocket client to establish a WebSocket communication link with the Android host computer under the WiFi channel.
[0067] In some embodiments, if the Universal Serial Bus connection between the host computer and the slave computer is disconnected, a Network Socket Protocol (NAT) connection between the host computer and the slave computer can be established through a backup wireless network, thereby establishing a bidirectional communication mechanism between the host computer and the slave computer.
[0068] In some embodiments, after a network socket protocol connection established based on a USB channel is switched to a network socket protocol connection established based on a backup wireless network, a switchback strategy is employed to switch the network socket protocol connection established based on the backup wireless network back to a network socket protocol connection established based on the USB channel. The switchback strategy may include: when the USB channel resumes normal connection, the proxy service immediately performs a channel switchback operation, switching back to the USB channel and setting it as the active communication channel; simultaneously, the previously active WiFi communication channel is downgraded to a backup channel, and both channels (USB channel and WiFi communication channel) are kept alive.
[0069] In some embodiments, all data transmissions between the host computer and the slave computer are encrypted. In some embodiments, before sending the first data to the slave computer via a network socket protocol connection, the method further includes: encrypting the first data using a pre-negotiated symmetric key, and sending the encrypted first data as the first data to the slave computer.
[0070] In this embodiment, the symmetric key is a shared key between the host computer and the slave computer. The host computer and the slave computer can use a preset symmetric encryption algorithm to encrypt or decrypt data using the symmetric key. The symmetric key can be a key corresponding to the AES-128 key length specification or a key adapted to the AES-GCM encryption mode. This symmetric key is a key pre-negotiated between the host computer and the slave computer. Specifically, the host computer encrypts the first data based on the symmetric key and sends the encrypted first data as the first data to the slave computer, and also sends the encrypted first data to the slave computer. After receiving the first data, the slave computer decrypts the first data using the symmetric key.
[0071] In some embodiments, before formally transmitting encrypted data, the host computer and the slave computer need to complete an encryption-related negotiation process in advance. Before encrypting the first data using the pre-negotiated symmetric key, the method further includes: receiving an asymmetric public key sent by the slave computer; generating a symmetric key and encrypting the symmetric key using the asymmetric public key to obtain a symmetric key to be transmitted; and sending the symmetric key to be transmitted to the slave computer so that the slave computer can decrypt the symmetric key to be transmitted based on the asymmetric private key corresponding to the asymmetric public key to obtain the symmetric key.
[0072] In this embodiment, the asymmetric public key and asymmetric private key are a set of asymmetric encryption keys. Data encrypted with the asymmetric public key can only be decrypted with the corresponding asymmetric private key, and vice versa. The asymmetric public key and asymmetric private key can be generated by a lower-level device (Ubuntu), and the upper-level device can receive the asymmetric public key generated and sent by the lower-level device. The upper-level device (Android) can generate a session-level symmetric key and encrypt the symmetric key using the asymmetric public key. Here, the data obtained by encrypting the symmetric key using the asymmetric public key is called the symmetric key to be transmitted. After generating the symmetric key to be transmitted, the upper-level device will send it to the lower-level device. Therefore, the lower-level device can use the corresponding asymmetric private key to decrypt the symmetric key to be transmitted and obtain the symmetric key. In this way, the upper-level device and the lower-level device implement the encryption negotiation process.
[0073] In some embodiments, the lower-level machine (Ubuntu side) can generate an asymmetric encryption public-private key pair based on the device's unique serial number (e.g., RO.serialno). The asymmetric encryption public-private key pair includes an asymmetric public key and an asymmetric private key, which can be an RSA public-private key pair. Then, the asymmetric public key in the asymmetric public-private key pair is pushed to a specified storage directory (e.g., / sdcard / pubkey.pem) on the upper-level machine (Android side) using the adb push command.
[0074] In this embodiment, RO.serialno is a read-only system attribute in the Android system that uniquely identifies the device and is also the device serial number of the Android device. The adb push command is the core file transfer command of the Android Debug Bridge (adb) toolset. It is a standard adb instruction for the host to send files to the Android device and is used to transfer data from the host on the Ubuntu side to a specified storage path on the Android side.
[0075] In some embodiments, the lower-level machine (Ubuntu) can initiate a key negotiation request through the communication channel with channel_id=1. After receiving the key negotiation request, the upper-level machine (Android) generates a session-level symmetric key (such as an AES-128 specification key), encrypts the symmetric key using the obtained RSA public key, and then sends the encrypted symmetric key back to the lower-level machine (Ubuntu) via a WebSocket connection or link. The lower-level machine (Ubuntu) uses the asymmetric private key corresponding to the RSA public key to complete the decryption and obtain the session-level symmetric key. Afterward, based on the symmetric key, it is recommended that both parties use the AES-GCM encryption mode to encrypt the subsequent transmitted service payload.
[0076] In some embodiments, the host computer and the slave computer can communicate via a heartbeat mechanism to announce the encryption algorithm and encryption status. Specifically, a dedicated transmission channel can be used to transmit heartbeat packets. These heartbeat packets can include at least the channel identifier, data type, timestamp, encryption status, and encryption algorithm or mode. For example, a heartbeat packet could be: {"channel_id":0,"type":"heartbeat","timestamp":1723462400,"encryption":{"enabled":true,"algo":"AES-GCM"}}. "channel_id":0 indicates that the channel identifier is 0, and the heartbeat packet is transmitted through the channel corresponding to channel_id zero. "Type" indicates the data type; "type":"heartbeat" indicates that the data type corresponds to the heartbeat packet type. "timestamp" indicates the timestamp. "encryption" indicates the encryption status, used to characterize whether the data is encrypted. "enabled":true indicates that the data has been encrypted. Algo represents the algorithm or mode used to encrypt the data. "algo":"AES-GCM" indicates that the encryption mode used for the encrypted data is AES-GCM.
[0077] In this embodiment, end-to-end encryption and negotiation can be achieved by using RSA and AES-GCM and announcing the encryption status in the heartbeat.
[0078] In some embodiments, sending first data to a lower-level device via a network socket protocol connection may include: determining first sub-data corresponding to different service types in the first data; allocating a corresponding transmission channel for each first sub-data; and sending each first sub-data to the lower-level device according to the corresponding transmission channel.
[0079] In this embodiment, the first data may include data corresponding to various different service types, such as control, status, image, and log data. The data corresponding to each service type is referred to as the first sub-data. A corresponding transmission channel can be allocated to each different first sub-data, thereby achieving isolated transmission of services through multiple channels. The first sub-data is then sent to the lower-level machine according to the transmission channel allocated to each type of first sub-data.
[0080] In some embodiments, different transmission channels can be allocated to data corresponding to different service types. Specifically, a fixed channel_id can be bound to a specific service type. For example, channel_id=0 can be bound to heartbeat, channel_id=1 to control commands, channel_id=2 to status reporting information, channel_id=3 to images or videos, and channel_id=4 to debug logs.
[0081] In some embodiments, to carry data corresponding to multiple different service types such as control commands, status reporting information, and images or videos in parallel, data can be transmitted using a message carrying a channel identifier (channel_id). This message can be a data frame, and the frame format of the message corresponding to the status reporting information can be: { "channel_id": 2, "type": "status_update", "timestamp": 1723462400 "payload": { "battery": 87, "temperature": 41.2}; } In this embodiment, "channel_id": 2 indicates that the channel identifier corresponding to this message is 2, and the message will be transmitted in the transmission channel with channel_id=2. "type": "status_update" indicates the service type of the data in this message, specifically the status update type. "timestamp" indicates the timestamp, and 1723462400 is the specific value of the timestamp. "payload" indicates the service data payload, that is, the actual content of the frame; in other words, the payload can be the first data. "battery": 87 indicates that the device's current battery power is 87%, and "temperature": 41.2 indicates that the device's current temperature is 41.2 degrees Celsius.
[0082] Figure 3 This diagram illustrates a system architecture for data communication according to an embodiment of this application. As shown, the system architecture may include a host computer 310 and a slave computer 320. The host computer 310 may be an Android device, and the slave computer 320 may be an Ubuntu device. The host computer and the slave computer are connected via a USB cable. The host computer with the Android system has a debug bridge daemon (adbd), a WebSocket server, and a communication encryption module. Here, adbd is the Android debug bridge daemon built into the Android device. The WebSocket server is a WebSocket protocol server, a network service program that follows the WebSocket protocol. The WebSocket server acts as both the service provider and the passive connection party in WebSocket bidirectional communication, and can establish a TCP-based bidirectional long connection. The communication encryption module is used to encrypt the first data using a pre-negotiated symmetric key, or to decrypt the received data using the symmetric key.
[0083] In this embodiment, the host computer can write the data to be sent (e.g., the first data) into a local network socket protocol server. The network socket protocol server then sends the data to the debug bridge daemon. The debug bridge daemon can encapsulate or convert the data to a format that can be transmitted via the USB channel. Finally, the debug bridge daemon sends the encapsulated or converted data to the Android debug bridge server (adb server) on the lower-level computer via a network socket protocol connection established based on the USB channel.
[0084] In this embodiment, the host computer can receive data (e.g., second data) sent by the Android debug bridge server (adb server) in the lower-level machine through the debug bridge daemon process. The debug bridge daemon process can then deseal or convert the received data to TCP data. The debug bridge daemon process can then send the TCP data to the network socket protocol server, enabling the host computer's application to consume or process the data from the lower-level machine, thereby achieving debugging or data transmission.
[0085] exist Figure 3 In the middle, the lower-level machine deploys a proxy service and an Android debugging bridge server (adb server). The lower-level machine also has a WebSocket client or a SocketClient client. The Android debugging bridge server (adb server) is a background service of the Android debugging bridge. The WebSocket client is a network program component running the corresponding WebSocket protocol. It is the party that actively initiates the WebSocket connection request, used to request and establish a WebSocket connection with the WebSocket server, and completes data sending and receiving based on the WebSocket connection.
[0086] In this embodiment, the proxy service also includes a proxy WebSocket client and a proxy WebSocket server. The proxy WebSocket client is a WebSocket client component integrated within the proxy service on the Ubuntu side, and the proxy WebSocket server is a WebSocket server component integrated within the proxy service on the Ubuntu side. The proxy WebSocket client is the initiator of the WebSocket connection, specifically used by the Ubuntu side to proactively initiate WebSocket connection requests to the Android side. The proxy WebSocket server is the listener of the WebSocket connection, used to respond to WebSocket connection requests. The proxy WebSocket client and the proxy WebSocket server can transmit data.
[0087] In this embodiment, a WiFi-based network connection can be established between the proxy WebSocket client and the proxy WebSocket server. The WebSocket client can establish a TCP connection or a WebSocket connection with the proxy WebSocket server, enabling data exchange between them. The host computer and the slave computer can connect via a USB channel, allowing debugging communication between the debug bridge daemon on the host computer and the Android debug bridge server on the slave computer.
[0088] In this embodiment, the proxy network socket protocol server can be used to listen to the second transmission control protocol port and to accept connections from applications within the lower-level machine. The proxy network socket protocol client can actively connect to the network socket protocol server on the upper-level machine, thus enabling data transmission and related operations between the USB and WiFi links.
[0089] It should be noted that on the lower-level machine side, the application only connects to the proxy network socket protocol server. The application does not need to be aware of the establishment and switching of the two underlying links, USB and WiFi.
[0090] In this embodiment, the Android debug bridge server can receive data sent by the host computer through the debug bridge daemon process, and decapsulate or convert the received data to a TCP data stream or TCP data. The Android debug bridge server can then send the TCP data stream or TCP data to the proxy network socket protocol client. The proxy network socket protocol client can then send the TCP data stream or TCP data to the proxy network socket protocol server, and the proxy network socket protocol server can then send the TCP data stream or TCP data to the network socket protocol client or socket protocol client of the lower-level machine, so that the lower-level machine's business applications can receive data from the host computer.
[0091] On the lower-level machine side, business applications can also write data into the network socket protocol client or socket protocol client. The network socket protocol client or socket protocol client can forward the data to the proxy network socket protocol server, and then forward it to the Android debug bridge server through the proxy network socket protocol client. The Android debug bridge server can encapsulate the data to convert it into a data format that can be transmitted through the USB channel, and then send the data to the debug bridge daemon process on the upper-level machine side through the USB channel.
[0092] In this embodiment, the proxy network socket protocol client on the lower-level machine can initiate a WebSocket connection request to the upper-level machine through the second transmission control protocol port. The second transmission control protocol port can be ws: / / 127.0.0.1:6001. This second transmission control protocol port is a normal TCP listening port protected by the Android debug bridge server. This second transmission control protocol port only forwards byte streams or TCP data streams and does not process the WebSocket protocol. The WebSocket handshake processing occurs between the proxy network socket protocol client and the network socket protocol server on the upper-level machine. If the network socket protocol server is not ready (the network socket protocol server is not running and the network socket protocol server is not listening on the first transmission control protocol port), the proxy service uses retry / exponential backoff until the handshake is successful.
[0093] The method provided in this embodiment allows a Network Sockets Protocol (NSP) server to be started on the host computer, and a proxy service on the slave computer to establish a connection (handshake) with the NSP server as an NSP client. The slave computer's business applications only connect to the proxy NSP client, enabling bidirectional communication with the host computer.
[0094] In some embodiments, after establishing an adb port mapping between the first and second Transmission Control Protocol (TCP) ports, the proxy network socket protocol client can initiate a WebSocket connection request to the host computer via the local port (the second TCP port) exposed by the port forwarding command (adb forward). Next, the host computer starts a network socket protocol server, which listens on the first TCP port. For example, the address of the TCP port could be 0.0.0.0:6000. At this point, the host computer service is ready. After the host computer service is ready, the proxy network socket protocol client on the slave device automatically completes the WebSocket handshake with the network socket protocol server. Thus, a WebSocket connection based on the USB channel is established between the host computer (Android device) and the slave device (Ubuntu device).
[0095] In some embodiments, the WebSocket handshake between the proxy network socket protocol client and the network socket protocol server can be completed via either the USB channel or the WiFi channel. In this embodiment, the application on the lower-level machine maintains a stable long-term connection with the proxy network socket protocol server. The link switching only occurs between the proxy network socket protocol client and the network socket protocol server on the upper-level machine. The proxy network socket protocol server itself does not need to be shut down or rebuilt. Therefore, the link switching between the USB channel and the WiFi channel is completely transparent to the Ubuntu application. On the Android side, the same network socket protocol server instance (e.g., 0.0.0.0:6000) continuously listens to the outside world. The switching process is only reflected as a normal event of the proxy network socket protocol client briefly disconnecting and then immediately reconnecting. The Android application does not need to perform any additional adaptation. Therefore, the entire link switching process is completely transparent to both the upper and lower-level applications. The application does not need to be aware of the switching process or participate in any switching operations.
[0096] Figure 4 The figure illustrates a flowchart of sending first data to a lower-level device according to an embodiment of this application. As shown, in some embodiments, sending the first data to a lower-level device via a network socket protocol connection may include the following steps: S401 to S404.
[0097] S401: Write the first data to the network socket protocol server deployed in the host computer.
[0098] In this embodiment, the WebSocket protocol server is a WebSocket Server within a host computer. The host computer can be an Android device. The application on the Android device can write data that needs to be sent to the lower-level device to the local WebSocket Server through the WebSocket protocol, i.e., write the first data.
[0099] S402. The first data is sent from the network socket protocol server to the socket client corresponding to the debug bridge daemon.
[0100] In this embodiment, the debug bridge daemon is a background daemon running on the Android device within the Android debug bridge system. It is used to send, receive, or process instructions or data from the debug bridge server locally. The debug bridge daemon can be adbd. Specifically, the first data can be sent to adbd via a WebSocket Server.
[0101] S403. The first data is encapsulated according to the preset debug bridge protocol through the debug bridge daemon process to obtain the first data packet of the debug bridge protocol.
[0102] In this embodiment, the debug bridge protocol refers to an Android debug bridge (adb) protocol, specifically the adb protocol. The debug bridge daemon adbd can encapsulate the first data according to the adb protocol to obtain the first data packet of the debug bridge protocol. The first data packet conforms to the ADB protocol specification and can be transmitted via the USB channel. It should be noted that in S401, the first data that the Android device application can write to the local WebSocket Server is in TCP format, such as a TCP data stream. In S403, this data can be converted to a USB-transmittable data format, making the data compatible with the transmission rules of the USB ADB debug bridge, ensuring that the lower-level ADB server can recognize, receive, and decapsulate it.
[0103] S404: Connect the corresponding batch channel via the universal serial bus and send the first data packet to the lower-level machine.
[0104] In this embodiment, the bulk channel corresponding to the Universal Serial Bus connection can refer to either the USB bulk logical channel dedicated to the ADB protocol or the USB Bulk channel. Relying on the established USB physical connection between the Android device and the Ubuntu device, the encapsulated first data packet can be sent to the Ubuntu device (the lower-level machine) via the USB Bulk channel. Subsequently, the debug bridge server on the lower-level machine can decapsulate the first data packet to obtain the first data, and then send the first data to the proxy service deployed within the lower-level machine through the socket server maintained within the debug bridge server. The proxy service then sends the first data to the application within the lower-level machine.
[0105] In some embodiments, receiving second data sent by a lower-level device via a network socket protocol connection may include: decapsulating the second data packet using a debug bridge daemon to obtain the second data, wherein the second data packet is obtained by the lower-level device from the encapsulation of the second data. The second data packet is data conforming to the adb protocol format, which is transmitted to the upper-level device's adbd via the USB Bulk channel.
[0106] In this embodiment, the debug bridge daemon adbd can read the second data from the USB Bulk channel, thereby decapsulating it layer by layer. This decapsulation process can include: first, decapsulating the second data packet in USB packet form to obtain ADB protocol data; then, parsing the ADB protocol data to restore the original TCP data stream, i.e., the second data. Subsequently, the Socket Client built into adbd actively connects to the WebSocket Server started by the Android device's local application (used to listen on the first Transmission Control Protocol port at address 0.0.0.0:6000), establishes a stable long connection after completing the WebSocket protocol handshake, and forwards the restored TCP data stream to the WebSocket Server, which is ultimately received and processed by the Android local application.
[0107] Figure 5 A flowchart illustrating a data communication method according to another embodiment of this application is shown. As shown, in some embodiments, after decapsulating the second data packet through the debug bridge daemon to obtain the second data, the method may further include the following steps: S501 to S503.
[0108] S501. Send the second data to the socket server maintained within the debug bridge daemon process.
[0109] In this embodiment, a socket client, i.e., the local socket client module of the Android device, can be deployed in the debug bridge daemon adbd. After decapsulating the second data packet and obtaining the second data, adbd can forward the second data to the socket client.
[0110] S502: Send the second data to the network socket protocol server through the socket server maintained in the debug bridge daemon process.
[0111] In this embodiment, the Socket Client maintained within adbd can be used to forward requests to the WebSocket Server.
[0112] S503. The second data is sent to the corresponding application on the host computer through the network socket protocol server, so that the corresponding application on the host computer can process the second data.
[0113] In this embodiment, the second data can be sent to the corresponding application on the host computer via a WebSocket server. The application on the Android device then consumes the second data, enabling the application on the host computer to process it.
[0114] Figure 6 A flowchart illustrating a data communication method according to another embodiment of this application is shown. As shown, in some embodiments, the data communication method is applied to a lower-level machine and may include the following steps: S601 to S604.
[0115] S601. Determine the second transmission control protocol port corresponding to the lower-level machine. The upper-level machine and the lower-level machine are connected by a universal serial bus.
[0116] In this embodiment, the second transmission control protocol port is a TCP port located on the lower-level machine. The upper-level machine and the lower-level machine can be connected via a USB channel.
[0117] S602. Initiate a port forwarding command to the host computer. The port forwarding command is used to trigger the host computer to establish port mapping rules between the first transmission control protocol port and the second transmission control protocol port corresponding to the host computer.
[0118] In this embodiment, the port forwarding command is a TCP port forwarding command, specifically an ADB-specific command initiated by the lower-level device based on a USB connection. It establishes a bidirectional TCP data logical forwarding channel between the lower-level device's second transmission control protocol port and the upper-level device's first transmission control protocol port. The port forwarding command can be an Android debug bridge forwarding command. The port forwarding command can be executed on the lower-level device running the Ubuntu system, enabling the binding between the lower-level device's second transmission control protocol port and the upper-level device's first transmission control protocol port. For example, the port forwarding command could be `adb forward tcp:6001 tcp:6000`. `tcp:6000` is the first transmission control protocol port of the Android device, and `tcp:6001` is the second transmission control protocol port of the Ubuntu device. In this embodiment, the Ubuntu device and the Android device can achieve bidirectional communication through `tcp:6000` and `tcp:6001`, i.e., `Ubuntu:6001`. Android: 6000.
[0119] In some embodiments, the proxy WebSocket Client can initiate a WebSocket connection request to the Android device via the local port (second Transmission Control Protocol port) exposed by the port forwarding command (adbforward). For example, the address of the second Transmission Control Protocol port could be ws: / / 127.0.0.1:6001. ws: / / 127.0.0.1:6001 is a normal TCP listening port exposed by the adb server. This port only forwards byte streams and does not handle the WebSocket protocol. The actual WebSocket handshake occurs between the proxy WebSocket Client and the Android device's WebSocket Server. If the WebSocket Server is not ready (the WebSocket Server is not running and is not listening on the first Transmission Control Protocol port), the proxy will use retries / exponential backoff until the handshake is successful.
[0120] In this embodiment, the WebSocket handshake can be completed through the first transmission control protocol port and the second transmission control protocol port, that is, the handshake request and handshake response can be transmitted through the first transmission control protocol port and the second transmission control protocol port.
[0121] In some embodiments, initiating a port forwarding instruction to the host computer may include: executing the Android debug bridge forwarding command and sending the Android debug bridge forwarding command to both the host computer and the slave computer. The Android debug bridge forwarding command includes at least the first transmission control protocol port and the second transmission control protocol port. In this embodiment, when executing the port forwarding instruction, a port forwarding instruction is also initiated to the host computer so that the host computer can establish a binding and mapping between the first transmission control protocol port and the second transmission control protocol port based on the first transmission control protocol port and the second transmission control protocol port included in the port forwarding instruction.
[0122] In some embodiments, the network socket protocol handshake can be performed in the following manner: deploying a proxy service in the lower-level machine, the proxy service including a proxy network socket protocol client; sending a network socket protocol connection request to the upper-level machine based on the second transmission control protocol port through the proxy network socket protocol client; and, when the upper-level machine starts the network socket protocol server, performing a network socket protocol handshake based on the network socket protocol connection response sent by the upper-level machine through the proxy network socket protocol client.
[0123] In this embodiment, a proxy service can be deployed within the lower-level machine. The proxy can include a proxy WebSocket Client and a proxy WebSocket Server. Using the proxy WebSocket Client, a WebSocket connection request is sent to the upper-level machine via the second Transmission Control Protocol (TCP) port; that is, a WebSocket connection request is sent to the upper-level machine. When the upper-level machine starts the WebSocket Server, the proxy WebSocket Client can perform a WebSocket handshake based on the connection response sent by the upper-level machine.
[0124] If the network socket protocol server on the host computer is not started, the proxy network socket protocol client will resend the network socket protocol connection request to the host computer based on the second transmission control protocol port until the network socket protocol handshake is successful.
[0125] S603. After the host computer and the slave computer perform a network socket protocol handshake, a network socket protocol connection is established between the host computer and the slave computer based on port mapping rules and universal serial bus connection.
[0126] In this embodiment, if the host computer and the slave computer perform a WebSocket handshake, a WebSocket connection can be established based on the USB physical connection (Universal Serial Bus connection) between the host computer and the slave computer after the WebSocket handshake is successful. Here, the WebSocket connection is a long connection bound to the USB physical layer and the port mapping rules (between the first transmission control protocol port and the second transmission control protocol port).
[0127] S604. When the Android debug bridge service is running normally, the system connects via network socket protocol to send second data to the host computer and / or receive first data sent by the host computer.
[0128] In this embodiment, when the Android Debug Bridge (ADB) service is running normally, bidirectional communication between the lower-level machine and the upper-level machine can be achieved through network socket protocol connection, enabling bidirectional data transmission and reception.
[0129] In some embodiments, sending second data to the host computer via the network socket protocol connection may include: receiving second data sent by a socket client through a proxy network socket protocol server, and sending the second data back to the proxy network socket protocol client, wherein the second data is transmission control protocol bearer data; sending the second data to a socket server maintained within a debug bridge server through the proxy network socket protocol client, wherein the proxy network socket protocol client and the socket server maintained within the debug bridge server have a transmission control protocol connection; encapsulating the second data according to a preset debug bridge protocol through the debug bridge server to obtain a second data packet of debug bridge protocol; and sending the second data packet to the host computer through a corresponding batch logic channel connected via a universal serial bus, so that the debug bridge daemon process of the host computer decapsulates the second data packet to obtain the second data, and sends the second data to the socket server maintained within the debug bridge daemon process.
[0130] In this embodiment, the proxy network socket protocol server is the proxy WebSocketServer within the proxy. The lower-level machine may also include a socket client. The lower-level machine can receive the second data sent by the socket client through the proxy WebSocket Server. The second data is Transmission Control Protocol (TCP) bearer data, i.e., TCP data, TCP data stream, or TCP message. In this embodiment, the lower-level machine's business application writes the second data to be sent into the socket client. The socket client forwards the second data to the proxy WebSocket Server, and the proxy WebSocket Server forwards the second data to the proxy WebSocket Client. The proxy network socket protocol client has a TCP connection with the socket server maintained within the debug bridge server, indicating that the proxy WebSocket Client will establish a TCP connection with the Socket Server (listening address 127.0.0.1:6001) maintained by the Ubuntu local adbserver. This Socket Server is a normal TCP server, only responsible for receiving TCP data streams from the client. After receiving the TCP data, the adb server encapsulates it according to the ADB protocol, and then uses Ubuntu as the USB host to send the encapsulated data packet to the Android device through the USB Bulk channel.
[0131] In this embodiment, the second data packet is sent to the host computer via a Universal Serial Bus connection to the corresponding bulk logic channel (USB Bulk channel). The host computer's debug bridge daemon process adb decapsulates the second data packet to obtain the second data, and then sends the second data to the socket server maintained within the debug bridge daemon process.
[0132] In some embodiments, receiving first data sent by the host computer via the network socket protocol connection may include: The first data packet is decapsulated by the debug bridge server to obtain the first data; the first data packet is obtained by the host computer from the first data; the first data is sent to the proxy network socket protocol client through the socket server maintained in the debug bridge server; the first data is sent to the proxy network socket protocol server through the proxy network socket protocol client; the first data is sent to the corresponding application on the lower-level machine through the proxy network socket protocol server, so that the corresponding application on the lower-level machine can process the first data.
[0133] In this embodiment, the debug bridge server is the adb server built into the lower-level machine of the Ubuntu system. The first data packet is obtained by the upper-level machine encapsulating the first data. This adb server can decapsulate the first data packet using the ADB protocol (adbprotocol) to obtain the first data. The socket server maintained within the debug bridge server refers to the Socket Server maintained within the adb server. The Socket Server can send the first data to the proxy WebSocket Client, which can then send the first data to the corresponding application on the lower-level machine, enabling the application to process the first data and thus achieve debugging.
[0134] Figure 7 A schematic diagram of a system architecture for another data communication provided by another embodiment of this application is shown.
[0135] As shown in the figure, the system architecture can include a host computer 310 and a slave computer 320, which can be an Android device and an Ubuntu device, respectively. The host computer 310 and the slave computer 320 are connected via a USB cable, and there is a USB channel or link between them. The host computer 310 contains a debug bridge daemon process called adbd, which includes a socket client 711, an Android debug bridge protocol (adb protocol) module 712, and a USB bulk transfer module 713. The Android debug bridge protocol module 712 is used to encapsulate or decapsulate data according to the adb protocol. The USB bulk transfer module 713 is used to transmit data to the slave computer 320 via the USB Bulk channel. The host computer 310 also contains a network socket protocol server, which listens on the first transmission control protocol port with the address 0.0.0.0.6000. The network socket protocol server can send and receive data with the socket protocol client 711 in the host computer 310. The socket protocol client 711 can send and receive data with the Android debug bridge protocol module 712. The Android debug bridge protocol module 712 can send and receive data with the USB bulk transfer module 713.
[0136] exist Figure 7 In the lower-level device 320, there is an Android debug bridge server and a socket protocol client. The Android debug bridge server includes a USB bulk transfer module 713, an Android debug bridge protocol module 712, and a socket protocol server 723. The Android debug bridge protocol module 712 is used to encapsulate or decapsulate data according to the Android debug bridge protocol. The USB bulk transfer module 713 is used to transmit data to the upper-level device 310 via the USB Bulk channel. The lower-level device 320 also deploys a proxy service, which can connect to the network socket protocol server via WiFi. The proxy service includes a proxy network socket protocol client (proxyWebSocket Client) and a proxy network socket protocol server (proxyWebSocket Server). The proxy network socket protocol server can listen on the second transmission control protocol port at address 127.0.01:6000, and can also establish a TCP connection with the socket protocol client in the lower-level device 320. A proxy network socket protocol server can send and receive data with a socket protocol client.
[0137] In this embodiment, the socket protocol server 723 can establish a basic TCP connection with the proxy network socket protocol client. Data can be sent and received between the USB bulk transfer module 713 and the Android debug bridge protocol module 712. Data can also be sent and received between the Android debug bridge protocol module 712 and the socket protocol server 723. The socket protocol server 723 can be used to listen on the TCP port with the address 127.0.01:6001.
[0138] In some embodiments, the message path from the Ubuntu device to the Android device is: Socket Protocol Client → Proxy Network Socket Protocol Server r → Proxy Network Socket Protocol Client → Socket Protocol Server → Android Debug Bridge Protocol Module → USB Bulk Transfer Module → Android Debug Bridge Protocol Module → Debug Bridge Daemon → Network Socket Protocol Server → Android Application. The reverse link (Android device → Ubuntu device) operates in the same way as the path from the Ubuntu device to the Android device. The complete Android → Ubuntu message path is: Android Application → Network Socket Protocol Server → Debug Bridge Daemon → Android Debug Bridge Protocol Module → USB Bulk Transfer Module → Android Debug Bridge Protocol Module → Android Debug Bridge Server → Proxy Network Socket Protocol Client → Proxy Network Socket Protocol Server → Socket Protocol Client → Ubuntu Application.
[0139] When the USB channel or link is disconnected, the proxy network socket protocol client connects to the network socket protocol server (0.0.0.0:6000) of the Android device via WiFi. The data packet flow is as follows: The message path from Ubuntu to Android is: Socket Protocol Client → Proxy Network Socket Protocol Server → Proxy Network Socket Protocol Client → Network Socket Protocol Server → Android Application.
[0140] The message path from Android to Ubuntu is: Android Application → Network Socket Protocol Server → Proxy Network Socket Protocol Client → Proxy Network Socket Protocol Server → Socket Protocol Client → Ubuntu Application.
[0141] The method provided in this embodiment introduces a WebSocket-based communication abstraction layer between Android and Ubuntu devices, completely shielding the underlying transmission differences between USB and WiFi links from the business logic. Upper-layer applications only need to use a unified WebSocket interface to issue commands and interact with data, without needing to concern themselves with details such as underlying transmission medium switching and port mapping. This achieves modularity and scalability of the communication layer, effectively reducing development and maintenance costs. Therefore, a unified communication abstraction based on WebSocket is implemented.
[0142] Traditional USB-based ADB forward communication links lack security mechanisms. The method provided in this embodiment generates a public-private key pair during the communication initialization phase and distributes the public key to the host computer (master device) via the ADB channel. The host computer uses this public key to encrypt a randomly generated session-level symmetric key and sends it back to the slave computer. Subsequent communication between the two parties is based on this symmetric key, thus providing reliable encryption protection for commands and data transmitted via the USB channel, effectively preventing data theft and tampering, and significantly improving communication security. Therefore, an encryption mechanism is introduced into the USB communication link.
[0143] The method provided in this embodiment can simultaneously maintain two communication channels, USB and WiFi, monitor the link status in real time, and automatically switch to the WiFi channel when the USB channel is abnormally disconnected, ensuring the continuous availability of the communication link. This mechanism significantly improves the communication robustness between the robot's main controller and the lower-level control board in real-world scenarios and reduces the risk of control failure due to link interruption. It achieves dual-channel link redundancy and automatic switching mechanism.
[0144] Figure 8 A schematic diagram of a data communication device according to an embodiment of this application is shown. As shown, the data communication device 800 may include a first determining module 810, a first port mapping rule establishing module 820, a first network socket protocol connection establishing module 830, and a first data transceiver module 840.
[0145] The first determining module 810 is used to determine the first transmission control protocol port corresponding to the host computer. The host computer and the slave computer are connected by a universal serial bus. The working mode of the host computer includes slave mode or master mode.
[0146] The first port mapping rule establishment module 820 is used to establish port mapping rules between the first transmission control protocol port and the corresponding second transmission control protocol port of the lower-level machine after receiving the port forwarding instruction initiated by the lower-level machine.
[0147] The first network socket protocol connection establishment module 830 is used to establish a network socket protocol connection between the host computer and the slave computer based on port mapping rules and universal serial bus connection after the host computer and the slave computer have performed a network socket protocol handshake.
[0148] The first data transceiver module 840 is used to send first data to the lower-level device and / or receive second data sent by the lower-level device via a network socket protocol connection when the Android debug bridge service is running normally.
[0149] In some embodiments, before sending first data to the lower-level machine via a network socket protocol connection, the first data transceiver module 840 is further configured to: Establish a backup wireless network between the host computer and the slave computer; Determine the first connection state corresponding to the network socket protocol connection and the second connection state of the backup wireless network; When the first connection is in a normal state, the lower-level device is connected via the network socket protocol to send the first data and / or receive the second data sent by the lower-level device. If the first connection status is abnormal and the second connection status is normal, the system sends the first data to the lower-level device and / or receives the second data sent by the lower-level device through the backup wireless network.
[0150] In some embodiments, when the first data transceiver module 840 is used to send first data to a lower-level machine via a network socket protocol connection, it is specifically used for: Write the first data to the network socket protocol server deployed in the host computer; The first data is sent from the network socket protocol server to the socket client corresponding to the debug bridge daemon process; The debug bridge daemon encapsulates the first data according to the preset debug bridge protocol to obtain the first data packet of the debug bridge protocol. The first data packet is sent to the lower-level machine via a batch channel connected through a universal serial bus. The lower-level machine's debug bridge server decapsulates the first data packet to obtain the first data. The debug bridge server then sends the first data to the agent service deployed in the lower-level machine through a socket server maintained within the debug bridge server. The agent service then sends the first data to the application in the lower-level machine.
[0151] In some embodiments, when the first data transceiver module 840 is used to receive second data sent by a lower-level machine via a network socket protocol connection, it is specifically used for: The second data packet is decapsulated by debugging the bridge daemon process to obtain the second data. The second data packet is obtained by the lower-level machine encapsulating the second data. After decapsulating the second data packet through the debug bridge daemon to obtain the second data, the method also includes: The second data is sent to the socket server maintained within the debug bridge daemon process; By debugging the socket server maintained within the bridge daemon process, the second data is sent to the network socket protocol server. The second data is sent to the corresponding application on the host computer via the network socket protocol server, so that the application on the host computer can process the second data.
[0152] In some embodiments, when the first data transceiver module 840 is used to send first data to a lower-level machine via a network socket protocol connection, it is specifically used for: Determine the first sub-data corresponding to different business types in the first data; Assign a corresponding transmission channel to each first sub-data item; Each first sub-data is sent to the lower-level machine according to its corresponding transmission channel.
[0153] In some embodiments, before sending first data to the lower-level machine via a network socket protocol connection, the first data transceiver module 840 is further configured to: The first data is encrypted using a pre-negotiated symmetric key, and the encrypted first data is then sent as the first data to the lower-level machine. Before encrypting the first data using a pre-negotiated symmetric key, the method also includes: Receive the asymmetric public key sent by the lower-level device; Generate a symmetric key and encrypt the symmetric key using an asymmetric public key to obtain the symmetric key to be transmitted; The symmetric key to be transmitted is sent to the lower-level machine, so that the lower-level machine can decrypt the symmetric key to be transmitted based on the asymmetric private key corresponding to the asymmetric public key, and obtain the symmetric key.
[0154] Figure 9 A schematic diagram of another data communication device provided in another embodiment of this application is shown. As shown, the other data communication device 900 may include a second determining module 910, a second port mapping rule establishing module 920, a second network socket protocol connection establishing module 930, and a second data transceiver module 940.
[0155] The second determining module 910 is used to determine the second transmission control protocol port corresponding to the lower-level machine, and there is a universal serial bus connection between the upper-level machine and the lower-level machine. The second port mapping rule establishment module 920 is used to send a port forwarding command to the host computer. The port forwarding command is used to trigger the host computer to establish a port mapping rule between the first transmission control protocol port and the second transmission control protocol port corresponding to the host computer. The second network socket protocol connection establishment module 930 is used to establish a network socket protocol connection between the host computer and the slave computer based on port mapping and universal serial bus connection after the host computer and the slave computer have performed a network socket protocol handshake. The second data transceiver module 940 is used to send second data to the host computer and / or receive first data sent by the host computer via a network socket protocol connection when the Android debug bridge service is running normally.
[0156] In some embodiments, the port forwarding instruction is an Android debug bridge forwarding command, and the second port mapping rule establishment module 920, when used to initiate a port forwarding instruction to the host computer, is specifically used for: Execute the Android debug bridge forwarding command and send the Android debug bridge forwarding command to the host computer. The Android debug bridge forwarding command includes at least the first transmission control protocol port and the second transmission control protocol port.
[0157] In some embodiments, the network socket protocol handshake is performed by another data communication device 900 in the following manner: Deploy a proxy service within the lower-level machine. The proxy service includes a proxy network socket protocol client. The proxy network socket protocol client sends a network socket protocol connection request to the host computer based on the second transmission control protocol port; When the host computer starts the network socket protocol server, the network socket protocol handshake is performed by proxying the network socket protocol client based on the network socket protocol connection response sent by the host computer. If the network socket protocol server on the host computer is not started, the proxy network socket protocol client will resend the network socket protocol connection request to the host computer based on the second transmission control protocol port until the network socket protocol handshake is successful.
[0158] In some embodiments, the proxy service further includes a proxy network socket protocol server. When the second data transceiver module 940 is used to send second data to the host computer via a network socket protocol connection, it is specifically used for: The proxy network socket protocol server receives the second data sent by the socket client and sends the second data back to the proxy network socket protocol client. The second data is transmission control protocol bearer data. The second data is sent to the socket server maintained in the debug bridge server through the proxy network socket protocol client. There is a transmission control protocol connection between the proxy network socket protocol client and the socket server maintained in the debug bridge server. The second data is encapsulated according to the preset debug bridge protocol by the debug bridge server to obtain the second data packet of the debug bridge protocol; The second data packet is sent to the host computer via a universal serial bus connection to the corresponding batch logic channel. The host computer's debug bridge daemon then decapsulates the second data packet to obtain the second data, which is then sent to the socket server maintained within the debug bridge daemon.
[0159] In some embodiments, the proxy service further includes a proxy network socket protocol server, and the second data transceiver module 940, when used to receive first data sent by the host computer via the network socket protocol connection, is specifically used for: The first data packet is decapsulated by the debugging bridge server to obtain the first data; the first data packet is obtained by the host computer from the first data. By debugging the socket server maintained within the bridge server, the first data is sent to the proxy network socket protocol client; The first data is sent to the proxy network socket protocol server through the proxy network socket protocol client; The first data is sent to the corresponding application on the lower-level machine through the proxy network socket protocol server, so that the application on the lower-level machine can process the first data.
[0160] Figure 10 A schematic diagram of the hardware structure of the data communication device provided in an embodiment of this application is shown.
[0161] The data communication device may include a processor 301 and a memory 302 storing computer program instructions.
[0162] Specifically, the processor 301 may include a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.
[0163] Memory 302 may include mass storage for data or instructions. For example, and not limitingly, memory 302 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. In one instance, memory 302 may include removable or non-removable (or fixed) media, or memory 302 may be non-volatile solid-state memory. Memory 302 may be internal or external to the integrated gateway disaster recovery device.
[0164] In one instance, memory 302 may be read-only memory (ROM). In one instance, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically rewritable ROM (EAROM), or flash memory, or a combination of two or more of these.
[0165] Memory 302 may include read-only memory (ROM), random access memory (RAM), disk storage media device, optical storage media device, flash memory device, electrical, optical, or other physical / tangible memory storage device. Therefore, generally, memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to one aspect of this disclosure.
[0166] The processor 301 reads and executes computer program instructions stored in the memory 302 to achieve... Figure 1 or Figure 6 The data communication method in the illustrated embodiment.
[0167] In one example, the data communication device may further include a communication interface 303 and a bus 304. Wherein, for example... Figure 10 As shown, the processor 301, memory 302, and communication interface 303 are connected through bus 304 and complete communication with each other.
[0168] The communication interface 303 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.
[0169] Bus 304 includes hardware, software, or both, that couples components of an online data traffic metering device together. For example, and not as a limitation, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 304 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, this application contemplates any suitable bus or interconnect.
[0170] This data communication device can execute the online data traffic billing method in this application embodiment based on currently blocked spam SMS messages and user-reported SMS messages, thereby achieving a combination of... Figure 1 and Figure 6 Describes the data communication method.
[0171] Furthermore, in conjunction with the data communication methods in the above embodiments, this application embodiment can provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when these computer program instructions are executed by a processor, they implement any of the data communication methods in the above embodiments.
[0172] This application also provides a computer program product, including a computer program that, when executed by a processor, implements any of the data communication methods described in the above embodiments.
[0173] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.
[0174] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, read-only memory (ROM), flash memory, erasable read-only memory (EROM), floppy disks, compact disc read-only memory (CD-ROM), optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0175] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0176] The aspects of this disclosure have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by special-purpose hardware performing the specified functions or actions, or can be implemented by a combination of special-purpose hardware and computer instructions.
[0177] The above description is merely a specific implementation of this application. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.
Claims
1. A data communication method, characterized in that, Applications in host computers include: Determine the first transmission control protocol port corresponding to the host computer. The host computer and the slave computer are connected by a universal serial bus. The working mode of the host computer includes slave mode or master mode. After receiving the port forwarding instruction initiated by the lower-level machine, a port mapping rule is established between the first transmission control protocol port and the second transmission control protocol port corresponding to the lower-level machine. After the host computer and the slave computer perform a network socket protocol handshake, a network socket protocol connection is established between the host computer and the slave computer based on the port mapping rules and the universal serial bus connection. When the Android debug bridge service is running normally, the system sends first data to the lower-level device and / or receives second data sent by the lower-level device through the network socket protocol connection.
2. The method according to claim 1, characterized in that, Before sending the first data to the lower-level machine via the network socket protocol connection, the method further includes: Establish a backup wireless network between the host computer and the slave computer; Determine the first connection state corresponding to the network socket protocol connection and the second connection state of the backup wireless network; When the first connection state is normal, the system sends first data to the lower-level device and / or receives second data sent by the lower-level device through the network socket protocol connection. If the first connection status is abnormal and the second connection status is normal, the system sends first data to the lower-level device and / or receives second data sent by the lower-level device through the backup wireless network.
3. The method according to claim 1, characterized in that, The first data is sent to the lower-level machine through the network socket protocol connection, including: Write the first data to the network socket protocol server deployed in the host computer; The first data is sent to the socket client corresponding to the debug bridge daemon process via the network socket protocol server. The debug bridge daemon encapsulates the first data according to a preset debug bridge protocol to obtain the first data packet of the debug bridge protocol. The first data packet is sent to the lower-level machine via a corresponding batch channel connected through a universal serial bus. The debug bridge server of the lower-level machine decapsulates the first data packet to obtain the first data. The debug bridge server then sends the first data to a proxy service deployed in the lower-level machine through a socket server maintained within the debug bridge server. The proxy service then sends the first data to the application in the lower-level machine.
4. The method according to claim 3, characterized in that, The system receives second data sent by the lower-level device via the network socket protocol connection, including: The second data packet is decapsulated by debugging the bridge daemon process to obtain the second data, which is obtained by the lower-level machine from the encapsulation of the second data. After decapsulating the second data packet through the debug bridge daemon to obtain the second data, the method further includes: The second data is sent to the socket server maintained within the debug bridge daemon process; The second data is sent to the network socket protocol server through the socket server maintained within the debug bridge daemon process; The second data is sent to the application corresponding to the host computer through the network socket protocol server, so that the application corresponding to the host computer can process the second data.
5. The method according to claim 1, characterized in that, The first data is sent to the lower-level machine through the network socket protocol connection, including: Determine the first sub-data corresponding to different business types in the first data; Allocate a corresponding transmission channel for each of the first sub-data items; Each of the first sub-data items is sent to the lower-level machine according to its corresponding transmission channel.
6. The method according to claim 1, characterized in that, Before sending the first data to the lower-level machine via the network socket protocol connection, the method further includes: The first data is encrypted using a pre-negotiated symmetric key, and the encrypted first data is then sent to the lower-level machine as the first data. Before encrypting the first data using a pre-negotiated symmetric key, the method further includes: Receive the asymmetric public key sent by the lower-level machine; A symmetric key is generated, and the symmetric key is encrypted using the asymmetric public key to obtain the symmetric key to be transmitted; The symmetric key to be transmitted is sent to the lower-level machine, so that the lower-level machine can decrypt the symmetric key to be transmitted based on the asymmetric private key corresponding to the asymmetric public key to obtain the symmetric key.
7. A data communication method, characterized in that, Applications in lower-level machines include: Determine the second transmission control protocol port corresponding to the lower-level machine, and the upper-level machine and the lower-level machine are connected by a universal serial bus; A port forwarding command is sent to the host computer, which triggers the host computer to establish a port mapping rule between the first transmission control protocol port and the second transmission control protocol port corresponding to the host computer. After the host computer and the slave computer perform a network socket protocol handshake, a network socket protocol connection is established between the host computer and the slave computer based on the port mapping rules and the universal serial bus connection. When the Android debugging bridge service is running normally, the second data is sent to the host computer and / or the first data is received from the host computer through the network socket protocol connection.
8. The method according to claim 7, characterized in that, The port forwarding command is an Android debug bridge forwarding command, which sends a port forwarding command to the host computer, including: The Android debug bridge forwarding command is executed and sent to the host computer. The Android debug bridge forwarding command includes at least the first transmission control protocol port and the second transmission control protocol port.
9. The method according to claim 7, characterized in that, The network socket protocol handshake is performed in the following way: A proxy service is deployed within the lower-level machine, and the proxy service includes a proxy network socket protocol client. The proxy network socket protocol client sends a network socket protocol connection request to the host computer based on the second transmission control protocol port; When the host computer starts the network socket protocol server, the network socket protocol handshake is performed by proxying the network socket protocol client based on the network socket protocol connection response sent by the host computer. If the network socket protocol server on the host computer is not started, the proxy network socket protocol client will resend the network socket protocol connection request to the host computer based on the second transmission control protocol port until the network socket protocol handshake is successful.
10. The method according to claim 9, characterized in that, The proxy service also includes a proxy network socket protocol server, which sends second data to the host computer via the network socket protocol connection, including: The proxy network socket protocol server receives the second data sent by the socket client and sends the second data back to the proxy network socket protocol client. The second data is transmission control protocol bearer data. The second data is sent to the socket server maintained in the debug bridge server through the proxy network socket protocol client. The proxy network socket protocol client and the socket server maintained in the debug bridge server have a transmission control protocol connection. The second data is encapsulated according to the preset debug bridge protocol through the debug bridge server to obtain the second data packet of the debug bridge protocol; The second data packet is sent to the host computer via a general serial bus connection to the corresponding batch logic channel, so that the debug bridge daemon of the host computer can decapsulate the second data packet to obtain the second data, and send the second data to the socket server maintained within the debug bridge daemon.
11. The method according to claim 9, characterized in that, The proxy service also includes a proxy network socket protocol server, which connects via the network socket protocol to receive first data sent by the host computer, including: The first data packet is decapsulated by the debugging bridge server to obtain the first data; the first data packet is obtained by the host computer from the first data. The first data is sent to the proxy network socket protocol client by debugging the socket server maintained in the bridge server. The first data is sent to the proxy network socket protocol server through the proxy network socket protocol client; The first data is sent to the application corresponding to the lower-level machine through the proxy network socket protocol server, so that the application corresponding to the lower-level machine can process the first data.
12. A data communication device, characterized in that, The device includes: The first determining module is used to determine the first transmission control protocol port corresponding to the host computer. The host computer and the slave computer are connected by a universal serial bus. The working mode of the host computer includes slave mode or master mode. The first port mapping rule establishment module is used to establish a port mapping rule between the first transmission control protocol port and the second transmission control protocol port corresponding to the lower-level machine after receiving the port forwarding instruction initiated by the lower-level machine. The first network socket protocol connection establishment module is used to establish a network socket protocol connection between the host computer and the slave computer based on the port mapping rules and the universal serial bus connection after the host computer and the slave computer perform a network socket protocol handshake. The first data transceiver module is used to send first data to the lower-level device and / or receive second data sent by the lower-level device through the network socket protocol connection when the Android debug bridge service is running normally.
13. A data communication device, characterized in that, The device includes: The second determining module is used to determine the second transmission control protocol port corresponding to the lower-level machine, and the upper-level machine and the lower-level machine are connected by a universal serial bus. The second port mapping rule establishment module is used to send a port forwarding instruction to the host computer. The port forwarding instruction is used to trigger the host computer to establish a port mapping rule between the first transmission control protocol port and the second transmission control protocol port corresponding to the host computer. The second network socket protocol connection establishment module is used to establish a network socket protocol connection between the host computer and the slave computer based on the port mapping and the universal serial bus connection after the host computer and the slave computer have performed a network socket protocol handshake. The second data transceiver module is used to send second data to the host computer and / or receive first data sent by the host computer through the network socket protocol connection when the Android debug bridge service is running normally.
14. A data communication device, characterized in that, The device includes: a processor, and a memory storing computer program instructions; the processor reads and executes the computer program instructions to implement the method as described in any one of claims 1-11.
15. A computer storage medium, characterized in that, The computer storage medium stores computer program instructions, which, when executed by a processor, implement the method as described in any one of claims 1-11.
16. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method as described in any one of claims 1-11.