Communication method and device based on message queue telemetry transport protocol, and storage medium

By using a communication method based on the MQTT protocol, precise pairing and control between the device and the remote control end were achieved, solving the problem of system communication chaos caused by multiple remote control ends and improving the working efficiency of engineering machinery equipment.

CN116261065BActive Publication Date: 2026-04-28BEIJING BUILDER INTELLIGENT TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING BUILDER INTELLIGENT TECHNOLOGY CO LTD
Filing Date
2023-02-15
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

In collaborative work environments with multiple remote control terminals and multiple device terminals, existing technologies sometimes result in device terminals being controlled by multiple remote control terminals, leading to chaotic system communication and affecting work efficiency.

Method used

The communication method based on Message Queuing Telemetry Transport Protocol (MQTT) is adopted. By matching the identifiers and monitoring the status between the device end and the remote control end, it is ensured that only one remote control end can effectively control the device end. The data transmission format of TLV mode and preset conditions are used to manage the connection of the remote control end, so as to achieve precise pairing and control.

Benefits of technology

This significantly reduces the probability of a device being controlled by multiple remote control terminals simultaneously, improves system efficiency, reduces instances where remote control terminals are offline, and minimizes system communication disruptions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116261065B_ABST
    Figure CN116261065B_ABST
Patent Text Reader

Abstract

The application discloses a communication method and device based on a message queue telemetry transport protocol and a storage medium. The method comprises the following steps: sending a first message containing a device end identifier and a device end working state to a server provided with an MQTT protocol; receiving a second message sent by the server based on the MQTT protocol, the second message being generated and sent to the server by one remote control end according to the first message, and the second message containing a remote control end identifier of the one remote control end and the device end identifier; and if the condition is met, storing the remote control end identifier and adding the remote control end identifier into the first message sent to the server subsequently. The communication method based on the message queue telemetry transport protocol provided in the application embodiment greatly reduces the occurrence probability of the situation that one device end is controlled by multiple remote control ends at the same time, supports device end working state acquisition, reduces the occurrence probability of the situation that the remote control end is connected to an offline device end, reduces the occurrence probability of system communication confusion, and improves working efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technology, specifically to a communication method, device, and storage medium based on a message queue telemetry transmission protocol. Background Technology

[0002] In the field of remote control of construction machinery and equipment, in application scenarios involving multiple remote control terminals and multiple devices, the remote control terminal needs to switch connections back and forth between different devices. In collaborative work environments, situations may arise where two remote control terminals need to operate the same device (mutually exclusive, not operating simultaneously; while one is operating, the other can access but cannot operate). In related technologies, it is common for a single device to be controlled by multiple remote control terminals simultaneously, leading to system communication chaos and impacting work efficiency. Summary of the Invention

[0003] The purpose of this application is to provide a communication method, device, and storage medium based on a message queue telemetry transmission protocol. To provide a basic understanding of some aspects of the disclosed embodiments, a brief summary is given below. This summary is not intended as a general description, nor is it intended to identify key / important components or describe the scope of protection of these embodiments. Its sole purpose is to present some concepts in a simple form as a prelude to the detailed description that follows.

[0004] According to a first aspect of the embodiments of this application, a communication method based on a message queue telemetry transmission protocol is provided, applied to a device, the method comprising:

[0005] Send a first message containing the device identifier and the device's working status to a server configured with the MQTT protocol. The device has pre-subscribed to a first topic preset by the server, and the topic of the first message is a second topic preset by the server.

[0006] The server receives a second message sent based on the MQTT protocol. The second message is generated by a remote control terminal based on the first message and sent to the server. The second message includes the remote control terminal identifier and the device terminal identifier of the remote control terminal. The subject of the second message is the first subject.

[0007] Determine whether the remote control terminal identifier meets the preset conditions;

[0008] If the conditions are met, the remote control terminal identifier is stored and added to the first message subsequently sent to the server.

[0009] In some embodiments of this application, the method further includes:

[0010] The system periodically sends a first message containing the remote control identifier to the server and monitors whether the second message is received within a preset time period.

[0011] In some embodiments of this application, the method further includes:

[0012] If the second message is not received within a preset time period, the remote control terminal identifier stored locally is cleared, thereby terminating the communication connection with the remote control terminal.

[0013] In some embodiments of this application, determining whether the remote control terminal identifier meets preset conditions includes:

[0014] If the remote control terminal identifier is consistent with the pre-stored remote control terminal identifier or there is no pre-stored remote control terminal identifier locally, then it is determined that the preset condition is met;

[0015] Otherwise, it is determined that the preset conditions are not met.

[0016] According to a second aspect of the embodiments of this application, a communication method based on the Message Queue Telemetry Transport (MQTT) protocol is provided, applied to a remote control terminal, the method comprising:

