A communication method, device and equipment based on MQTT and B / S architecture and a storage medium

By using a communication method based on MQTT and B/S architecture, the automation and visualization of simulated vehicle-to-vehicle signal communication were achieved, solving the problems of low testing efficiency and high cost in existing technologies, and improving the efficiency of communication testing while reducing costs.

CN116455895BActive Publication Date: 2026-11-20CHONGQING CHANGAN TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202310302297.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-24
Publication Date
2026-11-20
Estimated Expiration
2043-03-24

AI Technical Summary

Technical Problem

In existing technologies, analog vehicle signal communication software based on the MQTT protocol cannot perform regression testing and data feedback, resulting in low efficiency and high cost for developers in communication testing.

Method used

It adopts a communication method based on MQTT and B/S architecture, configures MQTT connection parameters through a browser, encapsulates communication messages into scripts, and executes signal transmission on the server to realize visual communication between message sender and receiver, and supports regression testing and data display on the front end.

Benefits of technology

It improves the reusability of communication messages, reduces testing costs, and enables efficient communication testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116455895B_ABST
    Figure CN116455895B_ABST
Patent Text Reader

Abstract

The application relates to the field of communication, and discloses a communication method and device based on MQTT and B / S architecture, equipment and a storage medium, wherein the method comprises the following steps: a browser configures connection parameters of MQTT; a message sending end is determined; the connection parameters are used as input parameters of scripts; communication messages sent by the message sending end to a message receiving end and communication configurations are encapsulated into a plurality of scripts; and the scripts are executed; and a server completes signal transmission between the message sending end and the message receiving end according to the communication configurations and the communication messages. The application realizes visualization of communication messages of the message sending end and the message receiving end at the front end, facilitates a developer to carry out regression testing and data echoing, and modifies message format attributes, greatly improves the repeated utilization rate of the messages, thereby realizing efficient communication testing work and reducing testing cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of communications, and more specifically, to a communication method, apparatus, device, and storage medium based on MQTT and B / S architecture. Background Technology

[0002] With the development of IoT technology, the MQTT protocol has become one of the important protocols for communication between IoT devices. MQTT is a lightweight publish / subscribe messaging protocol that can provide reliable service in low-bandwidth and unstable network environments. However, when manually sending signals for simulated communication using MQTT-based vehicle-mounted signal communication software, regression testing and data echoing of the software code and messages are not possible, nor are message format attributes that can be modified. This significantly reduces the efficiency of communication testing for developers and increases the cost of communication testing. Summary of the Invention

[0003] To overcome the shortcomings of existing technologies, such as the inability to perform regression testing and data display on software code and messages, and the inability to modify message format attributes, which leads to low efficiency and high cost of communication testing for developers, the present invention proposes the following technical solution:

[0004] Firstly, this invention proposes a communication method based on MQTT and a B / S architecture, comprising:

[0005] Configure MQTT connection parameters in your browser.

[0006] Determine the message sender, and use the connection parameters as input parameters for the scripts. Encapsulate the communication messages and communication configurations sent by the message sender to the message receiver into several scripts.

[0007] The script is executed, and the server completes the signal transmission between the message sender and the message receiver according to the communication configuration and communication messages.

[0008] As a preferred technical solution, when configuring MQTT connection parameters in a browser, the method further includes: storing the API interface address required for configuring MQTT connection parameters in a database.

[0009] As a preferred technical solution, the message sending end and message receiving end include the vehicle end, the APP end, and the cloud end.

[0010] As a preferred technical solution, the communication configuration is set as follows: the message sender sends a communication message to the server by specifying a Topic in the browser; after receiving the communication message, the server that subscribes to the corresponding Topic publishes a receiving message to the message receiver; after receiving the receiving message, the message receiver sends a reply message back to the browser through the server.

[0011] As a preferred technical solution, the communication configuration is set as follows: before the message sender sends a communication message to the server, the vehicle terminal or APP terminal logs into MQTT.

[0012] As a preferred technical solution, the step of logging into MQTT from the vehicle or APP terminal specifically includes:

