Asynchronous communication method and device, equipment and storage medium

By building an EMQX message server and creating an EMQX client, the problem of low performance of MQ services in the existing technology in high concurrency scenarios is solved, high throughput and reliable asynchronous communication are achieved, and maintenance costs are reduced.

CN120201044APending Publication Date: 2025-06-24GUANGDONG ESHORE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311787131.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-22
Publication Date
2025-06-24

AI Technical Summary

Technical Problem

In the prior art, message queue (MQ) services are difficult to achieve high throughput in high concurrency scenarios and have high maintenance costs.

Method used

By building an EMQX message server to connect to the platform, determining dynamic topics, creating an EMQX client to register and connect to the message server to realize asynchronous communication between the platform and the device.

Benefits of technology

The asynchronous communication method based on the EMQX message server realizes high throughput communication under high concurrency, reduces maintenance costs, and improves the performance and reliability of communication services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120201044A_ABST
    Figure CN120201044A_ABST
Patent Text Reader

Abstract

The invention provides an asynchronous communication method and device, equipment and a storage medium, and the asynchronous communication method comprises the steps: building an EMQX message server to be connected with a platform, determining a dynamic theme for the communication between the platform and the equipment, building an EMQX client according to the EMQX message server and the dynamic theme, and carrying out the registration connection between the EMQX client and the EMQX message server, the platform and the equipment are registered through the EMQX client, the asynchronous communication between the platform and the equipment is carried out through the EMQX client and the EMQX message server, the asynchronous communication between the platform and the equipment is realized based on the EMQX message server and the EMQX client, and the method is extensible and more reliable, and is beneficial to improving the service performance of communication.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communications, and in particular, to an asynchronous communication method, apparatus, device, and storage medium. Background Art

[0002] With the development of Internet of Things (IoT) technology, the number of IoT devices has been increasing continuously, and the communication between IoT devices has become more and more important. To ensure fast, efficient, and reliable communication between IoT devices, many existing technologies use message queues (MQs) to implement asynchronous communication. However, in traditional MQ implementations, common MQ services include RabbitMQ, Kafka, and ActiveMQ, etc. These services have low performance. Due to reasons such as data replication and message lifecycle management, these MQ services often fail to achieve high throughput under high concurrency; the maintenance cost is high, and often more manpower and material resources are required to maintain the entire MQ service. Summary of the Invention

[0003] Embodiments of this application provide an asynchronous communication method, apparatus, device, and storage medium to solve at least one problem existing in the related technologies. The technical solutions are as follows:

[0004] In a first aspect, embodiments of this application provide an asynchronous communication method, including:

[0005] Set up a connection between an EMQX message server and a platform, and determine a dynamic topic for communication between the platform and a device;

[0006] Create an EMQX client according to the EMQX message server and the dynamic topic, and register and connect the EMQX client to the EMQX message server;

[0007] Register the platform and the device through the EMQX client;

[0008] Perform asynchronous communication between the platform and the device through the EMQX client and the EMQX message server.

[0009] In an implementation, the determining the dynamic topic for communication between the platform and the device includes:

[0010] In response to a definition instruction, define a topic for communication between the platform and the device, and define a first field and a second field;

[0011] Determine a first prefix according to the topic and the first field, and determine a second prefix according to the topic and the second field;

[0012] Define a first fixed prefix for the platform to send messages to the device according to the first prefix and the device identifier;

[0013] Define a second fixed prefix for the device to report messages to the platform according to the second prefix, the device identifier, and the attribute reporting definition.

[0014] In one implementation, creating an EMQX client according to the EMQX message server and the dynamic topic includes:

[0015] Obtain the connection information between the EMQX message server and the platform;

[0016] Perform writing processing according to the connection information and the dynamic topic to create an mqtt-sub client and an mqtt-pub client, and the EMQX client includes the mqtt-sub client and the mqtt-pub client.

[0017] In one implementation, registering the platform and the device through the EMQX client includes:

