Equipment MQTT test method and system based on port forwarding function

By creating an MQTT server on the PC side and using the port forwarding function of OpenHarmony HDC tool, the problems of low efficiency and high cost caused by relying on the network environment for MQTT testing in the existing technology are solved, and efficient and flexible MQTT protocol testing is achieved.

CN119576759APending Publication Date: 2025-03-07深圳开鸿数字产业发展有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411511044.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-28
Publication Date
2025-03-07

AI Technical Summary

Technical Problem

In the prior art, testing MQTT on clients with OpenHarmony system installed requires relying on the network environment, resulting in low testing efficiency and high cost.

Method used

By creating an MQTT server on the PC side and using the port forwarding function of OpenHarmony HDC tool, the device can access the MQTT server on the PC side in a non-networked environment to replace the network connection, thereby conducting MQTT protocol testing.

Benefits of technology

It realizes efficient and flexible testing of the MQTT protocol, reduces testing costs, and improves the accuracy and stability of test efficiency and results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119576759A_ABST
    Figure CN119576759A_ABST
Patent Text Reader

Abstract

The invention provides an equipment MQTT testing method and system based on a port forwarding function, and particularly relates to the technical field of automated testing, and the scheme comprises the steps: installing an MQTT server compatible with target equipment, and configuring a monitoring interface of the MQTT server; based on the MQTT interface specification of the target device, creating a preset interface compatible with a local interface of the target device; connecting a local interface and a preset interface, starting a port forwarding function and setting an interface forwarding rule; and writing an MQTT test code based on the interface forwarding rule, and performing an MQTT test on the target device by using the MQTT test code to generate a test report. According to the scheme, the port forwarding function of the HDC tool is utilized, the target equipment can directly access the MQTT server built at the PC end in a network-free environment, so that the MQTT protocol is automatically tested, the operation process is simple, and the test environment is stable.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of automated testing technology, and in particular to a device MQTT testing method and system based on a port forwarding function. Background Art

[0002] In the prior art, when testing the Message Queuing Telemetry Transport (MQTT) protocol on a client with the OpenHarmony system installed, the client needs to be connected to the MQTT server for testing, which inevitably requires connecting to the network or using a local area network for testing. It can be seen that this testing method needs to rely on the network environment, and the construction of the network environment is relatively complex, and the test effect is easily affected by the network environment, resulting in low test efficiency and high test costs. Summary of the invention

[0003] In view of the above-mentioned deficiencies in the prior art, the purpose of the present invention is to provide a device MQTT testing method and system based on port forwarding function, aiming to solve the problems of low testing efficiency and high cost caused by the need to rely on the network environment to test the client's MQTT in the prior art.

[0004] In order to achieve the above object, the first aspect of the present invention provides a device MQTT testing method based on port forwarding function, comprising:

[0005] Install an MQTT server that is compatible with the target device and configure the listening interface of the MQTT server;

[0006] Based on the MQTT interface specification of the target device, create a preset interface compatible with the local interface of the target device;

[0007] Connecting the local interface of the target device and the preset interface;

[0008] Starting the port forwarding function and setting the interface forwarding rule, wherein the interface forwarding rule indicates establishing the forwarding rule of the local interface and the listening interface by using the preset interface;

[0009] Write an MQTT test code based on the interface forwarding rule, use the MQTT test code to perform an MQTT test on the target device, and generate a test report.

[0010] Optionally, installing an MQTT server compatible with the target device and configuring a listening interface of the MQTT server includes:

[0011] Determine the operating system of the target device, and download and install the MQTT server suitable for the operating system;

[0012] Determine the configuration items of the MQTT server, and configure the listening interface of the MQTT server by editing the configuration items.

[0013] Optionally, the creating a preset interface compatible with a local interface of the target device based on the MQTT interface specification of the target device includes:

[0014] Based on the MQTT interface specification of the target device, determine all compatibility indicators of the local interface of the target device;

[0015] Based on all of the compatibility indicators, a preset interface is created that is compatible with a native interface of the target device.

[0016] Optionally, the local interface connecting the target device and the preset interface includes:

[0017] The local interface of the target device and the preset interface are connected via a USB cable or an ADB serial port.

[0018] Optionally, if the target device is a target Hongmeng device, starting the port forwarding function and setting the interface forwarding rules include:

[0019] Open the OpenHarmony HDC tool, enable the port forwarding function of HDC, and set the interface forwarding rules in the HDC tool.

