Internet of Things terminal operation and maintenance method and device based on MQTT protocol, and electronic equipment
By adopting the MQTT protocol and silent cycle method in the operation and maintenance of IoT terminals, the operation and maintenance time and traffic consumption problems caused by the HTTP protocol are solved, and more efficient operation and maintenance and traffic savings are achieved.
Patent Information
- Application Number
- CN202411501332.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-25
- Publication Date
- 2025-02-18
AI Technical Summary
In the operation and maintenance of IoT terminal devices in the prior art, the request-response mode of the HTTP protocol leads to the extended operation and maintenance time of the device and the consumption of communication traffic is large.
The MQTT protocol is used to establish a communication connection between the platform and the Internet of Things terminal, set a silent cycle, and the Internet of Things terminal actively sends update information and receives operation and maintenance messages, executes operation commands and feedbacks the execution results.
It shortens the time required for the operation and maintenance of IoT terminals, improves operation and maintenance efficiency, reduces communication traffic consumption through silent cycles, and saves traffic during operation and maintenance.
Smart Images

Figure CN119484569A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of operation and maintenance technology of Internet of Things terminal equipment, and in particular to an Internet of Things terminal operation and maintenance method, device, electronic equipment and storage medium based on the MQTT protocol. Background Art
[0002] With the popularization of IoT technology and the importance of data collection, all walks of life are gradually using smart devices to provide services, and equipment manufacturers need to maintain the equipment after selling it. In the existing technology, information interaction is achieved through the HTTP protocol, but the HTTP protocol adopts a request-response mode, which requires the client to actively send a request to obtain data. Each HTTP communication requires a complete request-response cycle, which leads to an increase in the time required for the operation and maintenance of each device, and a large amount of traffic consumed by each device communication. Summary of the invention
[0003] To solve the problems existing in the prior art, one or more embodiments of this specification describe an IoT terminal operation and maintenance method, device, electronic device and storage medium based on the MQTT protocol.
[0004] According to a first aspect, a method for operating and maintaining an IoT terminal based on the MQTT protocol is provided, the method comprising: S101, establishing a communication connection between the platform and the IoT terminal based on the MQTT protocol, setting a silent period, and executing S102 once in each silent period; S102, the IoT terminal sends update information to the platform, and the platform generates an operation and maintenance message after receiving the update information. The platform sends the operation and maintenance message to the IoT terminal, and the IoT terminal receives the operation and maintenance message sent by the platform and executes the operation command. The platform receives the execution result fed back by the IoT terminal.
[0005] Preferably, the update information includes configuration information, device attributes and device status of the Internet of Things terminal.
[0006] Preferably, the following steps are performed before the IoT terminal sends the update information to the platform: The platform receives a subscription message sent by the IoT terminal, where the subscription message is used to subscribe to all messages containing a certain message topic; The operation and maintenance message includes a message subject corresponding to the subscription message and a message of the message subject.
[0007] Preferably, the message subject includes a first subject segment and a second subject segment, the first subject segment represents the device number of the Internet of Things terminal, and the second subject segment represents the actual message subject.
[0008] Preferably, the actual message topics include an upgrade task topic, a debugging task topic, an application installation task topic, and a log acquisition task topic.
[0009] Preferably, the method further comprises: A waiting time is set. If the IoT terminal does not receive the operation and maintenance information during the waiting time, it enters the next silent cycle after the waiting time.
[0010] Preferably, the silent period is 24 hours.
[0011] According to a second aspect, a target detection device is provided, the device comprising: The first operation and maintenance module is used to establish a communication connection between the platform and the IoT terminal based on the MQTT protocol, set a silent period, and execute the content of the second operation and maintenance module once in each silent period; The second operation and maintenance module is used for the IoT terminal to send update information to the platform. After receiving the update information, the platform generates an operation and maintenance message. The platform sends the operation and maintenance message to the IoT terminal. The IoT terminal receives the operation and maintenance message sent by the platform and executes the operation command. The platform receives the execution result fed back by the IoT terminal.
[0012] According to a third aspect, there is provided an electronic device, comprising a processor and a memory; The processor is connected to the memory; The memory is used to store executable program code; The processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the steps of the method provided in the first aspect or any possible implementation manner of the first aspect.
[0013] According to a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, and the computer-readable storage medium stores instructions, which, when the instructions are executed on a computer or a processor, cause the computer or the processor to execute the method provided in the first aspect or any possible implementation of the first aspect.
[0014] The beneficial effects of the present invention are: 1. The method and device provided in the embodiments of this specification establish a communication connection between the platform and the IoT terminal through the MQTT protocol. The IoT terminal can actively communicate with the platform without the need for the platform to actively send a request to obtain data. The time required for the operation and maintenance of each IoT terminal is shortened, thereby improving the operation and maintenance efficiency. By setting a silent period, the IoT terminal only performs communication and operation and maintenance operations once within a period of time, thereby avoiding the traffic consumption caused by continuous communication, thereby saving the required traffic during the operation and maintenance of the IoT terminal. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0016] Figure 1 It is a flowchart of an IoT terminal operation and maintenance method based on the MQTT protocol in the specific implementation of this specification; Figure 2 It is a structural diagram of an IoT terminal operation and maintenance device in the specific implementation of this specification; Figure 3 It is a structural schematic diagram of an electronic device in the specific implementation of this specification; DETAILED DESCRIPTION
[0017] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0018] In the following introduction, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance. The following introduction provides multiple embodiments of the present application, and different embodiments can be replaced or combined, so the present application can also be considered to include all possible combinations of the same and / or different embodiments recorded. Therefore, if one embodiment includes features A, B, and C, and another embodiment includes features B and D, then the present application should also be considered to include embodiments containing one or more of all other possible combinations of A, B, C, and D, although the embodiment may not be clearly recorded in the following text.
[0019] The following description provides examples and does not limit the scope, applicability or examples set forth in the claims. Changes may be made to the functions and arrangements of the elements described without departing from the scope of the present application. Various processes or components may be appropriately omitted, substituted or added to each example. For example, the described method may be performed in an order different from the order described, and various steps may be added, omitted or combined. In addition, features described in some examples may be combined in other examples.
[0020] See also Figure 1 , Figure 1 : is a flow chart of an IoT terminal operation and maintenance method based on the MQTT protocol provided in an embodiment of the present application. In an embodiment of the present application, the method includes: S101, establishing a communication connection between the platform and the IoT terminal based on the MQTT protocol, setting a silent period, and executing S102 once in each silent period; S102, the IoT terminal sends update information to the platform, and the platform generates an operation and maintenance message after receiving the update information. The platform sends the operation and maintenance message to the IoT terminal, and the IoT terminal receives the operation and maintenance message sent by the platform and executes the operation command. The platform receives the execution result fed back by the IoT terminal.
[0021] It should be noted that the platform side can specifically be a cloud service platform, which can be integrated on a server, and the platform side stores information of the IoT terminals in the entire system.
[0022] In the embodiment of this specification, the IoT terminal first sends a CONNECT data packet to the platform end, and this data packet includes various parameters of the connection request, such as the protocol version, the client identifier, etc. After receiving the CONNECT data packet, the platform end will perform identity authentication and authority verification. If the verification is successful, the platform end will send a CONNACK data packet to the IoT terminal, indicating that the communication connection has been established, and the IoT terminal and the platform end can start communicating. Then set a silent period, and perform the following operation and maintenance operations once in each silent period: the IoT terminal first sends update information to the platform end. After the platform end receives the update information, the operator can call up the update information initiated by the IoT terminal from the PC end, so as to interact with the platform end to issue operation and maintenance tasks. After receiving the operation and maintenance tasks, the platform end will generate an operation and maintenance message and send the operation and maintenance message to the IoT terminal. The IoT terminal has the operation and maintenance process required by the IoT terminal pre-integrated inside. After receiving the operation and maintenance message, the IoT terminal will execute the pre-set process according to the content of the operation and maintenance message. After the operation and maintenance operation of the IoT terminal is completed, the IoT terminal will feedback the execution result to the platform end.
[0023] To summarize, in the present application, a communication connection is established between the platform and the IoT terminal through the MQTT protocol. The IoT terminal can actively communicate with the platform without the need for the platform to actively send a request to obtain data. The time required for the operation and maintenance of each IoT terminal is shortened, thereby improving the operation and maintenance efficiency. By setting a silent period, the IoT terminal only performs communication and operation and maintenance operations once within a period of time, thereby avoiding the traffic consumption caused by constant communication, thereby saving the required traffic during the operation and maintenance of the IoT terminal.
[0024] Specifically, the silent period is 24 hours, that is, the IoT terminal will report update information and perform an operation and maintenance operation every 24 hours.
[0025] In one possible implementation, the update information includes configuration information of the IoT terminal, device attributes of the IoT terminal, and device status of the IoT terminal. The operator calls up the configuration information of the IoT terminal, the device attributes of the IoT terminal, and the device status of the IoT terminal to determine what operation and maintenance operation should be performed on each IoT terminal.
[0026] In one possible implementation, before the IoT terminal sends an update message to the platform, the IoT terminal will send a subscription message to the platform. The subscription message is presented in the form of a message, requesting to subscribe to a certain topic. After receiving the subscription message, the platform will confirm the subscription and return the subscription result, which is also presented in the form of a message. The operation and maintenance message includes the message subject corresponding to the subscription message and the message of the message subject. The message subject is used to identify the message, thereby classifying the message, making the communication between the platform and the IoT terminal more efficient.
[0027] It should be noted that the message subject is specifically a character string that identifies the communication information between the IoT terminal and the platform. When the IoT terminal communicates with the platform, all messages sent by both the IoT terminal and the platform carry a message subject. The IoT terminal can subscribe to a single or multiple topics. When the platform sends a message with a certain topic, all IoT terminals that subscribe to the topic can receive it.
[0028] Furthermore, the message subject includes a first subject segment and a second subject segment, the first subject segment indicates the device number of the IoT terminal, and the second subject segment indicates the actual message subject. The first subject segment indicates the device number of the IoT terminal. When the platform sends an operation and maintenance message to the IoT terminal, the corresponding IoT terminal will be retrieved according to the device number to ensure orderly and correct communication.
[0029] Specifically, the actual message topics include an upgrade task topic, a debugging task topic, an application installation task topic, and a log acquisition task topic.
[0030] For example, if an IoT terminal subscribes to the update topic, then after the platform sends a message with the update topic, all IoT terminals that subscribe to the update topic will receive the message. The IoT terminal will determine it as an upgrade task and then execute the upgrade process integrated in the IoT terminal.
[0031] In one possible implementation, when setting the silent period, the waiting time is also set. When the IoT terminal sends the update information to the platform, the timing starts. If the information sent by the platform is not received after the waiting time, the next silent period begins. By setting the waiting time, the IoT terminal can avoid the situation where it has to wait for information from the platform, thereby avoiding the waste of communication resources.
[0032] Specifically, the waiting time is generally set to 1 minute.
[0033] In one possible implementation, the IoT terminal also executes an operation and maintenance message execution process, a task retry process, and a task rollback process. That is, the operation and maintenance module needs to include an operation and maintenance message execution process, which is used to execute the operation and maintenance message according to the process. In addition, it can also include one or more of the task retry process and the task rollback process, so as to realize task retry, task rollback, etc. The operation and maintenance message retry process is to retry the operation and maintenance message, and the operation and maintenance message rollback process is to roll back the executed operation and maintenance message.
[0034] The following will be combined with the attached Figure 2 , the IoT terminal operation and maintenance device provided in the embodiment of the present application is introduced in detail. It should be noted that the attached Figure 2 The IoT terminal operation and maintenance device shown is used to execute this application Figure 1 For the convenience of explanation, only the part related to the embodiment of the present application is shown. For the specific technical details not disclosed, please refer to the present application. Figure 1 The embodiment shown.
[0035] See also Figure 2 , Figure 2 Schematic diagram of the structure of the IoT terminal operation and maintenance device provided in the embodiment of the present application. Figure 2 As shown, the device comprises: The first operation and maintenance module is used to establish a communication connection between the platform and the IoT terminal based on the MQTT protocol, set a silent period, and execute the content of the second operation and maintenance module once in each silent period; The second operation and maintenance module is used for the IoT terminal to send update information to the platform. After receiving the update information, the platform generates an operation and maintenance message. The platform sends the operation and maintenance message to the IoT terminal. The IoT terminal receives the operation and maintenance message sent by the platform and executes the operation command. The platform receives the execution result fed back by the IoT terminal.
[0036] Furthermore, the update information includes configuration information, device attributes and device status of the IoT terminal.
[0037] Furthermore, the following steps are performed before the IoT terminal sends update information to the platform: The platform receives a subscription message sent by the IoT terminal, where the subscription message is used to subscribe to all messages containing a certain message topic; The operation and maintenance message includes a message subject corresponding to the subscription message and a message of the message subject.
[0038] Furthermore, the message topic includes a first topic segment and a second topic segment, the first topic segment represents the device number of the Internet of Things terminal, and the second topic segment represents the actual message topic.
[0039] Furthermore, the actual message topics include an upgrade task topic, a debugging task topic, an application installation task topic, and a log acquisition task topic.
[0040] Furthermore, the method further comprises: A waiting time is set. If the IoT terminal does not receive the operation and maintenance information during the waiting time, it enters the next silent cycle after the waiting time.
[0041] Furthermore, the silent period is 24 hours.
[0042] Those skilled in the art can clearly understand that the technical solutions of the embodiments of the present application can be implemented with the help of software and / or hardware. The "unit" and "module" in this specification refer to software and / or hardware that can independently complete or cooperate with other components to complete specific functions, where the hardware can be, for example, a field programmable gate array (FPGA), an integrated circuit (IC), etc.
[0043] Each processing unit and / or module of the embodiments of the present application may be implemented by an analog circuit that implements the functions described in the embodiments of the present application, or may be implemented by software that executes the functions described in the embodiments of the present application.
[0044] See also Figure 3 , which shows a schematic diagram of the structure of an electronic device involved in an embodiment of the present application, the electronic device can be used to implement Figure 1 The method in the embodiment shown. Figure 3 As shown, the electronic device 300 may include: at least one central processor 301 , at least one network interface 304 , a user interface 303 , a memory 305 , and at least one communication bus 302 .
[0045] The communication bus 302 is used to realize the connection and communication between these components.
[0046] The user interface 303 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 303 may also include a standard wired interface and a wireless interface.
[0047] The network interface 304 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).
[0048] Among them, the central processing unit 301 may include one or more processing cores. The central processing unit 301 uses various interfaces and lines to connect various parts of the entire electronic device 300, and executes various functions and processes data of the terminal 300 by running or executing instructions, programs, code sets or instruction sets stored in the memory 305, and calling data stored in the memory 305. Optionally, the central processing unit 301 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The central processing unit 301 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the central processing unit 301, but implemented separately through a chip.
[0049] Among them, the memory 305 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 305 includes a non-transitory computer-readable storage medium. The memory 305 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 305 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 305 may optionally be at least one storage device located away from the aforementioned central processor 301. As Figure 3 As shown, the memory 305 as a computer storage medium may include an operating system, a network communication module, a user interface module, and program instructions.
[0050] exist Figure 3In the electronic device 300 shown, the user interface 303 is mainly used to provide an input interface for the user and obtain data input by the user; and the central processor 301 can be used to call the application stored in the memory 305 and specifically perform the following operations: S101, establishing a communication connection between the platform and the IoT terminal based on the MQTT protocol, setting a silent period, and executing S102 once in each silent period; S102, the IoT terminal sends update information to the platform, and the platform generates an operation and maintenance message after receiving the update information. The platform sends the operation and maintenance message to the IoT terminal, and the IoT terminal receives the operation and maintenance message sent by the platform and executes the operation command. The platform receives the execution result fed back by the IoT terminal.
[0051] The present application also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of the above method are implemented. The computer-readable storage medium may include, but is not limited to, any type of disk, including a floppy disk, an optical disk, a DVD, a CD-ROM, a micro drive, and a magneto-optical disk, a ROM, a RAM, an EPROM, an EEPROM, a DRAM, a VRAM, a flash memory device, a magnetic card or an optical card, a nanosystem (including a molecular memory IC), or any type of medium or device suitable for storing instructions and / or data.
[0052] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0053] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0054] In the several embodiments provided in the present application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of the units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some service interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0055] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0056] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0057] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned memory includes: U disk, read-only memory (ROM), random access memory (RAM), mobile hard disk, disk or optical disk and other media that can store program codes.
[0058] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable memory.
[0059] The above is only an exemplary embodiment of the present disclosure, and the scope of the present disclosure cannot be limited thereto. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the specification and practicing the disclosure here, those skilled in the art will easily think of the implementation scheme of the present disclosure. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary technical means in the technical field not recorded in the present disclosure. The description and examples are regarded as exemplary only, and the scope and spirit of the present disclosure are defined by the claims.
Claims
1. An IoT terminal operation and maintenance method based on the MQTT protocol, characterized in that: The method comprises: S101, establishing a communication connection between the platform and the IoT terminal based on the MQTT protocol, setting a silent period, and executing S102 once in each silent period; S102, the IoT terminal sends update information to the platform, and the platform generates an operation and maintenance message after receiving the update information. The platform sends the operation and maintenance message to the IoT terminal, and the IoT terminal receives the operation and maintenance message sent by the platform and executes the operation command. The platform receives the execution result fed back by the IoT terminal.
2. According to the MQTT protocol-based IoT terminal operation and maintenance method of claim 1, it is characterized in that: The update information includes configuration information, device attributes and device status of the IoT terminal.
3. The method for operating and maintaining an Internet of Things terminal based on the MQTT protocol according to claim 1, characterized in that: Before the IoT terminal sends update information to the platform, perform the following steps: The platform receives a subscription message sent by the IoT terminal, where the subscription message is used to subscribe to all messages containing a certain message topic; The operation and maintenance message includes a message subject corresponding to the subscription message and a message of the message subject.
4. According to the MQTT protocol-based IoT terminal operation and maintenance method of claim 3, it is characterized in that: The message topic includes a first topic segment and a second topic segment, the first topic segment represents the device number of the Internet of Things terminal, and the second topic segment represents the actual message topic.
5. The method for operating and maintaining an Internet of Things terminal based on the MQTT protocol according to claim 4, characterized in that: The actual message topics include an upgrade task topic, a debug task topic, an application installation task topic, and a log acquisition task topic.
6. The method for operating and maintaining an Internet of Things terminal based on the MQTT protocol according to claim 1, characterized in that: The method further comprises: A waiting time is set. If the IoT terminal does not receive the operation and maintenance information during the waiting time, it enters the next silent cycle after the waiting time.
7. The method for operating and maintaining an Internet of Things terminal based on the MQTT protocol according to claim 1, characterized in that: The silent period is 24 hours.
8. An IoT terminal operation and maintenance device, characterized in that: The device comprises: The first operation and maintenance module is used to establish a communication connection between the platform and the IoT terminal based on the MQTT protocol, set a silent period, and execute the content of the second operation and maintenance module once in each silent period; The second operation and maintenance module is used for the IoT terminal to send update information to the platform. After receiving the update information, the platform generates an operation and maintenance message. The platform sends the operation and maintenance message to the IoT terminal. The IoT terminal receives the operation and maintenance message sent by the platform and executes the operation command. The platform receives the execution result fed back by the IoT terminal.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, wherein the computer-readable storage medium has instructions stored therein, and when the instructions are executed on a computer or a processor, the computer or the processor executes the steps of the method according to any one of claims 1 to 7.