Message publishing method, communication device and storage medium

CN116743873BActive Publication Date: 2026-06-26ECOFLOW INC

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ECOFLOW INC
Filing Date
2023-07-12
Publication Date
2026-06-26

Smart Images

  • Figure CN116743873B_ABST
    Figure CN116743873B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a message publishing method, a communication device and a storage medium. The message publishing method comprises: receiving a message sent by any second node, wherein a first node is in communication connection with a plurality of second nodes; determining a target topic corresponding to the message; storing the message in a linked list corresponding to the target topic; wherein the messages in the same linked list come from the same or different second nodes; when the number of messages stored in the linked list exceeds a preset number, selecting and merging a preset number of messages from the linked list to obtain a to-be-pushed message package; and pushing the to-be-pushed message package to a server based on the target topic. The above method can improve the efficiency of message publishing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of communication technology, and in particular relates to a message publishing method, communication device and storage medium. Background Technology

[0002] In current message transmission schemes employing a publish-subscribe mechanism, if a local node needs to transmit a message to a server, it can use different topics to send the message to a message publishing node (such as an IoT (Internet of Things) node). The IoT node then pushes the message to the backend server according to the topic, thus achieving message publication. Therefore, anyone subscribing to that topic can receive the corresponding message push, thereby enabling message transmission between the local node, the server, and other nodes.

[0003] For example, a home energy storage system includes inverters and energy storage devices. The inverter itself includes an EMS (Energy Management System) module and a PCS (Power Conversion System) module. Each of these devices or modules can act as a local node to send messages to the IoT node, which then publishes the messages. These local nodes typically have one or more identical functions, such as temperature monitoring. When any local node needs to report a temperature value, it usually uses similar topics, such as EMStemperature or PCS temperature, and the amount of valid data is usually small. Therefore, if every time a local node needs to report a message, the IoT node needs to push the message to the server, and if the frequency of message uploads for the same function is too high, the topic bytes will consume excessive traffic and bandwidth, resulting in low efficiency for message publishing by the IoT node. Summary of the Invention

[0004] This application provides a message publishing method, communication device, and storage medium to solve the problem of low efficiency in message publishing.

[0005] The first aspect of this application provides a message publishing method applied to a first node communicating with a server. The message publishing method includes: receiving a message sent by any second node, wherein the first node is communicatively connected to multiple second nodes; determining a target topic corresponding to the message; storing the message in a linked list corresponding to the target topic; wherein messages in the same linked list come from the same or different second nodes; when the number of messages stored in the linked list exceeds a preset number, selecting and merging the preset number of messages from the linked list to obtain a message package to be pushed; and pushing the message package to be pushed to the server based on the target topic.

[0006] In the message publishing method provided in this application embodiment, a message sent by any second node is received, the target topic corresponding to the message is determined, and the message is stored in a linked list corresponding to the target topic. When the number of messages stored in the linked list exceeds a preset number, a preset number of messages are selected and merged from the linked list to obtain a message package to be pushed. The message package to be pushed is then pushed to the server based on the target topic. This application stores similar messages from different second nodes in a linked list corresponding to the target topic, and merges a preset number of messages from the linked list to obtain a message package to be pushed during a single message publishing. This allows the message package to carry multiple messages at once, resulting in more effective messages, saving traffic and bandwidth during message publishing, reducing the frequency of message publishing, and thus improving the efficiency of message publishing.

[0007] A second aspect of this application also provides a message publishing device applied to a first node communicating with a server. The message publishing device includes: a message receiving module for receiving messages sent by any second node, wherein the first node is communicatively connected to multiple second nodes; a topic determination module for determining the target topic corresponding to the message; a message storage module for storing the message in a linked list corresponding to the target topic, wherein messages in the same linked list come from the same or different second nodes; a message merging module for selecting and merging a preset number of messages from the linked list to obtain a message package to be pushed when the number of messages stored in the linked list exceeds a preset number; and a message pushing module for pushing the message package to be pushed to the server based on the target topic.

[0008] A third aspect of this application also provides a communication device, which includes a processor that executes a computer program stored in a memory to implement the above-described message publishing method.

[0009] A fourth aspect of this application also includes a computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned message publishing method. Attached Figure Description

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

[0011] Figure 1 This is an application scenario diagram of the message publishing method provided in the embodiments of this application;

[0012] Figure 2 This is a flowchart of the message publishing method provided in the embodiments of this application;

[0013] Figure 3 This is a flowchart illustrating the determination of the target subject provided in an embodiment of this application;

[0014] Figure 4 This is a flowchart illustrating the process of determining a linked list provided in an embodiment of this application;

[0015] Figure 5 This is a flowchart illustrating the message merging process provided in the embodiments of this application;

[0016] Figure 6 This is a flowchart illustrating the process of determining the message packet to be pushed, as provided in an embodiment of this application.

[0017] Figure 7 This is a schematic diagram of the structure of the message publishing device provided in the embodiments of this application;

[0018] Figure 8 This is a schematic diagram of the communication device provided in the embodiments of this application. Detailed Implementation

[0019] To better understand the above-mentioned objectives, features, and advantages of this application, the application will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.

[0020] Numerous specific details are set forth in the following description in order to provide a full understanding of this application. The described embodiments are only some, not all, of the embodiments of this application.

[0021] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application.

[0022] MQTT (Message Queuing Telemetry Transport) is a message transmission protocol based on a publish-subscribe mechanism for communication between nodes. Nodes can include devices or modules with communication capabilities. For example, nodes can include local nodes and other nodes. Local nodes publish messages to a server using different topics, and other nodes then subscribe to those topics to receive messages pushed by the server. When a local node transmits messages to the server, it can send messages on different topics to message publishing nodes, such as IoT (Internet of Things) nodes, which then push messages to the server according to the topics to publish the messages.

[0023] In related technologies, taking a home energy storage system including an inverter and energy storage devices as an example, the inverter includes an EMS (Energy Management System) module and a PCS (Power Conversion System) module, etc., and each of these devices or modules can act as a local node. Assuming that each of these local nodes has temperature monitoring capabilities, when reporting temperature values ​​to the IoT node, the EMS module uses the EMS temperature topic, and the PCS module uses the PCS temperature topic. Accordingly, the temperature message reported by the EMS module could be: EMS temperature, 25 degrees Celsius, and the temperature message reported by the PCS module could be: PCS temperature, 26 degrees Celsius. Then, the IoT node pushes these temperature messages to the server. However, if the frequency of message uploads corresponding to the same function is too high, the bytes of topics like EMS temperature and PCS temperature will consume excessive traffic and bandwidth, resulting in low efficiency in message publishing by the IoT node.

[0024] To address the aforementioned issues, this application provides a message publishing method that can save traffic and bandwidth during message publishing, reduce message publishing frequency, and thereby improve message publishing efficiency.

[0025] Combination Figure 1 This application illustrates an application scenario diagram of the message publishing method provided in the embodiments of this application. For example... Figure 1 As shown, the application scenario includes a first node, a second node, a third node, and a server. The number of the first node, the second node, the third node, and the server can be set according to actual needs and is not limited here. Figure 1 This example uses a scenario where there is one first node and one server, and n second and third nodes each. The first node can be a pre-configured module or device for providing message publishing functionality, such as an IoT node. The second node can be a module or device for providing messages, and the third node can be a module or device for subscribing to messages. The server provides an asynchronous communication mechanism to receive messages on different topics sent by the first node, and to send messages on subscribed topics to the third nodes.

[0026] In some embodiments, the first node is communicatively connected to multiple second nodes, and also communicatively connected to a server. The server is communicatively connected to multiple third nodes. The first node receives messages sent by the multiple second nodes, processes the messages according to topics, and obtains a message package to be pushed. Then, the first node is also used to send the message package to be pushed to the server according to the topic to publish the message. The server is communicatively connected to the multiple third nodes, and can be used to push messages corresponding to subscribed topics to the third nodes, thereby realizing message transmission between the first node, second nodes, third nodes, and the server.