[0018] Send the device parameters of the device to the EMQX message server through the mqtt-sub client;

[0019] Send the device parameters to the platform through the EMQX message server;

[0020] Authenticate the device parameters through the platform, and when the authentication passes, register the platform and the device.

[0021] In one implementation, the EMQX client includes an mqtt-pub client, and performing asynchronous communication between the platform and the device through the EMQX client and the EMQX message server includes:

[0022] When the platform sends a message, generate a message ID;

[0023] Concatenate the first fixed prefix according to the device identifier and the message of the target device to obtain a first concatenated message;

[0024] Send the first concatenated message and the message ID to the EMQX message server through the platform, and the EMQX message server sends the first concatenated message and the message ID to the mqtt-pub client, and the message ID is used to identify the first concatenated message;

[0025] Send the first spliced message and the message ID to the target device through the mqtt-pub client.

[0026] In one implementation, the EMQX client includes an mqtt-sub client. The asynchronous communication between the platform and the device through the EMQX client and the EMQX message server includes:

[0027] When the target device reports a message, splice the second fixed prefix according to the device identifier and the message of the target device to obtain a second spliced message;

[0028] Send the second spliced message and the message ID to the mqtt-sub client through the target device;

[0029] After receiving the second spliced message and the message ID from the mqtt-sub client through the EMQX message server, report the second spliced message and the message ID to the platform.

[0030] In a second aspect, an embodiment of the present application provides an asynchronous communication device, including:

[0031] A determination module for establishing a connection between the EMQX message server and the platform and determining a dynamic topic for communication between the platform and the device;

[0032] A creation module for creating an EMQX client according to the EMQX message server and the dynamic topic, and registering and connecting the EMQX client to the EMQX message server;

[0033] A registration module for registering the platform and the device through the EMQX client;

[0034] A communication module for performing asynchronous communication between the platform and the device through the EMQX client and the EMQX message server.

[0035] In one implementation, the determination module includes:

[0036] A response unit for responding to a definition instruction to define a topic for communication between the platform and the device, and defining a first field and a second field;

[0037] A determination unit for determining a first prefix according to the topic and the first field, and determining a second prefix according to the topic and the second field;

[0038] A first definition unit, configured to define a first fixed prefix for the platform to send messages to the device according to the first prefix and the device identifier.

[0039] A second definition unit, configured to define a second fixed prefix for the device to report messages to the platform according to the second prefix, the device identifier, and the attribute reporting definition.

[0040] In a third aspect, an embodiment of the present application provides an electronic device, including: a processor and a memory. Instructions are stored in the memory, and the instructions are loaded and executed by the processor to implement the method in any one of the above aspects.

[0041] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed, it implements the method in any one of the above aspects.

[0042] The beneficial effects in the above technical solutions at least include:

[0043] By connecting the EMQX message server to the platform and determining the dynamic topic for communication between the platform and the device, creating an EMQX client according to the EMQX message server and the dynamic topic, registering and connecting the EMQX client to the EMQX message server, registering the platform and the device through the EMQX client, and performing asynchronous communication between the platform and the device through the EMQX client and the EMQX message server. Implementing asynchronous communication between the platform and the device based on the EMQX message server and the EMQX client is scalable and more reliable, which is beneficial to improving the service performance of communication.

[0044] The above summary is only for the purpose of the specification and is not intended to be limiting in any way. In addition to the above-described illustrative aspects, embodiments, and features, further aspects, embodiments, and features of the present application will be readily apparent by reference to the drawings and the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In the drawings, unless otherwise specified, the same reference numerals throughout the drawings denote the same or similar components or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings only depict some embodiments disclosed in the present application and should not be regarded as limiting the scope of the present application.

[0046] Figure 1 It is a schematic flowchart of the steps of an asynchronous communication method according to an embodiment of the present application;

[0047] Figure 2 It is a schematic diagram of the communication between the platform and the device according to an embodiment of the present application;

[0048] Figure 3 Block diagram of an asynchronous communication device according to an embodiment of the present application;

