CN116261065A - Communication method, equipment and storage medium based on message queue telemetry transmission protocol - Google Patents
Communication method, equipment and storage medium based on message queue telemetry transmission protocol Download PDFInfo
- Publication number
- CN116261065A CN116261065A CN202310180006.0A CN202310180006A CN116261065A CN 116261065 A CN116261065 A CN 116261065A CN 202310180006 A CN202310180006 A CN 202310180006A CN 116261065 A CN116261065 A CN 116261065A
- Authority
- CN
- China
- Prior art keywords
- remote control
- message
- server
- equipment
- sent
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04Q—SELECTING
- H04Q9/00—Arrangements in telecontrol or telemetry systems for selectively calling a substation from a main station, in which substation desired apparatus is selected for applying a control signal thereto or for obtaining measured values therefrom
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D30/00—Reducing energy consumption in communication networks
- Y02D30/70—Reducing energy consumption in communication networks in wireless communication networks
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Computer And Data Communications (AREA)
Abstract
The application discloses a communication method, equipment and storage medium based on a message queue telemetry transmission protocol. The method comprises the following steps: sending a first message containing equipment end identifiers and equipment end working states to a server provided with an MQTT protocol; receiving a second message sent by the server based on the MQTT protocol, wherein the second message is generated by one remote control end according to the first message and is sent to the server, and the second message comprises a remote control end identifier of the one remote control end and a device end identifier; if yes, storing the remote control end identification and adding the remote control end identification into a first message which is subsequently sent to the server. According to the communication method based on the message queue telemetry transmission protocol, the occurrence probability of the condition that one equipment end is controlled by a plurality of remote control ends at the same time is greatly reduced, the acquisition of the working state of the equipment end is supported, the occurrence probability of the condition that the remote control ends are connected with the equipment end which is not on line is reduced, the occurrence probability of system communication confusion is reduced, and the working efficiency is improved.
Description
Technical Field
The present application relates to the field of communications technologies, and in particular, to a method, an apparatus, and a storage medium for communication based on a message queue telemetry transmission protocol.
Background
In the field of engineering mechanical equipment remote control, under the application scenes of multiple remote control ends and multiple equipment ends, the remote control ends need to switch connection back and forth between different equipment ends. In a collaborative environment, there may be a case where two remote control terminals need to operate the same device terminal (mutually exclusive and different operations, one being accessible but inoperable when the other is operated). In the related art, a situation that one equipment end is controlled by a plurality of remote control ends at the same time often occurs, so that system communication is disordered, and working efficiency is affected.
Disclosure of Invention
The application aims to provide a communication method, equipment and storage medium based on a message queue telemetry transmission protocol. The following presents a simplified summary in order to provide a basic understanding of some aspects of the disclosed embodiments. This summary is not an extensive overview and is intended to neither identify key/critical elements nor delineate the scope of such embodiments. Its sole purpose is to present some concepts in a simplified form as a prelude to the more detailed description that is presented later.
According to a first aspect of an embodiment of the present application, there is provided a communication method based on a message queue telemetry transport protocol, applied to a device side, the method including:
a first message containing a device end identifier and a device end working state is sent to a server provided with the MQTT protocol, the device end is subscribed with a first theme preset by the server in advance, and the theme of the first message is a second theme preset by the server;
receiving a second message sent by the server based on the MQTT protocol, wherein the second message is generated by a remote control end according to the first message and is sent to the server, the second message comprises a remote control end identifier of the remote control end and the equipment end identifier, and the topic of the second message is the first topic;
determining whether the remote control end identifier meets a preset condition;
if yes, storing the remote control end identifier and adding the remote control end identifier into the first message which is subsequently sent to the server.
In some embodiments of the present application, the method further comprises:
and periodically sending a first message added with the remote control end identifier to the server, and monitoring whether the second message is received within a preset time length.
In some embodiments of the present application, the method further comprises:
and if the second message is not received within the preset time, clearing the locally stored remote control terminal identifier, so that the communication connection relation with the remote control terminal is released.
In some embodiments of the present application, the determining whether the remote control identifier meets a preset condition includes:
if the remote control end identifier is consistent with the prestored remote control end identifier or the local remote control end identifier is not stored in advance, determining that the preset condition is met;
otherwise, determining that the preset condition is not met.
According to a second aspect of the embodiments of the present application, there is provided a communication method based on a message queue telemetry transport MQTT protocol, applied to a remote control end, the method including:
receiving a first message generated by a device side and sent by a server based on the MQTT protocol, wherein the theme of the first message is a second theme preset by the server, and the remote control side is subscribed with the second theme in advance;
acquiring an equipment end identifier and an equipment end working state from the first message;
and sending a second message containing a remote control end identifier and the equipment end identifier to the server under the condition that the working state is an idle state, wherein the topic of the second message is a first topic preset by the server.
In some embodiments of the present application, the method further comprises:
after receiving a first message which is sent by the server and contains the remote control end identifier, sending the second message to the server; the first message containing the remote control end identifier is generated by the equipment end and sent by the server.
According to a third aspect of an embodiment of the present application, there is provided a communication method based on an MQTT protocol for message queue telemetry transport, applied to a server provided with the MQTT protocol, the method including:
a first message which is sent by a device terminal and contains a device terminal identifier and a device terminal working state is sent to a remote control terminal, wherein the device terminal is pre-subscribed with a first theme preset by a server, and the theme of the first message is a second theme preset by the server;
a second message which is sent by the remote control terminal and contains a remote control terminal identifier and the equipment terminal identifier is sent to the equipment terminal, and the topic of the second message is a first topic preset by the server;
and sending a first message which is sent by the equipment end and added with the remote control end identifier to the remote control end.
In some embodiments of the present application, the method further comprises:
the first message which is periodically sent by the equipment end and added with the remote control end identifier is sent to the remote control end;
and sending a second message which is sent by the remote control terminal and contains the remote control terminal identifier to the equipment terminal.
According to a fourth aspect of embodiments of the present application, there is provided an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor executing the computer program to implement the method of any one of the above.
According to a fifth aspect of embodiments of the present application, there is provided a computer readable storage medium having stored thereon a computer program for execution by a processor to implement the method of any of the above.
According to a sixth aspect of the embodiments of the present application, there is provided a communication system based on the message queue telemetry transport MQTT protocol, including a server, and at least one device side and at least one remote control side communicatively connected to the server, respectively, where the device side is configured to perform the method according to the first aspect, the remote control side is configured to perform the method according to the second aspect, and the server is configured to perform the method according to the third aspect.
One of the technical solutions provided in one aspect of the embodiments of the present application may include the following beneficial effects:
according to the communication method based on the message queue telemetry transmission protocol, the occurrence probability of the condition that one equipment end is controlled by a plurality of remote control ends at the same time is greatly reduced, the acquisition of the working state of the equipment end is supported, the occurrence probability of the condition that the remote control ends are connected with the equipment end which is not on line is greatly reduced, the occurrence probability of system communication confusion is reduced, and the working efficiency is improved.
Additional features and advantages of the application will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the application.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments described in the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic diagram of a subscription and publication message model in the related art.
Fig. 2 shows a flow chart of a communication method 01 of the message queue telemetry transport MQTT protocol according to one embodiment of the present application.
Fig. 3 shows a flow chart of a communication method 02 of the message queue telemetry transport MQTT protocol in accordance with one embodiment of the present application.
Fig. 4 shows a flow chart of a communication method 03 of the message queue telemetry transport MQTT protocol based on one embodiment of the present application.
Fig. 5 shows a schematic diagram of a remote control terminal showing a current online device terminal pairing situation in a specific example.
Fig. 6 shows a schematic structural diagram of a communication system based on the message queue telemetry transport MQTT protocol according to one embodiment of the present application.
Fig. 7 shows a device-side functional flowchart in one example of the present application.
Fig. 8 shows a remote control side functional flowchart in one example of the present application.
Fig. 9 is a schematic diagram of a pairing process between a device side and a remote control side in an example of the present application.
Fig. 10 is a schematic diagram illustrating a process of unpairing a device side from a remote control side in an example of the present application.
Fig. 11 shows a block diagram of an electronic device according to an embodiment of the present application.
FIG. 12 illustrates a computer-readable storage medium schematic of one embodiment of the present application.
The achievement of the objects, functional features and advantages of the present application will be further described with reference to the accompanying drawings in conjunction with the embodiments.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
Term interpretation:
publish-subscribe: is a paradigm of messages in which the sender of a message (the sender is also referred to as a publisher) does not send the message directly to a particular recipient (the recipient is also referred to as a subscriber), but rather the published message is divided into different categories without knowing which subscribers, if any, may be present. Likewise, a subscriber may express interest in one or more categories, receive only messages of interest, and need not know which publishers (if any) are present.
MQTT protocol: message protocols based on publish/subscribe paradigms operate on the TCP/IP protocol family. MQTT is an acronym for Message Queuing Telemetry Transport, message queue telemetry transport.
MEC: multiple access edge computing (Multi-access Edge Computing) can utilize the wireless access network to provide services and cloud computing functions required by telecommunication users IT nearby, thereby creating a carrier class service environment with high performance, low delay and high bandwidth, and accelerating various contents in the network.
And a remote control end: the system comprises an industrial personal computer, wherein a remote control terminal is used for receiving data of an acquisition board, issuing a control command through an MQTT protocol, and playing a video stream to display a field picture.
And the equipment end: the method can be an industrial control computer, and can be widely applied to the calculation requirements of scenes such as unmanned scenes.
In the related art, the remote control instruction of the engineering mechanical equipment is realized by adopting an MQTT protocol based on a subscription and release paradigm message mechanism. The MQTT protocol publish-subscribe mode in the related art is different from the client-server mode, and as shown with reference to fig. 1, the MQTT protocol publish-subscribe mode separates a client (publisher) that sends a message from a client (subscriber) that receives a message, and the publisher and the subscriber do not need to establish a direct contact. The MQTT protocol publish-subscribe mode may enable multiple publishers to publish messages to the same subscriber, or may enable multiple subscribers to receive messages from the same publisher at the same time, where an intermediate role device, called a proxy, is responsible for all message routing and distribution operations. The client-server mode of the related art cannot be as simple as the MQTT protocol publish-subscribe mode. The publish/subscribe mode has the advantages of asynchronization, loose coupling and many-to-many communication, and is suitable for the requirements of a dynamically changeable large-scale distributed network environment.
The inventors of the present application have found that decoupling of the publish/subscribe mode results in the remote control not knowing whether the instruction delivery was successful or failed, the publisher being unsure of the status of the subscriber and vice versa. When a plurality of remote control ends send instructions to the same theme of the MQTT protocol, the equipment end can obtain all instructions on the theme, but in the practical situation, the remote control operation of the remote control end on the equipment end can only support one remote control end operation, if the corresponding plurality of remote control end instructions can cause the problem of equipment end out of control, the main defect is that in a subscription release mode, the instruction sending end can not know the condition of the instruction receiving end, the instruction receiving end can not determine which sending end the instruction is sent, so that the situation that a plurality of remote control ends can not switch back and forth among a plurality of equipment ends is caused, more than one remote control end can easily send operation instructions to one equipment end at the same time, the equipment end can not respond to the correct instructions, and finally the equipment out of control is caused.
The MQTT protocol publish-subscribe mode has the advantage of being capable of realizing the decoupling of publishers and subscribers, wherein the decoupling is expressed in two aspects of spatial decoupling and temporal decoupling:
spatial decoupling, the subscriber does not need to establish direct connection with the publisher, and the new subscriber does not need to modify the behavior of the publisher when wanting to join the network;
time decoupling does not require simultaneous presence of subscribers and publishers, and does not affect publishers to publish messages even if no subscribers are present.
The MQTT protocol is based on a subscription and publication message model, which is Topic-based. Illustratively, the flow of MQTT protocol message transmission and reception includes the steps of:
client A is attached to a Broker;
client B connects to the Broker and subscribes to Topic Topic1;
the Client A sends a message to a Broker, and the Topic is Topic1;
the Broker receives the message of Client A, determines that Client B subscribes to Topic1, and then sends the message to Client B;
client B receives the message from the Broker.
If Client B subscribes to Topic1 after Client A publishes the message, then Client B will not receive the message from Client A.
Client A and Client B represent two terminals, respectively. The Broker is the MQTT network central hub, which is a central node in the MQTT network, running on a central server, that 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, and to handle message persistence and offline messages.
The MQTT protocol decouples the publisher and subscriber of the message through a subscription and publication model, and the publisher does not need the subscriber to be connected to a Broker when publishing the message, so long as the subscriber subscribes to the corresponding topic before, the publisher can receive the message published by the publisher after connecting to the Broker.
For the situation that one device side is controlled by a plurality of remote control sides at the same time, which leads to system communication confusion and affects working efficiency in the related art, referring to fig. 2, an embodiment of the present application provides a communication method 01 based on a message queue telemetry transmission MQTT protocol, applied to the device side, where the communication method 01 may include steps S101 to S103:
s101, sending a first message containing equipment end identifiers and equipment end working states to a server provided with an MQTT protocol; the device side is pre-subscribed with a first theme preset by the server, and the theme of the first message is a second theme preset by the server.
The communication system based on the message queue telemetry transmission MQTT protocol includes a server, and at least one device side and at least one remote control side which are respectively in communication connection with the server, and the communication method 01 of this embodiment may be applied to any device side in the communication system.
In this embodiment, the communication protocol adopts TLV mode: tag value + length + data. When the data processing analysis is carried out, the type is judged according to the identification, the content is judged according to the length, the data is obtained, and the length of the corresponding marking data is variable. Custom protocol header, custom ID rules.
The transmission data format definition is shown in table 1.
Table 1 transport data format definition
Data content | Data format | Number of bytes |
Data head | BIN | Variable length |
Data volume | BIN | Variable length |
The transmission data content consists of a fixed data header 12 bytes and a variable length data body.
The header definition is shown in table 2.
Table 2 device side number field
The data volume definitions are shown in table 3.
TABLE 3 definition of data volume
Data content | Data format | Number of bytes |
ID=X | BIN | 2 |
TOTALLEN[4+n]=2+2+n (total length of data volume) | BIN | 2 |
Data N | BIN | n |
The first message may be set to an instruction of id=266, for example. The device side can send the message in a fixed 2HZ period, report its own status, and the message format is shown in table 4.
Table 4 id=266 message format
Data content | Data format | Number of bytes |
ID=266 | BIN | 2 |
TOTALLEN[8]=2+2+4 (total length of data volume) | BIN | 2 |
Control device numbering | BIN | 4 |
The first theme may be set as a to_device theme, for example, and the second theme may be set as a to_control theme, for example. The device may periodically send an instruction id=266 to the to_control theme of the MQTT protocol after the device is booted.
S102, receiving a second message sent by the server based on the MQTT protocol, wherein the second message is generated by a remote control terminal according to the first message and is sent to the server, the second message comprises a remote control terminal identifier of the remote control terminal and the equipment terminal identifier, and the theme of the second message is a first theme.
The second message may be set to an instruction of id=267, for example. The remote control terminal transmits the command id=267 at a fixed 2HZ period, and maintains the connection state, and the message format of the command id=267 is shown in table 5.
Table 5 id=267 message format
Data content | Data format | Number of bytes |
ID=267 | BIN | 2 |
LEN[4]=2+2 | BIN | 2 |
When the remote control end needs to acquire the list, the remote control end can subscribe to all the to_control topics, receive an instruction of id=266, and acquire and analyze pairing messages sent by all the equipment ends.
S103, determining whether the remote control end identifier meets a preset condition.
In one embodiment, determining whether the remote control identifier meets the preset condition may include:
if the remote control end identification is consistent with the prestored remote control end identification or the local remote control end identification is not stored in advance, determining that the preset condition is met; otherwise, determining that the preset condition is not met. The preset condition is that the remote control end identification is consistent with the prestored remote control end identification or the local remote control end identification is not prestored.
And S104, if the preset condition is met, storing the remote control terminal identification and adding the remote control terminal identification into a first message which is subsequently sent to the server.
The interface of the remote control terminal can display the pairing condition of the current online equipment, so that a user can conveniently select the pairing equipment or only observe the equipment.
In one embodiment, the communication method 01 may further include:
s105, periodically sending a first message added with the remote control end identifier to the server, and monitoring whether a second message is received within a preset time period.
The device side periodically sends an instruction of id=266 to the to_control subject of the MQTT protocol. The remote obtains an instruction of id=266 by subscribing to the to_control topic.
Illustratively, the remote control end obtains the device end information in the instruction of id=266, and if the control device number in the device end information is 0 or is the device number of the remote control end itself, the remote control end periodically sends the instruction of id=267; otherwise, the id=267 command is not sent, and the remote control terminal enters an observer mode, and in the observer mode, the remote control terminal can only acquire the state of the equipment terminal and cannot send an operation command to the equipment terminal.
The device obtains the id=267 instruction through subscribing to the to_device theme. The equipment end obtains remote control end information in an ID=267 instruction, and compares the remote control end number in the remote control end information with the control equipment number stored by the equipment end. If the control equipment number stored by the equipment end is 0, the equipment end stores the equipment number as the control equipment number; if the control equipment number stored by the equipment end is consistent with the remote control end number, receiving the number and sending all instructions, and if the control equipment number stored by the equipment end is inconsistent with the remote control end number, discarding the number and sending all instructions. In the instruction of periodically transmitting id=266, the control device number is filled out using the stored control device number.
In one embodiment, the communication method 01 may further include:
and S106, if the second message is not received within the preset time, clearing the locally stored remote control terminal identifier, so that the communication connection relation with the remote control terminal is released.
The preset duration may be, for example, a time duration taking the last time the second message was received as the starting time, and specifically may be set according to actual needs, for example, may be 2 seconds, 3 seconds, or 5 seconds.
The device side monitors whether a second message matched with the locally stored control device number is received within a preset time period or not, and if the second message is received within the preset time period, the second message is not processed; and if the second message is not received within the preset time period, changing the number of the locally stored control equipment to 0. Then, in the instruction of id=266 sent by the device side, the control device number field is filled in to 0, and the communication connection relationship with the remote control side is released successfully.
Compared with the related art, the communication method based on the message queue telemetry transmission MQTT protocol greatly reduces the occurrence probability of the condition that one equipment end is simultaneously controlled by a plurality of remote control ends, supports the acquisition of the working state of the equipment end, greatly reduces the occurrence probability of the condition that the remote control ends are not connected with the online equipment end, reduces the occurrence probability of system communication confusion, and improves the working efficiency.
Referring to fig. 3, another embodiment of the present application provides a communication method 02 based on a message queue telemetry transport MQTT protocol, applied to a remote control end, where the method includes steps S201 to S203:
s201, receiving a first message which is generated by a device side and is sent by a server based on an MQTT protocol, wherein the topic of the first message is a second topic preset by the server, and the remote control side is subscribed with the second topic in advance.
The communication system based on the message queue telemetry transmission MQTT protocol includes a server, and at least one device side and at least one remote control side which are respectively in communication connection with the server, and the communication method 02 of the embodiment is applied to any remote control side in the communication system. The server is provided with an MQTT protocol. For example, the first theme may be set as a to_device theme, for example, and the second theme may be set as a to_control theme, for example. The remote terminal subscribes to all to_control topics of the MQTT protocol. The first message is an instruction with id=266.
S202, acquiring the equipment end identifier and the equipment end working state from the first message.
The id=266 instruction includes a device end identifier and a device end working state, where the device end identifier may be a number. The equipment side working state comprises an idle state and an in-working state. After the remote control receives the id=266 instruction sent by the server, the serial number of the equipment end and the working state of the equipment end are extracted from the id=266 instruction.
S203, sending a second message containing the remote control end identifier and the equipment end identifier to the server under the condition that the working state is an idle state, wherein the topic of the second message is a first topic preset by the server.
The remote control terminal identifier may be a number, i.e. a remote control terminal number. Along with the above example, the topic of the second message is the to device topic.
In another embodiment, the communication method 02 may further include: after receiving a first message which is sent by a server and contains a remote control end identifier, sending a second message to the server; the first message including the remote control end identification is generated by the device end and sent by the server.
In some examples, after the device side receives the second message, if it is determined that the remote control end identifier in the second message meets the preset condition, the device side periodically sends a first message added with the remote control end identifier to the server, and monitors whether the second message is received within a preset duration. After receiving the first message which is sent by the server and contains the remote control end identifier, the remote control end sends a second message to the server, and the second message is sent to the equipment end through the server, so that the maintenance of the connection state is realized, and the equipment end determines whether the current communication connection with the remote control end is still maintained or not by monitoring the receipt of the second message.
According to the communication method based on the message queue telemetry transmission MQTT protocol, the occurrence probability of the condition that one equipment end is controlled by a plurality of remote control ends at the same time is greatly reduced, the acquisition of the working state of the equipment end is supported, and the occurrence probability of the condition that the remote control ends are not connected with the online equipment end is greatly reduced.
Referring to fig. 4, another embodiment of the present application provides a communication method 03 for transmitting MQTT protocol based on message queue telemetry, applied to a server provided with MQTT protocol, the method 03 comprising steps S301 to S303:
s301, a first message which is sent by a device side and contains a device side identifier and a device side working state is sent to a remote control side based on an MQTT protocol, the device side is pre-subscribed with a first theme preset by a server, and the theme of the first message is a second theme preset by the server.
For example, the first theme may be set as a to_device theme, for example, and the second theme may be set as a to_control theme, for example. The remote terminal subscribes to all to_control topics of the MQTT protocol. The first message is an instruction with id=266.
S302, a second message which is sent by the remote control terminal and contains the remote control terminal identification and the equipment terminal identification is sent to the equipment terminal based on the MQTT protocol, and the topic of the second message is a first topic preset by the server.
For example, the instruction id=266 includes a device end identifier and a device end operating state, where the device end identifier may be a number. The equipment side working state comprises an idle state and an in-working state. Along with the above example, the topic of the second message is the to device topic. The second message is an instruction with id=267.
S303, the first message which is sent by the equipment end and added with the remote control end identifier is sent to the remote control end based on the MQTT protocol.
The remote control terminal identifier may be a number, i.e. a remote control terminal number.
In one embodiment, the method 03 may further include: the method comprises the steps that a first message which is periodically sent by a device end and added with a remote control end identifier is sent to the remote control end based on an MQTT protocol; and sending a second message which is sent by the remote control terminal and contains the remote control terminal identifier and the equipment terminal identifier to the equipment terminal.
The communication method of the embodiment of the application is mainly based on a subscription and release paradigm message mechanism, and on the basis that the MQTT command receiving and transmitting frame is not changed, the remote control command of the engineering mechanical equipment adopts the MQTT command receiving and transmitting frame, so that accurate pairing and control of a remote control end and an equipment end are conveniently realized.
Another embodiment of the present application provides a communication method 04 based on a message queue telemetry transport protocol, comprising the steps of:
The method comprises the steps that a device end sends a first message containing a device end identifier to a server, a message queue telemetry transmission protocol is arranged on the server, the device end is subscribed to a first theme preset by the server in advance, and the theme of the first message is a second theme preset by the server;
the server sends the first message to the remote control end;
the remote control terminal obtains the equipment terminal identifier and the equipment terminal working state from the first message after receiving the first message, wherein the first message is sent by the server based on a message queue telemetry transmission protocol, and the remote control terminal is subscribed with a second theme in advance;
the remote control end sends a second message containing a remote control end identifier and a device end identifier to the server under the condition that the working state is an idle state, wherein the theme of the second message is a first theme;
the server sends a second message to the equipment end;
the equipment end receives the second message, obtains the remote control end identifier from the second message, and adds the remote control end identifier into the subsequently sent first message; the second message is sent by the server based on a message queue telemetry transport protocol.
The communication method may further include:
the equipment end periodically sends a first message added with a remote control end identifier to the server;
The remote control terminal sends a second message to the server after receiving a first message which is sent by the server and added with the remote control terminal identification;
the equipment end receives the second message sent by the server.
In a specific example, the communication method of the present embodiment may include the steps of:
(1) The MQTT protocol server establishes a to_control theme and a to_device theme based on the MQTT protocol, wherein the message of the to_control theme is sent to the remote control terminal by the equipment terminal, and the message of the to_device theme is sent to the equipment terminal by the remote control terminal; the two topics send instructions at a preset period (e.g., 2HZ frequency); the MQTT theme is essentially a character string coded by UTF-8, and is the basis for message routing by the MQTT protocol;
(2) Defining a new ID pairing instruction type in an instruction protocol (the old equipment end directly ignores the ID), wherein a field of own equipment number (unique number information of the whole network) is added, so that the opposite equipment is mainly convenient to identify and control the equipment number (mainly equipment end filling and remote control end filling 0) of the equipment, and the corresponding equipment end is mainly convenient to confirm whether the corresponding equipment end is controlled by the user or not (the equipment end filled with the equipment number of the control end in the instruction protocol head is received, and the equipment end controlled by the user is indicated, otherwise the equipment end is not controlled by the user);
(3) When subscribing, the device terminal subscribes to the MQTT theme, the remote control terminal subscribes to the to_control theme of the MQTT, and the to_control theme of different device terminals under different nodes subscribes, so that the remote control terminal can acquire a current online device terminal list, and is convenient for the remote control terminal to select a paired device terminal for login;
(4) After subscribing, the equipment terminal sends a status instruction to the to_control theme in a preset period, the remote control terminal subscribes to the to_control theme to acquire the equipment terminal number from the protocol header, if the equipment terminal is idle (i.e. the fields for representing the status are all 0), the remote control terminal can initiate a connection instruction to_device theme to the equipment terminal, otherwise, only the display status is received, and the operation of the equipment terminal cannot be performed;
(5) The equipment end acquires a remote control end number field after receiving an instruction through the to_device theme, if the equipment end is unpaired, the remote control end number field is reserved, and only the instruction sent by the remote control end corresponding to the remote control end number is responded, other remote control ends are not responded, the equipment end periodically sends the number field to a protocol header of the to_control theme, the number field is added to the equipment number field of the control end, meanwhile, the period (such as 3 seconds and 5 seconds) of the to_device instruction sent by the control end equipment is monitored, if the period from the last time of receiving the to_device instruction is longer than the monitored period, the abnormal exit of the remote control end is indicated, the equipment end clears the saved remote control end number field and starts the pairing operation with other remote control ends;
(6) If the remote control terminal exits the pairing, the remote control terminal stops sending the preset period instruction to the to_device theme.
Referring to fig. 5, in one specific example, the device side sends an id=266 message to the to_control theme period of the MQTT after power-on. When the remote control end needs to acquire the list, subscribing all the to_control topics, receiving the ID=266 message, and acquiring and analyzing all the equipment ends to send the pairing message. The remote control terminal displays the current pairing situation of the online equipment terminal through the interface, so that a user can conveniently select the paired equipment terminal or only observe the equipment terminal.
Compared with the related art, the communication method of the embodiment of the application achieves the following beneficial technical effects: the occurrence probability of the condition that one equipment end is controlled by a plurality of remote control ends at the same time is greatly reduced; the equipment state acquisition is supported, so that the occurrence probability of the condition that the remote control terminal is connected with off-line equipment is greatly reduced; the function of supporting the condition of a multi-remote control terminal remote observation device terminal is compatible; the system architecture of the related technology is not required to be greatly changed, the original instruction interaction is not affected, and functions can be expanded as plug-ins.
Another embodiment of the present application provides a communication system based on an MQTT protocol for message queue telemetry transmission, which includes a server, and at least one device side and at least one remote control side communicatively connected to the server, where the device side is configured to execute the communication method 01 of any one of the foregoing embodiments, and the remote control side is configured to execute the communication method 02 of any one of the foregoing embodiments, and the server is configured to execute the communication method 03 of any one of the foregoing embodiments.
The server may be a MEC server (MQTT service deployment device). The MEC server equipment can be an X86 high-performance server and is used for supporting the release and the consulting of control instructions and the like and supporting the push-pull flow of videos.
The equipment end comprises an industrial personal computer, CPE, a camera, a vehicle-mounted controller and the like.
The equipment end is used for subscribing the control instruction of the remote control end, releasing the state of the equipment end and the like, and can actively push the video stream of the camera of the equipment end to the MEC server equipment.
The remote control end comprises an operating handle, a pedal, a seat, CPE, an operating desk host device, a display and the like.
The remote control end is used for receiving hardware operation instructions such as an operation desk handle. And in a subscription state, streaming the video stream at the equipment end from MEC server equipment and displaying the video stream on a display.
Fig. 6 illustrates a specific example of a communication system based on the message queue telemetry transport MQTT protocol, with the device side, remote control side and MEC server devices configured by deploying a charging network connection. Referring to the device-side functional flowchart shown in fig. 7, after the device is started, the device always sends an instruction with id=266 to the to_control theme 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, defaults to 0, and the power-down restart value is clear 0.
Referring to the remote control end functional flowchart shown in fig. 8, the current online device number and the pairing situation thereof can be obtained by subscribing the instruction of the to_control subject id=266 of all nodes on the MQTT protocol through the operation interface of the operation console device, and displayed on the interface.
And the remote operator selects the online equipment pairing through the equipment interface of the operation platform. If the numbers of the online equipment are paired, the remote control terminal operation console can only receive the video and the command sent by the equipment and cannot send the operation command to control the equipment of the equipment terminal; if the numbers of the online devices are not paired, the remote control terminal operation console can not only receive the video and the command sent by the devices, but also send the operation command to control the devices at the device ends.
Fig. 9 is a schematic diagram illustrating a pairing process between a device side and a remote control side in a specific example, where the pairing process is that the remote control side sends an id=267 instruction to an MQTT service to_device theme, and the device side subscribes to the MQTT service to_device theme to obtain the id=267 instruction. If the control equipment number stored by the equipment end is 0, updating the number to the control equipment number stored by the equipment end; if the control equipment number stored by the equipment end is not 0, the number is consistent with the control equipment number stored by the equipment end, and the control equipment number receiving instruction time stored by the equipment end is updated and returned. If not, the instruction is discarded directly. The control device number in the id=266 instruction sent periodically to the MQTT service to_control subject is based on the control device number stored by itself.
After pairing is finished, the equipment end equipment only receives instruction operation sent by the remote control end of the equipment number which is consistent with the control equipment number stored by the equipment end equipment, and other instructions are discarded. The control of a single remote control end and the observation function of multiple remote control ends are realized.
Referring to fig. 10, when the remote operator logs in to the operation interface of the operation console device and exits, the remote control end stops sending the command with id=267 to the to_device theme of the MQTT protocol, the device end monitors the difference between the time of receiving the command by the control device number stored in the device end and the local time, and if the difference is greater than the preset duration (for example, 3 seconds), the device end clears the control device number stored in the device end to be 0. The control device number in the instruction of id=266 periodically sent to the to_control subject of the MQTT protocol is subject to the control device number stored by itself. The subsequent other remote control ends can continue to pair with the equipment end.
Another embodiment of the present application provides an electronic device including a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor executing the computer program to implement a method of any of the above embodiments.
Referring to fig. 11, the electronic device 10 may include: processor 100, memory 101, bus 102 and communication interface 103, processor 100, communication interface 103 and memory 101 being connected by bus 102; the memory 101 has stored therein a computer program executable on the processor 100, which when executed by the processor 100 performs the method provided by any of the embodiments described herein.
The memory 101 may include a high-speed random access memory (RAM: random Access Memory), and may further include a non-volatile memory (non-volatile memory), such as at least one disk memory. The communication connection between the device network element and the at least one other network element is achieved through at least one communication interface 103 (which may be wired or wireless), the internet, a wide area network, a local network, a metropolitan area network, etc. may be used.
The processor 100 may be an integrated circuit chip with signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in the processor 100 or by instructions in the form of software. The processor 100 may be a general-purpose processor, and may include a central processing unit (Central Processing Unit, CPU for short), a network processor (Network Processor, NP for short), and the like; but may also be a Digital Signal Processor (DSP), application Specific Integrated Circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components. The disclosed methods, steps, and logic blocks in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the embodiments of the present application may be embodied directly in hardware, in a decoded processor, or in a combination of hardware and software modules in a decoded processor. The software modules may be located in a random access memory, flash memory, read only memory, programmable read only memory, or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in the memory 101, and the processor 100 reads the information in the memory 101 and, in combination with its hardware, performs the steps of the method described above.
The electronic device provided by the embodiment of the application and the method provided by the embodiment of the application are the same in the invention conception, and have the same beneficial effects as the method adopted, operated or realized by the electronic device.
Another embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement a method of any of the above embodiments. Referring to fig. 12, a computer readable storage medium is shown as an optical disc 20 having a computer program (i.e., a program product) stored thereon, which, when executed by a processor, performs the method provided by any of the embodiments described above.
It should be noted that examples of the computer readable storage medium may also include, but are not limited to, a phase change memory (PRAM), a Static Random Access Memory (SRAM), a Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a flash memory, or other optical or magnetic storage medium, which will not be described in detail herein.
The computer readable storage medium provided by the above-described embodiments of the present application has the same advantageous effects as the method adopted, operated or implemented by the application program stored therein, for the same inventive concept as the method provided by the embodiments of the present application.
It should be noted that:
the algorithms and displays presented herein are not inherently related to any particular computer, virtual machine, or other apparatus. Various general purpose devices may also be used with the examples herein. The required structure for the construction of such devices is apparent from the description above. In addition, the present application is not directed to any particular programming language. It will be appreciated that a variety of programming languages may be used to implement the teachings of the present application as described herein, and the above description of specific languages is provided for disclosure of preferred embodiments of the present application.
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, these steps are not necessarily performed in order as indicated by the arrows. The steps are not strictly limited in order and may be performed in other orders, unless explicitly stated herein. Moreover, at least some of the steps in the flowcharts of the figures may include a plurality of sub-steps or stages that are not necessarily performed at the same time, but may be performed at different times, the order of their execution not necessarily being sequential, but may be performed in turn or alternately with other steps or at least a portion of the other steps or stages.
The foregoing examples merely represent embodiments of the present application, which are described in more detail and are not to be construed as limiting the scope of the present application. It should be noted that it would be apparent to those skilled in the art that various modifications and improvements could be made without departing from the spirit of the present application, which would be within the scope of the present application. Accordingly, the scope of protection of the present application shall be subject to the appended claims.
Claims (11)
1. A communication method based on the message queue telemetry transport MQTT protocol, applied to a device side, the method comprising:
a first message containing a device end identifier and a device end working state is sent to a server provided with the MQTT protocol, the device end is subscribed with a first theme preset by the server in advance, and the theme of the first message is a second theme preset by the server;
receiving a second message sent by the server based on the MQTT protocol, wherein the second message is generated by a remote control end according to the first message and is sent to the server, the second message comprises a remote control end identifier of the remote control end and the equipment end identifier, and the topic of the second message is the first topic;
Determining whether the remote control end identifier meets a preset condition;
if yes, storing the remote control end identifier and adding the remote control end identifier into the first message which is subsequently sent to the server.
2. The method according to claim 1, wherein the method further comprises:
and periodically sending a first message added with the remote control end identifier to the server, and monitoring whether the second message is received within a preset time length.
3. The method according to claim 2, wherein the method further comprises:
and if the second message is not received within the preset time, the stored remote control end identifier is cleared, so that the communication connection relation with the remote control end is released.
4. The method of claim 1, wherein the determining whether the remote control identifier meets a preset condition comprises:
if the remote control end identifier is consistent with the prestored remote control end identifier or the local remote control end identifier is not stored in advance, determining that the preset condition is met;
otherwise, determining that the preset condition is not met.
5. A communication method based on the message queue telemetry transport MQTT protocol, applied to a remote control end, the method comprising:
Receiving a first message generated by a device side and sent by a server based on the MQTT protocol, wherein the theme of the first message is a second theme preset by the server, and the remote control side is subscribed with the second theme in advance;
acquiring an equipment end identifier and an equipment end working state from the first message;
and sending a second message containing a remote control end identifier and the equipment end identifier to the server under the condition that the working state is an idle state, wherein the topic of the second message is a first topic preset by the server.
6. The method of claim 5, wherein the method further comprises:
after receiving a first message which is sent by the server and contains the remote control end identifier, sending the second message to the server; the first message containing the remote control end identifier is generated by the equipment end and sent by the server.
7. A communication method based on a message queue telemetry transport MQTT protocol, applied to a server provided with the MQTT protocol, the method comprising:
a first message which is sent by a device terminal and contains a device terminal identifier and a device terminal working state is sent to a remote control terminal, wherein the device terminal is pre-subscribed with a first theme preset by a server, and the theme of the first message is a second theme preset by the server;
A second message which is sent by the remote control terminal and contains a remote control terminal identifier and the equipment terminal identifier is sent to the equipment terminal, and the topic of the second message is a first topic preset by the server;
and sending a first message which is sent by the equipment end and added with the remote control end identifier to the remote control end.
8. The method of claim 7, wherein the method further comprises:
the first message which is periodically sent by the equipment end and added with the remote control end identifier is sent to the remote control end;
and sending a second message which is sent by the remote control terminal and contains the remote control terminal identifier to the equipment terminal.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor executing the computer program to implement the method of any one of claims 1-8.
10. A computer readable storage medium having stored thereon a computer program, wherein the computer program is executed by a processor to implement the method of any of claims 1-8.
11. A communication system based on the message queue telemetry transport MQTT protocol, comprising a server for performing the method of any one of claims 1-4 and at least one device side for performing the method of any one of claims 5 or 6 and at least one remote control side for performing the method of claim 7 or 8, respectively, communicatively connected to the server.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310180006.0A CN116261065A (en) | 2023-02-15 | 2023-02-15 | Communication method, equipment and storage medium based on message queue telemetry transmission protocol |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310180006.0A CN116261065A (en) | 2023-02-15 | 2023-02-15 | Communication method, equipment and storage medium based on message queue telemetry transmission protocol |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116261065A true CN116261065A (en) | 2023-06-13 |
Family
ID=86682243
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310180006.0A Pending CN116261065A (en) | 2023-02-15 | 2023-02-15 | Communication method, equipment and storage medium based on message queue telemetry transmission protocol |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116261065A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117014850A (en) * | 2023-10-07 | 2023-11-07 | 深圳市鲸视科技有限公司 | Device searching method, system, device, computer device and storage medium |
-
2023
- 2023-02-15 CN CN202310180006.0A patent/CN116261065A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117014850A (en) * | 2023-10-07 | 2023-11-07 | 深圳市鲸视科技有限公司 | Device searching method, system, device, computer device and storage medium |
CN117014850B (en) * | 2023-10-07 | 2024-01-19 | 深圳市鲸视科技有限公司 | Device searching method, system, device, computer device and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP3602979B1 (en) | System and method to facilitate content forwarding using bit index explicit replication (bier) in an information-centric networking (icn) environment | |
US9578081B2 (en) | System and method for providing an actively invalidated client-side network resource cache | |
CN109391500B (en) | Configuration management method, device and equipment | |
US8799400B2 (en) | System and method for managing multiple queues of non-persistent messages in a networked environment | |
US20140372516A1 (en) | System and method for providing a scalable translation between polling-based clients and connection-based message queues | |
CN107645386B (en) | Method and device for acquiring data resources | |
CN111803925B (en) | Scheduling method and device of forwarding server of cloud game and readable storage medium | |
CN116261065A (en) | Communication method, equipment and storage medium based on message queue telemetry transmission protocol | |
CN109257335B (en) | Method for maintaining back source link, back source method, related device and storage medium | |
CN106899605B (en) | Communication method and device based on STOMP protocol | |
CN112217649B (en) | Terminal equipment management method, server and terminal equipment | |
CN115002016B (en) | Message processing system, method, device and storage medium | |
CN113382065B (en) | File downloading method, device, system, equipment and storage medium | |
CN108460042B (en) | Page display method, related equipment and system | |
CN111371668B (en) | Method, device, equipment and storage medium for periodically sending based on free ARP | |
CN108259576B (en) | Software and hardware real-time information transmission system and method | |
CN115460134A (en) | MEC data multicast forwarding method for power 5G service | |
CN113810264B (en) | Information transmission method, device, electronic equipment and storage medium | |
CN113452471B (en) | Method for data processing, electronic device and computer program product | |
CN107465751B (en) | Communication method, device, client and computer storage medium | |
CN114385372A (en) | Message processing method, device and storage medium | |
CN107911477B (en) | Data communication method, device and system | |
CN112511440A (en) | Message forwarding method, system, storage medium and electronic equipment | |
CN112787970A (en) | Method and apparatus for subscribing to event streams | |
CN114760348B (en) | Service processing method and device, storage medium and electronic device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |