CN-121984965-A - Internet of things data interaction method and system based on MQTT and readable storage medium
Abstract
The invention relates to the technology of the Internet of things, in particular to an MQTT-based data interaction method and system of the Internet of things and a readable storage medium, wherein the MQTT-based data interaction method of the Internet of things comprises the steps that an equipment end uploads file fragments to a cloud platform end according to a fragment index sequence by the MQTT file, at least initial fragment size, total file size and verification value are designated in the file transmission request, when the cloud platform end monitors the file transmission request, the equipment end is verified, a fragment transmission strategy is issued to the equipment end by an MQTT dynamic theme, the fragment transmission strategy at least comprises the fragment size which is dynamically adjusted by the cloud platform end according to network conditions, the equipment end uploads the file fragments to the cloud platform end according to the fragment index sequence by the fragment transmission strategy issued by the cloud platform end, and notifies the cloud platform end after transmission is completed, the cloud platform end receives the transmission completion notification of the equipment end, the transmission condition is verified, and the transmission result is returned to the equipment end by the MQTT response theme.
Inventors
- Request for anonymity
- Request for anonymity
Assignees
- 上海同星智能科技有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20260122
Claims (20)
- 1. The data interaction method of the Internet of things based on the MQTT is characterized by comprising the following steps of: The device side reports a file transmission request to the cloud platform side through the MQTT file uploading topic, and at least an initial fragment size, a file total size and a check value are specified in the file transmission request; When the cloud platform end monitors the file transmission request, after verifying the equipment end, issuing a fragmentation transmission strategy to the equipment end through an MQTT dynamic theme, wherein the fragmentation transmission strategy at least comprises the fragments size dynamically adjusted by the cloud platform end according to the network condition; The equipment side uploads the file fragments to the cloud platform side according to the fragment index sequence according to the fragment transmission strategy issued by the cloud platform side and notifies the cloud platform side after the transmission is completed, and After receiving the transmission completion notification of the equipment end, the cloud platform verifies the transmission condition and returns a transmission result to the equipment end through the MQTT response theme.
- 2. The MQTT-based internet of things data interaction method of claim 1, further comprising: The cloud platform receives a file fragment, immediately verifies the integrity of the file fragment, if the verification fails, stores the index of the file fragment into a retransmission list of the cloud platform, sends the retransmission list to the equipment end, and retransmits the file fragment by the equipment end When file transmission is interrupted or abnormally terminated, the cloud platform end stores indexes of file fragments which are failed to be transmitted into a retransmission list, the retransmission list is issued to the equipment end, and the equipment end retransmits the file fragments which are failed to be transmitted.
- 3. The data interaction method of the internet of things based on the MQTT according to claim 1 is characterized in that, The MQTT file uploading topic is: Namespace prefix/{ product key } { device name }/s/service/file_upload; wherein s represents a device end to a cloud platform end, service represents service class operation, file_upload represents file upload, and The initial tile size is 1024KB.
- 4. The data interaction method of the internet of things based on the MQTT according to claim 1 is characterized in that, The MQTT dynamic theme is: namespace prefix/{ product key } { device name }/c/service/file_upload/{ message ID }; wherein c represents cloud platform end to equipment end, service represents service class operation, file_upload represents file upload, { message ID } is a unique identifier generated by the cloud platform end and is used for tracking the current session with the equipment end, and The cloud platform end dynamically adjusts the size of the fragments according to the network condition, wherein the cloud platform end reduces the size of the fragments when the network condition is weak.
- 5. The data interaction method based on the MQTT for the Internet of things according to claim 4, which is characterized in that, The device side uploads file fragments to the cloud platform side according to the fragment index sequence according to the fragment transmission strategy issued by the cloud platform side, and the method comprises the following steps: Each file fragment is uploaded to the cloud platform end through independent MQTT fragment theme/name space prefix/{ product key }/{ device name }/s/service/file_upload/{ file name }/{ offset of the fragment in the file }/{ file fragment index }/{ check value of the file fragment }, and The uploaded file fragment data is binary coded data.
- 6. The data interaction method based on the MQTT for the Internet of things according to claim 4, which is characterized in that, After receiving the transmission completion notification of the equipment end, the cloud platform verifies the transmission condition and returns a transmission result to the equipment end through the MQTT response theme, and the method comprises the following steps: After receiving the transmission completion notice from the equipment end, the cloud platform end verifies whether all the file fragments are completely received, if the verification is passed, the cloud platform end merges the file fragments into a complete file and stores the complete file, if the verification is not passed, the transmission failure is marked, and The cloud platform end responds to the theme through MQTT And returning a transmission result to the equipment side by the name space prefix/{ product key }/{ equipment name }/c/service/file_upload/{ file name }/fin/{ message ID }, wherein the returned data comprises a status code and a complete file storage path, the status code is used for indicating successful transmission or failed transmission, and fin represents that the processing is finished.
- 7. The MQTT-based internet of things data interaction method of claim 1, further comprising: The device side also reports tag information to the cloud platform side through an MQTT tag information reporting theme; The label information comprises a basic label and a business label; The basic tag is embedded into the file name uploaded by the equipment end and at least comprises an equipment number, a file starting time, a file ending time and resource binding information, and The business label is set by the cloud platform end and at least comprises one or more of a project number, a task number and a scene number.
- 8. The data interaction method based on the MQTT for the Internet of things according to claim 7 is characterized in that, The cloud platform end transmits the set business label to the equipment end; And the equipment end associates the business label with the corresponding basic label according to a preset association rule and reports the label information to the cloud platform end.
- 9. The MQTT-based internet of things data interaction method of claim 7, further comprising: the device side also reports the resource binding information to the cloud platform side through an MQTT binding information reporting theme; the resource binding information comprises a resource number bound with the equipment end.
- 10. The MQTT-based internet of things data interaction method of claim 1, further comprising: the device side also reports timing information to the cloud platform side through the MQTT signal reporting theme; the timing information at least comprises GPS data acquired by the equipment end in real time and hardware information of the equipment end.
- 11. A computer apparatus, the computer apparatus configured to include: the reporting request module is configured to report a file transmission request to the cloud platform end through the MQTT file uploading topic, and at least an initial fragment size, a total file size and a check value are specified in the file transmission request; the file transmission module is configured to upload file fragments to the cloud platform end according to the fragment index sequence according to the fragment transmission strategy issued by the cloud platform end, and notify the cloud platform end after the transmission is completed.
- 12. The computer device of claim 11, wherein the computer device comprises a memory for storing the data, The MQTT file uploading topic is: Namespace prefix/{ product key } { device name }/s/service/file_upload; wherein s represents a device end to a cloud platform end, service represents service class operation, file_upload represents file upload, and The initial tile size is 1024KB.
- 13. The computer device of claim 11, wherein the computer device comprises a memory for storing the data, Uploading file fragments to the cloud platform end according to a fragment index sequence according to a fragment transmission strategy issued by the cloud platform end, including: Each file fragment is uploaded to the cloud platform end through independent MQTT fragment theme/name space prefix/{ product key }/{ device name }/s/service/file_upload/{ file name }/{ offset of the fragment in the file }/{ file fragment index }/{ check value of the file fragment }, and The uploaded file fragment data is binary coded data.
- 14. A cloud platform end, wherein the cloud platform end is configured to include: The verification issuing module is configured to issue a fragmentation transmission strategy to the equipment terminal through an MQTT dynamic theme after verifying the equipment terminal when monitoring a file transmission request of the equipment terminal, wherein the fragmentation transmission strategy at least comprises a fragmentation size dynamically adjusted by the cloud platform terminal according to a network condition; And the result response module is configured to verify the transmission condition after receiving the transmission completion notification of the equipment end, and returns a transmission result to the equipment end through the MQTT response theme.
- 15. The cloud platform end as claimed in claim 14, wherein, The MQTT dynamic theme is: namespace prefix/{ product key } { device name }/c/service/file_upload/{ message ID }; wherein c represents cloud platform end to equipment end, service represents service class operation, file_upload represents file upload, { message ID } is a unique identifier generated by the cloud platform end and is used for tracking the current session with the equipment end, and The size of the fragments is dynamically adjusted according to the network condition, including the step of adjusting the size of the fragments to be smaller when the network condition is weaker.
- 16. An internet of things data interaction system for performing the MQTT-based internet of things data interaction method of any one of claims 1-10, comprising: Cloud platform end and equipment end; The device side reports a file transmission request to the cloud platform side through the MQTT file uploading topic, and at least an initial fragment size, a file total size and a check value are specified in the file transmission request; When the cloud platform end monitors the file transmission request, after verifying the equipment end, issuing a fragmentation transmission strategy to the equipment end through an MQTT dynamic theme, wherein the fragmentation transmission strategy at least comprises the fragments size dynamically adjusted by the cloud platform end according to the network condition; The equipment side uploads the file fragments to the cloud platform side according to the fragment index sequence according to the fragment transmission strategy issued by the cloud platform side and notifies the cloud platform side after the transmission is completed, and After receiving the transmission completion notification of the equipment end, the cloud platform verifies the transmission condition and returns a transmission result to the equipment end through the MQTT response theme.
- 17. A method for a computer device to perform file transfer, comprising: reporting a file transmission request to a cloud platform end through an MQTT file uploading theme, and at least designating an initial fragment size, a file total size and a check value in the file transmission request, and Uploading file fragments to the cloud platform end according to a fragment index sequence according to a fragment transmission strategy issued by the cloud platform end, and notifying the cloud platform end after transmission is completed.
- 18. A non-transitory computer readable storage medium storing instructions which, when executed by a processor, cause the processor to perform the method of the computer device of claim 17 to perform file transfer.
- 19. An electronic device, comprising: A non-transitory computer readable storage medium; A processor; wherein the non-transitory computer readable storage medium stores instructions that, when executed by a processor, cause the processor to perform the method of the computer device of claim 17 to perform file transfer.
- 20. A computer program product comprising instructions which, when executed by a processor, cause the processor to perform the method of file transfer by a computer device as claimed in claim 17.
Description
Internet of things data interaction method and system based on MQTT and readable storage medium Technical Field The invention relates to the technology of the Internet of things, in particular to an Internet of things data interaction method and system based on an MQTT and a readable storage medium. Background The application of the internet of things often faces the scene of diversified data transmission, and various data needs to be transmitted between the equipment and the cloud end quickly and reliably. As the internet of things is widely applied in more and more industries, more application scenes are discovered. In addition to real-time structured data such as sensor data and control instructions, offline type file data, such as audio and video, pictures, and diagnostic logs, also start to play an important role in the internet of things. The conventional internet of things system mostly adopts the HTTP/FTP protocol to carry out data transmission, but the conventional HTTP/FTP protocol is easy to cause transmission failure due to connection interruption in a weak network environment, and is especially not suitable for the internet of things application which needs to support mass file transmission. Therefore, the prior art has the technical problems that the traditional HTTP/FTP technology is easy to fail in transmission under the condition of weak network and can not support mass file transmission. It should be noted that the above information disclosed in this background section is only for understanding the background of the inventive concept and therefore the above description is not to be construed as constituting prior art information. Disclosure of Invention The invention aims to provide an Internet of things data interaction method and system based on MQTT and a readable storage medium. In order to solve the technical problems, the invention provides an Internet of things data interaction method based on MQTT, which comprises the following steps: The device side reports a file transmission request to the cloud platform side through the MQTT file uploading topic, and at least an initial fragment size, a file total size and a check value are specified in the file transmission request; When the cloud platform end monitors the file transmission request, after verifying the equipment end, issuing a fragmentation transmission strategy to the equipment end through an MQTT dynamic theme, wherein the fragmentation transmission strategy at least comprises the fragments size dynamically adjusted by the cloud platform end according to the network condition; The equipment side uploads the file fragments to the cloud platform side according to the fragment index sequence according to the fragment transmission strategy issued by the cloud platform side and notifies the cloud platform side after the transmission is completed, and After receiving the transmission completion notification of the equipment end, the cloud platform verifies the transmission condition and returns a transmission result to the equipment end through the MQTT response theme. In a second aspect, the present invention also provides a computer apparatus configured to include: the reporting request module is configured to report a file transmission request to the cloud platform end through the MQTT file uploading topic, and at least an initial fragment size, a total file size and a check value are specified in the file transmission request; the file transmission module is configured to upload file fragments to the cloud platform end according to the fragment index sequence according to the fragment transmission strategy issued by the cloud platform end, and notify the cloud platform end after the transmission is completed. In a third aspect, the present invention further provides a cloud platform end, where the cloud platform end is configured to include: the verification issuing module is configured to issue a fragment transmission strategy to the equipment terminal through the MQTT dynamic theme after verifying the equipment terminal when the file transmission request of the equipment terminal is monitored, wherein the fragment transmission strategy at least comprises an adjusted fragment size; And the result response module is configured to verify the transmission condition after receiving the transmission completion notification of the equipment end, and returns a transmission result to the equipment end through the MQTT response theme. In a fourth aspect, the present invention further provides an internet of things data interaction system for executing the MQTT-based internet of things data interaction method as described above, including: Cloud platform end and equipment end; The device side reports a file transmission request to the cloud platform side through the MQTT file uploading topic, and at least an initial fragment size, a file total size and a check value are specified in the file transmission request; When the cloud platfor