[0020] Optionally, the using the MQTT test code to perform the MQTT test on the target device and generate a test report includes:

[0021] Performing an MQTT test on the target device using the MQTT test code to obtain a test result, wherein the content of the MQTT test includes at least one of a topic subscription and publishing test, a message sending and receiving test, a connection stability test, a performance test, a compatibility test, and a fault recovery test;

[0022] Based on the test results, a test report is generated.

[0023] A second aspect of the present invention provides a device MQTT testing system based on a port forwarding function, the system comprising:

[0024] MQTT server installation module, used to install an MQTT server compatible with the target device and configure the listening interface of the MQTT server;

[0025] A preset interface creation module, used to create a preset interface compatible with a local interface of the target device based on the MQTT interface specification of the target device;

[0026] A local connection module, used for connecting the local interface of the target device and the preset interface;

[0027] An interface forwarding rule setting module, used to start the port forwarding function and set the interface forwarding rule, wherein the interface forwarding rule indicates the forwarding rule for establishing the local interface and the listening interface by using the preset interface;

[0028] The test module is used to write MQTT test code based on the interface forwarding rule, and use the MQTT test code to perform MQTT test on the target device and generate a test report.

[0029] Furthermore, if the target device is a target Hongmeng device, the interface forwarding rule setting module is used to open the OpenHarmony HDC tool, start the port forwarding function of HDC, and set the interface forwarding rules in the HDC tool.

[0030] A third aspect of the present invention provides an intelligent terminal, which includes a memory, a processor, and a device MQTT test program based on a port forwarding function stored in the memory and executable on the processor, wherein the device MQTT test program based on a port forwarding function implements any one of the steps of the above-mentioned device MQTT test method based on a port forwarding function when executed by the processor.

[0031] A fourth aspect of the present invention provides a computer-readable storage medium, on which is stored a device MQTT test program based on a port forwarding function. When the device MQTT test program based on a port forwarding function is executed by a processor, the step of any one of the above-mentioned device MQTT test methods based on a port forwarding function is implemented.

[0032] Compared with the prior art, the beneficial effects of this solution are as follows:

[0033] The present invention mainly creates an MQTT server on the PC side and uses the port forwarding function of the OpenHarmony HDC tool to enable the device to directly access the MQTT server built on the PC side without being connected to the Internet, that is, the port forwarding function of the HDC tool is used to replace the network connection, thereby achieving the purpose of testing the MQTT protocol. Since the server is set on the PC side, it is conducive to realizing automated testing, the operation process is simple, the test environment is stable, and the accuracy and stability of the test results can be improved. At the same time, the hardware of the device and the PC side can be connected by USB cable or serial port connection, and the environment is simple to build. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0035] Figure 1 It is a flow chart of the device MQTT testing method based on the port forwarding function of the present invention;

[0036] Figure 2 It is a schematic diagram of the module of the device MQTT test system based on the port forwarding function of the present invention;

[0037] Figure 3 It is a schematic diagram of the structure of the intelligent terminal of the present invention. DETAILED DESCRIPTION

[0038] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present invention. However, it should be clear to those skilled in the art that the present invention may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present invention.

[0039] It should be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.

[0040] It should also be understood that the terms used in the present specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, the singular forms "a", "an" and "the" are intended to include plural forms unless the context clearly indicates otherwise.

[0041] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0042] As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.

[0043] The following is a clear and complete description of the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0044] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.

[0045] In the face of the problem of low testing efficiency and high cost caused by the need to rely on the network environment to test the client's MQTT, the present invention proposes a device MQTT testing method based on the port forwarding function, which is mainly through creating an MQTT server on the PC side and using the port forwarding function of the OpenHarmony HDC tool to enable the device to directly access the MQTT server built on the PC side in a non-networked environment, that is, using the port forwarding function of the HDC tool to replace the network connection function, so as to achieve the purpose of efficient and flexible testing of the MQTT protocol; moreover, since the server is set on the PC side, it is conducive to the realization of automated testing, the operation process is simple, the test environment is stable, and the accuracy and stability of the test results can be improved. At the same time, the hardware of the device and the PC side can be connected only through a USB cable or a serial port connection, and the environment is simple to set up.