[0017] The device receives a first message generated by the device and sent by the server based on the MQTT protocol. The subject of the first message is a second topic preset by the server, and the remote control terminal has subscribed to the second topic in advance.

[0018] Obtain the device identifier and device working status from the first message;

[0019] When the working state is idle, a second message containing the remote control terminal identifier and the device terminal identifier is sent to the server. The subject of the second message is a first subject preset by the server.

[0020] In some embodiments of this application, the method further includes:

[0021] After receiving a first message containing the remote control terminal identifier sent by the server, the device sends a second message to the server; the first message containing the remote control terminal identifier is generated by the device and sent by the server.

[0022] According to a third aspect of the embodiments of this application, a communication method based on the Message Queuing Telemetry Transport (MQTT) protocol is provided, applied to a server configured with the MQTT protocol, the method comprising:

[0023] The device sends a first message containing the device identifier and the device's working status to the remote control terminal. The device has pre-subscribed to a first topic preset by the server, and the topic of the first message is a second topic preset by the server.

[0024] The remote control terminal sends a second message containing the remote control terminal identifier and the device terminal identifier to the device terminal, wherein the subject of the second message is a first subject preset by the server;

[0025] The first message sent by the device, which includes the identifier of the remote control terminal, is sent to the remote control terminal.

[0026] In some embodiments of this application, the method further includes:

[0027] The device periodically sends a first message containing the remote control terminal's identifier to the remote control terminal;

[0028] The second message, which includes the remote control identifier and the device identifier, is sent from the remote control terminal to the device terminal.

[0029] According to a fourth aspect of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method described in any of the preceding claims.

[0030] According to a fifth aspect of the present application, a computer-readable storage medium is provided having a computer program stored thereon, the computer program being executed by a processor to implement the method described in any of the preceding claims.

[0031] According to a sixth aspect of the embodiments of this application, a communication system based on the Message Queuing Telemetry Transmission (MQTT) protocol is provided, including a server and at least one device end and at least one remote control end respectively communicatively connected to the server. The device end is used to execute the method described in the first aspect, the remote control end is used to execute the method described in the second aspect, and the server is used to execute the method described in the third aspect.

[0032] One aspect of the technical solution provided in this application embodiment may include the following beneficial effects:

[0033] The communication method based on message queue telemetry transmission protocol provided in this application greatly reduces the probability of a device being controlled by multiple remote control terminals simultaneously, supports the acquisition of device working status, greatly reduces the probability of a remote control terminal being offline, reduces the probability of system communication chaos, and improves work efficiency.

[0034] Other features and advantages of this application will be set forth in the following description and will be apparent in part from the description, or some features and advantages may be inferred from the description or determined without doubt, or may be learned by practicing embodiments of this application. Attached Figure Description

[0035] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0036] Figure 1 This diagram illustrates the principle of the subscription and publish messaging model in related technologies.

[0037] Figure 2 A flowchart of a communication method 01 based on the Message Queuing Telemetry Transport (MQTT) protocol according to an embodiment of this application is shown.

[0038] Figure 3 A flowchart of a communication method 02 based on the Message Queuing Telemetry Transport (MQTT) protocol according to an embodiment of this application is shown.

[0039] Figure 4 A flowchart of a communication method 03 based on the Message Queuing Telemetry Transport (MQTT) protocol according to an embodiment of this application is shown.

[0040] Figure 5 This diagram illustrates the pairing status of currently online devices on the remote control in a specific example.

[0041] Figure 6 A schematic diagram of the structure of a communication system based on the Message Queuing Telemetry Transport (MQTT) protocol according to an embodiment of this application is shown.

[0042] Figure 7 A device-side functional flowchart is shown as an example of this application.

[0043] Figure 8 A flowchart of the remote control function is shown in one example of this application.

[0044] Figure 9 This illustration shows a schematic diagram of the pairing process between the device and the remote control in one example of this application.

[0045] Figure 10 This illustration shows a schematic diagram of the process of unpairing the device from the remote control in one example of this application.

[0046] Figure 11 A block diagram of an electronic device structure according to an embodiment of this application is shown.

[0047] Figure 12 A schematic diagram of a computer-readable storage medium according to an embodiment of this application is shown.

[0048] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0049] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application. All other embodiments obtained by those skilled in the art based on the embodiments in this application without inventive effort are within the scope of protection of this application.

[0050] It will be understood by those skilled in the art that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. It should also be understood that terms such as those defined in general dictionaries should be understood to have a meaning consistent with their meaning in the context of the prior art, and should not be interpreted in an idealized or overly formal sense unless specifically defined as herein.

[0051] Terminology Explanation:

