CN114115832A - Internet of things embedded equipment and cloud platform communication protocol implementation method - Google Patents

Internet of things embedded equipment and cloud platform communication protocol implementation method Download PDF

Info

Publication number
CN114115832A
CN114115832A CN202210083618.3A CN202210083618A CN114115832A CN 114115832 A CN114115832 A CN 114115832A CN 202210083618 A CN202210083618 A CN 202210083618A CN 114115832 A CN114115832 A CN 114115832A
Authority
CN
China
Prior art keywords
cloud platform
communication protocol
internet
interface
embedded equipment
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.)
Pending
Application number
CN202210083618.3A
Other languages
Chinese (zh)
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.)
Beijing Microchip Blockchain And Edge Computing Research Institute
Original Assignee
Beijing Microchip Blockchain And Edge Computing Research Institute
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 Beijing Microchip Blockchain And Edge Computing Research Institute filed Critical Beijing Microchip Blockchain And Edge Computing Research Institute
Priority to CN202210083618.3A priority Critical patent/CN114115832A/en
Publication of CN114115832A publication Critical patent/CN114115832A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/37Compiler construction; Parser generation

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Communication Control (AREA)

Abstract

The invention discloses a method for realizing a communication protocol between an Internet of things embedded device and a cloud platform; the method comprises the following steps: saving the communication protocol as a file with a preset format; compiling the file with the preset format by adopting a protocolbuf-c compiler to generate an interface file used by the embedded equipment; selecting a corresponding protocolbuf compiler according to a programming language used by the cloud platform, compiling the file with the preset format, and generating an interface file used by the cloud platform; analyzing the interface file used by the embedded equipment, analyzing the interface file used by the cloud platform, and butting the analysis contents corresponding to the interface file and the interface file used by the cloud platform to realize the communication between the embedded equipment and the cloud platform; by the method, the workload that after the communication protocol between the Internet of things embedded equipment and the cloud platform is changed, a code interface realized by a developer needs to be changed, and a tester needs to retest the changed code can be effectively reduced.

Description