[0027] In some embodiments, multiple third nodes communicating with the server can also push messages to the server by topic. Multiple second nodes and the first node can subscribe to relevant topics, and the server can push messages corresponding to the subscribed topics to the second nodes and the first node. When pushing messages corresponding to the subscribed topics to the second node, the message can be pushed to the first node first, and then the first node can send the message to the second node.

[0028] The message publishing method provided in this application has a wide range of applications, such as mobile live streaming, vehicle networking, financial payment, smart catering, instant messaging, and home energy storage. Taking the application of the message publishing method to a home energy storage scenario as an example, the home energy storage scenario includes an inverter, energy storage devices, a smart air conditioner, and a smart refrigerator. The inverter includes an EMS (Energy Management System) module and a PCS (Power Conversion System) module. The EMS module, PCS module, and energy storage devices are used as the second node, and the smart air conditioner and smart refrigerator are used as the third node. In some embodiments, the EMS module, PCS module, and energy storage devices send messages such as temperature, remaining power, and charging speed to a pre-set first node. The first node processes the messages according to the topic to obtain a message package to be pushed. Then, the first node is also used to send the message package to be pushed to the server according to the topic to publish the message. The smart air conditioner and smart refrigerator subscribe to the messages from the server to determine the status and energy output of the home energy storage system, thereby planning their respective electricity consumption plans to improve energy utilization and reduce electricity costs.

[0029] Figure 2 This is a flowchart illustrating the message publishing method provided in an embodiment of this application. The message publishing method can be applied to a communication device; specifically, the message distribution method is applied to the first node communicating with the server. Figure 2 As shown, the message publishing method may include the following steps. Depending on different needs, the order of the steps in this flowchart may be changed, and some may be omitted.

[0030] S11, receive a message sent by any second node, wherein the first node has communication connections with multiple second nodes.

[0031] In some embodiments, the second node can be a module or device that provides messages. The number of second nodes can be one or more, without limitation. Taking a home energy storage system as an example, it includes an inverter and an energy storage device. The inverter further includes an EMS (Energy Management System) module, a PCS (Power Conversion System) module, etc., and the aforementioned EMS module, PCS module, and energy storage device serve as second nodes. Each second node has one or more functions. For example, the EMS module can have temperature monitoring, heart rate monitoring, and energy consumption monitoring functions; the PCS module can have temperature monitoring, heart rate monitoring, and frequency regulation functions; and the energy storage device can have temperature monitoring, heart rate monitoring, and power consumption monitoring functions. The messages sent by the EMS module as the second node to the first node may include the EMS module temperature value, the EMS module heartbeat value, and the current energy consumption value of the EMS module; the messages sent by the PCS module as the second node to the first node may include the PCS module temperature value, the PCS module heartbeat value, and the PCS module frequency adjustment value; the messages sent by the energy storage device as the second node to the first node may include the energy storage device temperature value, the energy storage device heartbeat value, and the remaining power value of the energy storage device.

[0032] S12, determine the target topic corresponding to the message.

[0033] In some embodiments, a topic can refer to the category corresponding to a message. The category division can be determined according to the business scenario, such as by function, data type, region, and time. This application embodiment takes determining the topic by function as an example. In a home energy storage system, topics may include, but are not limited to: temperature topic, heartbeat topic, energy consumption topic, frequency topic, and power topic. Messages sent by multiple second nodes may belong to the same topic or different topics, which is not limited here. For example, following the above embodiments, the EMS module temperature value sent by the EMS module, the PCS module temperature value sent by the PCS module, and the energy storage device temperature value sent by the energy storage device belong to the same topic (e.g., temperature topic); the EMS module heartbeat value, the PCS module heartbeat value, and the energy storage device heartbeat value belong to the same topic (e.g., heartbeat topic); the current energy consumption value of the EMS module belongs to the energy consumption topic; the PCS module frequency adjustment value belongs to the frequency topic; and the remaining power value of the energy storage device belongs to the power topic.