[0049] Figure 4 Block diagram of an electronic device according to an embodiment of the present application. Detailed implementation manners

[0050] In the following, only some exemplary embodiments are simply described. As those skilled in the art can recognize, the described embodiments can be modified in various different ways without departing from the spirit or scope of the present application. Therefore, the drawings and the description are considered to be exemplary in nature rather than restrictive.

[0051] Referring to Figure 1 and Figure 2 , a flowchart of an asynchronous communication method according to an embodiment of the present application is shown. The asynchronous communication method may at least include steps S100 - S400:

[0052] S100. Set up the EMQX message server to connect with the platform and determine the dynamic topic for communication between the platform and the device.

[0053] S200. Create an EMQX client according to the EMQX message server and the dynamic topic, and register and connect the EMQX client to the EMQX message server.

[0054] S300. Register the platform and the device through the EMQX client.

[0055] S400. Perform asynchronous communication between the platform and the device through the EMQX client and the EMQX message server.

[0056] The asynchronous communication method of the embodiment of the present application can be executed by an electronic control unit, a controller, a processor, etc. of terminals such as a computer, a mobile phone, a tablet, a vehicle-mounted terminal, etc., or can also be executed by a cloud server.

[0057] The technical solution of the embodiment of the present application, by setting up the EMQX message server to connect with the platform and determining the dynamic topic for communication between the platform and the device, creating an EMQX client according to the EMQX message server and the dynamic topic, registering and connecting the EMQX client to the EMQX message server, registering the platform and the device through the EMQX client, and performing asynchronous communication between the platform and the device through the EMQX client and the EMQX message server, realizes asynchronous communication between the platform and the device based on the EMQX message server and the EMQX client, is extensible and more reliable, and is beneficial to improving the service performance of communication.

[0058] In one embodiment, in a Linux environment, the EMQX message server can be installed and started by means of installation packages, source code compilation, etc. provided in the official documentation, and the EMQX message server can be connected to the platform; then it is determined that the message server is connected to the platform, and the dynamic topics (message protocols) for the platform to communicate with the devices are determined.

[0059] Optionally, in step S100, determining the dynamic topics for the platform to communicate with the devices includes steps S110 - S140:

[0060] S110. In response to a definition instruction, define the topic for the platform to communicate with the devices, and define the first field and the second field.

[0061] It should be noted that in the embodiments of the present application, the mutual communication between the platform and the devices is based on the topic. Therefore, the protocol needs to be defined first. Optionally, by inputting a definition instruction, the platform or the EMQX message server responds to the definition instruction to define the topic for the platform to communicate with the devices, and define the first field and the second field. For example, the first field can be sys2dev, and the second field can be dev2sys.

[0062] S120. Determine the first prefix according to the topic and the first field, and determine the second prefix according to the topic and the second field.

[0063] For example, determine the first prefix according to the topic and the first field sys2dev: topic / sys2dev, and determine the second prefix according to the topic and the second field dev2sys: topic / dev2sys.

[0064] S130. Define the first fixed prefix for the platform to send messages to the devices according to the first prefix and the device identifier.

[0065] Optionally, define the first fixed prefix for the platform to send messages to the devices: topic / sys2dev / device identifier. For example, when the device identifier of the target device to which a message needs to be sent is E0B6I7 - VQKZ16, the first fixed prefix is topic / sys2dev / E0B6I7 - VQKZ16. It should be noted that the device identifier can be the device SN identifier.

[0066] S140. Define the second fixed prefix for the devices to report messages to the platform according to the second prefix, the device identifier, and the attribute reporting definition.

[0067] Optionally, define a second fixed prefix for the device to report messages to the platform: topic / sys2dev / device identifier / attribute reporting definition. For example, if the device identifier is E0B6I7-VQKZ16 and the attribute reporting definition is the business module interface name, such as prop or event, the corresponding second fixed prefix can be topic / sys2dev / E0B6I7-VQKZ16 / prop or topic / dev2sys / E0B6I7-VQKZ16 / event.