Internet of things embedded equipment and cloud platform communication protocol implementation method
Technical Field
The invention belongs to the technical field of Internet of things, and particularly relates to a method for realizing a communication protocol between an Internet of things embedded device and a cloud platform.
Background
In the actual use process of the embedded device, a customer inevitably needs to add other hardware devices such as sensors, and at this time, a corresponding communication protocol with the cloud platform needs to be changed. The difference between the internet of things embedded equipment and the cloud platform is very large, and by the fact that no standard and unified communication protocol exists at present, most companies can customize communication protocols with all requirements in the company according to specific requirements through common methods. In a traditional mode, an embedded software worker needs to complete an interface of an embedded device software code according to a communication protocol, correspondingly, a cloud platform developer completes the interface of the cloud platform software code, and after writing is completed, the embedded software worker and the cloud platform developer are in butt joint to ensure that data is received and sent without errors; but this conventional approach is time consuming and labor intensive.
The patent application with the patent number of CN113423025A discloses a data management terminal with artificial intelligence, wherein, in network data transmission, virtual data are serialized based on a cache protocol, so that the problems of weak concurrency capability, poor compatibility and poor expandability of the current hardware gateway are solved; however, the embedded device does not support the protocol buf serialization library, and therefore, the technical solution disclosed in the patent application of the present invention cannot solve the above mentioned technical problems.
Therefore, when a communication protocol between the embedded device and the cloud platform needs to be changed, how to reduce the workload of the embedded end and the cloud platform end in the changing process and reduce the time cost become a key problem of current research.
Disclosure of Invention
In view of the above problems, the present invention provides a method for implementing a communication protocol between an internet of things embedded device and a cloud platform, which solves at least some of the above technical problems, and by using the method, the workload that a developer needs to change a code interface and a tester needs to retest a changed code after the communication protocol between the internet of things embedded device and the cloud platform is changed can be effectively reduced.
The embodiment of the invention provides a method for realizing a communication protocol between an Internet of things embedded device and a cloud platform, which comprises the following steps:
s1, storing the communication protocol between the Internet of things embedded equipment and the cloud platform into a preset format file;
s2, compiling the file with the preset format by adopting a protocolbuf-c compiler to generate an interface file used by the embedded equipment;
selecting a corresponding protocolbuf compiler according to a programming language used by the cloud platform, compiling the preset format file, and generating an interface file used by the cloud platform;
and S3, analyzing the interface file used by the embedded equipment, analyzing the interface file used by the cloud platform, and butting the analysis contents corresponding to the interface file and the interface file used by the cloud platform to realize the communication between the embedded equipment and the cloud platform.
Further, the S1 specifically includes:
and sequentially extracting the data types and variable names in the communication protocol between the Internet of things embedded equipment and the cloud platform, and putting the data types and variable names into the message of the preset format file.
Further, in S1, the preset format file is a proto file.
Further, in S2, the interface file used by the embedded device includes a packed data function and a unpacked data function.
Further, in S2, the interface files used by the cloud platform include a packaging method and an unpacking method; wherein the packing function interfaces the unpacking method; and the unpacking function is in butt joint with the packing method.
Further, the S3 specifically includes:
analyzing a packed data function in an interface file used by the embedded equipment, analyzing an unpacking method in the interface file used by a cloud platform, and butting the packed data function with the unpacking method;
analyzing an unpacking data function in an interface file used by the embedded equipment, analyzing a packing method in the interface file used by a cloud platform, and butting the unpacking data function with the packing method; and realizing the communication between the embedded equipment and the cloud platform.
Compared with the prior art, the method for realizing the communication protocol between the Internet of things embedded equipment and the cloud platform has the following beneficial effects:
by converting the traditional communication protocol into the suffix proto format file, the conversion workload is very small and can be ignored, thereby greatly improving the efficiency of developers.
Compiling the same preset format file by using compilers corresponding to different languages, and automatically generating a corresponding programming language interface by the compilers to replace a mode that developers directly develop interfaces of communication protocols. The workload of each link is reduced, and the cost is reduced.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
The technical solution of the present invention is further described in detail by the accompanying drawings and embodiments.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description serve to explain the principles of the invention and not to limit the invention. In the drawings:
fig. 1 is a flow diagram illustrating a conventional method for implementing a communication protocol between an internet of things embedded device and a cloud platform.
Fig. 2 is a schematic flow chart of a method for implementing a communication protocol between an internet of things embedded device and a cloud platform according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
First, the related art related to the present invention will be described in detail.
The difference between the internet of things embedded equipment and the cloud platform is very large, and by the fact that no standard and unified communication protocol exists at present, most companies can customize communication protocols with all requirements in the company according to specific requirements through common methods. The embedded equipment of the Internet of things and the cloud platform realize interfaces of specific communication protocols (specific codes of different platforms: the embedded equipment codes of the Internet of things and the cloud platform codes) according to the communication protocols, and the realization of the interfaces represents the completion of the communication protocols.
In the prior art, a communication protocol is implemented in a company, namely an internet of things embedded device interface and a cloud platform data interface are compiled. Once the communication protocol is changed, the two types of interfaces must be changed, and if the protocol is changed to a small extent, the two types of interfaces are required to be changed, jointly adjusted and tested. When the protocol change is large, two types of interfaces are needed to carry out rewriting, joint debugging and testing processes. Specifically, reference may be made to fig. 1, that is, the conventional flow method is:
firstly, an embedded equipment developer of the Internet of things completes a C language interface according to a communication protocol, main interface functions are of 2 types, one type is a packaging function, and data to be sent is packaged according to the communication protocol. One type is an unpacking function, which analyzes received data according to a communication protocol to obtain valid data.
Secondly, the cloud platform developer completes the interface of the cloud platform software code, the main interface methods include 2 types, one is a packing method and the other is an unpacking method, and the functions of the 2 types of methods are the same as the first step.
And thirdly, the embedded equipment and the cloud platform are in butt joint by using the interface in the step I, namely, a unpacking method and an unpacking function butt joint method of the internet of things embedded equipment packing function butt joint cloud platform, and after a developer is put through, the specific communication protocol is realized.
Therefore, in the traditional mode, the whole process is time-consuming and labor-consuming. Assuming that the communication protocol is changed multiple times, the workload of more redundancy is correspondingly increased.
In view of the defects in the related art, an embodiment of the present invention provides a method for implementing a communication protocol between an internet of things embedded device and a cloud platform, where as shown in fig. 2, the method includes:
s1, storing the communication protocol between the Internet of things embedded equipment and the cloud platform into a preset format file;
s2, compiling the file with the preset format by adopting a protocolbuf-c compiler to generate an interface file used by the embedded equipment;
selecting a corresponding protocolbuf compiler according to a programming language used by the cloud platform, compiling the file with the preset format, and generating an interface file used by the cloud platform;
and S3, analyzing the interface file used by the embedded equipment, analyzing the interface file used by the cloud platform, and butting the analysis contents corresponding to the interface file and the interface file used by the cloud platform to realize the communication between the embedded equipment and the cloud platform.
The following is a detailed description of the above steps:
in the step S1, the communication protocol between the internet of things embedded device and the cloud platform is saved as a preset format file, in the embodiment of the present invention, the preset format file is a proto file; the specific preservation method comprises the following steps: sequentially extracting data types and variable names in a specific communication protocol, and putting the data types and the variable names in a message (message) in a proto file with a suffix; proto, for example, the communication protocol associated with the sensor is changed to sensor. Wherein for a data type, only individual data types need to be converted, e.g., int32 to sint 32.
In step S2, the embedded device uses a protocol-C (serialized C language compiler) compiler to compile the sensor. Compiling a command: the method comprises the steps that a sensor is used for generating an interface file used by an embedded device, namely a corresponding sensor.pb-c.c and a corresponding sensor.pb-c.h file, namely a C language interface file; two relatively important interface functions, namely a packed data function and a unpacked data function, exist in an interface file used by the embedded equipment; wherein: a packed data function: size _ t Sensor __ pack (const Sensor message, uint8_ t out), unpack data function: sensor __ unpackack (protobufcallocker Allocator, size _ t len, const uin 8_ t data);
the cloud platform selects a corresponding protocol buffer compiler according to the used programming language, compiles the sensor.
Assuming that the cloud platform is developed by using Java language, the corresponding compiling command, packaging method and unpacking method are as follows:
compiling a command: proto.exe-java _ out =/sensor.proto;
the packaging method comprises the following steps: byte [ ] data = sensor.
The unpacking method comprises the following steps: sensor1 = sensor parsefrom (data).
Assuming that the cloud platform is developed by using c # language, the corresponding compiling command, packaging method and unpacking method are as follows:
compiling a command: proto-i. -csharp _ out =. sensor.proto;
the packaging method comprises the following steps: public void WriteTo (pb:: CodedOutputStream output);
the unpacking method comprises the following steps: public void MergeFrom (pb:: CodedInputStream input).
Assuming that the cloud platform is developed by using C + + language, the corresponding compiling command, packaging method and unpacking method are as follows:
compiling a command: proto-I, -cpp _ out =. sensor;
the packaging method comprises the following steps: agent 8 sensor: _ InternalSerialize (: PROTOBUF _ NAMESPACE _ ID:: agent 8 target:: PROTOBUF _ NAMESPACE _ ID:: io:: EpsCopyOutputStream stream);
the unpacking method comprises the following steps: const char sensor: InternalParse (const char ptr: PROTOBUF NAMESPACE ID: internal: ParseContext ctx).
Assuming that the cloud platform is developed by using a python language, the corresponding compiling command, packaging method and unpacking method are as follows:
compiling a command: proto-I-python _ out =. sensor.proto;
the Python does not give a code for directly giving access data, and when the Python is actually used, a specific descriptor is used for generating all required Python methods and adding the Python methods into a corresponding class, and then the completely filled class can be used in the code;
the packaging method comprises the following steps: serializatostring (): serialize a message and return a string. The returned bytes are binary and not text, and only str type can be used for storage;
the unpacking method comprises the following steps: ParseFromString (data): the message is parsed from the given string.
Among them, protocol buffer (protocol for short) is a data exchange format of google, and it is independent of language and platform. google provides an implementation in multiple languages: java, c #, c + +, and python, each implementation containing a compiler in the corresponding language and a library file. Because it is a binary format, it can be used for data communication between distributed applications or data exchange in heterogeneous environments. As a binary data transmission format excellent in efficiency and compatibility, it can be used in various fields such as network transmission, profile, data storage, and the like.
In the step S3, according to the interface file used by the embedded device and the interface file used by the cloud platform, the interface used by the embedded device and the interface used by the cloud platform are docked; namely, a packed data function of the Internet of things embedded equipment is connected with an unpacking method in the cloud platform class; docking an unpacked data function of the Internet of things embedded equipment with a packing method in a cloud platform class; therefore, the correctness can be ensured without docking by developers; and because the proto files are compiled from the same suffix, the specific communication protocol is realized after the corresponding function or method is generated after the compilation of each compiler is finished.
The embodiment of the invention provides a method for realizing a communication protocol between an embedded device of the Internet of things and a cloud platform. The method specifically comprises the following steps: after the defined communication protocol is converted into the suffix proto file, the respective compilers are used for compiling and generating the corresponding interface file, the interface is not required to be specifically realized by developers completely depending on the traditional mode, and therefore the workload of the developers and testers is greatly reduced.
The embodiment of the invention does not destroy the field sequence in the original communication protocol, for example, only some fields are added on the basis of the communication protocol, only a new field interface is added in the proto file with the suffix, and the new interface generated after compiling is completely suitable for the old interface, so that the maintenance of the code only needs to maintain the new version, namely the interfaces of the new version and the old version do not need to be maintained. The flexibility is increased, and the workload of maintaining the software version is reduced.
The proto format file is compiled by utilizing proto compilers corresponding to different languages, and the compiler automatically generates a corresponding programming language interface to replace a mode that developers directly develop interfaces of communication protocols. The workload of each link is reduced, and the cost is reduced.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (6)