[0046] The embodiment of the present invention provides a device MQTT testing method based on port forwarding function, which is deployed on electronic devices such as computers and servers and is applied to the MQTT testing scenario of devices installed with OpenHarmony system through PC. Figure 1 As shown, the steps of the method in this embodiment include:

[0047] Step S100: Install an MQTT server compatible with the target device and configure the listening interface of the MQTT server;

[0048] Specifically, the operating system of the target device is determined, and an MQTT server suitable for the operating system is downloaded and installed; the configuration items of the MQTT server are determined, and the listening interface of the MQTT server is configured by editing the configuration items.

[0049] Determine the target device operating system by checking the device information. According to the target device operating system, consider the server's stability, performance, functions, and compatibility with the target operating system, and select a suitable MQTT server software. Common MQTT servers include Mosquitto, EMQ X, HiveMQ, etc. Download and install the selected MQTT server software.

[0050] Then find the configuration file of the MQTT server, and find the configuration item related to the listening interface in the configuration file. This configuration item may be named "port". For example, in the configuration file of Mosquitto, you can find "port1883", which means that the default listening interface is 1883. According to the actual test requirements such as security, compatibility and stability, change the value of the listening interface to a suitable port number, and ensure that the selected port number is not occupied by other programs and is within the port usage range of the system. For example, change the above port to "port 1884". Then save the configuration file and restart the MQTT server to make the configuration effective. Furthermore, if you need to implement connection authentication, you can set the relevant authentication parameters, such as username and password, in the configuration file of the MQTT server. According to security requirements, you can also configure SSL / TLS encryption to ensure the communication security between the MQTT client and the server. After completing the configuration, start the MQTT server software.

[0051] Step S200: creating a preset interface compatible with a local interface of the target device based on the MQTT interface specification of the target device;

[0052] Specifically, based on the MQTT interface specification of the target device, all compatibility indicators of the local interface of the target device are determined; based on all the compatibility indicators, a preset interface compatible with the local interface of the target device is created on the PC side.

[0053] First, according to the user manual, technical specifications or developer documentation of the target device, understand the MQTT interface specifications of the target device, including the supported MQTT protocol version, topic naming rules, message format, etc. At the same time, pay attention to the limitations and requirements of the interface in the document, such as the maximum message length, supported quality of service (QoS) level, etc. Alternatively, by capturing the communication log between the target device and other MQTT clients or servers, understand the MQTT interface features actually used by the device, such as the topics published and subscribed, message content, connection parameters, etc.

[0054] Then, determine the compatibility indicators of the local interface of the target device, including: determining the MQTT protocol version supported by the target device; checking whether the pre-set interface also supports the same protocol version to ensure that it can communicate with the target device; considering the differences between protocol versions, such as the support of new features, changes in message formats, etc., to ensure that the pre-set interface is compatible with the specific version requirements of the target device. Topic naming rule compatibility: Analyze the topic naming rules used by the target device, including hierarchical structure, use of wildcards, etc., to ensure that the pre-set interface can correctly understand and process the topics published and subscribed by the target device. For example, if the target device uses a specific prefix or naming convention, the pre-set interface follows the same rules to ensure topic matching and correct communication. Message format compatibility: Understand the message format sent and received by the target device, including data type, encoding method, etc., so that the pre-set interface can parse and generate message formats compatible with the target device. For example, if the target device uses JSON format messages, the pre-set interface should also be able to process JSON data and encode and decode according to the requirements of the target device. QoS level compatibility: Determine the QoS level supported by the target device so that the pre-set interface can set and process the corresponding QoS level according to the requirements of the target device to ensure reliable transmission of messages; consider the characteristics and behavioral differences between different QoS levels, such as message duplication, confirmation mechanism, etc., to ensure that the pre-set interface can handle these situations correctly. Connection parameter compatibility: Check the connection parameters of the target device, such as server address, port number, user name, password, etc., so that the pre-set interface can use the same connection parameters to connect to the target device. Pay attention to the security requirements of the connection parameters, such as encrypted connection, authentication method, etc., to ensure that the pre-set interface can meet the security requirements of the target device.

