Equipment communication method and device and storage medium
The establishment of a logical ring between devices through the MQTT proxy service solves the problems of high complexity and poor results between devices, and achieves more efficient inter-device messaging.
Patent Information
- Application Number
- CN202311569147.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-22
- Publication Date
- 2025-05-23
AI Technical Summary
In the prior art, the communication between devices is complex and the communication effect is poor, especially in complex network application scenarios.
The logical ring access and message delivery between devices are realized through the MQTT proxy service. The specific steps include the device accessing the logical ring through the MQTT proxy service, receiving and processing ring messages sent by other devices, and passing the processed messages to the target device.
It effectively reduces the complexity of communication between devices, improves communication effect, and makes messaging between devices more efficient and reliable.
Smart Images

Figure CN120034579A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a device communication method, apparatus and storage medium. Background Art
[0002] With the continuous development of network technology, various new network technology applications continue to emerge. The Internet of Things and Internet of Vehicles technologies have further promoted the access of a large number of devices to the network, and the networking and intelligence of products have been continuously improved. In complex network application scenarios, the network communication and network management of products are very important. In related technologies, communication and network management between devices mainly rely on servers, where device messages are processed and forwarded, and network management is performed on multiple devices. The overall network structure is a star structure. Summary of the invention
[0003] The present application aims to solve, at least to a certain extent, one of the technical problems in the related art of high complexity of communication between devices and poor communication effect.
[0004] To this end, the present application is to propose a device communication method, apparatus and processor-readable storage medium, which can effectively reduce the complexity of communication between devices and improve the communication effect.
[0005] The device communication method proposed in the embodiment of the first aspect of the present application is executed by the first device, and the first device, the second device and the third device have subscribed to the message queue telemetry transmission MQTT proxy service of the server, and the second device has access to the logical ring; wherein the method includes: accessing the logical ring through the MQTT proxy service; receiving the first ring message sent by the second device through the MQTT proxy service; processing the first ring message to obtain the second ring message, wherein the second ring message at least includes: the third identification information of the third device; sending the second ring message to the third device through the MQTT proxy service.
[0006] In some embodiments of the present application, the first ring message includes at least: first identification information of the first device; wherein processing the first ring message to obtain the second ring message includes:
[0007] The first identification information of the first device in the first ring message is updated to the third identification information of the third device to obtain a second ring message.
[0008] In some embodiments of the present application, the first ring message further includes: business data, and the second ring message further includes: business data.
[0009] In some embodiments of the present application, the third identification information of the third device is determined based on the following method:
[0010] Receiving a ring registration message sent by a third device through an MQTT proxy service, wherein the ring registration message is used for the third device to access the logical ring;
[0011] The third identification information of the third device is obtained from the ring registration message.
[0012] In some embodiments of the present application, accessing a logical ring through an MQTT proxy service includes:
[0013] Sending a ring registration message to the second device and the third device respectively through the MQTT proxy service, wherein the ring registration message includes: first identification information of the first device;
[0014] Access to the logical ring is based on the ring registration message.
[0015] In some embodiments of the present application, sending the second ring message to the third device through the MQTT proxy service includes:
[0016] Determine the duration after receiving the first ring message;
[0017] Determine that the duration reaches a first duration threshold, and send a second ring message to a third device through the MQTT proxy service;
[0018] If it is determined that the continuous duration does not reach the first duration threshold, the continuous duration is updated until the updated continuous duration reaches the first duration threshold, and a second ring message is sent to the third device through the MQTT proxy service.
[0019] In some embodiments of the present application, the method further comprises:
[0020] Determine the duration after receiving the first ring message;
[0021] Determine that the duration reaches a second duration threshold and no new first ring message is received, wherein the new first ring message is a first ring message sent again by the second device;
[0022] It is determined that the first device exits the logical ring.
[0023] In some embodiments of the present application, the method further comprises:
[0024] Determining that the first ring message was not received, or determining that the second ring message was not successfully sent;
[0025] The fault status message is sent to the second device and the third device respectively through the MQTT proxy service.
[0026] In some embodiments of the present application, the method further comprises:
[0027] Determining that the first ring message is re-received, or determining that the fault status message is successfully sent;
[0028] Access the logical ring through the MQTT proxy service.
[0029] In some embodiments of the present application, the first ring message further includes: a preset flag bit, the preset flag bit is used to indicate whether the second device applies to exit the logical ring;
[0030] The first ring message is processed to obtain the second ring message, including:
[0031] Determine whether the first device allows the second device to exit the logical ring, and obtain a determination result;
[0032] According to the determination result, the value corresponding to the preset flag bit in the first ring message is processed to obtain the second ring message.
[0033] In some embodiments of the present application, when all devices in the logical ring allow the second device to exit the logical ring, the second device exits the logical ring.
[0034] In some embodiments of the present application, the method further comprises:
[0035] Determining that the second device has exited the logical ring;
[0036] Receiving, through the MQTT proxy service, a ring registration message sent by the second device, wherein the ring registration message is used for the second device to access the logical ring;
[0037] The first identification information of the first device is provided to the second device.
[0038] In some embodiments of the present application, the method further comprises:
[0039] Determining that the first device has been connected to the logical ring;
[0040] Controlling the first device to switch from an initialization state to a normal communication state, wherein the first device enters the initialization state after connecting to the MQTT proxy service;
[0041] The step of receiving the first ring message sent by the second device through the MQTT proxy service includes:
[0042] In a normal communication state, a first ring message sent by the second device is received through the MQTT proxy service.
[0043] In some embodiments of the present application, the method further comprises:
[0044] Determining that the first device has exited the logical ring;
[0045] Controlling the first device to switch from a normal communication state to a communication stop state;
[0046] When the third ring message is received in the communication stop state, the first device is controlled to switch from the communication stop state to the initialization state, wherein the third ring message is used to trigger the first device to enter the initialization state.
[0047] In some embodiments of the present application, the method further comprises:
[0048] Determining that the first ring message was not received, or determining that the second ring message was not successfully sent;
[0049] Controlling the first device to switch from a normal communication state to a fault state;
[0050] Determining that the first ring message is re-received, or determining that the fault status message is successfully sent;
[0051] The first device is controlled to switch from a fault state to an initialization state.
[0052] The device communication device proposed in the second aspect of the embodiment of the present application is applied to the first device, the first device, the second device and the third device have subscribed to the message queue telemetry transmission MQTT proxy service of the server, and the second device has been connected to the logical ring; wherein the device includes: an access unit, which is used to access the logical ring through the MQTT proxy service; a receiving unit, which is used to receive the first ring message sent by the second device through the MQTT proxy service; a processing unit, which is used to process the first ring message to obtain the second ring message, wherein the second ring message at least includes: the third identification information of the third device; a sending unit, which is used to send the second ring message to the third device through the MQTT proxy service.
[0053] The device communication device proposed in the third aspect of the embodiment of the present application includes: a memory, a transceiver, and a processor: the memory is used to store computer programs; the transceiver is used to send and receive data under the control of the processor; the processor is used to read the computer program in the memory and perform the following operations: accessing the logical ring through the server's message queue telemetry transmission MQTT proxy service, wherein the logical ring has been connected to the second device and the second device has subscribed to the MQTT proxy service; receiving the first ring message sent by the second device through the MQTT proxy service; processing the first ring message to obtain the second ring message, wherein the second ring message at least includes: the third identification information of the third device, the third device has subscribed to the MQTT proxy service, and the logical ring has been connected to the third device; sending the second ring message to the third device through the MQTT proxy service.
[0054] In some embodiments of the present application, the first ring message includes at least: first identification information of the first device; wherein the processor is further configured to:
[0055] The first identification information of the first device in the first ring message is updated to the third identification information of the third device to obtain a second ring message.
[0056] In some embodiments of the present application, the first ring message further includes: business data, and the second ring message further includes: business data.
[0057] In some embodiments of the present application, the processor is further configured to determine the third identification information of the third device based on the following method:
[0058] Receiving a ring registration message sent by a third device through an MQTT proxy service, wherein the ring registration message is used for the third device to access the logical ring;
[0059] The third identification information of the third device is obtained from the ring registration message.
[0060] In some embodiments of the present application, the processor is further configured to:
[0061] Sending a ring registration message to the second device and the third device respectively through the MQTT proxy service, wherein the ring registration message includes: first identification information of the first device;
[0062] Access to the logical ring is based on the ring registration message.
[0063] In some embodiments of the present application, the processor is further configured to:
[0064] Determine the duration after receiving the first ring message;
[0065] Determine that the duration reaches a first duration threshold, and send a second ring message to a third device through the MQTT proxy service;
[0066] If it is determined that the continuous duration does not reach the first duration threshold, the continuous duration is updated until the updated continuous duration reaches the first duration threshold, and a second ring message is sent to the third device through the MQTT proxy service.
[0067] In some embodiments of the present application, the processor is further configured to:
[0068] Determine the duration after receiving the first ring message;
[0069] Determine that the duration reaches a second duration threshold and no new first ring message is received, wherein the new first ring message is a first ring message sent again by the second device;
[0070] It is determined that the first device exits the logical ring.
[0071] In some embodiments of the present application, the processor is further configured to:
[0072] Determining that the first ring message was not received, or determining that the second ring message was not successfully sent;
[0073] The fault status message is sent to the second device and the third device respectively through the MQTT proxy service.
[0074] In some embodiments of the present application, the processor is further configured to:
[0075] Determining that the first ring message is re-received, or determining that the fault status message is successfully sent;
[0076] Access the logical ring through the MQTT proxy service.
[0077] In some embodiments of the present application, the first ring message further includes: a preset flag bit, the preset flag bit is used to indicate whether the second device applies to exit the logical ring;
[0078] The processor is also used for:
[0079] Determine whether the first device allows the second device to exit the logical ring, and obtain a determination result;
[0080] According to the determination result, the value corresponding to the preset flag bit in the first ring message is processed to obtain the second ring message.
[0081] In some embodiments of the present application, when all devices in the logical ring allow the second device to exit the logical ring, the second device exits the logical ring.
[0082] In some embodiments of the present application, the processor is further configured to:
[0083] Determining that the second device has exited the logical ring;
[0084] Receiving, through the MQTT proxy service, a ring registration message sent by the second device, wherein the ring registration message is used for the second device to access the logical ring;
[0085] The first identification information of the first device is provided to the second device.
[0086] In some embodiments of the present application, the processor is further configured to:
[0087] Determining that the first device has been connected to the logical ring;
[0088] Controlling the first device to switch from an initialization state to a normal communication state, wherein the first device enters the initialization state after connecting to the MQTT proxy service;
[0089] In a normal communication state, a first ring message sent by the second device is received through the MQTT proxy service.
[0090] In some embodiments of the present application, the processor is further configured to:
[0091] Determining that the first device has exited the logical ring;
[0092] Controlling the first device to switch from a normal communication state to a communication stop state;
[0093] When the third ring message is received in the communication stop state, the first device is controlled to switch from the communication stop state to the initialization state, wherein the third ring message is used to trigger the first device to enter the initialization state.
[0094] In some embodiments of the present application, the processor is further configured to:
[0095] Determining that the first ring message was not received, or determining that the second ring message was not successfully sent;
[0096] Controlling the first device to switch from a normal communication state to a fault state;
[0097] Determining that the first ring message is re-received, or determining that the fault status message is successfully sent;
[0098] The first device is controlled to switch from a fault state to an initialization state.
[0099] The processor-readable storage medium proposed in the fourth aspect embodiment of the present application is characterized in that the processor-readable storage medium stores a computer program, and the computer program is used to enable the processor to execute the device communication method proposed in the first aspect embodiment of the present application.
[0100] The device communication method, apparatus and processor-readable storage medium proposed in this application, the first device, the second device and the third device have subscribed to the message queue telemetry transmission MQTT proxy service of the server, and the second device has accessed the logical ring; the first device accesses the logical ring through the MQTT proxy service, and receives the first ring message sent by the second device through the MQTT proxy service, processes the first ring message, and obtains the second ring message, wherein the second ring message at least includes: the third identification information of the third device, and sends the second ring message to the third device through the MQTT proxy service. It can effectively reduce the complexity of communication between devices and improve the communication effect.
[0101] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0102] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0103] Figure 1 is a schematic diagram of a communication system in an embodiment of the present application;
[0104] Figure 2It is a flowchart of a device communication method proposed in an embodiment of the present application;
[0105] Figure 3 is a flowchart of a device communication method proposed in another embodiment of the present application;
[0106] Figure 4 This is a schematic diagram of updating identification information in an embodiment of the present application;
[0107] Figure 5 This is a schematic diagram of a network communication management service on a device side in an embodiment of the present application;
[0108] Figure 6 It is a schematic diagram of switching between the initialization state and the normal communication state in an embodiment of the present application;
[0109] Figure 7 It is a schematic diagram of switching between a normal communication state and a communication stop state in an embodiment of the present application;
[0110] Figure 8 It is a schematic diagram of switching between a normal communication state and a fault state in an embodiment of the present application;
[0111] Fig. 9 is a schematic diagram of the switching process between different states in an embodiment of the present application;
[0112] Fig.10 It is a structural diagram of a device communication apparatus proposed in an embodiment of the present application;
[0113] Fig.11 It is a structural diagram of a device communication apparatus proposed in another embodiment of the present application. DETAILED DESCRIPTION
[0114] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements with the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be construed as limiting the present application. On the contrary, the embodiments of the present application include all changes, modifications and equivalents that fall within the spirit and connotation of the appended claims.
[0115] In the embodiments of the present application, the term "and / or" describes the association relationship of the associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.
[0116] In the embodiments of the present application, the term "plurality" refers to two or more than two, and other quantifiers are similar.
[0117] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0118] The technical solution provided in the embodiment of the present application can be applicable to a variety of systems, especially 5G systems. For example, the applicable system can be a global system of mobile communication (GSM) system, a code division multiple access (CDMA) system, a wideband code division multiple access (WCDMA) general packet radio service (GPRS) system, a long term evolution (LTE) system, a LTE frequency division duplex (FDD) system, a LTE time division duplex (TDD) system, an advanced long term evolution (LTE-A) system, a universal mobile telecommunication system (UMTS), a world-wide interoperability for microwave access (WiMAX) system, a 5G new radio (NR) system, etc. These various systems include terminals and network equipment. The system may also include a core network part, such as an evolved packet system (EPS), a 5G system (5GS), etc.
[0119] In the related technology, communication and network management between devices mainly rely on the server, where the server processes and forwards device messages and performs network management on multiple devices. The overall network structure is a star structure.
[0120] In this way, complex function development is required on the server, and there is a risk that the entire network will be paralyzed due to an abnormal function of the server. Therefore, the communication between devices is more complex and the communication effect is poor.
[0121] In an embodiment of the present application, a device remote self-organizing network communication method based on message queuing telemetry transport (MQTT) and embedded real-time operating system standard (Open Systems and the Embedded Kernel, OSEK) network management technology is provided. The method realizes the decentralization of network communication and management functions. The server only deploys a standard MQTT agent for message forwarding. Network communication, management, and networking functions are realized based on MQTT and OSEK network management technology.
[0122] The embodiments of the present application can be applied in device networking scenarios, in which devices deployed in the same or different regions can often achieve communication, networking and network management. For example: detecting the status of a member device in the network, adding a new member device to the network, removing a faulty member device from the network, etc. When a device joins or leaves the network, it will not affect the normal networking of other devices.
[0123] The embodiment of the present application provides a device communication and self-organizing network method based on MQTT and OSEK network management technology. It can be applied in a communication system, which mainly consists of two parts: a network communication management service deployed on the networked device side, and an MQTT broker service (Broker) deployed on a cloud server platform. Data packets are transmitted between different devices through MQTT based on specific networking logic and data packet formats, and messages are transparently transmitted between devices through MQTT subscription and publishing, indirectly forming a device networking management logic loop and realizing network management automation. And depending on the sending and receiving of network management messages, device application messages can be attached to management messages and sent simultaneously to realize device communication and networking management. As follows Figure 1 shown. Figure 1 It is a schematic diagram of a communication system in an embodiment of the present application.
[0124] Based on the above communication system architecture diagram, an embodiment of the present application also provides a device communication method.
[0125] Figure 2 It is a flowchart of a device communication method proposed in an embodiment of the present application.
[0126] Among them, it should be noted that the executor of the device communication method of this embodiment is a device communication device, which can be implemented by software and / or hardware. The device can be configured in the first device, and the first device can be any one of multiple devices. The second device and the third device can be devices different from the first device, and the second device and the third device are not the same devices. The first device, the second device, and the third device have subscribed to the message queue telemetry transmission MQTT proxy service of the server, and the second device has access to the logical ring. The logical ring refers to the communication link ring formed between multiple devices. For example, data can be transmitted between multiple devices, and the communication links between multiple devices form a logical ring. In an embodiment of the present application, the second device can be a device that can communicate directly with the first device, and the third device can also be a device that can communicate directly with the first device. Direct communication means that messages can be directly transmitted without the need for intermediate devices to forward.
[0127] like Figure 2 As shown, the method includes:
[0128] S201: Accessing the logical ring through the MQTT proxy service.
[0129] In some embodiments, the first device may be pre-connected to the MQTT proxy service of the server and access the logical ring through the MQTT proxy service.
[0130] In some embodiments, the first device may send a ring registration message to the second device and the third device respectively through the MQTT proxy service, wherein the ring registration message includes: first identification information of the first device, and accesses the logical ring based on the ring registration message.
[0131] The above-mentioned first ring message includes at least: the first identification information of the first device, wherein the first identification information is used to uniquely identify the first device. When the first device accesses the logical ring, it can send a ring registration message (Alive_message) to other devices on the logical ring to notify the first identification information of the device to each other device, and support complete communication data transmission on the logical ring.
[0132] S202: Receive a first ring message sent by a second device through the MQTT proxy service.
[0133] In some embodiments, the second device has been connected to the logical ring, and the first device, the second device, and the third device have subscribed to the message queue telemetry transmission MQTT proxy service of the server, then the first device can receive the first ring message sent by the second device through the MQTT proxy service, wherein the ring message sent by the second device to the first device can be referred to as the first ring message. The first ring message can be, for example, Ring_message.
[0134] S203: Process the first ring message to obtain a second ring message, wherein the second ring message at least includes: third identification information of the third device.
[0135] In some embodiments, after receiving the first ring message sent by the second device, the first device may forward the first ring message to the third device in succession, thereby automatically implementing the forwarding process of the ring message without relying on the server.
[0136] In some embodiments, the first device may update the first identification information of the first device in the first ring message with the third identification information of the third device to obtain the second ring message, so as to support accurate flow transmission of communication data on the logical ring.
[0137] The third identification information is used to uniquely identify the third device.
[0138] In some embodiments, the first ring message further includes: service data, and the second ring message further includes: service data. When the first device processes the first ring message, the second ring message still carries the service data sent by the second device to the first device, and sequentially transfers the service data to the third device, supporting complete service data transmission on the logical ring.
[0139] In some embodiments, the first device may also determine the third identification information of the third device in advance based on the following method: the first device may receive a ring registration message sent by the third device through an MQTT proxy service, wherein the ring registration message is used for the third device to access the logical ring, and obtain the third identification information of the third device from the ring registration message, so as to support accurate flow transmission of communication data on the logical ring.
[0140] S204: Send the second ring message to the third device through the MQTT proxy service.
[0141] After the first device processes the first ring message and obtains the second ring message, it can send the second ring message to the third device through the MQTT proxy service. Since the second ring message carries the third identification information of the third device, the first device clearly knows the destination sending device (the third device) of the second ring message, which can effectively support the flow and transmission of ring messages between different devices.
[0142] In some embodiments, after the first device transmits the ring message sent by the second device to the third device, the third device can also use the device communication method provided in the embodiment of the present application to transmit the ring message to other devices after the third device in turn, so as to realize the effective flow transmission of the ring message between different devices.
[0143] In this embodiment, the first device, the second device and the third device have subscribed to the message queue telemetry transmission MQTT proxy service of the server, and the second device has been connected to the logical ring; the first device accesses the logical ring through the MQTT proxy service, and receives the first ring message sent by the second device through the MQTT proxy service, processes the first ring message, and obtains the second ring message, wherein the second ring message at least includes: the third identification information of the third device, and sends the second ring message to the third device through the MQTT proxy service. It can effectively reduce the complexity of communication between devices and improve the communication effect.
[0144] Figure 3 It is a flowchart of a device communication method proposed in another embodiment of the present application.
[0145] like Figure 3 As shown, the method includes:
[0146] S301: Send a ring registration message to the second device and the third device respectively through the MQTT proxy service, wherein the ring registration message includes: first identification information of the first device.
[0147] S302: Accessing a logical ring based on a ring registration message.
[0148] S303: Receive a ring registration message sent by a third device through the MQTT proxy service, where the ring registration message is used for the third device to access the logical ring.
[0149] S304: Acquire third identification information of the third device from the ring registration message.
[0150] S305: Receive a first ring message sent by the second device through the MQTT proxy service, wherein the first ring message includes at least: first identification information of the first device.
[0151] S306: Update the first identification information of the first device in the first ring message to the third identification information of the third device to obtain a second ring message.
[0152] For the description of S301 - S306 , please refer to the above embodiment for details, which will not be repeated here.
[0153] S307: Send the second ring message to the third device through the MQTT proxy service.
[0154] In some embodiments, the duration after receiving the first ring message can also be determined, and the duration reaches the first duration threshold, and the second ring message is sent to the third device through the MQTT proxy service, or if the duration does not reach the first duration threshold, the duration is updated until the duration reaches the first duration threshold after the update, and the second ring message is sent to the third device through the MQTT proxy service. Redundant time can be reserved for the processing of the first ring message, and the accuracy of the second ring message generation can be improved, thereby improving the success rate of sending the second ring message.
[0155] Among them, the first duration threshold can be the threshold duration required to generate the second ring message. If the duration after receiving the first ring message reaches the first duration threshold, it means that the generation of the second ring message has been completed with a high probability. At this time, the sending of the second ring message can be triggered. If the first duration threshold is not reached, it means that the generation of the second ring message may not have been completed. At this time, the duration can be updated until the duration after the update reaches the first duration threshold, and the second ring message is sent to the third device through the MQTT proxy service.
[0156] S308: Determine the duration after receiving the first ring message.
[0157] In some embodiments, the first device may also determine whether to exit the logical ring based on a duration after receiving the first ring message.
[0158] S309: Determine that the duration reaches a second duration threshold and no new first ring message is received, wherein the new first ring message is a first ring message sent again by the second device.
[0159] S310: Determine whether the first device exits the logical ring.
[0160] The second duration threshold is a duration threshold value for determining that the logical ring can be exited. In the embodiment of the present application, the first device can determine that the logical ring can be exited when the duration after receiving the first ring message reaches the second duration threshold and no new first ring message is received, thereby effectively reducing the operating resources required for logical ring maintenance, and subsequently re-accessing the logical ring can be triggered based on a flexible mechanism, thereby improving the flexibility of communication management between devices.
[0161] In this embodiment, the first device, the second device and the third device have subscribed to the message queue telemetry transmission MQTT proxy service of the server, and the second device has accessed the logical ring; the first device accesses the logical ring through the MQTT proxy service, and receives the first ring message sent by the second device through the MQTT proxy service, processes the first ring message, and obtains the second ring message, wherein the second ring message at least includes: the third identification information of the third device, and sends the second ring message to the third device through the MQTT proxy service. It can effectively reduce the complexity of communication between devices and improve the communication effect. The first device can determine that it can exit the logical ring when the duration of receiving the first ring message reaches the second duration threshold and no new first ring message is received, thereby effectively reducing the operating resources required for logical ring maintenance, and can subsequently trigger re-access to the logical ring based on a flexible mechanism, thereby improving the flexibility of communication management between devices.
[0162] In the embodiment of the present application, a fault notification mechanism is also provided. When the first device determines that the first ring message has not been received, or determines that the second ring message has not been successfully sent, a fault status message can be sent to the second device and the third device respectively through the MQTT proxy service. This is to timely notify other devices in the logical ring of the fault of the device, so that other devices can take timely fault response measures and improve the integrity of communication control between devices.
[0163] In an embodiment of the present application, a mechanism is also provided for flexibly and quickly re-triggering access to the logical ring. The first device determines that the first ring message has been re-received, or that the fault status message has been successfully sent, and accesses the logical ring through the MQTT proxy service.
[0164] The embodiment of the present application also provides an exit application mechanism. If a device needs to exit a logical ring, the device can send an application to other devices to request other devices to allow the device to exit the logical ring. This can effectively avoid the impact of a device's unilateral exit decision on the data flow and transmission of the entire logical ring, thereby improving the reliability and stability of communication between devices.
[0165] In some embodiments, the first ring message also includes: a preset flag bit, which is used to indicate whether the second device applies to exit the logical ring. After receiving the first ring message, the first device can determine whether the device allows the second device to exit the logical ring and obtain a determination result. According to the determination result, the value corresponding to the preset flag bit in the first ring message is processed to obtain the second ring message.
[0166] For example, if the first device allows the second device to exit the logical ring, the preset flag bit can be set to a first value to indicate that the present device allows the second device to exit the logical ring. If the first device does not allow the second device to exit the logical ring, the preset flag bit can be set to a second value to indicate that the present device does not allow the second device to exit the logical ring. Then, the second ring message after the setting is transmitted to a third device, and the third device decides whether to allow the second device to exit the logical ring.
[0167] In some embodiments, the second device exits the logical ring if all devices in the logical ring allow the second device to exit the logical ring.
[0168] In the embodiment of the present application, after the second device exits the logical ring, it can re-access the logical ring, then the first device can determine that the second device has exited the logical ring, and the first device can also receive the ring registration message sent by the second device again through the MQTT proxy service, wherein the ring registration message is used for the second device to access the logical ring, and the first device provides the first identification information of the first device to the second device. Effectively improve the flexibility of communication management between devices.
[0169] The embodiment of the present application also provides a state management mechanism to achieve dynamic management of the states of multiple devices to support efficient operation of communications between multiple devices.
[0170] In the embodiment of the present application, the states that each device can be in include: initialization state, normal communication state, communication stop state, and fault state. The switching method between each state can be as follows:
[0171] In some embodiments, if it is determined that the first device has been connected to the logical ring, the first device can be controlled to switch from an initialization state to a normal communication state, wherein the first device enters the initialization state after connecting to the MQTT proxy service, and then the first ring message sent by the second device can be received through the MQTT proxy service in the normal communication state.
[0172] In some embodiments, if it is determined that the first device has exited the logical ring, the first device can be controlled to switch from a normal communication state to a communication stop state, and a third ring message is received in the communication stop state, and the first device is controlled to switch from the communication stop state to the initialization state, wherein the third ring message is used to trigger the first device to enter the initialization state.
[0173] In some embodiments, if it is determined that the first ring message is not received, or it is determined that the second ring message is not sent successfully, the first device can be controlled to switch from a normal communication state to a fault state, and it is determined that the first ring message is received again, or it is determined that the fault state message has been successfully sent, and the first device can be controlled to switch from a fault state to an initialization state.
[0174] Therefore, through the above method, it is possible to effectively support dynamic management of the possible states of each device, improve the management orderliness and management effect of communication between devices, and improve the efficiency of communication between devices.
[0175] The description in the above embodiment can be illustrated as follows:
[0176] Each device participating in the network has a unique device id (Identifier) and a successor_id to record its own logical successor device id. The initial value of the successor_id is the id of this device. After the device is powered on, the network communication management service is started. This service will use MQTT configuration to connect to the MQTT proxy service if the network environment is available. The device subscribes to network messages of a fixed topic (such as osek_mqtt_all_message) through MQTT. The ring registration message (Alive_message) of a fixed topic (the same as the subscription topic: such as osek_mqtt_all_message) is published through MQTT. The message contains the id information of this device. The device can receive the ring registration message (Alive_message) of other devices through subscription. Each time an Alive_message is received, it follows Figure 4 Update the successor_id of this device using the algorithm in.
[0177] Figure 4 This is a schematic diagram of the update of identification information in the embodiment of the present application. The devices in the logical ring send ring messages (Ring_message) through MQTT in turn according to the time period T_type. After receiving the Ring_message sent by the upstream device, each device sends a Ring_message with the destination id as successor_id after T_type time. If a new device sends a ring registration message (Alive_message) after startup, it will also send a Ring_message. Figure 4The algorithm in the protocol updates the successor_id of each device and forms a new logical ring. If a device in the logical ring does not receive the Ring_message within the T_max time, it is considered that the device has left the logical ring and can rejoin the logical ring. If a network failure occurs in a device in the logical ring, resulting in multiple failures to send the Ring_message and the inability to receive the Ring_message sent by other devices, the device is marked as a faulty state and attempts to send a faulty state message (limphome_message) according to the T_error cycle. Once the device network failure is eliminated and the limphome_message is sent successfully, or a message from another device is received, the device rejoins the logical ring. When a device in the logical ring actively exits the networking due to functional requirements, the device will send an exit request to other devices in the device logical ring by marking the corresponding bit of Opcode.sleep in the Ring_message message, and exit the networking after being allowed. When the device needs to rejoin the networking, it can rejoin the logical ring. While each device in the logical ring publishes Ring_message through MQTT for networking and network management, it can also transmit business data through the Data field of Ring_message. The device application layer can obtain any Data of Ring_message for business processing; it can also place the application layer business data into the Data area of Ring_message for sending within T_type time.
[0178] The device communication method provided in the embodiment of the present application can be implemented by the network communication management service on the device side, such as Figure 5 As shown, Figure 5 This is a schematic diagram of the network communication management service on the device side in the embodiment of the present application. The network communication management service on the device side is based on the autonomous networking and MQTT network message subscription and publishing of OSEK network management, combined with a specific communication message format, to achieve the construction and maintenance of autonomous networking of the device. Based on the OSEK network management function, the data encapsulation and self-organizing networking functions of the device are realized, and based on the MQTT network transmission, one-to-many data transmission across regions of the device is realized, and the cross-regional remote communication and self-organizing network management functions of the device are realized as a whole. The networking process has low functional requirements on the server, and only requires the MQTT service proxy function, which largely gets rid of the dependence on the server processing function, and realizes the decentralized requirements of device network management and data transmission.
[0179] The server in the embodiment of the present application can be a cloud server platform, in which the MQTT proxy service is deployed. Based on the MQTT proxy service technology, the forwarding and transmission of device subscription and publishing messages can be realized. The requirements for the server's computing power and storage capacity are low, the overall function is single, and the requirements for low cost and high reliability of the platform are achieved.
[0180] In the embodiment of the present application, the device status can be classified as follows during the entire process from startup to network access, and then to data communication and network management through MQTT transmission of OSEK data packets:
[0181] (1) Initialization state (Reset_State):
[0182] The device will enter the initialization state in three cases: the device enters the initialization state after completing the network connection; the device enters the initialization state when it detects that it is skipped by Ring_message in the normal communication state; the device enters the initialization state after the fault problem is solved in the Limphome_State state.
[0183] In the initialization state, the device's network is normal and has the ability to communicate with MQTT. It will be added to the device logical ring as a new device by sending Alive_message through MQTT.
[0184] (2) Normal communication state (Normal_State):
[0185] After joining the logical ring, the device enters the normal communication state and can receive the Alive_message sent by the newly joined device and the Ring_message sent by other devices in the logical ring. When the DestID of the received Ring_message is the device ID, the device can actively send a Ring_message with the DestID as the successor_id to maintain the operation of the logical ring. In the process of receiving and sending messages, business data transmission and reception, network management and networking are completed. The application layer can meet business logic processing according to the data.
[0186] (3) Communication stop state (Sleep_State):
[0187] In some cases, when the device no longer needs to perform network management and data communication, it can switch from the normal communication state to the communication stop state. In the communication stop state, the device maintains the connection with the MQTT proxy service, does not participate in the maintenance of the device logical ring, and does not send Alive_message and Ring_message. After receiving a specific Ring_message sent by other devices, the device in the communication stop state will exit the current state, enter the initialization state, and then re-enter the normal communication state.
[0188] (4) Fault state (Limphome_State):
[0189] When the device is in normal communication state (Normal_State), if the number of Ring_message sending failures exceeds the preset value due to network anomalies or other reasons, the device will enter the fault state. In the fault state, the device cannot participate in the logical ring maintenance, which will cause the device logical ring to be rebuilt under the action of messages from other devices. The newly built device logical ring does not contain the device in the fault state. The device in the fault state will send device fault messages outward according to the time period T_error, and the application layer will process and solve the network anomaly problem of the device. When the network anomaly is eliminated, the device connects to the MQTT proxy service again, enters the initialization state after receiving the Ring_message message from other devices, and then rejoins the device logical ring through the Alive_message.
[0190] The following describes the detailed implementation process of the embodiment of the present application by taking the switching of a device between different states as an example.
[0191] 1. Initialization state (Reset_State) and normal communication state (Normal_State):
[0192] In a network environment that supports MQTT proxy service, the device enters the initialization state after connecting to the MQTT proxy server. The initialization state is a prerequisite for the device to enter the normal communication state. Any other device state (such as communication stop state, fault state) can be converted to the initialization state before it can be further converted to the normal communication state.
[0193] as follows Figure 6 As shown, Figure 6This is a schematic diagram of switching between the initialization state and the normal communication state in the embodiment of the present application. In the initialization state, the device will first send a registration message (Alive_message) through MQTT, and enter the normal communication state after the sending is successful, and further send a ring message (Ring_message) to participate in the establishment and maintenance of the logical ring. When the device exceeds T_max and does not receive a Ring_message message with dest_id as the device id, it enters the initialization state and re-executes the registration operation.
[0194] 2. Normal communication state (Normal_State) and communication stop state (Sleep_State):
[0195] When the device does not need to conduct networking and network data transmission, it will apply to enter the communication stop state, and apply to other devices to stop communication by setting the sleep.ind flag of the published Ring_message message to 1. The Ring_message passes through each device on the logical ring in turn. If other devices allow communication to stop, the sleep.ind flag of the Ring_message is kept set to 1. When the Ring_message is passed back to the requesting device on the logical ring, if the sleep.ind flag is still 1, the device enters the communication stop state.
[0196] The device that enters the communication stop state can still receive messages through MQTT. When the sleep.ind flag of the received message is 0, it exits the current state and enters the initialization state, and then joins the device logic ring through the registration message (Alive_message) to enter the normal communication state. The specific implementation process is as follows Figure 7 As shown, Figure 7 It is a schematic diagram of switching between a normal communication state and a communication stop state in an embodiment of the present application.
[0197] 3. Normal communication state (Normal_State) and fault state (Limphome_State):
[0198] A device in a normal communication state will be unable to publish or receive messages when the sending function is abnormal or the network is abnormal. When the number of message publishing failures exceeds the limit value tx_limit, the device will enter a fault state. In the fault state, maintenance can be performed based on the application layer. When the fault problem is solved, the device can receive messages from other devices through MQTT subscription, enter the initialization state, and then join the device logical ring through the registration message (Alive_message) to enter the normal communication state. The specific implementation process is as follows Figure 8 As shown, Figure 8It is a schematic diagram of switching between normal communication state and fault state in an embodiment of the present application.
[0199] like Fig. 9 As shown, Fig. 9 It is a schematic diagram of the switching process between different states in the embodiment of the present application. In the embodiment of the present application, cross-regional device message broadcast transmission, message filtering, and message parsing are realized based on MQTT technology and device logical ring mechanism. Multi-state management of devices and synchronization of device states in the logical ring are realized based on OSEK network management technology. Autonomous network construction and autonomous network maintenance of devices are realized based on OSEK network management technology. Cross-regional remote communication and networking of multiple devices are realized based on MQTT technology and OSEK network management technology.
[0200] In the embodiment of the present application, under the premise that the server only has the MQTT proxy function, cross-regional remote communication and autonomous networking of devices are realized, and the dependence on centralized server management is eliminated. While reducing development and operation costs, the robustness and convenience of device networking are improved. The network data communication function and networking management function are realized more efficiently, and the requirements for hardware resources are lower, further reducing the cost of device communication and networking.
[0201] Fig.10 It is a structural diagram of a device communication apparatus proposed in one embodiment of the present application.
[0202] like Fig.10 As shown, the device communication device 100 is applied to a first device, the first device, the second device and the third device have subscribed to the message queue telemetry transmission MQTT proxy service of the server, and the second device has been connected to the logical ring; the device communication device 100 includes:
[0203] The access unit 1001 is used to access the logical ring through the MQTT proxy service.
[0204] The receiving unit 1002 is configured to receive a first ring message sent by a second device through an MQTT proxy service.
[0205] The processing unit 1003 is configured to process the first ring message to obtain a second ring message, wherein the second ring message at least includes: third identification information of the third device.
[0206] The sending unit 1004 is configured to send the second ring message to the third device through the MQTT proxy service.
[0207] It should be noted that the division of units in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, each functional unit in each embodiment of the present application may be integrated into a processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0208] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a processor-readable storage medium.
[0209] Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program codes.
[0210] It should be noted here that the above-mentioned device provided in the embodiment of the present application can implement all the method steps implemented in the above-mentioned method embodiment, and can achieve the same technical effect. The parts and beneficial effects of this embodiment that are the same as those in the method embodiment will not be described in detail here.
[0211] In this embodiment, the first device, the second device and the third device have subscribed to the message queue telemetry transmission MQTT proxy service of the server, and the second device has been connected to the logical ring; the first device accesses the logical ring through the MQTT proxy service, and receives the first ring message sent by the second device through the MQTT proxy service, processes the first ring message, and obtains the second ring message, wherein the second ring message at least includes: the third identification information of the third device, and sends the second ring message to the third device through the MQTT proxy service. It can effectively reduce the complexity of communication between devices and improve the communication effect.
[0212] Fig.11 It is a structural diagram of a device communication apparatus proposed in another embodiment of the present application.
[0213] See also Fig.11The device communication device 110 includes a memory 1101, a transceiver 1102, a processor 1103 and a user interface 1104: the memory 1101 is used to store computer programs; the transceiver 1102 is used to send and receive data under the control of the processor 1103; the processor 1103 is used to read the computer program in the memory 1101 and perform the following operations:
[0214] Accessing the logical ring through the message queue telemetry transmission MQTT proxy service of the server, wherein the logical ring has been connected to the second device, and the second device has subscribed to the MQTT proxy service;
[0215] Receiving a first ring message sent by a second device through an MQTT proxy service;
[0216] Processing the first ring message to obtain a second ring message, wherein the second ring message at least includes: third identification information of the third device, the third device has subscribed to the MQTT proxy service, and the logical ring has connected to the third device;
[0217] The second ring message is sent to the third device through the MQTT proxy service.
[0218] In some embodiments of the present application, the first ring message includes at least: first identification information of the first device; wherein the processor 1103 is further configured to:
[0219] The first identification information of the first device in the first ring message is updated to the third identification information of the third device to obtain a second ring message.
[0220] In some embodiments of the present application, the first ring message further includes: business data, and the second ring message further includes: business data.
[0221] In some embodiments of the present application, the processor 1103 is further configured to determine the third identification information of the third device based on the following method:
[0222] Receiving a ring registration message sent by a third device through an MQTT proxy service, wherein the ring registration message is used for the third device to access the logical ring;
[0223] The third identification information of the third device is obtained from the ring registration message.
[0224] In some embodiments of the present application, the processor 1103 is further configured to:
[0225] Sending a ring registration message to the second device and the third device respectively through the MQTT proxy service, wherein the ring registration message includes: first identification information of the first device;
[0226] Access to the logical ring is based on the ring registration message.
[0227] In some embodiments of the present application, the processor 1103 is further configured to:
[0228] Determine the duration after receiving the first ring message;
[0229] Determine that the duration reaches a first duration threshold, and send a second ring message to a third device through the MQTT proxy service;
[0230] If it is determined that the continuous duration does not reach the first duration threshold, the continuous duration is updated until the updated continuous duration reaches the first duration threshold, and a second ring message is sent to the third device through the MQTT proxy service.
[0231] In some embodiments of the present application, the processor 1103 is further configured to:
[0232] Determine the duration after receiving the first ring message;
[0233] Determine that the duration reaches a second duration threshold and no new first ring message is received, wherein the new first ring message is a first ring message sent again by the second device;
[0234] It is determined that the first device exits the logical ring.
[0235] In some embodiments of the present application, the processor 1103 is further configured to:
[0236] Determining that the first ring message is not received, or determining that the second ring message is not successfully sent;
[0237] The fault status message is sent to the second device and the third device respectively through the MQTT proxy service.
[0238] In some embodiments of the present application, the processor 1103 is further configured to:
[0239] Determining that the first ring message is re-received, or determining that the fault status message is successfully sent;
[0240] Access the logical ring through the MQTT proxy service.
[0241] In some embodiments of the present application, the first ring message further includes: a preset flag bit, the preset flag bit is used to indicate whether the second device applies to exit the logical ring;
[0242] The processor 1103 is further configured to:
[0243] Determine whether the first device allows the second device to exit the logical ring, and obtain a determination result;
[0244] According to the determination result, the value corresponding to the preset flag bit in the first ring message is processed to obtain the second ring message.
[0245] In some embodiments of the present application, when all devices in the logical ring allow the second device to exit the logical ring, the second device exits the logical ring.
[0246] In some embodiments of the present application, the processor 1103 is further configured to:
[0247] Determining that the second device has exited the logical ring;
[0248] Receiving, through the MQTT proxy service, a ring registration message sent by the second device, wherein the ring registration message is used for the second device to access the logical ring;
[0249] The first identification information of the first device is provided to the second device.
[0250] In some embodiments of the present application, the processor 1103 is further configured to:
[0251] Determining that the first device has been connected to the logical ring;
[0252] Controlling the first device to switch from an initialization state to a normal communication state, wherein the first device enters the initialization state after connecting to the MQTT proxy service;
[0253] In a normal communication state, a first ring message sent by the second device is received through the MQTT proxy service.
[0254] In some embodiments of the present application, the processor 1103 is further configured to:
[0255] Determining that the first device has exited the logical ring;
[0256] Controlling the first device to switch from a normal communication state to a communication stop state;
[0257] When the third ring message is received in the communication stop state, the first device is controlled to switch from the communication stop state to the initialization state, wherein the third ring message is used to trigger the first device to enter the initialization state.
[0258] In some embodiments of the present application, the processor 1103 is further configured to:
[0259] Determining that the first ring message was not received, or determining that the second ring message was not successfully sent;
[0260] Controlling the first device to switch from a normal communication state to a fault state;
[0261] Determining that the first ring message is re-received, or determining that the fault status message is successfully sent;
[0262] The first device is controlled to switch from a fault state to an initialization state.
[0263] Among them, Fig.11 In the embodiment, the bus architecture may include any number of interconnected buses and bridges, specifically one or more processors represented by processor 1103 and various circuits of memory represented by memory 1101 are linked together. The bus architecture may also link together various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. The bus interface provides an interface. The transceiver 1102 may be a plurality of components, namely, a transmitter and a receiver, providing a unit for communicating with various other devices on a transmission medium, which may include wireless channels, wired channels, optical cables, and other transmission media. For different user devices, the user interface 1104 may also be an interface capable of externally and internally connecting required devices, and the connected devices include but are not limited to a keypad, a display, a speaker, a microphone, a joystick, and the like.
[0264] The processor 1103 is responsible for managing the bus architecture and general processing, and the memory 1101 can store data used by the processor 1103 when performing operations.
[0265] Optionally, the processor 1103 may be a CPU (central processing unit), an ASIC (Application Specific Integrated Circuit), an FPGA (Field-Programmable Gate Array) or a CPLD (Complex Programmable Logic Device), and the processor may also adopt a multi-core architecture.
[0266] The processor calls the computer program stored in the memory to execute any method provided in the embodiments of the present application according to the obtained executable instructions. The processor and the memory can also be arranged physically separately.
[0267] It should be noted here that the above-mentioned device provided in the embodiment of the present application can implement all the method steps implemented in the above-mentioned method embodiment, and can achieve the same technical effect. The parts and beneficial effects of this embodiment that are the same as those in the method embodiment will not be described in detail here.
[0268] In order to implement the above-mentioned embodiment, the embodiment of the present application proposes a processor-readable storage medium, and the processor-readable storage medium stores a computer program, and the computer program is used to enable the processor to execute the device communication method.
[0269] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) that contain computer-usable program code.
[0270] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer executable instructions. These computer executable instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0271] These processor executable instructions may also be stored in a processor readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the processor readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0272] These processor-executable instructions may also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0273] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
[0274] It should be noted that, in the description of this application, the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, the meaning of "plurality" is two or more.
[0275] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0276] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0277] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0278] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0279] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.
[0280] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0281] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.
[0282] It should be noted that, in the description of this application, the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, the meaning of "plurality" is two or more.
[0283] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0284] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0285] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0286] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0287] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.
[0288] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0289] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.
[0290] It should be noted that, in the description of this application, the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, the meaning of "plurality" is two or more.
[0291] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0292] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0293] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0294] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0295] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.
[0296] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0297] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A device communication method, It is characterized in that The method is executed by a first device, wherein the first device, the second device and the third device have subscribed to the message queue telemetry transmission MQTT proxy service of the server, and the second device has been connected to the logical ring; wherein the method includes: Accessing the logical ring through the MQTT proxy service; Receiving, through the MQTT proxy service, a first ring message sent by the second device; Processing the first ring message to obtain a second ring message, wherein the second ring message at least includes: third identification information of the third device; The second ring message is sent to the third device through the MQTT proxy service.
2. The method according to claim 1, It is characterized in that The first ring message includes at least: first identification information of the first device; wherein, processing the first ring message to obtain the second ring message includes: The first identification information of the first device in the first ring message is updated to the third identification information of the third device to obtain the second ring message.
3. The method according to claim 2, It is characterized in that The first ring message further includes: service data, and the second ring message further includes: the service data.
4. The method according to claim 1, It is characterized in that The third identification information of the third device is determined based on the following method: Receiving, through the MQTT proxy service, a ring registration message sent by the third device, wherein the ring registration message is used for the third device to access the logical ring; The third identification information of the third device is acquired from the ring registration message.
5. The method according to claim 1, It is characterized in that The accessing the logical ring through the MQTT proxy service includes: Sending a ring registration message to the second device and the third device respectively through the MQTT proxy service, wherein the ring registration message includes: first identification information of the first device; Accessing the logical ring based on the ring registration message.
6. The method according to claim 1, It is characterized in that The sending the second ring message to the third device through the MQTT proxy service includes: Determine the duration after receiving the first ring message; Determine that the duration of the duration reaches a first duration threshold, and send the second ring message to the third device through the MQTT proxy service; If it is determined that the duration has not reached the first duration threshold, the duration is updated until the updated duration reaches the first duration threshold, and the second ring message is sent to the third device through the MQTT proxy service.
7. The method according to claim 1, It is characterized in that The method further comprises: Determine the duration after receiving the first ring message; Determine that the duration of the duration reaches a second duration threshold and no new first ring message is received, wherein the new first ring message is a first ring message sent again by the second device; It is determined that the first device exits the logical ring.
8. The method according to claim 1, It is characterized in that The method further comprises: Determining that the first ring message is not received, or determining that the second ring message is not sent successfully; A fault status message is sent to the second device and the third device respectively through the MQTT proxy service.
9. The method according to claim 8, It is characterized in that The method further comprises: determining that the first ring message is received again, or determining that the fault status message is sent successfully; The logical ring is accessed through the MQTT proxy service.
10. The method according to claim 1, It is characterized in that The first ring message further includes: a preset flag bit, the preset flag bit is used to indicate whether the second device applies to exit the logical ring; The processing of the first ring message to obtain the second ring message includes: determining whether the first device allows the second device to exit the logical ring, and obtaining a determination result; According to the determination result, the value corresponding to the preset flag bit in the first ring message is processed to obtain the second ring message.
11. The method according to claim 10, It is characterized in that In a case where all devices in the logical ring allow the second device to exit the logical ring, the second device exits the logical ring.
12. The method according to claim 11, It is characterized in that The method further comprises: Determining that the second device has exited the logical ring; Receiving, through the MQTT proxy service, a ring registration message sent by the second device, wherein the ring registration message is used for the second device to access the logical ring; The first identification information of the first device is provided to the second device.
13. The method of claim 1, It is characterized in that The method further comprises: Determining that the first device has been connected to the logical ring; Controlling the first device to switch from an initialization state to a normal communication state, wherein the first device enters the initialization state after connecting to the MQTT proxy service; The receiving, through the MQTT proxy service, a first ring message sent by the second device includes: In the normal communication state, a first ring message sent by the second device is received through the MQTT proxy service.
14. The method of claim 1, It is characterized in that The method further comprises: Determining that the first device has exited the logical ring; Controlling the first device to switch from a normal communication state to a communication stop state; A third ring message is received in the communication stop state, and the first device is controlled to switch from the communication stop state to the initialization state, wherein the third ring message is used to trigger the first device to enter the initialization state.
15. The method of claim 1, It is characterized in that The method further comprises: Determining that the first ring message is not received, or determining that the second ring message is not sent successfully; Controlling the first device to switch from a normal communication state to a fault state; Determining that the first ring message is received again, or determining that the fault status message is sent successfully; The first device is controlled to switch from the fault state to an initialization state.
16. A device communication apparatus, It is characterized in that Applied to a first device, the first device, the second device and the third device have subscribed to the message queue telemetry transmission MQTT proxy service of the server, and the second device has been connected to the logical ring; wherein the apparatus comprises: An access unit, configured to access the logical ring through the MQTT proxy service; A receiving unit, configured to receive, through the MQTT proxy service, a first ring message sent by the second device; A processing unit, configured to process the first ring message to obtain a second ring message, wherein the second ring message at least includes: third identification information of the third device; A sending unit is used to send the second ring message to the third device through the MQTT proxy service.
17. A device communication apparatus, It is characterized in that The invention comprises a memory, a transceiver and a processor: the memory is used to store a computer program; the transceiver is used to send and receive data under the control of the processor; the processor is used to read the computer program in the memory and perform the following operations: Accessing a logical ring through a message queue telemetry transmission MQTT proxy service of a server, wherein the logical ring has access to a second device, and the second device has subscribed to the MQTT proxy service; Receiving, through the MQTT proxy service, a first ring message sent by the second device; Processing the first ring message to obtain a second ring message, wherein the second ring message at least includes: third identification information of a third device, the third device has subscribed to the MQTT proxy service, and the logical ring has connected to the third device; The second ring message is sent to the third device through the MQTT proxy service.
18. The device according to claim 17, It is characterized in that The first ring message includes at least: first identification information of the first device; wherein the processor is further configured to: The first identification information of the first device in the first ring message is updated to the third identification information of the third device to obtain the second ring message.
19. The device according to claim 18, It is characterized in that The first ring message further includes: service data, and the second ring message further includes: the service data.
20. The device according to claim 17, It is characterized in that The processor is further configured to determine the third identification information of the third device based on the following method: Receiving, through the MQTT proxy service, a ring registration message sent by the third device, wherein the ring registration message is used for the third device to access the logical ring; The third identification information of the third device is acquired from the ring registration message.
21. The device according to claim 17, It is characterized in that The processor is further configured to: Sending a ring registration message to the second device and the third device respectively through the MQTT proxy service, wherein the ring registration message includes: first identification information of the first device; Accessing the logical ring based on the ring registration message.
22. The device according to claim 17, It is characterized in that The processor is further configured to: Determine the duration after receiving the first ring message; Determine that the duration of the duration reaches a first duration threshold, and send the second ring message to the third device through the MQTT proxy service; If it is determined that the duration has not reached the first duration threshold, the duration is updated until the updated duration reaches the first duration threshold, and the second ring message is sent to the third device through the MQTT proxy service.
23. The device according to claim 17, It is characterized in that The processor is further configured to: Determine the duration after receiving the first ring message; Determine that the duration of the duration reaches a second duration threshold and no new first ring message is received, wherein the new first ring message is a first ring message sent again by the second device; It is determined that the first device exits the logical ring.
24. The device of claim 17, It is characterized in that The processor is further configured to: Determining that the first ring message is not received, or determining that the second ring message is not sent successfully; A fault status message is sent to the second device and the third device respectively through the MQTT proxy service.
25. The device according to claim 24, It is characterized in that The processor is further configured to: determining that the first ring message is received again, or determining that the fault status message is sent successfully; The logical ring is accessed through the MQTT proxy service.
26. The device of claim 17, It is characterized in that The first ring message further includes: a preset flag bit, the preset flag bit is used to indicate whether the second device applies to exit the logical ring; Wherein, the processor is further used for: determining whether the first device allows the second device to exit the logical ring, and obtaining a determination result; According to the determination result, the value corresponding to the preset flag bit in the first ring message is processed to obtain the second ring message.
27. The device according to claim 26, It is characterized in that In a case where all devices in the logical ring allow the second device to exit the logical ring, the second device exits the logical ring.
28. The device according to claim 27, It is characterized in that The processor is further configured to: Determining that the second device has exited the logical ring; Receiving, through the MQTT proxy service, a ring registration message sent by the second device, wherein the ring registration message is used for the second device to access the logical ring; The first identification information of the first device is provided to the second device.
29. The device of claim 17, It is characterized in that The processor is further configured to: Determining that the first device has been connected to the logical ring; Controlling the first device to switch from an initialization state to a normal communication state, wherein the first device enters the initialization state after connecting to the MQTT proxy service; In the normal communication state, a first ring message sent by the second device is received through the MQTT proxy service.
30. The device of claim 17, It is characterized in that The processor is further configured to: Determining that the first device has exited the logical ring; Controlling the first device to switch from a normal communication state to a communication stop state; A third ring message is received in the communication stop state, and the first device is controlled to switch from the communication stop state to the initialization state, wherein the third ring message is used to trigger the first device to enter the initialization state.
31. The device of claim 17, It is characterized in that The processor is further configured to: Determining that the first ring message is not received, or determining that the second ring message is not sent successfully; Controlling the first device to switch from a normal communication state to a fault state; Determining that the first ring message is received again, or determining that the fault status message is sent successfully; The first device is controlled to switch from the fault state to an initialization state.
32. A processor-readable storage medium, It is characterized in that The processor-readable storage medium stores a computer program, and the computer program is used to enable the processor to execute the device communication method according to any one of claims 1 to 15.