[0034] In one embodiment, a message identifier can be added to the messages sent by the second node to facilitate subsequent determination of the target topic corresponding to the message based on the message identifier. The message identifier can be a numerical identifier, a color identifier, or a text identifier, and there is no limitation thereto. The message identifier is used to identify the function to which the message belongs.

[0035] S13, store the message in the linked list corresponding to the target topic; messages in the same linked list come from the same or different second nodes.

[0036] In some embodiments, the linked list can be a pre-defined array space within the first node for storing messages. For each topic, there is a corresponding linked list for storing multiple messages under that topic. Since messages within the same topic can come from a single second node or from multiple second nodes, messages in the same linked list can come from the same or different second nodes.

[0037] For example, in a home energy storage system, corresponding linked lists are constructed for temperature, heartbeat, energy consumption, frequency, and power consumption, respectively. Specifically, the temperature linked list stores messages about temperature values ​​sent by the second node-EMS module, the second node-PCS module, and the second node-energy storage device; the heartbeat linked list stores messages about heartbeat values ​​sent by the second node-EMS module, the second node-PCS module, and the second node-energy storage device; the energy consumption linked list stores messages about energy consumption values ​​sent by the second node-EMS module; the frequency linked list stores messages about frequency values ​​sent by the second node-PCS module; and the power consumption linked list stores messages about power consumption values ​​sent by the second node-energy storage device.

[0038] S14. When the number of messages stored in the linked list exceeds the preset number, select and merge the preset number of messages from the linked list to obtain the message package to be pushed.

[0039] In some embodiments, considering communication efficiency and cost, when the first node publishes a message to the server in a single instance, a preset number of messages can be selected from the linked list and merged to obtain a message packet to be pushed. This allows the message packet to carry multiple messages at once, ensuring that it contains more valid messages and reducing the frequency of message publication, thereby improving communication efficiency and reducing communication costs. The preset number can be set according to actual needs; for example, the preset number can be 15 messages. When the number of messages stored in the linked list exceeds 15, 15 messages are selected and merged from the linked list according to the first-in-first-out principle to generate a message packet to be pushed. When the number of messages stored in the linked list does not exceed 15, it can wait cyclically for a preset time. If, after the preset time, the number of messages in the linked list still does not exceed 15, all messages are retrieved from the linked list and merged to generate a message packet to be pushed. The preset time can be set according to timeliness requirements; for example, the preset time can be 2 seconds.

[0040] S15, push the message packet to be pushed to the server based on the target topic.

[0041] In some embodiments, the message packet to be pushed carries corresponding topic information, and the message packet is pushed to the server according to the topic information. Within the server's preset storage space, storage spaces are set up for each topic, and each storage space stores the message packet to be pushed for the corresponding topic. The server also stores topic subscription information for each third node, and messages under that topic are pushed to the third node according to the topic subscription information.

[0042] In the message publishing method provided in this application embodiment, a message sent by any second node is received, the target topic corresponding to the message is determined, and the message is stored in a linked list corresponding to the target topic. When the number of messages stored in the linked list exceeds a preset number, a preset number of messages are selected and merged from the linked list to obtain a message package to be pushed. The message package to be pushed is then pushed to the server based on the target topic. This application stores similar messages from different second nodes in a linked list corresponding to the target topic, and merges a preset number of messages from the linked list to obtain a message package to be pushed during a single message publishing. This allows the message package to carry multiple messages at once, resulting in more effective messages, saving traffic and bandwidth during message publishing, reducing the frequency of message publishing, and thus improving the efficiency of message publishing.

[0043] Figure 3 This is a flowchart illustrating the process of determining the target subject according to an embodiment of this application. The process of determining the target subject can be applied to communication devices. For example... Figure 3 As shown, it includes the following steps:

[0044] S21, parse the message and obtain the message identifier.