[0055] Finally, based on all compatibility indicators, create a preset interface on the PC that is compatible with the local interface of the target device, including: according to the MQTT interface specification and compatibility indicators of the target device, select appropriate development tools and technologies based on the PC to create the preset interface, such as using programming languages ​​such as Python, Java, C++, etc., combined with the corresponding MQTT library to implement the interface; use the selected development tools and MQTT library to implement an MQTT client that can communicate with the target device and support basic functions such as connecting to the MQTT server, subscribing to and publishing topics, and processing messages. According to the compatibility indicators of the target device, configure the client's connection parameters, protocol version, QoS level, etc. to ensure compatibility with the target device. According to the topic naming rules of the target device, implement the subscription and publishing functions of the topic, ensure that the preset interface can correctly process the topics published by the target device, and can send messages to the topics subscribed by the target device; according to the message format of the target device, implement the message parsing and generation functions, ensure that the preset interface can correctly understand the messages sent by the target device, and can generate message formats that meet the requirements of the target device. After creating the preset interface, perform compatibility testing to ensure that the interface can communicate normally with the target device, and perform various scenario tests, such as different topics, message formats, QoS levels, etc., to ensure that the preset interface can send and receive data normally in various situations.

[0056] In this embodiment, the compatibility index is determined according to the MQTT interface specification of the target device, and a preset interface compatible with the local interface of the target device is created, which lays a good foundation for subsequently ensuring effective MQTT communication between the local interface of the target device and the MQTT interface in the PC.

[0057] Step S300: connecting the local interface of the target device and the preset interface;

[0058] Specifically, this embodiment mainly establishes a hardware connection relationship between the local interface of the target device and the preset interface through a USB cable or an ADB serial port, specifically including: for the case of connecting using a USB cable, the local interface of the target device is identified through a development tool or a command line tool, and the local interface name or identifier of the target device is determined; on the PC side, the relevant program or service of the preset interface is started, and in the configuration of the preset interface, the local interface of the target device is specified as the connection target, so as to ensure that the preset interface can correctly identify and connect to the local interface of the target device according to the specific interface type, including connection parameters such as interface name and port number. For the case of connecting using an ADB serial port, ensure that the Android Debug Bridge (ADB) tool has been installed on the PC side, confirm that the USB debugging mode of the target device has been turned on, use a USB data cable to connect the target device to the PC side, ensure that the target device is recognized by the PC side, and the ADB tool can detect the connection status of the target device. On the target device, enable ADB serial port communication. On the PC side, use the ADB tool or other serial communication tools to identify the ADB serial port of the target device. Usually, the ADB serial port is displayed as a device name or port number, so as to determine the name or identification of the ADB serial port; at the same time, start the relevant program or service of the preset interface and configure it to use the ADB serial port for connection. According to the requirements of the preset interface, provide the connection parameters such as the name, baud rate, and data bits of the ADB serial port to ensure that the preset interface can correctly identify and connect to the ADB serial port of the target device. Furthermore, you can also confirm whether the connection is successful by viewing the status information or log of the preset interface.

[0059] It should be stated that whether using a USB cable or an ADB serial port connection, you need to ensure that the connection is stable and reliable, and perform appropriate configuration and debugging according to the specific interface type and development requirements.

[0060] Step S400: starting the port forwarding function and setting the interface forwarding rule, wherein the interface forwarding rule indicates establishing the forwarding rule of the local interface and the listening interface by using the preset interface;

[0061] Specifically, if the target device is a target Harmony device, ensure that the device with the OpenHarmony system installed has been connected to the PC via a USB cable or ADB connection, and that the PC has recognized the device. Open the OpenHarmony HDC (HarmonyOSDevice Connect) tool. The HDC tool is a tool provided by the OpenHarmony system for device connection and communication. In the HDC tool, set the local interface of the target device to be forwarded to the specified port on the PC. That is, when the MQTT client on the device tries to connect to the local interface, the HDC tool will forward its request to the specified port on the PC, thereby establishing a connection with the MQTT server. The specific process of starting the port forwarding function of HDC is to open a command prompt window on the PC (cmd or PowerShell can be used under Windows, and the terminal can be used under Linux / MacOS); in the command prompt window, enter the HDC port forwarding command. The specific command format may vary depending on the version of the HDC tool, but generally follows the following format:

[0062] hdc forward<device_local_port><host_port>

[0063] in,<device_local_port> is the local interface number on the device,<host_port> It is the port number specified on the PC side.

[0064] After entering the command, the port forwarding connection is established through the HDC tool. If the connection is successful, relevant information will be displayed in the command prompt window, indicating that the port forwarding has been successfully started.