[0068] In one implementation, the EMQX client is used for authenticating devices, sending and receiving device messages, including the mqtt-sub client and the mqtt-pub client. Creating the EMQX client according to the EMQX message server and the dynamic topic in step S200 includes steps S210 - S220:

[0069] S210. Obtain the connection information between the EMQX message server and the platform.

[0070] S220. Write and process according to the connection information and the dynamic topic to create the mqtt-sub client and the mqtt-pub client.

[0071] Optionally, after the EMQX message server is connected to the platform, the connection information between the EMQX message server and the platform can be obtained and written in the Java language in combination with the dynamic topic to create the mqtt-sub client and the mqtt-pub client.

[0072] In the embodiment of the present application, after creating the mqtt-sub client and the mqtt-pub client, register and connect the mqtt-sub client and the mqtt-pub client to the EMQX message server. The platform will communicate asynchronously with the IOT device through mqtt-sub and mqtt-pub, define the payload data structure, and thus realize the interaction at the business logic level. Specifically, the message is sent by connecting the mqtt-pub client to the EMQX message server, and the message is subscribed through the mqtt-sub client, that is, the message reported by the device is received.

[0073] In one implementation, step S300 includes steps S310 - S330:

[0074] S310. Send the device parameters of the device to the EMQX message server through the mqtt-sub client.

[0075] Optionally, the device parameters include but are not limited to ClientID, Username (device identifier such as device SN code), and Password (the hash of the device SN code after being encrypted by sha256). That is, the device parameters are encrypted according to the encryption rule and then sent to the mqtt-sub client, and the device parameters of the device are sent to the EMQX message server through the mqtt-sub client.

[0076] S320: Send the device parameters to the platform through the EMQX message server.

[0077] S330: Authenticate the device parameters through the platform. When the authentication passes, register the platform and the device.

[0078] Optionally, authenticate the device parameters through the platform. When the authentication passes, the device is allowed to register. The device initiates a long connection with the MQTT message server. After the connection is successful, the device can communicate with the platform asynchronously. Among them, when the authentication passes, the platform creates a topic for the device to monitor the messages reported by the device.

[0079] In one implementation, step S400 includes steps S410 - S440:

[0080] S410: Generate a message ID when the platform sends a message.

[0081] Optionally, when the platform needs to send a message to a device (denoted as the target device), the platform generates a unique message ID.

[0082] S420: Concatenate the first fixed prefix according to the device identifier of the target device and the message to obtain the first concatenated message.

[0083] Optionally, concatenate the first fixed prefix according to the device identifier of the target device and the message to obtain the first concatenated message. For example, if the device identifier is E0B6I7-VQKZ16, the first concatenated message is topic / sys2dev / E0B6I7-VQKZ16 / message.

[0084] S430: Send the first concatenated message and the message ID to the EMQX message server through the platform. The EMQX message server sends the first concatenated message and the message ID to the mqtt-pub client. The message ID is used to identify the first concatenated message.

[0085] Among them, the platform sends the first spliced message and the message ID to the EMQX message server according to the dynamic topic, and then the EMQX message server stores the first spliced message and the message ID under the corresponding Topic. Among them, the storage of messages can adopt various methods, such as memory storage, disk storage, database storage, and the storage strategy can be determined according to the requirements of the actual application scenario. The message ID is used to identify the first spliced message. Then, the EMQX message server sends the first spliced message and the message ID to the mqtt-pub client.

[0086] S440. Send the first spliced message and the message ID to the target device through the mqtt-pub client.

[0087] Finally, send the first spliced message and the message ID to the target device through the mqtt-pub client, thus completing the message sending.

[0088] It should be noted that the platform can listen to the messages reported by the device side by automatically subscribing to the prefix including the topic in the dynamic topic.

[0089] In one implementation, step S400 includes steps S450 - S470:

[0090] S450. When the target device reports a message, splice the second fixed prefix according to the device identifier and the message of the target device to obtain the second spliced message.

[0091] It should be noted that when the target device receives the first spliced message and the message ID sent by the platform and needs to report a message after processing the first spliced message, that is, when the target device reports a message, splice the second fixed prefix according to the device identifier and the message of the target device to obtain the second spliced message. For example, the second spliced message is: topic / sys2dev / E0B6I7-VQKZ16 / prop / message.

[0092] S460. Send the second spliced message and the message ID to the mqtt-sub client through the target device.

[0093] Optionally, send the second spliced message and the message ID to the mqtt-sub client through the target device, and the message ID is used to represent the processing result of the reply report, that is, the second spliced message.

[0094] S470. After receiving the second spliced message and the message ID from the mqtt-sub client through the EMQX message server, report the second spliced message and the message ID to the platform.

[0095] Optionally, after receiving the second spliced message and the message ID of the mqtt-sub client through the EMQX message server, the EMQX message server reports the second spliced message and the message ID to the platform, completes the message reporting from the device to the platform, and completes the asynchronous communication process between the platform and the device.

[0096] Through the method of the embodiments of the present application, at least the following effects can be achieved:

[0097] 1) An EMQX message server based on the MQTT protocol implements an extensible, reliable, and high-transmission-efficiency IOT asynchronous communication method. EMQX is an MQTT message server based on the Erlang language, adopting features such as asynchronous event-driven and non-blocking I / O to improve the performance of message delivery, so as to meet the requirements of message communication in large-scale and high-concurrency application scenarios, and has good performance and reliability.

[0098] 2) Through the agreed topic, the data transmission between the platform and the IOT device is asynchronous. An MQTT message server is created through the EMQX framework, that is, the EMQX message server is used as an MQTT message service middleware, and asynchronous communication is carried out with the Internet of Things (IOT) devices through the publish-subscribe method, with high efficiency of message transmission. Achieving a response speed in milliseconds can meet the performance requirements in high-concurrency application scenarios. At the same time, in order to ensure that the IOT device can normally receive the transmitted data and process the business logic, a message reply confirmation mechanism such as a message ID is introduced to achieve reliable message transmission and form a closed loop for the system business;

[0099] 3) It can reduce the maintenance cost, and at the same time improve the performance and efficiency of message transmission, and is applicable to various IOT scenarios, such as artificial intelligence, smart home, smart healthcare, etc.

[0100] 4) The EMQX message server supports cluster deployment and can be horizontally scaled to meet the high-concurrency access requirements in application scenarios. The device sends messages to the EMQX message server through the MQTT protocol. During the process of sending messages, content such as the QoS level and Payload data of the message can be set. The EMQX message server supports multiple protocols and can adapt to different IOT devices and application scenarios.

[0101] 5) Easy to deploy and maintain: The EMQX framework has friendly development documentation and community support, as well as a convenient plugin management system, and can quickly build an IOT device asynchronous communication system based on the EMQX framework.

[0102] Referring to Figure 3 , a structural block diagram of an asynchronous communication device according to an embodiment of the present application is shown. The device may include:

[0103] A determination module, configured to establish a connection between the EMQX message server and the platform, and determine a dynamic topic for communication between the platform and the device;

[0104] A creation module, configured to create an EMQX client according to the EMQX message server and the dynamic topic, and register and connect the EMQX client to the EMQX message server;

[0105] A registration module, configured to register the platform and the device through the EMQX client;

[0106] A communication module, configured to perform asynchronous communication between the platform and the device through the EMQX client and the EMQX message server.

[0107] In one implementation manner, the determination module includes:

[0108] A response unit, configured to, in response to a definition instruction, define a topic for communication between the platform and the device, and define a first field and a second field;

[0109] A determination unit, configured to determine a first prefix according to the topic and the first field, and determine a second prefix according to the topic and the second field;

[0110] A first definition unit, configured to define a first fixed prefix for the platform to send a message to the device according to the first prefix and the device identifier;