[0045] In some embodiments, in a home energy storage system, taking the second node as an EMS module as an example, a 0x0 code is pre-set to correspond to the EMS module. Accordingly, the EMS module sends the EMS module temperature value, the EMS module heartbeat value, and the EMS module current energy consumption value to the first node. The message identifiers corresponding to the above three types of messages are 0x01, 0x02, and 0x03, respectively. Among them, message identifier 0x01 is used to identify that the message is the EMS module temperature value sent by the EMS module, message identifier 0x02 is used to identify that the message is the EMS module heartbeat value sent by the EMS module, and message identifier 0x03 is used to identify that the message is the EMS module current energy consumption value sent by the EMS module.

[0046] S22, traverse the pre-set first mapping relationship between message identifiers and topics to determine the target topic corresponding to the message.

[0047] In some embodiments, a first mapping relationship between message identifiers and topics is pre-established. For example, message identifier 0x01 corresponds to the temperature topic, 0x02 to the heartbeat topic, and 0x03 to the energy consumption topic. By traversing the first mapping relationship, the target topic corresponding to the message can be obtained. In one embodiment, the first mapping relationship between message identifiers and topics can be a many-to-one relationship, that is, multiple message identifiers correspond to one topic. For example, 0x1 is pre-set to correspond to the PCS module, and message identifier 0x11 is used to represent the PCS module temperature value sent by the PCS module; thus, 0x11 also corresponds to the temperature topic.

[0048] This application embodiment establishes a correspondence between message identifiers and topics. By traversing this correspondence, the target topic corresponding to the message can be quickly determined, improving the efficiency of topic determination and further improving the efficiency of message publishing.

[0049] Figure 4 This is a flowchart illustrating the process of determining a linked list according to an embodiment of this application. The process of determining a linked list can be applied to a communication device.

[0050] like Figure 4 As shown, it includes the following steps:

[0051] S31, traverse the pre-set second mapping relationship between topics and linked lists to determine the linked list corresponding to the target topic.

[0052] In some embodiments, for each topic, there exists a corresponding linked list to store multiple messages under that topic. A second mapping relationship between topics and linked lists is pre-defined to determine the linked list corresponding to a target topic.

[0053] Understandably, each linked list corresponds to a storage space, and the second mapping relationship also records the storage address of the linked list. When performing a linked list query based on a topic, the storage address of the linked list corresponding to the target topic can be retrieved for message storage.

[0054] S32, store the message in the linked list corresponding to the target topic.

[0055] In some embodiments, the linked list contains multiple linked list nodes, and the linked list supports adding, deleting, and inserting linked list nodes. Each linked list node may contain a data field and a pointer field, wherein the data field may store the message type (also referred to as message identifier in this application), and the pointer field is used to point to the next linked list node.

[0056] This application embodiment stores messages using a linked list. The linked list supports adding, deleting, and inserting nodes, avoiding the need to pre-allocate a fixed amount of space like an array. This improves the flexibility and reliability of message storage, thereby enhancing the accuracy of message delivery.

[0057] Figure 5 This is a flowchart of message merging provided in an embodiment of this application. The message merging process can be applied to communication devices.

[0058] like Figure 5 As shown, it includes the following steps:

[0059] S41, when a message is stored in the linked list, the timer starts.

[0060] In some embodiments, selecting one message from the linked list and pushing it to the server each time would result in frequent calls to the push interface and increase the number of messages received by the server. When network jitter or latency occurs, many messages may accumulate. Therefore, considering communication efficiency and cost, a timer is invoked to keep track of messages while they are stored in the linked list.

[0061] S42, after a preset time, if the number of messages in the linked list does not exceed the preset number, then all messages are retrieved from the linked list and merged to obtain the message package to be pushed.

[0062] In some embodiments, the preset duration can be determined based on timeliness requirements; for example, the preset duration can be 2 seconds. The preset quantity can be determined based on network load capacity; for example, the preset quantity can be 15 messages. When the number of messages stored in the linked list does not exceed 15, the system can wait cyclically for the preset duration. After the preset duration is reached, if the number of messages in the linked list still does not exceed 15, all messages are retrieved from the linked list and merged to obtain the message packet to be pushed.

