CN109327424B - MQTT protocol implementation method with buffer area based on small-memory single chip microcomputer - Google Patents

MQTT protocol implementation method with buffer area based on small-memory single chip microcomputer Download PDF

Info

Publication number
CN109327424B
CN109327424B CN201710648748.6A CN201710648748A CN109327424B CN 109327424 B CN109327424 B CN 109327424B CN 201710648748 A CN201710648748 A CN 201710648748A CN 109327424 B CN109327424 B CN 109327424B
Authority
CN
China
Prior art keywords
single chip
chip microcomputer
mqtt
mqtt protocol
memory
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
Application number
CN201710648748.6A
Other languages
Chinese (zh)
Other versions
CN109327424A (en
Inventor
熊国安
胡楠
付尧
彭广斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tianrong Medical & Communication Equipment Co ltd
Original Assignee
Tianrong Medical & Communication Equipment Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Tianrong Medical & Communication Equipment Co ltd filed Critical Tianrong Medical & Communication Equipment Co ltd
Priority to CN201710648748.6A priority Critical patent/CN109327424B/en
Publication of CN109327424A publication Critical patent/CN109327424A/en
Application granted granted Critical
Publication of CN109327424B publication Critical patent/CN109327424B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/06Notations for structuring of protocol data, e.g. abstract syntax notation one [ASN.1]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/03Protocol definition or specification 

Abstract

The invention discloses a method for realizing a self-contained buffer MQTT protocol based on a small-memory single chip microcomputer, which uses an internal FLASH chip or an extended peripheral FLASH chip in the circuit structure of the small-memory single chip microcomputer and realizes an MQTT protocol stack, a buffer control flow and a retransmission flow; the single chip microcomputer receives original data from an external circuit, temporarily stores the original data into the RAM, and temporarily stores the original data into the FLASH when the space of the RAM is insufficient; the single chip microcomputer takes out data to be sent, packages the data through an MQTT protocol stack, outputs a message packet which accords with the MQTT protocol to a communication module, and transmits the message packet to a far-end MQTT server through a TCP/IP protocol through the communication module, so that a large number of electronic equipment instruments based on the single chip microcomputer with small memory can realize the MQTT protocol of IBM company more conveniently and low cost, and the technical purpose of accessing an Internet of things system based on the MQTT protocol is achieved.

Description

MQTT protocol implementation method with buffer area based on small-memory single chip microcomputer
Technical Field
The invention relates to a technology for realizing an MQTT protocol of a single chip microcomputer, in particular to a method for realizing the MQTT protocol with a buffer area based on a small-memory single chip microcomputer.
Background
The MQTT protocol is an internet of things transmission protocol developed by IBM corporation, is used for lightweight publish/subscribe message transmission, and aims to provide reliable network services for internet of things devices in low-bandwidth and unstable network environments.
With the popularization of the application of the internet of things devices, conventional electronic devices also have more and more internet of things connection requirements, and they are generally single-chip microcomputers with small application volumes and limited RAM, such as 8051 series micro single-chip microcomputers, the RAM capacity of which is usually measured in 4KB and 8KB, while memory buffering as large as possible is required in low-bandwidth and unstable network environments. How to realize the MQTT protocol of IBM company conveniently and low-cost for electronic equipment instruments using a large number of single-chip microcomputers to access an Internet of things system based on the MQTT protocol is a research subject with remarkable economic prospect.
Disclosure of Invention
In order to overcome the defects of the prior art, the invention aims to provide a self-contained buffer MQTT protocol implementation method based on a small-memory single chip microcomputer, which is transmitted to a remote MQTT server through a communication module through a TCP/IP protocol for further processing so as to achieve the purpose that a large number of electronic equipment instruments based on a limited RAM type single chip microcomputer can more conveniently and low-cost implement the MQTT protocol of IBM company and access the IOT system based on the MQTT protocol.
The method for realizing the self-contained buffer MQTT protocol based on the small-memory single chip microcomputer comprises the following steps:
A) in the small memory single chip circuit structure, if a FLASH memory is lacked or the FLASH capacity is not enough, a peripheral FLASH chip is expanded;
B) on a small memory single chip microcomputer, an MQTT protocol stack with a large space buffer area, a buffer control flow and a retransmission flow are realized;
C) the single chip microcomputer runs an MQTT client program;
D) the single chip microcomputer receives original data from an external circuit, temporarily stores the original data into the RAM, and temporarily stores the original data into the FLASH when the space of the RAM is insufficient;
E) the single chip microcomputer takes out original data to be sent stored in the RAM memory buffer area or the FLASH buffer area, packages the original data through the MQTT protocol stack, outputs a message packet which accords with the MQTT protocol to the communication module, and transmits the message packet to the remote MQTT server through the TCP/IP protocol through the communication module;
F) the MQTT client on the single chip receives a response message (ACK/NAK) returned by the server, and retransmits or sends the next piece of data according to a retransmission mechanism.
Further, the buffer control process in step B) is used to store the data to be temporarily stored in the peripheral FLASH chip when the RAM space is insufficient, so as to expand the size of the memory buffer area that the single chip microcomputer can operate.
Further, the retransmission process in step B) is performed by using a sliding window protocol.
Furthermore, the MQTT protocol stack is used for the single chip microcomputer to mutually convert data between an original data format and an MQTT protocol format.
Further, the communication module is one or more of ethernet, mobile communication network and WIFI.
Compared with the prior art, the invention has the beneficial effects that: the invention relates to a method for realizing a self-contained buffer MQTT protocol based on a small-memory single chip microcomputer, which uses an internal FLASH chip or an extended peripheral FLASH chip in the circuit structure of the small-memory single chip microcomputer and realizes an MQTT protocol stack, a buffer control flow and a retransmission flow; the single chip microcomputer receives original data from an external circuit, temporarily stores the original data into the RAM, and temporarily stores the original data into the FLASH when the space of the RAM is insufficient; the single chip microcomputer takes out data to be sent, packages the data through an MQTT protocol stack, outputs a message packet which accords with the MQTT protocol to a communication module, and transmits the message packet to a far-end MQTT server through a TCP/IP protocol through the communication module, so that a large number of electronic equipment instruments based on the single chip microcomputer with small memory can realize the MQTT protocol of IBM company more conveniently and low cost, and the technical purpose of accessing an Internet of things system based on the MQTT protocol is achieved.
Drawings
FIG. 1 is a flow chart of the implementation of the MQTT protocol with buffer area based on a small-memory single chip microcomputer, wherein 1-the single chip microcomputer, 2-a communication module, 3-a far-end MQTT server, 11-RAM, 12-FLASH and 4-a data source;
FIG. 2 is a schematic connection diagram for implementing a self-contained buffer MQTT protocol based on a small-memory single chip microcomputer;
FIG. 3 is a flow chart of a buffer control of a method for implementing the MQTT protocol with buffer area based on a small-memory single chip microcomputer;
fig. 4 is a data transmission flow chart of a self-contained buffer MQTT protocol implementation method based on a small-memory single chip microcomputer.
Detailed Description
For the purpose of enhancing the understanding of the present invention, the present invention will be further explained with reference to the accompanying drawings and examples, which are only for the purpose of explaining the present invention and do not limit the scope of the present invention.
Firstly, as shown in step S1 in the flowchart 1, if a circuit structure of the small memory single chip microcomputer lacks a FLASH memory or the capacity of the FLASH is insufficient, a peripheral FLASH chip is expanded, and the structure of the peripheral FLASH chip is as shown in fig. 2. A common example of such a small-memory single chip microcomputer is Intel 8051, which usually has only a few KB RAM capacity, and is applied to a scene that an MQTT protocol Internet of things system needs to cache a large amount of data, and the RAM capacity is obviously insufficient.
The peripheral FLASH chip 12 can be parallel interface, I2The high-speed bus interfaces such as the C interface and the like are connected with the single chip microcomputer 1, and data access is carried out between the single chip microcomputer 1 and the address space mapped by the peripheral FLASH chip 12.
As shown in fig. 2, the small-memory single chip microcomputer 1 needs to implement the MQTT protocol stack, the buffer control process, and the retransmission process by software, as shown in step S2 of the flowchart 1.
The MQTT protocol stack is used for mutually converting data between an original data format and an MQTT protocol format.
The buffering control flow is shown in fig. 3 and is shown in step S4 of the flowchart 1. The data which the single chip microcomputer needs to write into the buffer area mainly comprises original data from an external circuit. As shown in fig. 3, the one-chip microcomputer first receives data as by step S21, then attempts to write the data into the internal RAM buffer as by step S22, and determines whether the RAM space is sufficient as by step S23. When the RAM space is sufficient, writing the data to the RAM as by step S24; when the internal RAM space is insufficient, the data is written into the FLASH space as by step S25. After the writing in steps S24 and S25 is completed, the one-chip microcomputer re-executes step S21 to receive data.
When the FALSH space buffer is not enough to write new data, the processing measures include: firstly, the new data to be written is abandoned, and secondly, the unnecessary data is deleted from the stored data. By the measures, the size of the memory buffer area which can be operated by the small memory single chip microcomputer is expanded, and the sum of the RAM capacity and the FLASH capacity is achieved.
The retransmission process is performed by adopting a sliding window protocol, and the sliding window protocol belongs to an application of a TCP (transmission control protocol) and is used for flow control during network data transmission so as to avoid congestion. In the data sending process shown in fig. 4, see step S5 in fig. 1, first, the single chip microcomputer fetches the original data to be sent stored in the RAM memory buffer or the FLASH buffer, as shown in step S31 in fig. 4; packing the data through the MQTT protocol stack as shown in step S32; then, outputting a message packet conforming to the MQTT protocol to the communication module, and transmitting the message packet to the remote MQTT server through the TCP/IP protocol by the communication module, as shown in step S33; subsequently, step S31 is executed to start a new data transmission. The MQTT client on the single chip receives a response message (ACK/NAK) returned by the MQTT server, retransmits or sends the next piece of data according to a retransmission mechanism, and therefore, a message packet which accords with an MQTT protocol is sent to the remote MQTT server in an efficient, safe and reliable mode.
As shown in fig. 2, the communication module 2 may be one or more of ethernet, a mobile communication network and WIFI, where the mobile communication network is further divided into 2G, 3G, 4G, and the like, and one or more of them may be installed according to the actual needs of the user electronic device, or an operation entrance for the user to select and switch these communication modes in real time is provided.
In summary, the invention has the following beneficial effects: the invention uses an internal FLASH chip or an extended peripheral FLASH chip in the circuit structure of the small memory singlechip, and realizes an MQTT protocol stack, a buffer control flow and a retransmission flow; the single chip microcomputer receives original data from an external circuit, temporarily stores the original data into the RAM, and temporarily stores the original data into the FLASH when the space of the RAM is insufficient; the single chip microcomputer takes out data to be sent, packages the data through an MQTT protocol stack, outputs a message packet which accords with the MQTT protocol to the communication module, and transmits the message packet to the remote MQTT server through the TCP/IP protocol through the communication module; the MQTT client on the single chip microcomputer receives a response message (ACK/NAK) returned by the server and retransmits or sends the next piece of data according to a retransmission mechanism, so that the technical aim of enabling a large number of electronic equipment instruments based on the limited RAM type single chip microcomputer to more conveniently realize the MQTT protocol of the IBM company at low cost so as to access the IOT system based on the MQTT protocol is fulfilled.
The embodiments of the present invention are disclosed as the preferred embodiments, but not limited thereto, and those skilled in the art can easily understand the spirit of the present invention and make various extensions and changes without departing from the spirit of the present invention.