[0065] Then, after the port forwarding function of HDC is started, the interface forwarding rules are set based on the local interface, preset interface and listening interface of the target device, so as to connect the local interface of the target device and the listening interface of the MQTT server through the preset interface, and establish a connection relationship between the local interface and the listening interface, that is, the preset interface is equivalent to the medium for the local interface and the listening interface to establish a connection, thereby getting rid of the dependence on the network environment. According to the determined forwarding rule format, the interface forwarding rules are set, specifically, the local interface number on the target device is clarified; the information of the listening interface on the PC side is determined, including the port number or network address, etc.; in the port forwarding setting page or dialog box in the HDC tool, find the field or option for setting the forwarding rule; enter the local interface number and the listening interface information to establish the forwarding rule. For example, enter the local interface number of the target device and the listening interface number on the PC side, or the forwarding protocol type (such as TCP or UDP), the forwarding direction, etc. in the corresponding fields. Finally, by checking the log or status information of the HDC tool, confirm whether the port forwarding is successfully started and whether the forwarding rules are correctly applied.

[0066] In this embodiment, by starting the port forwarding function in the OpenHarmony HDC tool and setting the interface forwarding rules, a forwarding relationship between the local interface of the target device and the listening interface on the PC is established using the preset interface, and the correct setting and use of the port forwarding function can be ensured.

[0067] Step S500: Write an MQTT test code based on the interface forwarding rule, and use the MQTT test code to perform an MQTT test on the target device to generate a test report.

[0068] Specifically, the MQTT test code is used to perform an MQTT test on the target device to obtain a test result, wherein the content of the MQTT test includes at least one of a topic subscription and publishing test, a message sending and receiving test, a connection stability test, a performance test, a compatibility test, and a fault recovery test; based on the test result, a test report is generated.

[0069] For topic subscription and publishing tests, use the MQTT test code to connect to the MQTT server of the target device. By subscribing to different topics, ensure that messages published to these topics can be correctly received; by using multiple PCs to subscribe to different topics at the same time, verify the uniqueness of the topic and the correct distribution of messages; by publishing messages to different topics, check whether the client subscribed to the corresponding topic can correctly receive the message, and verify whether the content of the message, QoS level, etc. are consistent with when it was published.

[0070] For the message sending and receiving test, by sending different types of messages, such as text messages, binary data, etc., verify that the target device can correctly receive and process these messages; by comparing the contents of the sent and received messages, check the integrity and accuracy of the received messages; by observing the performance of the target device under high load conditions, test the performance of sending and receiving a large number of messages.

[0071] For the connection stability test, check whether the target device can automatically reconnect to the MQTT server by simulating network interruption, device restart, etc.; observe whether the connection is stable and whether there will be unexpected disconnection by running the test for a long time; test the connection stability in different network environments, such as weak signal areas, network congestion, etc.

[0072] For performance testing, measure the throughput of the target device when processing messages, that is, the number of messages that can be processed per unit time; calculate the throughput by sending a large number of messages and recording the processing time; test the message delay time by detecting the time interval from sending a message to receiving a message. Furthermore, you can also use multiple PCs to send messages simultaneously to obtain more accurate delay measurements; check the resource usage of the target device under high load conditions, such as CPU, memory, etc.

[0073] For compatibility testing, test the compatibility of the target device with different versions of the MQTT protocol, verify whether the communication is normal by connecting to the target device using a PC that supports different protocol versions; check the compatibility of the target device with different types of MQTT servers and PCs; test the compatibility of the target device on different operating systems and hardware platforms.

[0074] For fault recovery testing, simulate MQTT server failures, network interruptions, etc., and then restore to normal status to check whether the target device can automatically restore the connection and continue to work normally; test whether the target device can correctly handle unsuccessful messages when a fault occurs, and whether it can resend these messages after recovery; check the target device's log records during the fault recovery process to understand the cause of the fault and the recovery process.

[0075] During the entire test process described above, test data is recorded using log files, databases or spreadsheets, including the sending and receiving time of messages, connection status, error messages, etc., so that the performance of the target device in each test item can be analyzed based on the recorded test data to obtain analysis results. For example, statistical analysis methods are used to obtain analysis results for evaluating performance indicators. Check whether there are errors or abnormal conditions, such as message loss, connection interruption, performance degradation, etc. Determine the cause of the problem and the scope of impact. It should be stated that the content of the MQTT test in this embodiment includes at least one of topic subscription and publishing tests, message sending and receiving tests, connection stability tests, performance tests, compatibility tests, and fault recovery tests, but is not limited to these tests, and can be flexibly adjusted according to actual application requirements.