[0063] This embodiment of the application starts timing when messages are stored in the linked list. After a preset time, if the number of messages in the linked list does not exceed a preset limit, all messages are retrieved from the linked list and merged to obtain the message packet to be pushed. This embodiment of the application can ensure timeliness requirements by using a preset time limit, while allowing the message packet to carry multiple messages at once, resulting in more effective messages and reducing the frequency of message publishing, thereby improving communication efficiency and reducing communication costs.

[0064] In some embodiments, the first node adds a timestamp to each received message, the timestamp indicating the time when the first node received the message. By adding timestamps to the messages, the time when the messages were received can be determined, and then the order in which the messages are pushed to the server can be determined according to the timeliness requirements of the messages, thus ensuring the timeliness of the messages.

[0065] In some embodiments, the timeliness requirement of a message can be determined by the real-time level corresponding to the topic; the higher the real-time level of the topic, the higher the timeliness requirement of the message. Therefore, step S32 may include:

[0066] When the real-time level of the target topic is Level 1, the message is stored in the linked list corresponding to the target topic.

[0067] For example, a first level and a second level can be set, with the second level being higher than the first level. When the real-time level corresponding to the target topic is the first level, it indicates that the real-time requirements of messages under that target topic are not high. The messages can be stored in the linked list corresponding to the target topic. Within a preset time period, when the number of messages in the linked list exceeds a preset threshold, the messages are merged to obtain the message package to be pushed.

[0068] Accordingly, after determining the topic corresponding to the message, the above message distribution method may also include:

[0069] When the real-time level corresponding to the target topic is Level 2, a message packet to be pushed is generated based on the message, and the message packet to be pushed is pushed to the server based on the target topic.

[0070] When the real-time level corresponding to the target topic is Level 2, it indicates that the real-time requirements of messages under the target topic are high. The message packets to be pushed can be generated based on the messages first, and the message packets to be pushed can be pushed to the server based on the target topic.

[0071] This application sets a real-time level for topics, enabling messages with high real-time levels to be pushed to the server in a timely manner, while messages with low real-time levels can be merged into a message package to be pushed to the server, thereby improving the accuracy of message delivery.

[0072] Figure 6This is a flowchart illustrating the process of determining a message packet to be pushed, as provided in an embodiment of this application. This process can be applied to communication devices. Figure 6 As shown, it includes the following steps:

[0073] S51, adjust the format of a preset number of messages in the linked list to the target message format.

[0074] In some embodiments, after retrieving and merging a preset number of messages from the linked list to obtain the message packet to be pushed, the message format is adjusted to a target message format that is easy for the server to parse. For example, for a local node, the initial message format is usually data using a proprietary protocol, which is not universal, while the server uses Java or other languages. Therefore, if the original message is used for pushing, using a new protocol each time will increase development costs. Therefore, the message format is adjusted before sending the message, and the target message format can be protobuff format. Protobuff format data has the advantages of cross-platform and cross-language compatibility.

[0075] This application embodiment reduces communication costs and improves communication efficiency by adjusting the format of a preset number of messages in the linked list to a target message format that is easy for the server to parse.

[0076] S52 merges a preset number of messages with adjusted formats into a message package to be pushed.

[0077] In some embodiments, a communication protocol is established between the first node and the server. This communication protocol may include mainstream protocols such as MQTT, STOMP, GB-808, and the national standard for new energy. This application embodiment uses MQTT as an example. After the MQTT connection between the first node and the server is successfully established, all message packets to be pushed are uploaded via the MQTT connection. Each message packet carries a target topic. In one embodiment, the control flow for the first node to upload message packets to be pushed can be written into a while loop. A while loop is a control flow structure that repeatedly executes a block of code until a specified condition is met. By writing the control flow for the first node to upload message packets to be pushed into a while loop, the message to be pushed can be promptly pushed to the server after the first node receives the message, further improving the efficiency of message publishing.