[0111] A second definition unit, configured to define a second fixed prefix for the device to report a message to the platform according to the second prefix, the device identifier, and the attribute reporting definition.

[0112] For the functions of the modules in each device of the embodiments of the present application, reference may be made to the corresponding descriptions in the above methods, which will not be elaborated here.

[0113] Refer to Figure 4 , which shows a structural block diagram of an electronic device according to an embodiment of the present application. The electronic device includes: a memory 310 and a processor 320. Instructions that can run on the processor 320 are stored in the memory 310, and the processor 320 loads and executes the instructions to implement the asynchronous communication method in the above embodiment. Among them, the number of the memory 310 and the processor 320 may be one or more.

[0114] In one embodiment, the electronic device further includes a communication interface 330 for communicating with external devices and performing data interaction and transmission. If the memory 310, the processor 320, and the communication interface 330 are implemented independently, the memory 310, the processor 320, and the communication interface 330 can be interconnected through a bus to complete communication with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 only a thick line is used to represent it in Figure 4 , but it does not mean that there is only one bus or one type of bus.

[0115] Optionally, in a specific implementation, if the memory 310, the processor 320, and the communication interface 330 are integrated on a single chip, the memory 310, the processor 320, and the communication interface 330 can complete communication with each other through an internal interface.

[0116] The embodiment of the present application provides a computer-readable storage medium storing a computer program, which when executed by a processor implements the asynchronous communication method provided in the above embodiment.

[0117] The embodiment of the present application further provides a chip, which includes a processor for calling and running instructions stored in a memory, so that a communication device installed with the chip executes the method provided in the embodiment of the present application.

[0118] The embodiment of the present application further provides a chip, including: an input interface, an output interface, a processor, and a memory. The input interface, the output interface, the processor, and the memory are connected through an internal connection path. The processor is used to execute the code in the memory, and when the code is executed, the processor is used to execute the method provided in the embodiment of the application.

[0119] It should be understood that the above-mentioned processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc. It is worth noting that the processor can be a processor that supports the advanced RISC machines (ARM) architecture.

[0120] Furthermore, optionally, the above-mentioned memory can include a read-only memory and a random access memory, and can also include a non-volatile random access memory. The memory can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can include a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can include a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available. For example, static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchlink dynamic random access memory (SLDRAM), and direct rambus random access memory (DR RAM).

[0121] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions according to the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another.

[0122] In the description of this specification, the descriptions with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples", etc. mean that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present application. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples.

[0123] In addition, the terms "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" can explicitly or implicitly include at least one of the features. In the description of the present application, "a plurality of" means two or more, unless otherwise specifically defined.

[0124] Any process or method description represented in the flowchart or described in other ways herein can be understood as representing a module, segment, or part of the code of executable instructions including one or more steps for implementing a specific logical function or process. And the scope of the preferred embodiments of the present application includes additional implementations, where the functions can be executed in a substantially simultaneous manner or in the reverse order according to the involved functions, rather than in the order shown or discussed.

[0125] The logic and / or steps represented in the flowchart or described in other ways herein, for example, can be considered as a sequenced list of executable instructions for implementing a logical function and can be specifically implemented in any computer-readable medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other systems that can fetch and execute instructions from the instruction execution system, apparatus, or device), or in connection with these instruction execution systems, apparatus, or devices.

[0126] It should be understood that each part of the present application can be implemented by hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. All or part of the steps of the method in the above embodiments can be completed by a program instructing relevant hardware. The program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiments.

[0127] In addition, each functional unit in various embodiments of the present application can be integrated into a processing module, or each unit can exist physically alone, or two or more units can be integrated into one module. The above integrated module can be implemented in the form of hardware or in the form of a software functional module. If the above integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. The storage medium can be a read-only memory, a magnetic disk, an optical disk, etc.