[0076] Finally, based on the analysis results, determine the pass or fail status of the target device in each test item, and use clear standards to determine whether the test results meet performance requirements, are consistent with expected results, etc. Further, generate a test report based on the purpose, scope, environment, and methods of the test.

[0077] In this embodiment, the MQTT test code is used to implement a comprehensive test of the target device and generate a detailed test report, which is conducive to improving the accuracy of evaluating the performance and quality of the target device and can provide a favorable basis for the smooth progress of the project.

[0078] In summary, the present invention mainly creates an MQTT server on the PC side and uses the port forwarding function of the OpenHarmony HDC tool to enable the device to directly access the MQTT server built on the PC side without being connected to the Internet, that is, the port forwarding function of the HDC tool is used to replace the network connection, thereby achieving the purpose of testing the MQTT protocol. Moreover, since the server is set on the PC side, it is conducive to realizing automated testing, the operation process is simple, and the test environment is stable. At the same time, the hardware of the device and the PC side can be connected by USB cable or serial port connection, and the environment is simple to build.

[0079] like Figure 2 As shown, corresponding to the above-mentioned device MQTT test method based on the port forwarding function, an embodiment of the present invention further provides a device MQTT test system based on the port forwarding function, and the above-mentioned device MQTT test system based on the port forwarding function includes:

[0080] The MQTT server installation module 201 is used to install an MQTT server compatible with the target device and configure the listening interface of the MQTT server;

[0081] A preset interface creation module 202, configured to create a preset interface compatible with a local interface of the target device based on an MQTT interface specification of the target device;

[0082] A local connection module 203, used to connect the local interface of the target device and the preset interface;

[0083] The interface forwarding rule setting module 204 is used to start the port forwarding function and set the interface forwarding rule, wherein the interface forwarding rule indicates the forwarding rule for establishing the local interface and the listening interface by using the preset interface;

[0084] The testing module 205 is used to write an MQTT test code based on the interface forwarding rule, and use the MQTT test code to perform an MQTT test on the target device to generate a test report.

[0085] Furthermore, if the target device is a target Hongmeng device, the interface forwarding rule setting module 204 is used to open the OpenHarmony HDC tool, start the port forwarding function of HDC, and set the interface forwarding rules in the HDC tool.

[0086] Specifically, in this embodiment, the specific functions of the above-mentioned device MQTT testing system based on the port forwarding function can also refer to the corresponding description in the above-mentioned device MQTT testing method based on the port forwarding function, which will not be repeated here.

[0087] Based on the above embodiments, the present invention further provides an intelligent terminal, whose principle block diagram can be shown as follows: Figure 3 As shown. The above-mentioned intelligent terminal includes a processor, a memory, a network interface and a display screen connected through a system bus. Among them, the processor of the intelligent terminal is used to provide computing and control capabilities. The memory of the intelligent terminal includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a device MQTT test program based on a port forwarding function. The internal memory provides an environment for the operation of the operating system in the non-volatile storage medium and the device MQTT test program based on the port forwarding function. The network interface of the intelligent terminal is used to communicate with an external terminal through a network connection. When the device MQTT test program based on the port forwarding function is executed by the processor, the steps of any one of the above-mentioned device MQTT test methods based on the port forwarding function are implemented. The display screen of the intelligent terminal can be a liquid crystal display screen or an electronic ink display screen.

[0088] Those skilled in the art will understand that Figure 3The principle block diagram shown in the figure is only a block diagram of a partial structure related to the scheme of the present invention, and does not constitute a limitation on the smart terminal to which the scheme of the present invention is applied. The specific smart terminal may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0089] In one embodiment, a smart terminal is provided, which includes a memory, a processor, and a device MQTT test program based on a port forwarding function stored in the memory and executable on the processor. When the device MQTT test program based on a port forwarding function is executed by the processor, the steps of any one of the device MQTT test methods based on a port forwarding function provided in an embodiment of the present invention are implemented.

[0090] An embodiment of the present invention also provides a computer-readable storage medium, on which is stored a device MQTT test program based on a port forwarding function. When the device MQTT test program based on a port forwarding function is executed by a processor, the steps of any one of the device MQTT test methods based on a port forwarding function provided in an embodiment of the present invention are implemented.