[0078] Please see Figure 7 , Figure 7 This is a schematic diagram of the structure of a message publishing device provided in an embodiment of this application. In some embodiments, the message publishing device 20 may include multiple functional modules composed of computer program segments. The computer programs of each program segment in the message publishing device 20 may be stored in the memory of the communication device and executed by at least one processor to perform (see details). Figure 2 (Description) The function of publishing messages.

[0079] In this embodiment, the message publishing device 20 can be divided into multiple functional modules according to its functions. These functional modules may include: a message receiving module 201, a topic determination module 202, a message storage module 203, a message merging module 204, and a message push module 205. The term "module" in this application refers to a series of computer program segments that can be executed by at least one processor and perform a fixed function, and which are stored in memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.

[0080] The message receiving module 201 can be used to receive messages sent by any second node, wherein the first node is communicatively connected to multiple second nodes.

[0081] The topic determination module 202 can be used to determine the target topic corresponding to the message.

[0082] The message storage module 203 can be used to store messages in a linked list corresponding to the target topic; where messages in the same linked list come from the same or different second nodes.

[0083] The message merging module 204 can be used to select and merge a preset number of messages from the linked list to obtain a message packet to be pushed when the number of messages stored in the linked list exceeds a preset number.

[0084] The message push module 205 can be used to push message packets to the server based on the target topic.

[0085] It is understood that the message publishing device 20 and the message publishing method of the above embodiments belong to the same inventive concept. The specific implementation of each module of the message publishing device 20 corresponds to each step of the message publishing method in the above embodiments, and will not be repeated here.

[0086] The module division described above is a logical functional division, and other division methods may be used in actual implementation. Furthermore, the functional modules in the various embodiments of this application can be integrated into the same processing unit, or each module can exist physically separately, or two or more modules can be integrated into the same unit. The integrated modules described above can be implemented in hardware or in a combination of hardware and software functional modules.

[0087] Figure 8 This is a schematic diagram of the communication device provided in an embodiment of this application. Figure 8As shown, the communication device 30 includes a memory 31, at least one processor 32, at least one communication bus 33, and a transceiver 34. The processor 32 is used to execute a message publishing method implemented when executing a computer program stored in the memory 31.

[0088] Those skilled in the art should understand that Figure 8 The structure of the communication device shown does not constitute a limitation of the embodiments of this application. It can be a bus structure or a star structure. The communication device 30 may also include more or fewer other hardware or software than shown, or different component arrangements.

[0089] In some embodiments, the communication device 30 is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions. Its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits, programmable gate arrays, digital processors, and embedded devices. The communication device 30 can also connect to client devices, which include, but are not limited to, any electronic product that can interact with a client via a keyboard, mouse, remote control, touchpad, or voice control device, such as personal computers, tablet computers, smartphones, and digital cameras.

[0090] It should be noted that the communication device 30 is only an example. Other existing or future electronic products that are suitable for this application should also be included within the scope of protection of this application and are incorporated herein by reference.

[0091] In some embodiments, at least one communication bus 33 is configured to enable communication between the memory 31 and at least one processor 32, etc.

[0092] Although not shown, the communication device 30 may also include a power supply (such as a battery) to power the various components. Preferably, the power supply can be logically connected to at least one processor 32 via a power management device, thereby enabling functions such as charging, discharging, and power consumption management through the power management device. The power supply may also include one or more DC or AC power supplies, recharging devices, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The communication device 30 may also include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be described in detail here.

[0093] In some embodiments, the memory 31 stores a computer program that, when executed by at least one processor 32, implements all or part of the steps in a message publishing method, as described above. The memory 31 includes read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable medium capable of carrying or storing data.

[0094] Furthermore, the computer-readable storage medium may primarily include a program storage area and a data storage area, wherein the program storage area may store the operating system, an application program required for at least one function, etc.; and the data storage area may store data created based on the use of the communication device 30, etc.