[0052] Publish-subscribe is a messaging paradigm where the sender (also called the publisher) does not send messages directly to specific receivers (also called subscribers). Instead, the sender categorizes the messages and does not need to know which subscribers (if any) might exist. Similarly, subscribers can express interest in one or more categories and only receive messages that interest them, without needing to know which publishers (if any) exist.

[0053] MQTT protocol: A message protocol based on the publish / subscribe paradigm that operates on the TCP / IP protocol suite. MQTT is an abbreviation for Message Queuing Telemetry Transport.

[0054] MEC: Multi-access Edge Computing utilizes wireless access networks to provide telecommunications users with the IT services and cloud computing capabilities they need, creating a high-performance, low-latency, and high-bandwidth carrier-grade service environment that accelerates various aspects of the network.

[0055] Remote control terminal: including industrial control computer. The remote control terminal is used to receive data from the acquisition board, issue control commands through the MQTT protocol, and play video streams to display the on-site scene.

[0056] On the device side: it can be an industrial control computer, which can be widely used for computing needs in scenarios such as autonomous driving.

[0057] In related technologies, remote control commands for engineering machinery are implemented using a publish-subscribe messaging mechanism and the MQTT protocol. The MQTT publish-subscribe pattern differs from the client-server pattern in these technologies. (See reference...) Figure 1 As shown, the MQTT publish / subscribe pattern separates the client sending messages (publisher) from the client receiving messages (subscriber), eliminating the need for direct communication between them. The MQTT publish / subscribe pattern allows multiple publishers to publish messages to the same subscriber, and multiple subscribers to simultaneously receive messages from the same publisher, with a middleman device called a broker handling all message routing and distribution. Related client-server models cannot achieve the same level of simplicity as the MQTT publish / subscribe pattern. The publish / subscribe pattern offers advantages such as asynchronous operation, loose coupling, and many-to-many communication, making it suitable for the needs of dynamic and ever-changing large-scale distributed network environments.

[0058] The inventors of this application discovered that the decoupling of the publish / subscribe model prevents the remote control from knowing whether the command transmission was successful or failed, and the publisher is unsure of the subscriber's status, and vice versa. When multiple remote control ends send commands to the same topic in the MQTT protocol, the device receives all the commands on the topic. However, in reality, remote control operations on the device can only support one remote control end at a time. If multiple remote control end commands are responded to simultaneously, it will cause the device to malfunction. The main drawback is that in the publish / subscribe model, the command sender cannot know the status of the command receiver, and the command receiver cannot determine which sender sent the command. This leads to a situation where multiple remote control ends cannot switch back and forth between multiple device ends, and it is very easy for more than one remote control end to send operation commands to a single device end at the same time, causing the device end to be unable to respond to the correct commands, ultimately leading to device malfunction.

[0059] The advantage of the MQTT publish-subscribe pattern lies in its ability to decouple publishers and subscribers. This decoupling manifests in two aspects: spatial decoupling and temporal decoupling.

[0060] Spatial decoupling means that subscribers and publishers do not need to establish direct connections, and new subscribers do not need to modify the behavior of publishers when they want to join the network.

[0061] Time decoupling means that subscribers and publishers do not need to be online at the same time, and the absence of subscribers does not affect the publisher's ability to publish messages.

[0062] The MQTT protocol is based on a publish-subscribe messaging model, and MQTT subscriptions and publications are topic-based. For example, the MQTT message sending and receiving process includes the following steps:

[0063] Client A connects to the Broker;

[0064] Client B connects to the Broker and subscribes to Topic1;

[0065] Client A sends a message to Broker with Topic 1 as the subject;

[0066] When the Broker receives a message from Client A, it determines that Client B has subscribed to Topic 1, and then sends the message to Client B.

[0067] Client B receives the message from the Broker.

[0068] If Client B subscribes to Topic1 after Client A publishes a message, Client B will not receive the message published by Client A.

[0069] Client A and Client B represent two terminals. The Broker is the central hub of the MQTT network, a central node running on a central server. It receives inbound messages from client publishers and routes them to the appropriate subscribers. The Broker is used to enforce access control and quality of service policies, as well as handle message persistence and offline messages.

[0070] The MQTT protocol decouples message publishers and subscribers through a publish-subscribe model. When a publisher publishes a message, the subscriber does not need to be connected to the Broker. As long as the subscriber has previously subscribed to the corresponding topic, it can receive the message published by the publisher after connecting to the Broker.

[0071] To address the common issue in related technologies where a single device is simultaneously controlled by multiple remote control terminals, leading to system communication chaos and reduced work efficiency, refer to... Figure 2 As shown, one embodiment of this application provides a communication method 01 based on the Message Queue Telemetry Transmission (MQTT) protocol, applied to a device. The communication method 01 may include steps S101 to S103:

[0072] S101. Send a first message containing the device identifier and the device's working status to a server configured with the MQTT protocol; wherein the device has pre-subscribed to a first topic preset by the server, and the topic of the first message is a second topic preset by the server.