1. An Internet of things embedded device and cloud platform communication protocol implementation method is characterized by comprising the following steps:
s1, storing the communication protocol between the Internet of things embedded equipment and the cloud platform into a preset format file;
s2, compiling the file with the preset format by adopting a protocolbuf-c compiler to generate an interface file used by the embedded equipment;
selecting a corresponding protocolbuf compiler according to a programming language used by the cloud platform, compiling the preset format file, and generating an interface file used by the cloud platform;
and S3, analyzing the interface file used by the embedded equipment, analyzing the interface file used by the cloud platform, and butting the analysis contents corresponding to the interface file and the interface file used by the cloud platform to realize the communication between the embedded equipment and the cloud platform.
2. The method for implementing communication protocol between internet of things embedded device and cloud platform of claim 1, wherein the S1 includes:
and sequentially extracting the data types and variable names in the communication protocol between the Internet of things embedded equipment and the cloud platform, and putting the data types and variable names into the message of the preset format file.
3. The method for implementing the communication protocol between the internet of things embedded device and the cloud platform as claimed in claim 2, wherein in S1, the preset format file is a proto file.
4. The method for implementing the communication protocol between the internet of things embedded device and the cloud platform as claimed in claim 1, wherein in S2, the interface file used by the embedded device includes a packed data function and a unpacked data function.
5. The method for implementing the communication protocol between the internet of things embedded device and the cloud platform according to claim 4, wherein in S2, the interface files used by the cloud platform include a packaging method and an unpacking method; wherein the packing function interfaces the unpacking method; and the unpacking function is in butt joint with the packing method.
6. The method for implementing the communication protocol between the internet of things embedded device and the cloud platform according to claim 5, wherein the step S3 specifically includes:
analyzing a packed data function in an interface file used by the embedded equipment, analyzing an unpacking method in the interface file used by a cloud platform, and butting the packed data function with the unpacking method;
analyzing an unpacking data function in an interface file used by the embedded equipment, analyzing a packing method in the interface file used by a cloud platform, and butting the unpacking data function with the packing method; and realizing the communication between the embedded equipment and the cloud platform.
CN202210083618.3A 2022-01-25 2022-01-25 Internet of things embedded equipment and cloud platform communication protocol implementation method Pending CN114115832A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210083618.3A CN114115832A (en) 2022-01-25 2022-01-25 Internet of things embedded equipment and cloud platform communication protocol implementation method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210083618.3A CN114115832A (en) 2022-01-25 2022-01-25 Internet of things embedded equipment and cloud platform communication protocol implementation method