Claims (2)

1. The method for realizing the self-contained buffer MQTT protocol based on the small-memory single chip microcomputer is characterized by comprising the following steps of:
A) in the small memory single chip circuit structure, if a FLASH memory is lacked or the FLASH capacity is not enough, a peripheral FLASH chip is expanded;
B) on a small memory single chip microcomputer, an MQTT protocol stack with a large space buffer area, a buffer control flow and a retransmission flow are realized;
when the space of the RAM is insufficient, the buffer control flow stores the data to be temporarily stored in a peripheral FLASH chip, so that the size of a memory buffer area which can be operated by the single chip microcomputer is expanded;
the retransmission process is carried out by adopting a sliding window protocol;
C) the single chip microcomputer runs an MQTT client program;
D) the single chip microcomputer receives original data from an external circuit, temporarily stores the original data into the RAM, and temporarily stores the original data into the FLASH when the space of the RAM is insufficient;
E) the single chip microcomputer takes out original data to be sent stored in the RAM memory buffer area or the FLASH buffer area, packages the original data through the MQTT protocol stack, outputs a message packet which accords with the MQTT protocol to the communication module, and transmits the message packet to the remote MQTT server through the TCP/IP protocol through the communication module;
F) the MQTT client on the single chip receives a response message returned by the server, and retransmits or sends the next piece of data according to a retransmission mechanism;
the MQTT protocol stack is used for the single chip microcomputer to mutually convert data between an original data format and an MQTT protocol format.
2. The MQTT protocol implementation method for the buffer zone based on the small-memory single-chip microcomputer is characterized in that the communication module is one or more of Ethernet, a mobile communication network and WIFI.
CN201710648748.6A 2017-08-01 2017-08-01 MQTT protocol implementation method with buffer area based on small-memory single chip microcomputer Active CN109327424B (en)

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 CN109327424A (en) 2019-02-12
CN109327424B true 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)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
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 (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
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

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6347051B2 (en) * 1991-11-26 2002-02-12 Hitachi, Ltd. Storage device employing a flash memory

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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

Also Published As

Publication number Publication date
CN109327424A (en) 2019-02-12

Similar Documents

Publication Publication Date Title
EP3873062A1 (en) Data transmission method, system, and proxy server
US10609125B2 (en) Method and system for transmitting communication data
CN104811478A (en) Remote control system and method of wireless terminal equipment
EP2437569A1 (en) Method and terminal for data transmission
CN103780972A (en) Server, client device, and control methods thereof
CN105376173A (en) Sending window flow control method and terminal
CN111092854B (en) Method for transmitting packets transmitted from a source device to a destination device
KR20190062166A (en) Communication system and method for network address translation
CN109327424B (en) MQTT protocol implementation method with buffer area based on small-memory single chip microcomputer
CN108432287A (en) A kind of data transmission method and network side equipment
CN103368872A (en) Data packet forwarding system and method
KR20220050104A (en) Method for transmitting stream, streaming server and streaming system
TWI759471B (en) Method and related products for controlling data retransmission
CN103338156A (en) Thread pool based named pipe server concurrent communication method
CN113285839A (en) Design method of programmable data plane software switch based on DPDK
WO2015055008A1 (en) Storage controller chip and disk packet transmission method
CN110958658A (en) Communication equipment and method
CN103347023B (en) A kind of HDLC communication controller under industrial field environment
US8705425B2 (en) Wireless receiving apparatus and transmitting apparatus having a sleep control unit
WO2019015487A1 (en) Data retransmission method, rlc entity and mac entity
Kuang et al. A Modbus Protocol Stack Compatible with RTU/TCP Frames and Embedded Application
CN104378778A (en) Method and system for communication between master station and slave station in Internet of Things and conversion gateway
Liao et al. Optimized design and implementation of TCP/IP software architecture based on embedded system
CN113300971A (en) Data processing system and method
TW202125291A (en) Gateway device with built-in server module and communication system thereof

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