[0013] The vehicle or app client sends a socket login command to the server via the browser.

[0014] After receiving the socket login command, the server creates an MQTT proxy server and subscribes to the topic of the vehicle or APP client logging into the MQTT proxy server.

[0015] The server publishes a login message to the vehicle or app, and the vehicle or app receives the login message and connects to the MQTT proxy server.

[0016] As a preferred technical solution, when the communication message received by the server contains replacement parameters, the server sends a*b receive messages to the message receiver according to the replacement parameters, where a is the number of groups of replacement parameters and b is the number of parameters in each group of replacement parameters; and the value of the field 'r' representing the fixed requestID in each receive message is encapsulated and replaced according to the replacement parameters in the format of "current millisecond timestamp + current message sequence number".

[0017] Secondly, the present invention also proposes a communication device based on MQTT and B / S architecture, comprising:

[0018] The configuration module is used to configure MQTT connection parameters in the browser.

[0019] The encapsulation module is used to determine the message sender, and use the connection parameters as input parameters for the script to encapsulate the communication messages and communication configuration sent by the message sender to the message receiver into several scripts.

[0020] The execution module is used to execute scripts. The server completes signal transmission between the message sender and message receiver based on the communication configuration and communication messages.

[0021] Thirdly, the present invention also proposes a computing device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to perform operations performed by the communication method based on MQTT and B / S architecture as described in any of the embodiments of the first aspect.

[0022] In a fourth aspect, the present invention also proposes a computer-readable storage medium storing a program that is executed by a processor using the communication method based on MQTT and B / S architecture as described in any of the embodiments of the first aspect.

[0023] Compared with existing technologies, the beneficial effects of the technical solution of this invention are as follows: This invention scripts the required communication configuration and communication messages based on MQTT and B / S architecture. By calling existing MQTT interfaces, multiple runtime environments can be configured. By executing the script, users can automatically simulate the signal communication process by accessing the corresponding URL through a browser. The communication messages of the message sender and receiver are visualized at the front end, which facilitates regression testing and data display for developers, and allows modification of message format attributes. This greatly improves the reusability of messages, thereby achieving highly efficient communication testing and reducing testing costs. Attached Figure Description

[0024] Figure 1 This is a flowchart illustrating the communication method based on MQTT and B / S architecture provided in the embodiments of this application.

[0025] Figure 2 This is a schematic diagram illustrating the communication and interaction between the vehicle, the APP, and the cloud in an embodiment of this application.

[0026] Figure 3 This is a schematic diagram illustrating the specific structure of the debugging page during script encapsulation in an embodiment of this application.

[0027] Figure 4 This is a flowchart illustrating the communication interaction between the APP and the vehicle in this embodiment of the application.

[0028] Figure 5 This is an architecture diagram of a communication device based on MQTT and B / S architecture according to an embodiment of this application.

[0029] Figure 6 A schematic diagram of the structure of a computing device provided in an embodiment of this application. Detailed Implementation

[0030] The embodiments of the present invention will be described below with reference to the accompanying drawings and preferred technical solutions. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be understood that the preferred technical solutions are only for illustrating the present invention and not for limiting the scope of protection of the present invention.

[0031] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of the present invention. Therefore, the drawings only show the components related to the present invention and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.

[0032] In the following description, numerous details are explored to provide a more thorough explanation of embodiments of the invention. However, it will be apparent to those skilled in the art that embodiments of the invention may be practiced without these specific details. In other embodiments, well-known structures and devices are shown in block diagram form rather than in detail to avoid obscuring embodiments of the invention.

[0033] Specifically, Figure 1 This is a flowchart illustrating the communication method based on MQTT and B / S architecture provided in the embodiments of this application.

[0034] like Figure 1 As shown, this communication method based on MQTT and B / S architecture includes the following steps:

[0035] S101: Configure MQTT connection parameters in the browser.

[0036] In the specific implementation process, this includes configuring MQTT connection parameters in the operating environment, the APP, and the vehicle's browser.

[0037] Optionally, in one embodiment of this application, when configuring MQTT connection parameters in a browser, the API interface address required for configuring MQTT connection parameters is stored in a database.