[0073] The communication system based on the Message Queuing Telemetry Transmission (MQTT) protocol includes a server and at least one device and at least one remote control terminal that are respectively connected to the server. The communication method 01 of this embodiment can be applied to any device in the communication system.

[0074] In this embodiment, the communication protocol adopts the TLV (Tag Value + Length + Data) model. During data processing and parsing, the type is determined based on the tag, the content is determined based on the length, and the data is obtained. The length of the corresponding tag data is variable. A custom protocol header and custom ID rules are used.

[0075] The data transmission format is defined as shown in Table 1.

[0076] Table 1 Definition of Transmission Data Format

[0077] Data content Data format byte count Data Header BIN Length Data body BIN Length

[0078] The transmitted data consists of a fixed 12-byte header and a variable-length data body.

[0079] The header definition is shown in Table 2.

[0080] Table 2 Device ID Field

[0081]

[0082]

[0083] The data body definition is shown in Table 3.

[0084] Table 3 Data Body Definition

[0085] Data content Data format byte count ID=X BIN 2 TOTALLEN[4+n] = 2 + 2 + n (total length of the data body) BIN 2 Data N BIN n

[0086] The first message can be set to an instruction with ID=266, for example. The device can send this message at a fixed 2Hz cycle to report its own status. The message format is shown in Table 4.

[0087] Table 4 Message Format for ID=266

[0088] Data content Data format byte count ID=266 BIN 2 TOTALLEN[8] = 2 + 2 + 4 (total length of data body) BIN 2 Control device number BIN 4

[0089] The first topic can be set as the "to_device" topic, and the second topic can be set as the "to_control" topic. After the device starts up, it can periodically send commands with ID=266 to the "to_control" topic of the MQTT protocol.

[0090] S102. Receive a second message sent by the server based on the MQTT protocol. The second message is generated by a remote control terminal based on the first message and sent to the server. The second message includes the remote control terminal identifier of the remote control terminal and the device terminal identifier. The subject of the second message is the first subject.

[0091] The second message can be set to an ID=267 command, for example. The remote control sends the ID=267 command at a fixed 2Hz cycle to maintain the connection. The message format of the ID=267 command is shown in Table 5.

[0092] Table 5 Message Format for ID=267

[0093] Data content Data format byte count ID=267 BIN 2 LEN[4]=2+2 BIN 2

[0094] When the remote control needs to obtain the list, it can subscribe to all the to_control topics, receive the instruction with ID=266, and obtain and parse the pairing messages sent by all devices.

[0095] S103. Determine whether the remote control terminal identifier meets the preset conditions.

[0096] In one implementation, determining whether the remote control identifier meets preset conditions may include:

[0097] If the remote control identifier matches the pre-stored remote control identifier or there is no pre-stored remote control identifier locally, then the preset condition is met; otherwise, the preset condition is not met. That is, the preset condition is that the remote control identifier matches the pre-stored remote control identifier or there is no pre-stored remote control identifier locally.

[0098] S104. If the preset conditions are met, store the remote control terminal identifier and add the remote control terminal identifier to the first message sent to the server later.

[0099] The remote control interface can display the current online device pairing status, making it convenient for users to select paired devices or simply observe the devices.

[0100] In one embodiment, the communication method 01 may further include:

[0101] S105. Periodically send the first message containing the remote control terminal identifier to the server, and monitor whether the second message is received within a preset time period.

[0102] The device periodically sends a command with ID=266 to the MQTT protocol's `to_control` topic. The remote control receives the command with ID=266 by subscribing to the `to_control` topic.

[0103] For example, the remote control terminal obtains device information from the instruction with ID=266. If the control device number in the device information is 0 or is the remote control terminal's own device number, the remote control terminal periodically sends the instruction with ID=267; otherwise, it does not send the instruction with ID=267. At this time, the remote control terminal enters observer mode. In observer mode, the remote control terminal can only obtain the device status and cannot send operation instructions to the device.

[0104] The device subscribes to the `to_device` topic to obtain the command with ID=267. The device receives the remote control information from the command with ID=267 and compares the remote control number in the remote control information with the control device number stored in the device's own database. If the control device number stored in the device's own database is 0, then the device stores this device number as the control device number; if the control device number stored in the device's own database matches the remote control number, then this number is received and all commands are sent; if the control device number stored in the device's own database does not match, this number is discarded and all commands are sent. In the periodically sent command with ID=266, the control device number is filled in using the stored control device number.

[0105] In one embodiment, the communication method 01 may further include:

[0106] S106. If the second message is not received within the preset time period, the remote control terminal identifier stored locally is cleared, thereby terminating the communication connection with the remote control terminal.

