CN112118296B - Internet of things file transmission method based on mqtt protocol - Google Patents
Internet of things file transmission method based on mqtt protocol Download PDFInfo
- Publication number
- CN112118296B CN112118296B CN202010891292.8A CN202010891292A CN112118296B CN 112118296 B CN112118296 B CN 112118296B CN 202010891292 A CN202010891292 A CN 202010891292A CN 112118296 B CN112118296 B CN 112118296B
- Authority
- CN
- China
- Prior art keywords
- information
- file
- byte
- array
- cloud
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 230000005540 biological transmission Effects 0.000 title claims abstract description 36
- 238000000034 method Methods 0.000 title claims abstract description 30
- 230000004044 response Effects 0.000 claims abstract description 14
- 238000003491 array Methods 0.000 claims abstract description 11
- 238000012795 verification Methods 0.000 claims description 12
- 230000008569 process Effects 0.000 claims description 10
- 208000032370 Secondary transmission Diseases 0.000 claims description 3
- 238000004891 communication Methods 0.000 abstract description 6
- 238000012545 processing Methods 0.000 description 4
- 230000007246 mechanism Effects 0.000 description 2
- 230000009471 action Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000018109 developmental process Effects 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 230000011218 segmentation Effects 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/06—Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]
Abstract
The invention discloses an internet of things file transmission method based on an mqtt protocol, which is characterized in that a cloud end converts a file into a byte array form; creating a download form of the first information packet; taking out a first array from the byte arrays obtained in the first step, and sending the first array to a device terminal topic through an mqtt protocol after the first array is placed in a json character string generated by a form; the cloud stores the byte arrays obtained in the first step; the equipment terminal subscribes the same topic, receives information and checks; after the accuracy of the information is verified, response information is fed back to the cloud; and after receiving the response information, the cloud end verifies, takes out the next file sub-byte array according to the file sequence, combines the next information form and sends the next information form to the equipment. Through the mode, the method and the device can avoid the problem that the processor cannot successfully receive the data due to the too small buffer area, and have the characteristics of controllable communication flow, safe transmission, stable operation and the like.
Description
Technical Field
The invention relates to the technical field of data transmission of the Internet of things, in particular to an Internet of things file transmission method based on an mqtt protocol, which realizes file transmission between a cloud end and a singlechip based on Internet of things communication.
Background
With the development of the internet of things technology, the communication level of the remote equipment and the cloud is remarkably improved, the tcp protocol-based product support such as mqtt gradually goes to the field of view, and the accuracy and the stability between information transmission are more effectively guaranteed.
However, for file property transmission, there is no general flow method at present, and for most lightweight communication components deployed on devices, such as a single-chip microcomputer, there are a certain amount of technical limitations on quantitative transmission, processing time, parallel mechanism, information verification and code conversion of information packets, and the method specifically includes the following defects:
1. the file package is directly sent in one time in full quantity through the mqtt protocol, and the problem of insufficient memory caused by file information cache of the lightweight processor such as the singlechip is solved;
2. after the file package is issued, the accuracy and feasibility of the information can be responded only after the whole package is analyzed, and a response mechanism is not sensitive enough;
3. when the parallel processing is issued for a plurality of times, the judgment of the current execution action by the singlechip is influenced, and the possibility of confusion among all processes is improved;
4. the whole file package is issued, and the accuracy of the issued information cannot be rapidly positioned.
Disclosure of Invention
The technical problem to be solved by the invention is to provide the file transmission method of the internet of things based on the mqtt protocol, which can provide flow suggestions for realizing functions such as remote version upgrading of lightweight equipment components, and provide an effective solution for processing file receiving and caching work and the like by equipment processors such as a singlechip, so that the problem that the file cannot be successfully received due to too small cache area of the processor is avoided to a certain extent, and the file transmission method has the characteristics of controllable communication flow, safe transmission, stable operation and the like.
In order to solve the technical problems, the invention adopts a technical scheme that: the file transmission method of the internet of things based on the mqtt protocol comprises the following steps:
s1, converting a file into a byte array form by a cloud end, and splitting the array according to a specified sub-package size;
s2, the cloud creates a delivery form of the first information packet;
s3, after the information download list is created, the first array is taken out from the byte arrays obtained in S1, the information is placed in the json character string generated by the list, and the final character string is generated
S4, transmitting the piece of information to a device terminal topic through an mqtt protocol, and adding a device-level logic lock to the transmission method;
s5, the cloud end stores the byte array obtained in the S1;
s6, subscribing the same topic by the equipment end, receiving information and checking;
s7, after the accuracy of the information is verified, the response information is fed back to the cloud;
s8, after the cloud receives the response information, if the verification is passed, the stored file byte form array is taken out, the next file sub-package byte array is taken out according to the current file sequence, and the next information form is combined and issued to the equipment;
s9, after the equipment completely receives the information packet, the information feedback is correct, and the singlechip end can combine and issue byte information arrays and process the byte information arrays;
s10, after the cloud receives the last information feedback packet, if verification is correct, judging that file transmission is successful, and canceling the logic lock of the equipment level for the sending method;
s11, ending the process.
Further, the form in S2 includes the following elements: a unique identification id representing the current transmission; representing a specific type of file so that the recipient can distinguish between different files; the order of the file packages in the whole files; and performing exclusive OR check on each sub-packed byte array to obtain a result value.
Further, the order of the file packets in the whole file is expressed in a/b format, a represents what packet is, and b represents the number of bytes or the packet size of each packet sharing several packets.
Further, the response information in S7 includes the following elements: the unique identification id of the current transmission; the file sequence of the current transmission; and whether the secondary transmission equipment passes the verification.
The beneficial effects of the invention are as follows: 1. the invention can control the specific processing flow of transmission and support the transmission of the sub-packets;
2. the size of the sub-packet can be controlled, and fields are provided so that the single chip microcomputer can identify the sequential logic sequence of the sub-packet;
3. locking a transmission process from a cloud end, and controlling file transmission single process execution;
4. the cloud provides an information verification field in the sub-package so that the singlechip can verify the accuracy of the information;
5. the Mqtt communication protocol ensures the safety of information;
6. when the cloud transmits the byte information, the byte information is not placed in the same form with other fields, and the byte segmentation information is directly placed behind the transmitted information, so that the byte information is not transcoded, and is convenient for the single chip microcomputer to recognize.
Drawings
FIG. 1 is a schematic diagram of a preferred embodiment of an Internet of things file transfer method based on the mqtt protocol of the present invention;
fig. 2 is a flow chart of another embodiment of the present invention.
Detailed Description
The preferred embodiments of the present invention will be described in detail below with reference to the accompanying drawings so that the advantages and features of the present invention can be more easily understood by those skilled in the art, thereby making clear and defining the scope of the present invention.
Referring to fig. 1, an embodiment of the present invention includes:
an internet of things file transmission method based on an mqtt protocol comprises the following steps:
s1, converting a file into a byte array form by a cloud end, and splitting the array according to a specified sub-package size;
s2, creating a delivery form of the first information packet by the cloud, wherein the form comprises the following elements: a unique identification id representing the current transmission; representing a specific type of file so that the recipient can distinguish between different files; the sequence of the file packages in all files is expressed in a/b format, wherein a represents the package, and b represents the byte number or the package size of each package of several packages; performing exclusive OR check on each sub-packed byte array to obtain a result value;
s3, after the information download list is created, the first array is taken out from the byte arrays obtained in S1, the information is placed in the json character string generated by the list, and the final character string is generated
S4, transmitting the piece of information to a device terminal topic through an mqtt protocol, and adding a device-level logic lock to the transmission method;
s5, the cloud end stores the byte array obtained in the S1;
s6, subscribing the same topic by the equipment end, receiving information and checking;
s7, after the accuracy of the information is verified, response information is fed back to the cloud, wherein the response information comprises the following elements: the unique identification id of the current transmission; the file sequence of the current transmission; the secondary transmission equipment end passes the verification;
s8, after the cloud receives the response information, if the verification is passed, the stored file byte form array is taken out, the next file sub-package byte array is taken out according to the current file sequence, and the next information form is combined and issued to the equipment;
s9, after the equipment completely receives the information packet, the information feedback is correct, and the singlechip end can combine and issue byte information arrays and process the byte information arrays;
s10, after the cloud receives the last information feedback packet, if verification is correct, judging that file transmission is successful, and canceling the logic lock of the equipment level for the sending method;
s11, ending the process.
In another embodiment, see fig. 2, a cloud platform communicates with a device through an internet of things platform implementing the mqtt protocol, and this implementation takes upgrading a hardware control board file with a size of 10K as an example.
C1: the cloud platform groups the hardware control board files according to 1024 bytes per packet to generate byte [10 ].
C2: the combined download list form has a file sequence of 1/10 and a file type of a default value.
And C3: converting form into character string via json, and adding byte [0] at the end
And C4: the string is sent to the topic to which the device subscribes and a distributed lock is added to the device.
C5: cloud platform local storage byte [10] [
C6: the device receives the transmitted character string and carries out exclusive OR operation on the byte [ ] at the end, and the character string is checked to be correct when the character string is compared with the check value in the form.
C7: the equipment end sends response information to the cloud platform, the information form contains 1/10 file sequence, and the verification result is passed.
And C8: and the cloud platform takes out byte [1], combines the forms and sends the combined forms to the equipment.
C9: after the device receives all bytes [ ], it combines and upgrades the hardware control board.
C10: and after the cloud platform receives the last response message, judging that the transmission is successful, and releasing the distributed lock.
C11: and (5) ending.
The foregoing description is only illustrative of the present invention and is not intended to limit the scope of the invention, and all equivalent structures or equivalent processes or direct or indirect application in other related technical fields are included in the scope of the present invention.
Claims (4)
1. The file transmission method of the internet of things based on the mqtt protocol is characterized by comprising the following steps of:
s1, converting a file into a byte array form by a cloud end, and splitting the array according to a specified sub-package size;
s2, the cloud creates a delivery form of the first information packet;
s3, after the information issuing list is established, a first array is taken out from the byte arrays obtained in the S1, and the information is placed in a json character string generated by the list to generate a final character string;
s4, transmitting the piece of information to a device terminal topic through an mqtt protocol, and adding a device-level logic lock to a transmission process;
s5, the cloud end stores the byte array obtained in the S1;
s6, subscribing the same topic by the equipment end, receiving information and checking;
s7, after the accuracy of the information is verified, the response information is fed back to the cloud;
s8, after the cloud receives the response information, if the verification is passed, the stored file byte form array is taken out, the next file sub-package byte array is taken out according to the current file sequence, and the next information form is combined and issued to the equipment;
s9, after the equipment completely receives the information packet, the information feedback is correct, and the singlechip end can combine and issue byte information arrays and process the byte information arrays;
s10, after the cloud receives the last information feedback packet, if verification is correct, judging that file transmission is successful, and canceling the logic lock of the equipment level for the sending process;
s11, ending the process.
2. The method for transmitting the file of the internet of things based on the mqtt protocol according to claim 1, wherein the form in S2 comprises the following elements: a unique identification id representing the current transmission; representing a specific type of file so that the recipient can distinguish between different files; the order of the files in the whole files is divided; and performing exclusive OR check on each sub-packed byte array to obtain a result value.
3. The method for transmitting files in internet of things based on mqtt protocol according to claim 2, wherein the order of the files in the whole files is expressed in a/b format, a represents what packet is, and b represents the number of bytes or the packet size of each packet sharing several packets.
4. The method for transmitting the file of the internet of things based on the mqtt protocol according to claim 1, wherein the response information in S7 comprises the following elements: the unique identification id of the current transmission; the file sequence of the current transmission; and whether the secondary transmission equipment passes the verification.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010891292.8A CN112118296B (en) | 2020-08-30 | 2020-08-30 | Internet of things file transmission method based on mqtt protocol |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010891292.8A CN112118296B (en) | 2020-08-30 | 2020-08-30 | Internet of things file transmission method based on mqtt protocol |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112118296A CN112118296A (en) | 2020-12-22 |
CN112118296B true CN112118296B (en) | 2023-12-29 |
Family
ID=73804563
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010891292.8A Active CN112118296B (en) | 2020-08-30 | 2020-08-30 | Internet of things file transmission method based on mqtt protocol |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112118296B (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106133705A (en) * | 2014-03-14 | 2016-11-16 | 国际商业机器公司 | The consistency protocol of instruction transaction status strengthens |
CN110138867A (en) * | 2019-05-17 | 2019-08-16 | 哈工大机器人(山东)智能装备研究院 | File transmission and method of reseptance, computer equipment and storage medium |
CN110691134A (en) * | 2019-09-29 | 2020-01-14 | 北京首汽智行科技有限公司 | MQTT protocol-based file transmission method |
CN111131228A (en) * | 2019-12-21 | 2020-05-08 | 广州保仕盾智能科技有限公司 | MQTT protocol-based gateway dynamic theme and stable operation processing method |
CN111562992A (en) * | 2020-04-14 | 2020-08-21 | 广东博智林机器人有限公司 | Message consumption method and device for client, electronic equipment and storage medium |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
KR102004160B1 (en) * | 2016-12-22 | 2019-07-26 | 경희대학교 산학협력단 | Apparatus and method for logical grouping method of iot connected client nodes using client identifier |
-
2020
- 2020-08-30 CN CN202010891292.8A patent/CN112118296B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106133705A (en) * | 2014-03-14 | 2016-11-16 | 国际商业机器公司 | The consistency protocol of instruction transaction status strengthens |
CN110138867A (en) * | 2019-05-17 | 2019-08-16 | 哈工大机器人(山东)智能装备研究院 | File transmission and method of reseptance, computer equipment and storage medium |
CN110691134A (en) * | 2019-09-29 | 2020-01-14 | 北京首汽智行科技有限公司 | MQTT protocol-based file transmission method |
CN111131228A (en) * | 2019-12-21 | 2020-05-08 | 广州保仕盾智能科技有限公司 | MQTT protocol-based gateway dynamic theme and stable operation processing method |
CN111562992A (en) * | 2020-04-14 | 2020-08-21 | 广东博智林机器人有限公司 | Message consumption method and device for client, electronic equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN112118296A (en) | 2020-12-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
KR100810771B1 (en) | Accelerated tcptransport control protocol stack processing | |
CN109246188B (en) | System supporting multi-channel transaction and multi-channel transaction processing method | |
CN104408003B (en) | The wireless usb protocol and hub of enhancing | |
CN111083161A (en) | Data transmission processing method and device and Internet of things equipment | |
FR2804816A1 (en) | TRANSPORT OF PROTOCOL PORTABLE ELECTRONIC OBJECT PROTOCOL UNITS FOR MICROCOMPUTER DEVICES | |
CN101009649A (en) | Queue management in a network processor | |
CN107728497B (en) | Communication method for man-machine interaction | |
CN113360301B (en) | Message transmission system and method | |
CN112637198B (en) | Multi-protocol self-adaption module design method based on OPC UA PubSub | |
WO2011137640A1 (en) | File transmission method, file transmission apparatus and file reception apparatus | |
CN108614978B (en) | Compressed packet checking method and device, storage medium and terminal | |
CN107508828B (en) | A kind of very-long-range data interaction system and method | |
CN109688208B (en) | Data loading method based on FC-AE-ASM message | |
CN112118296B (en) | Internet of things file transmission method based on mqtt protocol | |
CN114844842A (en) | Data transmission method and device, electronic equipment and readable storage medium | |
EP1641217A2 (en) | Method, apparatus and system for passing messages to a web browser | |
CN109189419A (en) | Method for upgrading system, apparatus and system, server-side and client | |
US20140297753A1 (en) | Method for transferring network event protocol messages | |
CN102238493A (en) | Machine-to-machine (M2M)-platform-based message sequential transmission and receiving method and device | |
CN106685854A (en) | Data transmission method and system | |
CN107040523B (en) | Transaction data transmission method and device and electronic equipment | |
CN111240867B (en) | Information communication system and method | |
CN113518087A (en) | IOT protocol reverse docking method and device | |
CN106685600A (en) | Method for messaging among work stations within local area network | |
CN113645175A (en) | Data communication method, device, equipment and computer readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |