Detailed Description
To make the objects, technical solutions and advantages of the embodiments of the present application more clear, the embodiments of the present application will be further described in detail with reference to the accompanying drawings.
The following explains an application scenario of the present application.
The application is applied to an application scene that cloud equipment sends messages to the Internet of things equipment in the Internet of things. The Internet of things comprises cloud equipment and Internet of things equipment, connection is established between the cloud equipment and the Internet of things equipment, connection is established between the Internet of things equipment and the Internet of things equipment, and the cloud equipment can send messages to the Internet of things equipment. The cloud device referred to herein may be implemented as a server.
Referring to fig. 1, a flowchart of a method for sending a message according to an embodiment of the present application is shown, where the method can be applied to a cloud device. The message sending method may include:
step 101, when a message is sent to an internet of things device, recording the message state of the message as a sent state.
The message status is read after a first time period, step 102.
The first time period may be a preset time period, and the preset time period is not limited in this embodiment.
In one embodiment, the preset time duration is 30 seconds, the cloud device starts timing when the message status is set to the sent status, and reads the message status when the timing reaches 30 seconds.
In this embodiment, if the internet of things device receives the message, the confirmation receiving message is immediately sent to the cloud end device, and the cloud end device can modify the message state into the received state. Then, after the first time period, when the cloud reads the message status, the message status should be the received status. If the message status read by the cloud is still the sent status after the first time period, it indicates that the equipment of the internet of things does not send a receiving confirmation message to the cloud equipment, that is, the equipment of the internet of things does not receive the message, and then step 103 is executed.
And step 103, if the message state is the sent state, sending the message to the equipment of the internet of things again.
In this embodiment, the number of times of retransmission of the message may be preset, and when the number of times of retransmission is reached and the internet of things device still does not receive the message, the message is not retransmitted to the internet of things device.
For example, if the retransmission number is 1, when the message is sent to the internet of things device again, the cloud device may count time again, and read the message state again when the counted time reaches 30 seconds, and if the message state is still not sent, the message is not retransmitted to the internet of things device, and the process is ended; if the retransmission frequency is 2, the cloud device may record the retransmission frequency and resend the message to the internet of things device again when the internet of things device still does not receive the message after retransmission, count the time again, read the message state again when the time reaches 30 seconds, and if the message state is still in the sent state, no message is retransmitted to the internet of things device, and the process is ended.
In a specific example, the cloud device may record the message status as a sent status, set a delay task of checking whether to resend the message after 30 seconds, trigger the delay task after 30 seconds, resend the message if the message status is still the sent status, update the message sending time and the sending times, and set the delay task again, where the resending times are limited to at most 3 retries.
And after the retransmission times reach the preset retransmission times and the internet of things device does not receive the message, warning can be given out to prompt the staff to carry out problem troubleshooting. The mode that the cloud end equipment sent the warning has a lot of, for example, the cloud end equipment can send messages such as mail, SMS, little letter to the staff, and perhaps, the cloud end equipment can make a sound, and this embodiment does not limit.
In summary, according to the message sending method provided in the embodiment of the present application, when the cloud device sends a message to the equipment of the internet of things, the message state of the message is recorded as a sent state, the message state is read after a first time period, and if the message state is the sent state, it is indicated that the equipment of the internet of things does not receive the message, and at this time, the cloud device can send the message to the equipment of the internet of things again, so that the success rate of the equipment of the internet of things receiving the message can be improved.
Please refer to fig. 2, which shows a flowchart of a method for sending a message according to another embodiment of the present application, where the message sending method can be applied to a cloud device. The message sending method may include:
step 201, when sending a message to an internet of things device, recording the message state of the message as a sent state.
The message status is read after a first time period, step 202.
The first time period may be a preset time period, and the preset time period is not limited in this embodiment.
In one embodiment, the preset time duration is 30 seconds, the cloud device starts timing when the message status is set to the sent status, and reads the message status when the timing reaches 30 seconds.
In this embodiment, if the internet of things device receives the message, the confirmation receiving message is immediately sent to the cloud end device, and the cloud end device can modify the message state into the received state. Then, after the first time period, when the cloud reads the message status, the message status should be the received status. If the message status read by the cloud is still the sent status after the first time period, it indicates that the equipment of the internet of things does not send a receiving confirmation message to the cloud equipment, that is, the equipment of the internet of things does not receive the message, and then step 203 is executed.
And step 203, if the message state is the sent state, sending the message to the equipment of the internet of things again.
In this embodiment, the number of times of retransmission of the message may be preset, and when the number of times of retransmission is reached and the internet of things device still does not receive the message, the message is not retransmitted to the internet of things device.
For example, if the retransmission number is 1, when the message is sent to the internet of things device again, the cloud device may count time again, and read the message state again when the counted time reaches 30 seconds, and if the message state is still not sent, the message is not retransmitted to the internet of things device, and the process is ended; if the retransmission frequency is 2, the cloud device may record the retransmission frequency and resend the message to the internet of things device again when the internet of things device still does not receive the message after retransmission, count the time again, read the message state again when the time reaches 30 seconds, and if the message state is still in the sent state, no message is retransmitted to the internet of things device, and the process is ended.
In a specific example, the cloud device may record the message status as a sent status, set a delay task of checking whether to resend the message after 30 seconds, trigger the delay task after 30 seconds, resend the message if the message status is still the sent status, update the message sending time and the sending times, and set the delay task again, where the resending times are limited to at most 3 retries.
In this embodiment, when the number of times of retransmitting the message reaches the predetermined threshold and the message status is the sent status, the cloud device may modify the message status to the reception timeout status.
And after the retransmission times reach the preset retransmission times and the internet of things device does not receive the message, warning can be given out to prompt the staff to carry out problem troubleshooting. The mode that the cloud end equipment sent the warning has a lot of, for example, the cloud end equipment can send messages such as mail, SMS, little letter to the staff, and perhaps, the cloud end equipment can make a sound, and this embodiment does not limit.
And step 204, if the receiving confirmation message sent by the internet of things equipment is received in the first time period, modifying the message state into the received state.
Wherein the acknowledgment receipt message may be an ack message.
And step 205, when the message is a control instruction, reading the message state after a second time interval.
The second time period may be a preset time period, and the preset time period is not limited in this embodiment.
In one embodiment, the preset time duration is 5 minutes, the cloud device starts timing when the message status is set to the received status, and reads the message status when the timing reaches 5 minutes.
In this embodiment, if the internet of things device executes the control instruction, the execution result is sent to the cloud device after execution, and the cloud device may modify the message state according to the execution result. Then, after the second time period, when the cloud reads the message status, the message status should not be the received status. If the message status read by the cloud is still the received status after the second time period, it indicates that the equipment of the internet of things does not send a confirmation message to the cloud equipment, that is, the equipment of the internet of things does not execute the control instruction, at this time, step 206 is executed.
In a specific example, the cloud device may set the message status to the received status, and set a delay task of checking whether the device responds to the execution result after 5 minutes.
In step 206, if the message status is the received status, the message status is modified to execute the timeout status.
And step 207, if the execution result sent by the internet of things equipment is received in the second time period, modifying the message state according to the execution result.
The two execution results are provided, one is used for indicating the internet of things device to successfully execute the control instruction, and the other is used for indicating the internet of things device to unsuccessfully execute the control instruction, and at this time, modifying the message state according to the execution results may include: when the execution result is used for indicating the Internet of things equipment to successfully execute the control instruction, the message state is modified into an execution success state; and when the execution result is used for indicating that the control instruction is not successfully executed by the Internet of things equipment, modifying the message state into an execution failure state.
In summary, according to the message sending method provided in the embodiment of the present application, when the cloud device sends a message to the equipment of the internet of things, the message state of the message is recorded as a sent state, the message state is read after a first time period, and if the message state is the sent state, it is indicated that the equipment of the internet of things does not receive the message, and at this time, the cloud device can send the message to the equipment of the internet of things again, so that the success rate of the equipment of the internet of things receiving the message can be improved.
Referring to fig. 3, a block diagram of a message sending apparatus according to an embodiment of the present disclosure is shown, where the message sending apparatus may be applied to a cloud device. The message sending device may include:
the recording module 310 is configured to record a message state of a message as a sent state when the message is sent to the internet of things device;
a reading module 320, configured to read a message status after a first time period;
the sending module 330 is configured to send the message to the internet of things again if the message status is the sent status.
In an optional embodiment, the apparatus further comprises:
and the modification module is used for modifying the message state into the received state if receiving a receiving confirmation message sent by the Internet of things equipment in a first time period after the message state of the message is recorded as the sent state.
In an alternative embodiment, when the message is a control instruction,
the reading module 320 is further configured to read the message status after a second time period after the message status is modified to the received status;
and the modification module is also used for modifying the message state into an execution overtime state if the message state is the received state.
In an optional embodiment, the modifying module is further configured to:
and after the message state is modified into the received state, if an execution result sent by the Internet of things equipment is received in a second time period, modifying the message state according to the execution result.
In an optional embodiment, the modifying module is further configured to:
when the execution result is used for indicating the Internet of things equipment to successfully execute the control instruction, the message state is modified into an execution success state;
and when the execution result is used for indicating that the control instruction is not successfully executed by the Internet of things equipment, modifying the message state into an execution failure state.
In an optional embodiment, the modifying module is further configured to:
and after the message is sent to the Internet of things equipment again, when the number of times of message retransmission reaches a preset threshold value and the message state is the sent state, modifying the message state into a receiving overtime state.
To sum up, the message sending apparatus provided in the embodiment of the present application records that the message state of the message is the sent state when the cloud device sends the message to the equipment of the internet of things, reads the message state after a first time interval, and if the message state is the sent state, it indicates that the equipment of the internet of things does not receive the message, and at this time, the cloud device can send the message to the equipment of the internet of things again, so that the success rate of the equipment of the internet of things receiving the message can be improved.
One embodiment of the present application provides a computer-readable storage medium having at least one instruction, at least one program, a set of codes, or a set of instructions stored therein, which is loaded and executed by a processor to implement the message sending method as described above.
One embodiment of the present application provides a server, which includes a processor and a memory, where the memory stores at least one instruction, and the instruction is loaded and executed by the processor to implement the message sending method as described above.
It should be noted that: in the message sending device provided in the above embodiment, only the division of the above functional modules is taken as an example when sending a message, and in practical applications, the above function distribution may be completed by different functional modules according to needs, that is, the internal structure of the message sending device is divided into different functional modules to complete all or part of the above described functions. In addition, the message sending apparatus provided in the foregoing embodiment and the message sending method embodiment belong to the same concept, and specific implementation processes thereof are described in the method embodiment, and are not described herein again.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description should not be taken as limiting the embodiments of the present application, and any modifications, equivalents, improvements, etc. made within the spirit and principle of the embodiments of the present application should be included in the scope of the embodiments of the present application.