[0107] The preset duration can be, for example, the duration of the countdown starting from the last received second message. The specific duration can be set according to actual needs, such as 2 seconds, 3 seconds, or 5 seconds.

[0108] For example, the device monitors whether it receives a second message matching the locally stored control device number within a preset time period. If the second message is received within the preset time period, no action is taken; if the second message is not received within the preset time period, the locally stored control device number is changed to 0. Then, in the instruction with ID=266 sent by the device, the control device number field is filled with 0, and the communication connection with the remote control terminal is successfully terminated.

[0109] Compared to related technologies, the communication method based on the Message Queue Telemetry Transmission (MQTT) protocol in this application embodiment greatly reduces the probability of a device being controlled by multiple remote control terminals simultaneously, supports the acquisition of device working status, greatly reduces the probability of a remote control terminal being offline, reduces the probability of system communication chaos, and improves work efficiency.

[0110] refer to Figure 3 As shown, another embodiment of this application provides a communication method 02 based on the Message Queue Telemetry Transmission (MQTT) protocol, applied to a remote control terminal. This method includes steps S201 to S203:

[0111] S201. Receive a first message generated by the device and sent by the server based on the MQTT protocol. The subject of the first message is a second topic preset by the server, and the remote control terminal has subscribed to the second topic in advance.

[0112] A communication system based on the Message Queuing Telemetry Transport (MQTT) protocol includes a server and at least one device and at least one remote control terminal respectively connected to the server. The communication method 02 of this embodiment is applied to any of the remote control terminals in this communication system. The server is equipped with the MQTT protocol. For example, a first topic can be set as a "to_device" topic, and a second topic can be set as a "to_control" topic. The remote control terminal subscribes to all "to_control" topics of the MQTT protocol. The first message is an instruction with ID = 266.

[0113] S202. Obtain the device identifier and device working status from the first message.

[0114] The instruction with ID=266 contains the device identifier and the device's operating status. The device identifier can be a number. The device's operating status includes idle and active states. After receiving the instruction with ID=266 sent by the server, the remote control extracts the device's number and operating status from the instruction with ID=266.

[0115] S203. When the working state is idle, send a second message containing the remote control terminal identifier and the device terminal identifier to the server. The subject of the second message is the first subject preset by the server.

[0116] The remote control identifier can be a number, i.e., the remote control number. Continuing with the example above, the subject of the second message is the "to_device" subject.

[0117] In another embodiment, the communication method 02 may further include: after receiving a first message containing a remote control identifier sent by the server, sending a second message to the server; the first message containing the remote control identifier is generated by the device and sent by the server.

[0118] In some examples, after receiving the second message, if the device determines that the remote control identifier in the second message meets preset conditions, it periodically sends a first message containing the remote control identifier to the server and monitors whether the second message is received within a preset time period. Upon receiving the first message containing the remote control identifier from the server, the remote control sends a second message to the server, which then forwards it to the device, thus maintaining the connection. The device determines whether it is still maintaining a communication connection with the remote control by monitoring the receipt of the second message.

[0119] The communication method based on the Message Queue Telemetry Transmission (MQTT) protocol in this application embodiment greatly reduces the probability of a device being controlled by multiple remote control terminals simultaneously, supports the acquisition of the device's working status, and greatly reduces the probability of a remote control terminal being connected to an offline device.

[0120] refer to Figure 4 As shown, another embodiment of this application provides a communication method 03 based on the Message Queue Telemetry Transmission (MQTT) protocol, applied to a server configured with the MQTT protocol. Method 03 includes steps S301 to S303:

[0121] S301. Based on the MQTT protocol, the device sends a first message containing the device identifier and the device working status to the remote control. The device has subscribed to a first topic preset by the server, and the topic of the first message is a second topic preset by the server.

[0122] For example, the first topic could be set to the `to_device` topic, and the second topic could be set to the `to_control` topic. The remote terminal subscribes to all `to_control` topics in the MQTT protocol. The first message is an instruction with ID=266.

[0123] S302. Based on the MQTT protocol, the second message sent by the remote control terminal, which includes the remote control terminal identifier and the device terminal identifier, is sent to the device terminal. The subject of the second message is the first subject preset by the server.

[0124] For example, the instruction with ID=266 contains a device identifier and the device's operating status. The device identifier can be a number. The device's operating status includes an idle state and an active state. Continuing with the example above, the subject of the second message is the "to_device" subject. The second message is the instruction with ID=267.

[0125] S303. Based on the MQTT protocol, send the first message sent by the device to the remote control terminal to add the remote control terminal identifier.

[0126] The remote control terminal identifier can be a number, namely the remote control terminal number.

[0127] In one embodiment, the method 03 may further include: sending a first message containing a remote control identifier, which is periodically sent by the device, to the remote control terminal based on the MQTT protocol; and sending a second message containing the remote control terminal identifier and the device identifier, which is sent by the remote control terminal, to the device.

