Industrial router short message sending and receiving method and industrial router
By deploying the MQTT server and Node-Red in the industrial router, combined with the event management program, the problem that Node-Red does not support SMS sending and receiving is solved, the SMS sending and receiving function of the industrial router is realized, and the reliability and success of the delivery are improved. efficiency, reducing resource overhead.
Patent Information
- Application Number
- CN202410864661.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2044-07-01
AI Technical Summary
Node-Red's components do not support the SMS sending and receiving function of industrial routers, which limits users' ability to obtain SMS messages received on industrial routers and control the sending of SMS messages through Node-Red.
Deploy the internal MQTT server, Node-Red and event management program in the industrial router. Through MQTT communication technology, Node-Red controls the industrial router to send text messages and obtain the content of received text messages, including process management of text message sending and receiving, and supports text messages. Resend mechanism and blacklist judgment.
It realizes the control of SMS sending and receiving of industrial routers through Node-Red, improves the reliability and success rate of SMS delivery, reduces resource overhead, and meets the needs of real-time and stability.
Smart Images

Figure CN118433647B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to an industrial router short message receiving and sending method and an industrial router. Background Art
[0002] Node-Red is being promoted and used on more and more embedded devices (including industrial routers) because of its ease of use, high scalability, support for multiple protocols, and visual graphical page editing and deployment, which allows users to build complex applications in a short period of time. Currently, the components of Node-Red do not support the control of sending and receiving SMS messages, but industrial routers are often used for sending and receiving SMS messages, that is, users need to be able to use Node-Red to obtain SMS messages received on industrial routers and control industrial routers to send SMS messages. Summary of the invention
[0003] In order to solve the above problems, the present invention proposes an industrial router SMS receiving and sending method and an industrial router.
[0004] The specific plan is as follows:
[0005] An industrial router SMS sending and receiving method includes: deploying an internal MQTT server, Node-Red and an event management program in the industrial router, and the three perform the following steps:
[0006] (1) Node-Red controls the industrial router to send text messages:
[0007] The event management program subscribes to the topic of SMS sending to the internal MQTT server;
[0008] When the flow in Node-Red is triggered, Node-Red assembles the SMS recipient and SMS content carried in the flow into a Message, and sends the Message to the internal MQTT server. When sending, the Topic of the Message is specified as the Topic subscribed by the event manager.
[0009] After receiving the message, the internal MQTT server forwards it to the event management program that subscribes to the Topic;
[0010] After receiving the message, the event management program extracts the SMS recipient and the SMS content, and sends the SMS content to the SMS recipient;
[0011] (2) Node-Red obtains the text message content received by the industrial router:
[0012] Node-Red subscribes to the topic of SMS reception from the internal MQTT server, and the event manager subscribes to the topic of SMS confirmation from the internal MQTT server;
[0013] When the event management program receives a text message, it extracts the text message content and the sender of the text message based on the received text message, and constructs a message based on the unique code of the text message, and sends the message to the internal MQTT server, and specifies the topic of the message as the topic subscribed by Node-Red when sending;
[0014] After receiving the message, the internal MQTT server forwards it to the Node-Red that subscribes to the Topic;
[0015] After receiving the message, Node-Red extracts the SMS content, SMS sender and SMS unique code, and determines whether the SMS unique code is the same as the SMS unique code of the historically received message. If so, the process ends; otherwise, the SMS content and SMS sender are sent to the next node in the Node-Red flow.
[0016] Furthermore, when the flow in Node-Red is triggered, it is first determined whether the industrial router dials successfully and whether the SMS function is normal. When the dialing is successful and the SMS function is normal, the subsequent steps are performed; otherwise, the subsequent steps are not performed.
[0017] Furthermore, after the event management program sends the SMS content to the SMS recipient, it determines whether the SMS fails to be sent. If the SMS fails to be sent, it is resent. When the number of resends is greater than the number threshold, the resend is stopped.
[0018] Furthermore, the interval between resending the SMS is proportional to the current number of resending times.
[0019] Furthermore, when the event management program receives a text message, it first determines whether the text message sender of the text message exists in the blacklist. If not, the subsequent steps are performed; otherwise, the subsequent steps are not performed.
[0020] Furthermore, after Node-Red performs the operation of determining whether the unique code of the SMS is the same as the unique code of the historically received Message and the corresponding determination result, the Message is sent to the internal MQTT server, and the Topic of the Message is specified as the Topic subscribed by the event manager when sending the Message;
[0021] After receiving the message, the internal MQTT server forwards it to the event management program that subscribes to the Topic;
[0022] After sending the message to the internal MQTT server, the event management program enters a waiting state to determine whether a message with the same SMS unique code as the message is received before the waiting time reaches the waiting time threshold. If not, the event management program re-executes the operation of sending the message to the internal MQTT server.
[0023] Furthermore, when the event management program re-executes the operation of sending the message to the internal MQTT server for a number of times greater than a threshold, the operation is stopped.
[0024] An industrial router includes an internal MQTT server, Node-Red and an event management program, through which the above method of the embodiment of the present invention is implemented.
[0025] The present invention adopts the above technical solution, based on the internal MQTT communication technology, and controls the sending of SMS and the receiving and display of SMS by the industrial router by deploying the SMS sending and SMS receiving functions in Node-Red. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 The figure shows a flow chart of Node-Red controlling an industrial router to send text messages in the first embodiment of the present invention.
[0027] Figure 2 The flowchart shown is when Node-Red obtains the content of the short message received by the industrial router in the first embodiment of the present invention. DETAILED DESCRIPTION
[0028] To further illustrate various embodiments, the present invention provides drawings. These drawings are part of the disclosure of the present invention, which are mainly used to illustrate the embodiments and can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these contents, ordinary technicians in this field should be able to understand other possible implementations and advantages of the present invention.
[0029] The present invention will now be further described with reference to the accompanying drawings and specific implementation methods.
[0030] Embodiment 1:
[0031] An embodiment of the present invention provides an industrial router SMS sending and receiving method. In the method, an internal MQTT server, Node-Red and an event management program are deployed in the industrial router. The following functions can be realized through the deployed three: Node-Red controls the industrial router to send SMS and Node-Red obtains the content of SMS received by the industrial router.
[0032] (1) Node-Red controls the industrial router to send text messages, such as Figure 1 shown.
[0033] Step 1: The event management program subscribes to the topic of SMS sending to the internal MQTT server.
[0034] Step 2: When the flow in Node-Red is triggered, Node-Red assembles the SMS recipient and SMS content carried in the flow into a Message, and sends the Message to the internal MQTT server (that is, publishes the Message), and specifies the Topic of the Message as the Topic subscribed by the event manager when sending it.
[0035] Furthermore, when the flow in Node-Red is triggered, this embodiment first determines whether the industrial router dials successfully and whether the SMS function is normal. When the dialing is successful and the SMS function is normal, the subsequent steps are performed; otherwise, the subsequent steps are not performed to save resource overhead.
[0036] The format of assembling the SMS recipient and SMS content into a Message can be set by yourself and is not limited here.
[0037] Step 3: After receiving the message, the internal MQTT server forwards it to the event management program that subscribes to the Topic.
[0038] Step 4: After receiving the message, the event management program extracts the SMS recipient and the SMS content therein, and sends the SMS content to the SMS recipient.
[0039] The method of extracting the SMS recipient and the SMS content is to parse the SMS based on the parsing algorithm set in the format of the assembled Message.
[0040] The method for sending SMS messages by the event management program can be pre-configured in the industrial router and can be called when sending is required.
[0041] Furthermore, in order to improve the probability of successful SMS sending, the event management program of this embodiment, after sending the SMS content to the SMS recipient, further includes: determining whether the SMS fails to be sent, and if so, resending it, and stopping resending when the number of resending times is greater than the number threshold. In this embodiment, the interval for SMS resending is set to be proportional to the current number of resending times, that is, the product of 30 seconds and the current number of resending times. Since the SMS content has lost its real-time nature after too many resending times, therefore, in this embodiment, it is set to stop resending when the number of resending times is greater than 3 times, which indicates that the current SMS function is abnormal.
[0042] (2) Node-Red obtains the content of the SMS received by the industrial router, such as Figure 2 shown.
[0043] Step 1: Node-Red subscribes to the topic of SMS reception from the internal MQTT server, and the event manager subscribes to the topic of SMS confirmation from the internal MQTT server.
[0044] Step 2: When the event management program receives the SMS, it extracts the SMS content and the sender based on the received SMS, builds a Message based on the unique SMS code, and sends the Message to the internal MQTT server. When sending, the Topic of the Message is specified as the Topic subscribed by Node-Red.
[0045] Furthermore, when the event management program receives a text message, it first determines whether the text message sender of the text message exists in the blacklist. If not, the subsequent steps are performed; otherwise, the subsequent steps are not performed. The blacklist can be pre-configured in the industrial router.
[0046] The unique code of the SMS is generated by the event management program when constructing the message. The format of the message can be set by yourself and there is no restriction here.
[0047] Step 3: After receiving the message, the internal MQTT server forwards it to the Node-Red that subscribes to the Topic.
[0048] Step 4: After receiving the message, Node-Red extracts the SMS content, SMS sender and SMS unique code, and determines whether the SMS unique code is the same as the SMS unique code of the historically received message. If so, the process ends (i.e., it will not be sent to the next node in the Node-Red flow); otherwise, the SMS content and SMS sender are sent to the next node in the Node-Red flow.
[0049] In this embodiment, when the SMS content and the SMS sender are sent to the next node of the Node-Red flow, the SMS content and the SMS sender are reassembled into a new Message for sending, which no longer contains the SMS unique code.
[0050] Furthermore, in order to increase the probability of successful SMS reception, in this embodiment, after Node-Red executes the operation of determining whether the SMS unique code is the same as the SMS unique code of the historically received Message and the corresponding determination result, it also includes sending the Message to the internal MQTT server, and when sending, specifies the Topic of the Message as the Topic subscribed by the event manager.
[0051] After receiving the message, the internal MQTT server forwards it to the event management program that subscribes to the Topic.
[0052] After sending the Message to the internal MQTT server (i.e., completing the operation of step 2), the event management program enters a waiting state to determine whether a Message with the same SMS unique code as the Message is received before the waiting time reaches the waiting time threshold. If not, the event management program re-executes the operation of sending the Message to the internal MQTT server (i.e., resending). In this embodiment, the waiting time threshold is set to 15 seconds. In other embodiments, those skilled in the art can set the size of the waiting time threshold as needed. Furthermore, since the data has real-time requirements, in this embodiment, the event management program is set to re-execute the operation of sending the Message to the internal MQTT server a number of times less than or equal to the number threshold (i.e., 3 times). When the number threshold is exceeded, it indicates that the current internal MQTT server is abnormal.
[0053] This embodiment uses MQTT for communication between Node-Red and the event management program, which has the advantages of low power consumption, low protocol overhead, and push notification. Among them, push notification allows both ends to receive messages from the other end in a timely manner, so that there is no need to use polling methods in Node-Red and the event management program to query whether to send text messages and obtain text message information. Before Node-Red and the event management program publish information, they will first determine whether the industrial router can send text messages (when Node-Red publishes information) and whether Node-Red needs to obtain the text message information received by the industrial router, and whether the text message publisher is in the blacklist (when the event management program publishes information). If the conditions for information publishing are not met, the relevant information will not be published, which greatly reduces the overhead of system-related resources. In the process of sending text messages, a retransmission mechanism is designed, and in the process of receiving text messages, a "confirmation package" mechanism is used. The above two mechanisms ensure the stability of information and can ensure the publishing and receiving of text messages in most abnormal situations.
[0054] Embodiment 2:
[0055] The present invention also provides an industrial router, including an internal MQTT server, Node-Red and an event management program, through which the steps in the above method embodiment of the first embodiment of the present invention are implemented.
[0056] Although the present invention has been specifically shown and described in conjunction with the preferred embodiments, it should be understood by those skilled in the art that various changes may be made to the present invention in form and details without departing from the spirit and scope of the present invention as defined by the appended claims, all of which are within the scope of protection of the present invention.
Claims
1. A method for sending and receiving short messages of an industrial router, characterized in that: include: Deploy an internal MQTT server, Node-Red, and event manager in an industrial router and perform the following steps: (1) Node-Red controls the industrial router to send text messages: The event management program subscribes to the topic of SMS sending to the internal MQTT server; When the flow in Node-Red is triggered, Node-Red assembles the SMS recipient and SMS content carried in the flow into a Message, and sends the Message to the internal MQTT server. When sending, the Topic of the Message is specified as the Topic subscribed by the event manager. After receiving the message, the internal MQTT server forwards it to the event management program that subscribes to the Topic; After receiving the message, the event management program extracts the SMS recipient and the SMS content, and sends the SMS content to the SMS recipient; (2) Node-Red obtains the text message content received by the industrial router: Node-Red subscribes to the topic of SMS reception from the internal MQTT server, and the event manager subscribes to the topic of SMS confirmation from the internal MQTT server; When the event management program receives a text message, it extracts the text message content and the sender of the text message based on the received text message, and constructs a message based on the unique code of the text message, and sends the message to the internal MQTT server, and specifies the topic of the message as the topic subscribed by Node-Red when sending; After receiving the message, the internal MQTT server forwards it to the Node-Red that subscribes to the Topic; After receiving the message, Node-Red extracts the SMS content, the sender and the unique SMS code, and determines whether the unique SMS code is the same as the unique SMS code of the historically received message. If so, it ends. Otherwise, the SMS content and the SMS sender are sent to the next node in the Node-Red flow.
2. The method for sending and receiving short messages of an industrial router according to claim 1, characterized in that: When the flow in Node-Red is triggered, first determine whether the industrial router dials successfully and whether the SMS function is normal. If the dialing is successful and the SMS function is normal, proceed to the subsequent steps; otherwise, do not proceed to the subsequent steps.
3. The method for sending and receiving short messages of an industrial router according to claim 1, characterized in that: After the event management program sends the SMS content to the SMS recipient, it determines whether the SMS fails to be sent. If it fails, it is resent. When the number of resends is greater than the number threshold, the resend is stopped.
4. The method for sending and receiving short messages of an industrial router according to claim 3, characterized in that: The interval between SMS resending is proportional to the current resending count.
5. The method for sending and receiving short messages of an industrial router according to claim 1, characterized in that: When the event management program receives a text message, it first determines whether the text message sender of the text message exists in the blacklist. If not, it proceeds to the subsequent steps; otherwise, it does not proceed to the subsequent steps.
6. The method for sending and receiving short messages of an industrial router according to claim 1, characterized in that: After Node-Red has completed the operation of determining whether the unique code of the SMS is the same as the unique code of the historically received Message and the corresponding determination result, it sends the Message to the internal MQTT server and specifies the Topic of the Message as the Topic subscribed by the event manager when sending the Message; After receiving the message, the internal MQTT server forwards it to the event management program that subscribes to the Topic; After sending the message to the internal MQTT server, the event management program enters a waiting state to determine whether a message with the same SMS unique code as the message is received before the waiting time reaches the waiting time threshold. If not, the event management program re-executes the operation of sending the message to the internal MQTT server.
7. The method for sending and receiving short messages of an industrial router according to claim 6, characterized in that: When the number of times that the event management program re-executes the operation of sending the message to the internal MQTT server exceeds the number threshold, the operation is stopped.
8. An industrial router, characterized in that: The invention comprises an internal MQTT server, Node-Red and an event management program, through which the method as claimed in any one of claims 1 to 7 is implemented.