[0095] In some embodiments, at least one processor 32 is the control unit of the communication device 30, connecting various components of the communication device 30 via various interfaces and lines. It executes programs or modules stored in the memory 31 and calls data stored in the memory 31 to perform various functions and process data within the communication device 30. For example, when at least one processor 32 executes a computer program stored in the memory, it implements all or part of the steps of the message publishing method in this embodiment; or it implements all or part of the functions of the message publishing device. At least one processor 32 may be composed of integrated circuits, such as a single-packaged integrated circuit or multiple integrated circuits with the same or different functions, including combinations of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips.

[0096] The integrated unit implemented as a software functional module described above can be stored in a computer-readable storage medium. This software functional module, stored in a storage medium, includes several instructions to cause a communication device (which may be a personal computer, a communication device, or a network device, etc.) or a processor to execute portions of the methods of the various embodiments of this application.

[0097] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and other division methods may be used in actual implementation.

[0098] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0099] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional modules.

[0100] It will be apparent to those skilled in the art that this application is not limited to the details of the exemplary embodiments described above, and that it can be implemented in other specific forms without departing from the spirit or essential characteristics of this application. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of this application is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be embraced within this application. No reference numerals in the claims should be construed as limiting the scope of the claims. Furthermore, it is clear that the word "comprising" does not exclude other elements or, and the singular does not exclude the plural. Multiple elements or devices recited in the specification may also be implemented by a single element or device through software or hardware. The terms "first," "second," etc., are used to indicate names and do not indicate any particular order.

[0101] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application and are not intended to limit it. Although this application has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of this application without departing from the spirit and scope of the technical solutions of this application.

Claims

1. A message publishing method, applied to a first node communicating with a server, characterized in that, The message publishing method includes: Receive a message sent by any second node, wherein the first node is communicatively connected to multiple second nodes; Determine the target topic corresponding to the message; Storing the message in the linked list corresponding to the target topic includes: when the real-time level corresponding to the target topic is the first level, storing the message in the linked list corresponding to the target topic; when the real-time level corresponding to the target topic is the second level, generating a message package to be pushed based on the message, and pushing the message package to be pushed to the server based on the target topic; wherein messages in the same linked list come from the same or different second nodes, and the second level is higher than the first level; When the number of messages stored in the linked list exceeds a preset number, the preset number of messages are selected and merged from the linked list to obtain a message packet to be pushed. The message packet to be pushed is pushed to the server based on the target topic.

2. The message publishing method as described in claim 1, characterized in that, Determining the target topic corresponding to the message includes: Parse the message to obtain the message identifier; Traverse the pre-set first mapping relationship between message identifiers and topics to determine the target topic corresponding to the message.

3. The message publishing method as described in claim 1, characterized in that, The step of storing the message in the linked list corresponding to the target topic includes: Traverse the pre-defined second mapping relationship between topics and linked lists to determine the linked list corresponding to the target topic; The message is stored in the linked list corresponding to the target topic.

4. The message publishing method as described in claim 1, characterized in that, The method further includes: The timer starts when a message is stored in the linked list. After a preset time period, if the number of messages in the linked list does not exceed the preset number, then all the messages are retrieved from the linked list and merged to obtain the message package to be pushed.

5. The message publishing method as described in claim 1, characterized in that, The method further includes: A timestamp is added to each received message, the timestamp representing the time when the first node received the message.

6. The message publishing method as described in claim 1, characterized in that, The step of selecting and merging the preset number of messages from the linked list to obtain the message packet to be pushed includes: Adjust the format of the preset number of messages in the linked list to the target message format; The preset number of messages, after format adjustment, are merged into the message package to be pushed.

7. The message publishing method as described in claim 1, characterized in that, Pushing the message packet to be pushed to the server based on the target topic includes: After a successful MQTT connection with the server is established, all message packets to be pushed are uploaded through the MQTT connection, with each message packet carrying the target topic.

8. A communication device, characterized in that, The communication device includes a processor that executes a computer program stored in a memory to implement the message publishing method as described in any one of claims 1 to 7.

9. A computer-readable storage medium storing a computer program thereon, characterized in that, When the computer program is executed by a processor, it implements the message publishing method as described in any one of claims 1 to 7.