[0128] The communication method in this application embodiment is mainly based on the publish-subscribe paradigm message mechanism. Without changing the MQTT send and receive command framework, the remote control command for engineering machinery equipment adopts the MQTT send and receive command framework, which can conveniently realize accurate pairing and control between the remote control end and the equipment end.

[0129] Another embodiment of this application provides a communication method 04 based on a message queue telemetry transmission protocol, comprising the following steps:

[0130] The device sends a first message containing the device's identifier to the server. The server is equipped with a message queue telemetry transmission protocol. The device has pre-subscribed to a first topic preset by the server. The topic of the first message is a second topic preset by the server.

[0131] The server sends the first message to the remote control.

[0132] After receiving the first message, the remote control terminal obtains the device identifier and device working status from the first message. The first message is sent by the server based on the message queue telemetry transmission protocol. The remote control terminal has subscribed to the second topic in advance.

[0133] When the remote control is in an idle state, it sends a second message to the server containing the remote control identifier and the device identifier. The subject of the second message is the same as the first subject.

[0134] The server sends the second message to the device.

[0135] After receiving the second message, the device obtains the remote control terminal identifier from the second message and adds the remote control terminal identifier to the first message sent subsequently; the second message is sent by the server based on the message queue telemetry transmission protocol.

[0136] The communication method may also include:

[0137] The device periodically sends the first message to the server to add the remote control identifier;

[0138] After receiving the first message from the server indicating that the remote control terminal has been added, the remote control terminal sends a second message to the server.

[0139] The device receives the second message sent by the server.

[0140] In a specific example, the communication method of this embodiment may include the following steps:

[0141] (1) The MQTT protocol server establishes the to_control topic and the to_device topic based on the MQTT protocol. The messages in the to_control topic are sent from the device to the remote control, and the messages in the to_device topic are sent from the remote control to the device. The two topics send instructions at a preset period (e.g., 2Hz frequency). The MQTT topic is essentially a UTF-8 encoded string, which is the basis for message routing in the MQTT protocol.

[0142] (2) Define a new ID pairing instruction type in the instruction protocol (old devices can ignore this ID directly). Add a field for your own device number (a unique number in the whole network) to facilitate identification of the peer device and the control device number (mainly filled in by the device end, and all zeros by the remote control end). This is mainly to help the remote control end confirm whether the corresponding device end is under its control (if the control device number in the received instruction protocol header is your own number, it means that it is a device end controlled by you, otherwise it is not).

[0143] (3) When the device subscribes, it will subscribe to the MQTT topic. The remote control subscribes to all to_control topics of MQTT. Different devices subscribe to the to_control topics under different nodes. In this way, the remote control can obtain the list of currently online devices, making it convenient for the remote control to select the paired device for login.

[0144] (4) After the device subscribes, it sends status instructions to the to_control topic at a preset period. The remote control subscribes to the to_control topic and obtains the device number from the protocol header. If the device is idle (i.e., all fields indicating the status are 0), the remote control can send a connection instruction to the device to the to_device topic. Otherwise, it only receives the status display and cannot operate the device.

[0145] (5) After receiving the instruction through the to_device topic, the device obtains the remote control terminal number field. If the device itself is not paired, it retains this remote control terminal number field and only responds to the instructions sent by the remote control terminal corresponding to this remote control terminal number, without responding to other remote control terminals. The device adds this number field to the control terminal device number field in the protocol header it periodically sends to the to_control topic. At the same time, it monitors the period of the to_device instruction sent by the control terminal device (e.g., 3 seconds, 5 seconds, etc.). If the duration since the last received to_device instruction is greater than the monitored period, it indicates that the remote control terminal has exited abnormally. The device clears the saved remote control terminal number field and starts the pairing operation with other remote control terminals.

[0146] (6) If the remote control exits pairing, stop sending preset periodic commands to the to_device topic.

[0147] refer to Figure 5 As shown in the example, after the device starts up, it periodically sends a message with ID=266 to the MQTT topic "to_control". When the remote control needs to retrieve the list, it subscribes to all "to_control" topics, receives the message with ID=266, and retrieves and parses all the pairing messages sent by the devices. The remote control displays the current pairing status of online devices through its interface, allowing users to easily select and pair devices or simply observe the devices.

[0148] Compared with related technologies, the beneficial technical effects achieved by the communication method in this application include: greatly reducing the probability of a device being controlled by multiple remote control terminals at the same time; supporting device status acquisition, greatly reducing the probability of a remote control terminal connecting to an offline device; compatible with supporting the function of multiple remote control terminals to remotely observe the status of the device; not requiring major changes to the system architecture of related technologies, not affecting the original command interaction, and can be used as a plug-in to expand functionality.