[0038] It is understood that by storing the API interface address required for configuring MQTT connection parameters in the database, the API interface address and subsequent communication messages are stored in a unified manner. This avoids excessive user input, facilitates verification and feedback by developers, and allows the messages sent and received by the script associated with the task to be visualized on the front end, reducing frequent user input. By executing the script and automating the simulation of the entire signal communication process, the reuse rate of communication messages is greatly improved, thereby achieving highly efficient testing.

[0039] S102: Determine the message sending end, and use the connection parameters as the input parameters of the script to encapsulate the communication messages and communication configuration sent by the message sending end to the message receiving end into several scripts.

[0040] Optionally, in one embodiment of this application, the message sending end and message receiving end include a vehicle end, an APP end, and a cloud end.

[0041] like Figure 2 As shown, Figure 2 This is a schematic diagram illustrating the communication and interaction between the vehicle, the APP, and the cloud in an embodiment of this application.

[0042] It is understood that the communication parties (message sender and message receiver) in this application embodiment specifically include three roles: vehicle, APP, and cloud. Since the communication process is bidirectional, each end may become both a sender and a receiver. Here, the message sender tells MQTT where the communication process starts. The communication messages between the two ends and the required communication configuration can be packaged into multiple scripts. During testing, only the script needs to be executed to enable the vehicle-cloud team to manage the MQTT communication messages in a scripted and scenario-based manner.

[0043] S103: Execute the script. The server completes the signal transmission between the message sender and the message receiver according to the communication configuration and communication messages.

[0044] Optionally, in one embodiment of this application, the communication configuration is set as follows: the message sender sends a communication message to the server by specifying a Topic in the browser; after receiving the communication message, the server that subscribes to the corresponding Topic publishes a reception message to the message receiver; after receiving the reception message, the message receiver sends a reply message back to the browser through the server.

[0045] In the actual implementation, communication between the two ends can be simulated on the debugging page of the communication system. After the message sender clicks "send" in the browser, it sends a communication message to the server by specifying a Topic type "mqttMsg". The server, which subscribes to the payload corresponding to the "mqttMsg" event, receives the communication message and receives a socket instruction. Following the simulation of communication via the "mqttMsg" event, it publishes a receive message to the message receiver. After receiving the receive message, the message receiver sends a reply message back to the browser through the server, realizing communication between the browser and the server. At the same time, the reply message received by the message receiver is also sent back through the "mqttMsg" event and displayed in the browser, realizing a complete communication process.

[0046] It is understood that the embodiments of this application visualize the sending and receiving of messages between the APP and the vehicle on the front end, which facilitates verification and feedback by developers. In addition, the sending or receiving messages in the scripts associated with the task can also be visualized on the front end.

[0047] In addition, before the message sender sends a communication message to the server, the vehicle or APP client should log in to MQTT to establish a connection with MQTT.

[0048] In the specific implementation process, the vehicle or APP client sends a socket login command to the server through the browser via the socket "loginMsg"; after receiving the socket login command, the server creates an MQTT proxy server and subscribes to the topic of the vehicle or APP client logging into the MQTT proxy server; the server publishes a login message to the vehicle or APP client, and the vehicle or APP client receives the login message and connects to the MQTT proxy server.

[0049] Optionally, in one embodiment of this application, when the communication message received by the server contains replacement parameters, the server sends a*b receive messages to the message receiver according to the replacement parameters, where a is the number of groups of replacement parameters and b is the number of parameters in each group of replacement parameters; and the value of the field 'r' representing the fixed requestID in each receive message is encapsulated and replaced according to the replacement parameters in the format of "current millisecond timestamp + current message sequence number".

[0050] like Figure 3 As shown, Figure 3 This diagram illustrates the specific structure of the debugging page during script encapsulation in this application embodiment. From top to bottom, it includes prompts indicating whether login was successful on the APP and vehicle sides, the specific JSON message received by the communication receiver, and the specific JSON message sent by the communication sender. The specific JSON message sent by the communication sender contains a "replace variable" field, using the format {'variable1':[value1, value2], 'variable2':[value1, value2]}. The variables to be replaced in the communication message are replaced using the format "$variable1$", "$variable2$".