[0091] It should be understood that the serial numbers of the steps in the above embodiments do not imply a sequence of execution, and the execution sequence of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0092] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the above-mentioned device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0093] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0094] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0095] In the embodiments provided by the present invention, it should be understood that the disclosed apparatus / terminal equipment and method can be implemented in other ways. For example, the apparatus / terminal equipment embodiments described above are only illustrative, for example, the division of the above modules or units is only a logical function division, and in actual implementation, other division methods can be used, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.

[0096] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, it should be understood by those skilled in the art that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features therein may be replaced by equivalents. However, these modifications or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention.

Claims

1. A device MQTT testing method based on port forwarding function, characterized in that: The following steps are involved: Install an MQTT server that is compatible with the target device and configure the listening interface of the MQTT server; Based on the MQTT interface specification of the target device, create a preset interface compatible with the local interface of the target device; Connecting the local interface of the target device and the preset interface; Starting the port forwarding function and setting the interface forwarding rule, wherein the interface forwarding rule indicates establishing the forwarding rule of the local interface and the listening interface by using the preset interface; Write an MQTT test code based on the interface forwarding rule, use the MQTT test code to perform an MQTT test on the target device, and generate a test report.

2. The device MQTT testing method based on port forwarding function according to claim 1 is characterized in that: The step of installing an MQTT server compatible with the target device and configuring the listening interface of the MQTT server includes: Determine the operating system of the target device, and download and install the MQTT server suitable for the operating system; Determine the configuration items of the MQTT server, and configure the listening interface of the MQTT server by editing the configuration items.

3. The device MQTT testing method based on port forwarding function according to claim 1 is characterized in that: The step of creating a preset interface compatible with a local interface of the target device based on the MQTT interface specification of the target device includes: Based on the MQTT interface specification of the target device, determine all compatibility indicators of the local interface of the target device; Based on all of the compatibility indicators, a preset interface is created that is compatible with a native interface of the target device.

4. The device MQTT testing method based on port forwarding function according to claim 1 is characterized in that: The local interface and the preset interface connected to the target device include: Connect the local interface of the target device and the preset interface via a USB cable or an ADB serial port.

5. The device MQTT testing method based on port forwarding function according to claim 1 is characterized in that: If the target device is a target Hongmeng device, starting the port forwarding function and setting the interface forwarding rules include: Open the OpenHarmony HDC tool, enable the port forwarding function of HDC, and set the interface forwarding rules in the HDC tool.

6. The device MQTT testing method based on port forwarding function according to claim 1 is characterized in that: The using the MQTT test code to perform the MQTT test on the target device and generate a test report includes: Performing an MQTT test on the target device using the MQTT test code to obtain a test result, wherein the content of the MQTT test includes at least one of a topic subscription and publishing test, a message sending and receiving test, a connection stability test, a performance test, a compatibility test, and a fault recovery test; Based on the test results, a test report is generated.

7. A device MQTT testing system based on port forwarding function, characterized in that: The system comprises: MQTT server installation module, used to install an MQTT server compatible with the target device and configure the listening interface of the MQTT server; A preset interface creation module, used to create a preset interface compatible with a local interface of the target device based on the MQTT interface specification of the target device; A local connection module, used for connecting the local interface of the target device and the preset interface; An interface forwarding rule setting module, used to start the port forwarding function and set the interface forwarding rule, wherein the interface forwarding rule indicates the forwarding rule for establishing the local interface and the listening interface by using the preset interface; The test module is used to write MQTT test code based on the interface forwarding rule, and use the MQTT test code to perform MQTT test on the target device and generate a test report.

8. The device MQTT testing method based on port forwarding function according to claim 7 is characterized in that: If the target device is a target Hongmeng device, the interface forwarding rule setting module is used to open the OpenHarmony HDC tool, start the port forwarding function of HDC, and set the interface forwarding rules in the HDC tool.

9. An intelligent terminal, characterized in that: The intelligent terminal includes a memory, a processor, and a device MQTT test program based on a port forwarding function stored in the memory and executable on the processor. When the device MQTT test program based on a port forwarding function is executed by the processor, the steps of the device MQTT test method based on a port forwarding function as described in any one of claims 1 to 6 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a device MQTT test program based on a port forwarding function, and when the device MQTT test program based on a port forwarding function is executed by a processor, the steps of the device MQTT test method based on a port forwarding function as described in any one of claims 1-6 are implemented.