CN109327424A - Included buffer area MQTT protocol implementing method based on small memory single-chip microcontroller - Google Patents
Included buffer area MQTT protocol implementing method based on small memory single-chip microcontroller Download PDFInfo
- Publication number
- CN109327424A CN109327424A CN201710648748.6A CN201710648748A CN109327424A CN 109327424 A CN109327424 A CN 109327424A CN 201710648748 A CN201710648748 A CN 201710648748A CN 109327424 A CN109327424 A CN 109327424A
- Authority
- CN
- China
- Prior art keywords
- chip microcontroller
- mqtt
- buffer area
- small memory
- flash
- 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.)
- Granted
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/06—Notations for structuring of protocol data, e.g. abstract syntax notation one [ASN.1]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/03—Protocol definition or specification
Abstract
The invention discloses the included buffer area MQTT protocol implementing methods based on small memory single-chip microcontroller, by using internal FLASH chip in the circuit structure of small memory single-chip microcontroller or extending peripheral FLASH chip, and realizes MQTT protocol stack, cushioning control process and retransmit process;Single-chip microcontroller receives the initial data from external circuit, keeps in RAM, when ram space deficiency, keeps in FLASH;Single-chip microcontroller takes out data to be sent, by MQTT protocol stack package, output meets the message package of MQTT agreement to communication module, and distal end MQTT server is transmitted to by ICP/IP protocol through communication module, to reach the electronic equipment instrument made largely based on small memory single-chip microcontroller, more convenient, inexpensive realization IBM Corporation MQTT agreement, to access the technical purpose of the Internet of things system based on MQTT agreement.
Description
Technical field
The present invention relates to the MQTT protocol realization technology of single-chip microcontroller more particularly to a kind of carrying based on small memory single-chip microcontroller
Buffer area MQTT protocol implementing method.
Background technique
MQTT agreement is an Internet of Things transport protocol of IBM Corporation's exploitation, the publish/subscribe formula message for lightweight
Transmission, it is intended to provide reliable network service for the internet of things equipment in low bandwidth and unstable network environment.
With popularizing for internet of things equipment application, conventional electronic device also has more and more Internet of Things connection requirements, it
Be usually to apply the limited single-chip microcontroller of small in size and RAM, such as 8051 series mini single-chip microcontrollers, RAM capacity usually with
4KB, 8KB meter, and memory buffer as big as possible is then required under low bandwidth and unstable network environment.To largely using such
How the electronic equipment instrument of single-chip microcontroller makes the realization IBM Corporation MQTT agreement that they are convenient, inexpensive, is based on access
The Internet of things system of MQTT agreement is the research topic with significant economic prospect.
Summary of the invention
In order to overcome the above-mentioned deficiencies of the prior art, the present invention is intended to provide a kind of pass through ICP/IP protocol through communication module
It is transmitted to distal end MQTT server, to be further processed, to reach the electronics made largely based on limited RAM type single-chip microcontroller
Equipment and instrument, more convenient, inexpensive realization IBM Corporation MQTT agreement, to access the Internet of things system based on MQTT agreement
Included buffer area MQTT protocol implementing method of the technical purpose based on small memory single-chip microcontroller.
Included buffer area MQTT protocol implementing method based on small memory single-chip microcontroller, includes the following steps:
A) in small memory single chip circuit structure, if lacking FLASH memory or FLASH capacity is inadequate, periphery is just extended
FLASH chip;
B) on small memory single-chip microcontroller, MQTT protocol stack, cushioning control process and the re-transmission for having larger space buffer area are realized
Process;
C) single-chip microcontroller runs MQTT client-side program;
D) single-chip microcontroller receives the initial data from external circuit, keeps in RAM, when ram space deficiency, keeps in FLASH;
E) single-chip microcontroller takes out the initial data to be sent being stored in memory ram buffer area or the buffer area FLASH, by MQTT
Protocol stack package, output meet the message package of MQTT agreement to communication module, and are transmitted through communication module by ICP/IP protocol
To distal end MQTT server;
F) the MQTT client on single-chip microcontroller receives the response message (ACK/NAK) that server returns, and is retransmitted according to retransmission mechanism
Or send next data.
Further, step B) the cushioning control process is used for when ram space deficiency, and temporary data will be needed to deposit
Peripheral FLASH chip is stored up, to extend the manipulable core buffer size of single-chip microcontroller.
Further, step B) the re-transmission process carried out using sliding window protocol.
Further, the MQTT protocol stack for single-chip microcontroller by data raw data format and MQTT protocol format it
Between do mutual conversion.
Further, the communication module is one or more of Ethernet, mobile communications network and WIFI.
Compared with prior art, the present invention the beneficial effect is that: it is of the invention it is a kind of based on small memory single-chip microcontroller from
Band buffer area MQTT protocol implementing method, by the circuit structure of small memory single-chip microcontroller use internal FLASH chip or
Peripheral FLASH chip is extended, and realizes MQTT protocol stack, cushioning control process and retransmits process;Single-chip microcontroller is received from outside
The initial data of circuit, keeps in RAM, when ram space deficiency, keeps in FLASH;Single-chip microcontroller takes out data to be sent,
By MQTT protocol stack package, the message package that output meets MQTT agreement passes through TCP/IP to communication module, and through communication module
Agreement is transmitted to distal end MQTT server, to reach the electronic equipment instrument made largely based on small memory single-chip microcontroller, more convenient,
The realization IBM Corporation MQTT agreement of low cost, to access the technical purpose of the Internet of things system based on MQTT agreement.
Detailed description of the invention
Fig. 1 is a kind of implementation flow chart of included buffer area MQTT protocol implementing method based on small memory single-chip microcontroller,
In, 1- single-chip microcontroller, 2- communication module, the distal end 3- MQTT server, 11-RAM, 12-FLASH, 4- data source;
Fig. 2 is connection schematic diagram needed for a kind of included buffer area MQTT protocol implementing method based on small memory single-chip microcontroller;
Fig. 3 is a kind of cushioning control flow chart of included buffer area MQTT protocol implementing method based on small memory single-chip microcontroller;
Fig. 4 is a kind of data transmission flow figure of included buffer area MQTT protocol implementing method based on small memory single-chip microcontroller.
Specific embodiment
In order to deepen the understanding of the present invention, present invention will be further explained below with reference to the attached drawings and examples, the implementation
Example for explaining only the invention, does not constitute protection scope of the present invention and limits.
A kind of included buffer area MQTT protocol implementing method based on small memory single-chip microcontroller, first such as 1 step S1 of flow chart,
It needs in the circuit structure of small memory single-chip microcontroller just to extend periphery if lacking FLASH memory or FLASH capacity is inadequate
FLASH chip, structure are as described in Figure 2.The a common examples such as Intel 8051 of such small memory single-chip microcontroller, they are usually
Only with the RAM capacity of several KB sizes, the scene of mass data, this RAM need to be cached applied to MQTT agreement Internet of things system
Capacity is clearly inadequate.
Peripheral FLASH chip 12 can be with parallel interface, I2The high speed bus interfaces such as C interface are connected with single-chip microcontroller 1, and press
Data access is carried out between the address space and single-chip microcontroller 1 that peripheral FLASH chip 12 maps.
Such as the small memory single-chip microcontroller 1 of Fig. 2, MQTT protocol stack, cushioning control process and re-transmission process implemented in software are needed, such as
The step S2 of flow chart 1.
The MQTT protocol stack between raw data format and MQTT protocol format for mutually converting data.
The cushioning control process is as shown in figure 3, and see 1 step S4 of flow chart.Wherein, single-chip microcontroller is needed to buffer area
The data of write-in mainly include the initial data from external circuit.As shown in figure 3, single-chip microcontroller receives data, such as step first
Then S21 attempts to write data into internal RAM buffer area, such as step S22, and judges whether ram space is enough, such as step
S23.When ram space abundance, RAM is just write data into, such as step S24;When internal RAM insufficient space, write data into
The space FLASH, such as step S25.After step S24 and S25 write-in are completed, single-chip microcontroller re-execute the steps S21 to receive data.
And when FALSH space buffer area also is not enough to that new data is written, treatment measures include: one, are given up this time to be written
The new data entered, two, unwanted data are deleted from storing data.By above-mentioned measure, small memory single-chip microcontroller is extended
Manipulable core buffer size, has reached the sum of RAM capacity and FLASH capacity.
The re-transmission process is carried out using sliding window protocol, and sliding window protocol belongs to a kind of application of Transmission Control Protocol, is used
Flow control when network data transmission, to avoid the generation of congestion.In data transmission flow as described in Figure 4, stream is seen
Journey Fig. 1 step S5, firstly, single-chip microcontroller takes the initial data to be sent being stored in memory ram buffer area or the buffer area FLASH
Out, such as Fig. 4 step S31;By MQTT protocol stack packaged data, such as step S32;Hereafter output meets the message package of MQTT agreement
Distal end MQTT server is transmitted to by ICP/IP protocol to communication module, and through communication module, such as step S33;Then, it executes
Step S31 starts a new data and sends.Wherein, the MQTT client on single-chip microcontroller receives the response report that MQTT server returns
Literary (ACK/NAK) is retransmitted according to retransmission mechanism or is sent next data, so just ensure compliance with the message package of MQTT agreement with
As efficient as possible, safe and reliable mode is sent on the MQTT server of distal end.
Such as the communication module 2 of Fig. 2, one or more of Ethernet, mobile communications network and WIFI can be,
Mobile communications network is divided into 2G, 3G, 4G etc. again, can be fitted into according to the actual needs of consumer electronic devices a kind of or more
Kind, or user's real-time selection is provided and switches the operation entry of these communication modes.
In short, the invention has the following beneficial effects: the present invention by using in the circuit structure of small memory single-chip microcontroller
Internal FLASH chip extends peripheral FLASH chip, and realizes MQTT protocol stack, cushioning control process and retransmit process;It is single
Piece machine receives the initial data from external circuit, keeps in RAM, when ram space deficiency, keeps in FLASH;Single-chip microcontroller will
Data to be sent are taken out, and by MQTT protocol stack package, output meets the message package of MQTT agreement to communication module, and through communicating
Module is transmitted to distal end MQTT server by ICP/IP protocol;MQTT client on single-chip microcontroller receives the sound that server returns
Message (ACK/NAK) is answered, retransmitted according to retransmission mechanism or sends next data, so that having reached makes largely to be based on limited RAM
The electronic equipment instrument of type single-chip microcontroller, more convenient, inexpensive realization IBM Corporation MQTT agreement are based on MQTT with access
The technical purpose of the Internet of things system of agreement.
What the embodiment of the present invention was announced is preferred embodiment, and however, it is not limited to this, the ordinary skill people of this field
Member, easily according to above-described embodiment, understands spirit of the invention, and make different amplification and variation, but as long as not departing from this
The spirit of invention, all within the scope of the present invention.
Claims (5)
1. the included buffer area MQTT protocol implementing method based on small memory single-chip microcontroller, which comprises the steps of:
A) in small memory single chip circuit structure, if lacking FLASH memory or FLASH capacity is inadequate, periphery is just extended
FLASH chip;
B) on small memory single-chip microcontroller, MQTT protocol stack, cushioning control process and the re-transmission for having larger space buffer area are realized
Process;
C) single-chip microcontroller runs MQTT client-side program;
D) single-chip microcontroller receives the initial data from external circuit, keeps in RAM, when ram space deficiency, keeps in FLASH;
E) single-chip microcontroller takes out the initial data to be sent being stored in memory ram buffer area or the buffer area FLASH, by MQTT
Protocol stack package, output meet the message package of MQTT agreement to communication module, and are transmitted through communication module by ICP/IP protocol
To distal end MQTT server;
F) the MQTT client on single-chip microcontroller receives the response message that server returns, and retransmits or sends next according to retransmission mechanism
Data.
2. the included MQTT protocol implementing method in buffer area according to claim 1 based on small memory single-chip microcontroller, feature
It is, step B) when ram space deficiency, the cushioning control process will need temporary data storage to peripheral FLASH core
Piece, to extend the manipulable core buffer size of single-chip microcontroller.
3. the included MQTT protocol implementing method in buffer area according to claim 2 based on small memory single-chip microcontroller, feature
It is, step B) the re-transmission process carried out using sliding window protocol.
4. the included MQTT protocol implementing method in buffer area according to claim 3 based on small memory single-chip microcontroller, feature
It is, the MQTT protocol stack does data for single-chip microcontroller between raw data format and MQTT protocol format to be turned mutually
It changes.
5. the protocol realization side included buffer area MQTT according to any one of claims 1-4 based on small memory single-chip microcontroller
Method, which is characterized in that the communication module is one or more of Ethernet, mobile communications network and WIFI.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710648748.6A CN109327424B (en) | 2017-08-01 | 2017-08-01 | MQTT protocol implementation method with buffer area based on small-memory single chip microcomputer |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710648748.6A CN109327424B (en) | 2017-08-01 | 2017-08-01 | MQTT protocol implementation method with buffer area based on small-memory single chip microcomputer |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109327424A true CN109327424A (en) | 2019-02-12 |
CN109327424B CN109327424B (en) | 2021-06-04 |
Family
ID=65245327
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710648748.6A Active CN109327424B (en) | 2017-08-01 | 2017-08-01 | MQTT protocol implementation method with buffer area based on small-memory single chip microcomputer |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109327424B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110601799A (en) * | 2019-09-12 | 2019-12-20 | 无锡江南计算技术研究所 | Link retransmission method and device based on double sliding windows |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101369983A (en) * | 2008-10-15 | 2009-02-18 | 杭州华三通信技术有限公司 | Internal memory buffer area management method and system |
US20100191902A1 (en) * | 1991-11-26 | 2010-07-29 | Hajime Yamagami | Storage device employing a flash memory |
CN103218323A (en) * | 2013-03-25 | 2013-07-24 | 广东工业大学 | High-speed data acquisition and transmission device |
CN204993410U (en) * | 2015-08-13 | 2016-01-20 | 徐晓哲 | Serial ports and ethernet conversion equipment based on MQTT thing networking protocol |
CN205304837U (en) * | 2016-01-08 | 2016-06-08 | 武汉科技大学 | Intelligence house electrical apparatus control communications system based on MQTT agreement |
CN106033397A (en) * | 2015-03-17 | 2016-10-19 | 小米科技有限责任公司 | Method and device for adjusting memory buffer, and terminal |
CN106094534A (en) * | 2016-05-23 | 2016-11-09 | 深圳市汉科电子股份有限公司 | The intelligent domestic system that a kind of wearable device intelligent watch controls |
-
2017
- 2017-08-01 CN CN201710648748.6A patent/CN109327424B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20100191902A1 (en) * | 1991-11-26 | 2010-07-29 | Hajime Yamagami | Storage device employing a flash memory |
CN101369983A (en) * | 2008-10-15 | 2009-02-18 | 杭州华三通信技术有限公司 | Internal memory buffer area management method and system |
CN103218323A (en) * | 2013-03-25 | 2013-07-24 | 广东工业大学 | High-speed data acquisition and transmission device |
CN106033397A (en) * | 2015-03-17 | 2016-10-19 | 小米科技有限责任公司 | Method and device for adjusting memory buffer, and terminal |
CN204993410U (en) * | 2015-08-13 | 2016-01-20 | 徐晓哲 | Serial ports and ethernet conversion equipment based on MQTT thing networking protocol |
CN205304837U (en) * | 2016-01-08 | 2016-06-08 | 武汉科技大学 | Intelligence house electrical apparatus control communications system based on MQTT agreement |
CN106094534A (en) * | 2016-05-23 | 2016-11-09 | 深圳市汉科电子股份有限公司 | The intelligent domestic system that a kind of wearable device intelligent watch controls |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110601799A (en) * | 2019-09-12 | 2019-12-20 | 无锡江南计算技术研究所 | Link retransmission method and device based on double sliding windows |
Also Published As
Publication number | Publication date |
---|---|
CN109327424B (en) | 2021-06-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106559739B (en) | Lightweight data transmission method suitable for Bluetooth low-power wireless communication system | |
CN104518853B (en) | Method, receiving terminal and the system that a kind of data retransmit | |
US9601097B2 (en) | Reliable real-time transmission of musical sound control data over wireless networks | |
CN102780705B (en) | Ethernet-(controller area network) CAN protocol converter | |
US11671210B2 (en) | Retransmission control method, communications interface, and electronic device | |
CN102217258B (en) | Detection processing method, data sending terminal, data receiver and communication system | |
CN103780972A (en) | Server, client device, and control methods thereof | |
EP2119171A1 (en) | Improved data transfer method, system and protocol | |
CN103957169A (en) | Reliable UDP achievement method based on reserve request | |
CN104243267A (en) | Data transmission method and device | |
CN203151742U (en) | A short message intercommunicating system between network clients and Beidou RDSS terminals | |
CN111092854B (en) | Method for transmitting packets transmitted from a source device to a destination device | |
CN105376173A (en) | Sending window flow control method and terminal | |
CN109067796A (en) | A kind of data transmission method and device | |
CN105430320A (en) | Audio and video media data transmission method based on UDP (User Datagram Protocol) and TCP (Transmission Control Protocol) | |
CN104618260A (en) | UDP (User Datagram Protocol) based matchable strategy data transmission method | |
CN101605128A (en) | The method that the LINUX master-slave equipment communicates by Ethernet interface | |
TWI759471B (en) | Method and related products for controlling data retransmission | |
CN109327424A (en) | Included buffer area MQTT protocol implementing method based on small memory single-chip microcontroller | |
US8705425B2 (en) | Wireless receiving apparatus and transmitting apparatus having a sleep control unit | |
CN110798355A (en) | Network distribution method and device for intelligent socket, intelligent socket and storage medium | |
CN109605383A (en) | Information communication method, robot and storage medium | |
CN104012054A (en) | Video processing method, device and system | |
CN109586931B (en) | Multicast method and terminal equipment | |
CN103888629B (en) | The device that voice compression/meeting exchanges process is carried out to PCM speech |
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 |