[0051] In the actual implementation process, on the debugging page, input the communication message to be sent, the replacement parameter A, and parameter values ​​B1, B2, ... , and simultaneously change the value of the attribute to be replaced to "$A$" in the sent message. Then click send. For the timeliness of the message, the server will send a number of replacement parameter groups * the number of parameters in each group (b1+b2+b3...+bn) messages based on the received replacement parameters. The value of field r in each message will be encapsulated according to the format of "current millisecond timestamp + current message sequence number". The value of the field to be replaced will also be changed one by one according to the parameter group. Then the server communicates according to the order of topic subscription and message sending. Figure 4 As shown, Figure 4This is a flowchart illustrating the communication interaction between the APP and the vehicle in this embodiment. At the MQTT message receiver, such as the vehicle, a*b receive messages are received. The 'r' field in these receive messages is now up-to-date. After receiving the latest receive message, if the vehicle wants to send a reply message to the APP, it needs to re-encapsulate the different values ​​of the 'r' field in the vehicle's receive message using the aforementioned encapsulation process to replace the 'r' field in the vehicle's reply message. In other words, the message sender and receiver use the same requestId to represent a completed process.

[0052] It is understood that the embodiments of this application use a parameterized approach that combines use cases and tasks. The message sender sets replacement parameters in the communication message to achieve the effect of sending multiple messages at once and changing the attributes of the message format.

[0053] It is understood that the embodiments of this application script the required communication configuration and communication messages based on MQTT and B / S architecture. By calling existing MQTT interfaces, multiple runtime environments can be configured. By executing the script, users can automatically simulate the signal communication process by accessing the corresponding URL through a browser. The communication messages of the message sender and receiver are visualized at the front end, which facilitates regression testing and data display for developers, and allows modification of message format attributes. This greatly improves the reusability of messages, thereby achieving highly efficient communication testing and reducing testing costs.

[0054] Next, referring to the accompanying drawings, a communication device based on MQTT and B / S architecture proposed according to an embodiment of this application is described.

[0055] Figure 5 This is an architecture diagram of a communication device based on MQTT and B / S architecture according to an embodiment of this application.

[0056] like Figure 5 As shown, the communication device includes: a configuration module 100, an encapsulation module 200, and an execution module 300.

[0057] The configuration module 100 is used to configure MQTT connection parameters in the browser. The encapsulation module 200 is used to determine the message sender, and using the connection parameters as input parameters for the scripts, encapsulates the communication messages sent by the message sender to the message receiver and the communication configuration into several scripts. The execution module 300 is used to execute the scripts, and the server completes the signal transmission between the message sender and the message receiver according to the communication configuration and communication messages.

[0058] It should be noted that the foregoing explanation of the communication method embodiment based on MQTT and B / S architecture also applies to the communication device based on MQTT and B / S architecture in this embodiment, and will not be repeated here.

[0059] It is understood that the embodiments of this application are based on MQTT and B / S architecture to build a complete communication device and carry out functional development and debugging. Users do not need to install additional client software. They can simulate the vehicle signal communication process by using a browser to access the corresponding website, which reduces the operation threshold and the performance requirements of the terminal.

[0060] Figure 6 This is a schematic diagram of the structure of a computing device 400 provided in an embodiment of this application. The computing device 400 includes: a memory 401, a processor 402, and a computer program stored in the memory 401 and executable on the processor 402.

[0061] When the processor 402 executes the program, it implements the communication method based on MQTT and B / S architecture provided in the above embodiments.

[0062] Furthermore, the computing device 400 also includes a communication interface 403 for communication between the memory 401 and the processor 402.

[0063] The memory 401 may include high-speed RAM (Random Access Memory) memory, and may also include non-volatile memory, such as at least one disk storage device.