Publications (1)

Publication Number Publication Date
CN114115832A true CN114115832A (en) 2022-03-01

Family

ID=80360900

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210083618.3A Pending CN114115832A (en) 2022-01-25 2022-01-25 Internet of things embedded equipment and cloud platform communication protocol implementation method

Country Status (1)

Country Link
CN (1) CN114115832A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114826938A (en) * 2022-04-20 2022-07-29 国家工业信息安全发展研究中心 Method for realizing communication protocol simulation

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103747004A (en) * 2014-01-19 2014-04-23 樊建 Realizing method of internet of things communication protocol
CN104378236A (en) * 2014-11-24 2015-02-25 青岛海尔软件有限公司 Internet of things device management platform and method
CN105763426A (en) * 2016-04-12 2016-07-13 北京理工大学 Multiprotocol instant messaging system-based Internet of Things business processing system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103747004A (en) * 2014-01-19 2014-04-23 樊建 Realizing method of internet of things communication protocol
CN104378236A (en) * 2014-11-24 2015-02-25 青岛海尔软件有限公司 Internet of things device management platform and method
CN105763426A (en) * 2016-04-12 2016-07-13 北京理工大学 Multiprotocol instant messaging system-based Internet of Things business processing system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
张军辉: "基于ARM-Linux的物联网M2M中间件的研究与实现", 《中国优秀硕士学位论文全文数据库(电子期刊) 信息科技辑》 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114826938A (en) * 2022-04-20 2022-07-29 国家工业信息安全发展研究中心 Method for realizing communication protocol simulation

Similar Documents

Publication Publication Date Title
US7346897B2 (en) System for translating programming languages
US7152229B2 (en) Workflow code generator
US9086931B2 (en) System for translating diverse programming languages
US8332828B2 (en) System for translating diverse programming languages
JP3179513B2 (en) Application program integration system in heterogeneous network environment
Knabe Language support for mobile agents
Crnkovic et al. Challenges of component-based development
US7844958B2 (en) System and method for creating target byte code
Mainland et al. Flask: Staged functional programming for sensor networks
US7526755B2 (en) Plug-in pre- and postconditions for static program analysis
CN109308224B (en) Cross-platform data communication and cross-platform data processing method, device and system
US6055370A (en) Apparatus which allows data sharing amongst computer programs from different program environments
US20150242194A1 (en) System for Translating Diverse Programming Languages
US20130081004A1 (en) System for Translating Diverse Programming Languages
EP2652609A2 (en) Fusing debug information from different compiler stages
WO1998002810A1 (en) Method and apparatus for transporting interface definition language-defined data structures between heterogeneous systems
WO2022099888A1 (en) Method for implementing compiled embedded python
US20080178043A1 (en) Pipelining of input/output parameters between application tests written in a DBMS procedural language
CN114327477A (en) Intelligent contract execution method and device, electronic device and storage medium
EP0520708B1 (en) Method and apparatus for converting high level form abstract syntaxes into an intermediate form
CN114115832A (en) Internet of things embedded equipment and cloud platform communication protocol implementation method
CN114968192A (en) Project creation method and device, computer equipment and storage medium
Hayes et al. A simple system for constructing distributed, mixed‐language programs
US6321347B1 (en) Network testing system and method
US7174539B2 (en) Program coupling method

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20220301