[0149] Another embodiment of this application provides a communication system based on the Message Queuing Telemetry Transmission (MQTT) protocol, including a server and at least one device end and at least one remote control end respectively communicated with the server. The device end is used to execute the communication method 01 of any of the above embodiments, the remote control end is used to execute the communication method 02 of any of the above embodiments, and the server is used for the communication method 03 of any of the above embodiments.

[0150] The server can be an MEC server (MQTT service deployment device). MEC server devices can be high-performance x86 servers used to support the issuance and retrieval of control commands, and to support push and pull video streaming.

[0151] On the equipment side, there are industrial control computers, CPEs, cameras, and vehicle controllers.

[0152] The device side is used to subscribe to remote control commands, publish device status, and actively push the device's camera video stream to the MEC server device.

[0153] The remote control includes a control handle, foot pedal, seat, CPE, control panel host device, and display, etc.

[0154] The remote control is used to receive hardware operation commands from the control panel handle, etc. In subscribed mode, it pulls the device's video stream from the MEC server and displays it on the monitor.

[0155] Figure 6 A concrete example of a communication system based on the Message Queuing Telemetry Transport (MQTT) protocol is shown, where the device, remote control, and MEC server are configured to be connected via a power-on network. (Reference) Figure 7 The device-side functional flowchart shown shows that after the device starts up, it periodically sends the instruction with ID=266 to the to_control topic of the MQTT protocol. The control device number in the instruction with ID=266 is obtained from the control device number stored in the device itself, which is 0 by default and is cleared to 0 when the device is powered off and restarted.

[0156] refer to Figure 8 The flowchart of the remote control terminal shown allows users to subscribe to the command of the topic ID=266 under all nodes on the MQTT protocol through the operation interface of the console device to obtain the current online device number and its pairing status, which is then displayed on the interface.

[0157] The remote operator selects and pairs online devices through the console device interface. If the online device number is already paired, the remote console can only receive video and commands sent by the device, but cannot send operation commands to control the device itself. If the online device number is not paired, the remote console can not only receive video and commands sent by the device, but also send operation commands to control the device itself.

[0158] Figure 9This diagram illustrates a specific example of the pairing process between a device and a remote control. The pairing process involves the remote control sending an ID=267 command to the MQTT service's `to_device` topic. The device subscribes to the `to_device` topic and retrieves the ID=267 command. If the device's stored control device number is 0, it updates this number to its own stored control device number. If the device's stored control device number is not 0, and this number matches its own stored control device number, it updates its stored control device number and returns upon receiving the command. If they don't match, the command is discarded. The control device number in the periodically sent ID=266 command to the MQTT service's `to_control` topic is based on the device's own stored control device number.

[0159] After pairing, the device will only accept commands from remote control terminals whose device numbers match the stored control device numbers; all other commands will be discarded. This enables control from a single remote control terminal and observation from multiple remote control terminals.

[0160] refer to Figure 10 As shown, when unpairing is required, when the remote operator logs out of the control panel device interface, the remote control stops sending the command with ID=267 to the MQTT protocol's `to_device` topic. The device monitors the difference between the time the command is received and its local time for the control device ID stored in its own memory. If this difference exceeds a preset duration (e.g., 3 seconds), the device clears its stored control device ID to 0. The control device ID in the command with ID=266 periodically sent to the MQTT protocol's `to_control` topic is based on its own stored control device ID. Other remote control devices can then continue to pair with this device.

[0161] Another embodiment of this application provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method of any of the above embodiments.

[0162] refer to Figure 11 As shown, the electronic device 10 may include: a processor 100, a memory 101, a bus 102 and a communication interface 103. The processor 100, the communication interface 103 and the memory 101 are connected through the bus 102. The memory 101 stores a computer program that can run on the processor 100. When the processor 100 runs the computer program, it executes the method provided in any of the foregoing embodiments of this application.

[0163] The memory 101 may include high-speed random access memory (RAM), and may also include non-volatile memory, such as at least one disk storage device. Communication between this device network element and at least one other network element is achieved through at least one communication interface 103 (which may be wired or wireless), such as the Internet, wide area network, local area network, metropolitan area network, etc.

[0164] Bus 102 can be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. Memory 101 is used to store programs. After receiving an execution instruction, processor 100 executes the program. The methods disclosed in any of the foregoing embodiments of this application can be applied to processor 100, or implemented by processor 100.

[0165] Processor 100 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of processor 100 or by instructions in software form. The processor 100 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application-Specific Integrated Circuit (ASIC), an Off-the-shelf Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules may reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory 101. The processor 100 reads the information in memory 101 and, in conjunction with its hardware, completes the steps of the above method.

[0166] The electronic devices and methods provided in the embodiments of this application are based on the same inventive concept and have the same beneficial effects as the methods they employ, operate, or implement.