[0128] The above is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art within the technical scope disclosed in the present application can easily think of various changes or substitutions, and these should all be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. An asynchronous communication method, characterized in that, Including: Set up the connection between the EMQX message server and the platform, and determine the dynamic topic for the platform to communicate with the device; Create an EMQX client according to the EMQX message server and the dynamic topic, and register and connect the EMQX client to the EMQX message server; Register the platform and the device through the EMQX client; Perform asynchronous communication between the platform and the device through the EMQX client and the EMQX message server.

2. The asynchronous communication method according to claim 1, wherein: The determination of the dynamic topic for the platform to communicate with the device includes: In response to a definition instruction, define the topic for the platform to communicate with the device, and define the first field and the second field; Determine the first prefix according to the topic and the first field, and determine the second prefix according to the topic and the second field; Define the first fixed prefix for the platform to send messages to the device according to the first prefix and the device identifier; Define the second fixed prefix for the device to report messages to the platform according to the second prefix, the device identifier, and the attribute reporting definition.

3. The asynchronous communication method according to claim 1 or 2, wherein: The creation of the EMQX client according to the EMQX message server and the dynamic topic includes: Obtain the connection information between the EMQX message server and the platform; Perform writing and processing according to the connection information and the dynamic topic to create an mqtt-sub client and an mqtt-pub client, and the EMQX client includes the mqtt-sub client and the mqtt-pub client.

4. The asynchronous communication method according to claim 3, wherein: The registration of the platform and the device through the EMQX client includes: Send the device parameters of the device to the EMQX message server through the mqtt-sub client; Send the device parameters to the platform through the EMQX message server; Authenticate the device parameters through the platform, and when the authentication passes, register the platform and the device.

5. The asynchronous communication method according to claim 2, characterized in that: The EMQX client includes an mqtt-pub client. The asynchronous communication between the platform and the device through the EMQX client and the EMQX message server includes: Generate a message ID when the platform sends a message; Concatenate the first fixed prefix according to the device identifier and the message of the target device to obtain a first concatenated message; Send the first concatenated message and the message ID to the EMQX message server through the platform, and the EMQX message server sends the first concatenated message and the message ID to the mqtt-pub client, and the message ID is used to identify the first concatenated message; Send the first concatenated message and the message ID to the target device through the mqtt-pub client.

6. The asynchronous communication method according to claim 5, wherein: The EMQX client includes an mqtt-sub client. The asynchronous communication between the platform and the device through the EMQX client and the EMQX message server includes: When the target device reports a message, the second fixed prefix is concatenated according to the device identifier of the target device and the message to obtain a second concatenated message; The second concatenated message and the message ID are sent to the mqtt-sub client through the target device; After receiving the second concatenated message and the message ID from the mqtt-sub client through the EMQX message server, the second concatenated message and the message ID are reported to the platform.

7. An asynchronous communication device, characterized in that, Includes: A determination module, configured to establish a connection between the EMQX message server and the platform, and determine a dynamic topic for communication between the platform and the device; A creation module, configured to create an EMQX client according to the EMQX message server and the dynamic topic, and register and connect the EMQX client to the EMQX message server; A registration module, configured to register the platform and the device through the EMQX client; A communication module, configured to perform asynchronous communication between the platform and the device through the EMQX client and the EMQX message server.

8. The asynchronous communication device according to claim 7, wherein: The determination module includes: A response unit, configured to define a topic for communication between the platform and the device, and define a first field and a second field in response to a definition instruction; A determination unit, configured to determine a first prefix according to the topic and the first field, and determine a second prefix according to the topic and the second field; A first definition unit, configured to define a first fixed prefix for the platform to send a message to the device according to the first prefix and the device identifier; A second definition unit, configured to define a second fixed prefix for the device to report a message to the platform according to the second prefix, the device identifier, and the attribute reporting definition.

9. An electronic device, characterized in that, Includes: A processor and a memory, wherein instructions are stored in the memory, and the instructions are loaded and executed by the processor to implement the method according to any one of claims 1 to 6.

10. A computer-readable storage medium, in which a computer program is stored, and when the computer program is executed, the method according to any one of claims 1-6 is implemented.