[0064] If the memory 401, processor 402, and communication interface 403 are implemented independently, then the communication interface 403, memory 401, and processor 402 can be interconnected via a bus to complete communication between them. The bus can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 6 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0065] Optionally, in a specific implementation, if the memory 401, processor 402, and communication interface 403 are integrated on a single chip, then the memory 401, processor 402, and communication interface 403 can communicate with each other through an internal interface.

[0066] Processor 402 may be a CPU (Central Processing Unit), an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement embodiments of this application.

[0067] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described communication method based on MQTT and B / S architecture.

[0068] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0069] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0070] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more N executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.

[0071] It should be understood that the various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, the N steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (FPGAs), field-programmable gate arrays (FPGAs), etc.

[0072] Those skilled in the art will understand that all or part of the steps of the methods described in the above embodiments can be implemented by a program instructing related hardware, and the program can be stored in a computer-readable storage medium. When executed, the program includes one or a combination of the steps of the method embodiments.

[0073] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the implementation of the present invention. Those skilled in the art can make other variations or modifications based on the above description. It is neither necessary nor possible to exhaustively describe all embodiments here. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the claims of the present invention.

Claims

1. A communication method based on MQTT and B / S architecture, characterized in that, include: Configure MQTT connection parameters in your browser; The message sender is determined, and the connection parameters are used as input parameters for the scripts. The communication messages and communication configurations sent by the message sender to the message receiver are encapsulated into several scripts. The message sender and message receiver include a vehicle-side client, an app-side client, and a cloud-based client. The communication configuration is set as follows: before the message sender sends a communication message to the server, the vehicle-side client or app-side client sends a socket login command to the server through the browser. After receiving the socket login command, the server creates an MQTT proxy server and subscribes to the Topic where the vehicle-side client or app-side client logs into the MQTT proxy server. The server publishes a login message to the vehicle-side client or app-side client, and the vehicle-side client or app-side client receives the login message and connects to the MQTT proxy server. The message sender sends the communication message to the server by specifying a Topic in the browser; after receiving the communication message, the server that has subscribed to the corresponding Topic publishes a reception message to the message receiver; after receiving the reception message, the message receiver sends a reply message back to the browser through the server. The script is executed, and the server completes signal transmission between the message sender and message receiver based on the communication configuration and communication messages. When the communication message received by the server contains replacement parameters, the server sends a to the message receiver according to the replacement parameters. b is the received message, where a is the number of groups of replacement parameters and b is the number of parameters in each group of replacement parameters; and the value of the field representing the fixed requestID in each received message is encapsulated and replaced according to the replacement parameters in a format that combines the current millisecond timestamp and the sequence number of the current message. When the message receiving end sends the reply message back to the browser, it replaces the requestID field in the reply message with the replaced value encapsulated in the received message. Based on the replaced requestID field, the reply message is matched with the corresponding communication message to form the same communication process, and the reply message is visualized in the browser.

2. The communication method based on MQTT and B / S architecture according to claim 1, characterized in that, When configuring MQTT connection parameters in a browser, the method further includes storing the API interface addresses required for configuring MQTT connection parameters in a database.

3. A communication device based on MQTT and B / S architecture, applied to the communication method based on MQTT and B / S architecture as described in any one of claims 1 to 2, characterized in that, include: The configuration module is used to configure MQTT connection parameters in the browser; The encapsulation module is used to determine the message sender, and use the connection parameters as input parameters for the script to encapsulate the communication messages and communication configuration sent by the message sender to the message receiver into several scripts. The execution module is used to execute scripts. The server completes signal transmission between the message sender and message receiver based on the communication configuration and communication messages.

4. A computing device, characterized in that, The computing device includes a memory, a processor, and storage devices. A computer program stored in memory and executable on a processor, wherein when the processor executes the program... Implement the operations performed by the communication method based on MQTT and B / S architecture as described in any one of claims 1 to 2.

5. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a program that is executed by a processor according to the communication method based on MQTT and B / S architecture as described in any one of claims 1 to 2.

Citation Information

Patent Citations

  • System testing method and device, computer equipment and storage medium

    CN110413507A

  • APP detection system based on electric power fusion terminal

    CN112463604A

  • Data communication method based on MQTT and Websocket

    CN114866528A