[0167] Another embodiment of this application provides a computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the methods of any of the above embodiments. Reference Figure 12 As shown, the computer-readable storage medium is an optical disc 20, on which a computer program (i.e., a program product) is stored. When the computer program is run by a processor, it executes the methods provided in any of the aforementioned embodiments.

[0168] It should be noted that examples of computer-readable storage media may also include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other optical and magnetic storage media, which will not be elaborated here.

[0169] The computer-readable storage medium provided in the above embodiments of this application and the method provided in the embodiments of this application are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by the applications stored therein.

[0170] It should be noted that:

[0171] The algorithms and displays provided herein are not inherently related to any particular computer, virtual device, or other equipment. Various general-purpose devices can also be used with the examples based on this. The required structure for constructing such devices is obvious from the above description. Furthermore, this application is not directed to any particular programming language. It should be understood that the content of this application described herein can be implemented using various programming languages, and the above description of specific languages ​​is for the purpose of disclosing the best mode of implementation of this application.

[0172] It should be understood that although the steps in the flowcharts of the accompanying figures are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the accompanying figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.

[0173] The above embodiments merely illustrate the implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A communication method based on the Message Queue Telemetry Transmission (MQTT) protocol, characterized in that, Applied to the device side, the method includes: Send a first message containing the device identifier and the device's working status to a server configured with the MQTT protocol. The device has pre-subscribed to a first topic preset by the server, and the topic of the first message is a second topic preset by the server. The server receives a second message sent based on the MQTT protocol. The second message is generated by a remote control terminal based on the first message and sent to the server. The second message includes the remote control terminal identifier and the device terminal identifier of the remote control terminal. The subject of the second message is the first subject. Determine whether the remote control terminal identifier meets the preset conditions; If the conditions are met, the remote control terminal identifier is stored and added to the first message subsequently sent to the server.

2. The method according to claim 1, characterized in that, The method further includes: The system periodically sends a first message containing the remote control identifier to the server and monitors whether the second message is received within a preset time period.

3. The method according to claim 2, characterized in that, The method further includes: If the second message is not received within a preset time period, the stored remote control terminal identifier is cleared, thereby terminating the communication connection with the remote control terminal.

4. The method according to claim 1, characterized in that, Determining whether the remote control terminal identifier meets the preset conditions includes: If the remote control terminal identifier is consistent with the pre-stored remote control terminal identifier or there is no pre-stored remote control terminal identifier locally, then it is determined that the preset condition is met; Otherwise, it is determined that the preset conditions are not met.

5. A communication method based on the Message Queue Telemetry Transmission (MQTT) protocol, characterized in that, Applied to a remote control terminal, the method includes: The device receives a first message generated by the device and sent by the server based on the MQTT protocol. The subject of the first message is a second topic preset by the server, and the remote control terminal has subscribed to the second topic in advance. Obtain the device identifier and device working status from the first message; When the working state is idle, a second message containing the remote control terminal identifier and the device terminal identifier is sent to the server. The subject of the second message is a first subject preset by the server.

6. The method according to claim 5, characterized in that, The method further includes: After receiving a first message containing the remote control terminal identifier sent by the server, the device sends a second message to the server; the first message containing the remote control terminal identifier is generated by the device and sent by the server.

7. A communication method based on the Message Queue Telemetry Transmission (MQTT) protocol, characterized in that, Applied to a server configured with the MQTT protocol, the method includes: The device sends a first message containing the device identifier and the device's working status to the remote control terminal. The device has pre-subscribed to a first topic preset by the server, and the topic of the first message is a second topic preset by the server. The remote control terminal sends a second message containing the remote control terminal identifier and the device terminal identifier to the device terminal, wherein the subject of the second message is a first subject preset by the server; The first message sent by the device, which includes the identifier of the remote control terminal, is sent to the remote control terminal.

8. The method according to claim 7, characterized in that, The method further includes: The device periodically sends a first message containing the remote control terminal's identifier to the remote control terminal; The second message, which includes the remote control identifier and the device identifier, is sent from the remote control terminal to the device terminal.

9. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor executing the computer program to implement the method as described in any one of claims 1-8.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, The computer program is executed by a processor to implement the method as described in any one of claims 1-8.

11. A communication system based on the Message Queuing Telemetry Transmission (MQTT) protocol, comprising a server and at least one device end and at least one remote control end respectively communicatively connected to the server, wherein the device end is used to perform the method according to any one of claims 1-4, the remote control end is used to perform the method according to any one of claims 5 or 6, and the server is used to perform the method according to claim 7 or 8.

Citation Information

Patent Citations

  • Rule-based IOT equipment linkage method

    CN107864174A

  • Message processing method and device based on MQTT protocol and computer equipment

    CN111182065A