CN114979296B - Internet of things communication method, related terminal and storage medium - Google Patents

Internet of things communication method, related terminal and storage medium Download PDF

Info

Publication number
CN114979296B
CN114979296B CN202210549525.5A CN202210549525A CN114979296B CN 114979296 B CN114979296 B CN 114979296B CN 202210549525 A CN202210549525 A CN 202210549525A CN 114979296 B CN114979296 B CN 114979296B
Authority
CN
China
Prior art keywords
iot terminal
iot
data packet
json
communication
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
CN202210549525.5A
Other languages
Chinese (zh)
Other versions
CN114979296A (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.)
Shenzhen Chenbei Technology Co Ltd
Original Assignee
Shenzhen Chenbei Technology 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 Shenzhen Chenbei Technology Co Ltd filed Critical Shenzhen Chenbei Technology Co Ltd
Priority to CN202210549525.5A priority Critical patent/CN114979296B/en
Publication of CN114979296A publication Critical patent/CN114979296A/en
Application granted granted Critical
Publication of CN114979296B publication Critical patent/CN114979296B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/08Protocols for interworking; Protocol conversion
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/12Protocols specially adapted for proprietary or special-purpose networking environments, e.g. medical networks, sensor networks, networks in vehicles or remote metering networks
    • 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/18Multiprotocol handlers, e.g. single devices capable of handling multiple protocols
    • 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/22Parsing or analysis of headers
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Health & Medical Sciences (AREA)
  • Computing Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Informatics (AREA)
  • Communication Control (AREA)

Abstract

The embodiment of the application discloses an Internet of things communication method, a related terminal and a storage medium, which can improve the service expansion and service realization capacity of Internet of things equipment, improve maintainability of a communication interface for a developer and shorten the development period of project codes. The communication method of the Internet of things comprises the following steps: the method comprises the steps that a first IOT terminal detects a sending request for calling an IOT equipment communication interface, the sending request is used for indicating to send communication protocol data to a second IOT terminal, the IOT equipment communication interface is generated based on an IOT terminal object model, and the IOT terminal object model is defined based on an object model description language TSL; aiming at a sending request, the first IOT terminal encodes communication protocol data according to a target encoding format to obtain a first data packet, wherein the target encoding format is determined according to the transmission bandwidth of a current transmission link layer; the first IOT terminal encapsulates the first data packet according to the link protocol to generate an encapsulated second data packet; and the first IOT terminal sends a second data packet to the second IOT terminal through the IOT equipment communication interface.

Description

Internet of things communication method, related terminal and storage medium
Technical Field
The application relates to the technical field of communication of the internet of things, in particular to a communication method of the internet of things, a related terminal and a storage medium.
Background
In related internet of things (internet of thing, IOT) communication technologies, a corresponding interface generally adopts a JS object profile (JavaScript Object Notation, JSON) coding format to encode communication protocol data and then transmit the communication protocol data in a network through a communication protocol such as TCP/IP protocol.
At present, through high-bandwidth communication technologies such as Wi-Fi or 4G-LTE, a data packet with a JSON coding format can be transmitted instantly and reliably, but the coding format cannot be compatible with low-bandwidth communication technologies such as BLE or Zigbee, an interface coded by a compact protocol is often required to be redefined for the IOT equipment, for example, protocol data is coded by using a TLV format, and because the IOT equipment interface is strongly coupled with a service, the interface needs to respond to the change of the service sensitively, so that a developer is tired of maintaining multiple sets of interfaces; because of the non-unification of interfaces, the service expansion capability of the IOT equipment is limited, and further, the expansion of upper-layer services is limited.
Disclosure of Invention
Based on the above, it is necessary to address the above problems, the present application provides an internet of things communication method, a related terminal and a storage medium, which can improve the service expansion and service implementation capabilities of the internet of things device, and simultaneously improve maintainability of a developer on a communication interface, and shorten the development period of project codes.
In a first aspect, the present application provides a communication method of the internet of things, including:
The method comprises the steps that a first IOT terminal detects a sending request for calling an IOT equipment communication interface, the sending request is used for indicating to send communication protocol data to a second IOT terminal, the IOT equipment communication interface is generated based on an IOT terminal object model, and the IOT terminal object model is defined based on an object model description language TSL;
Aiming at a sending request, the first IOT terminal encodes communication protocol data according to a target encoding format to obtain a first data packet, wherein the target encoding format is determined according to the transmission bandwidth of a current transmission link layer;
The first IOT terminal encapsulates the first data packet according to a link protocol, generates an encapsulated second data packet, and the link protocol corresponds to the current transmission link layer;
and the first IOT terminal sends a second data packet to the second IOT terminal through the IOT equipment communication interface.
Optionally, in a possible implementation manner of the first aspect, the target encoding format includes a JSON encoding format or a Protobuf encoding format;
When the transmission bandwidth of the current transmission link layer is high bandwidth, the target coding format is a JSON coding format;
When the transmission bandwidth of the current transmission link layer is low bandwidth, the target coding format is a Protobuf coding format.
Optionally, in a possible implementation manner of the first aspect, the encoding, by the first IOT terminal, communication protocol data according to the target encoding format to obtain a first data packet includes:
the first IOT terminal generates a JSON object according to communication protocol data through an RPC frame code library, wherein the JSON object is generated according to a JSON coding format, and the RPC frame code library is generated according to an IOT device communication interface;
Under the condition that the target coding format is determined to be the JSON coding format, the first IOT terminal sequences the JSON object into a binary byte stream through an RPC frame code library;
the first IOT terminal packages the binary byte stream into a first data packet according to a high bandwidth communication transport protocol.
Optionally, in a possible implementation manner of the first aspect, the encoding, by the first IOT terminal, communication protocol data according to the target encoding format to obtain a first data packet includes:
The first IOT terminal generates a JSON object according to communication protocol data through an RPC frame code library, wherein the JSON object is generated according to a JSON coding format, and the RPC frame code library is generated according to an IOT device communication interface;
Under the condition that the target coding format is determined to be the Protobuf coding format, the first IOT terminal converts the JSON object into the Protobuf object through an RPC frame code library, wherein the Protobuf object corresponds to the Protobuf coding format;
the first IOT terminal sequences the Protobuf object into a binary byte stream through an RPC frame code library;
The first IOT terminal packages the binary byte stream into a first data packet according to a low bandwidth communication transport protocol.
In a second aspect, the present application further provides an internet of things communication method, including:
Under the condition that the second internet of things IOT terminal detects that the IOT equipment communication interface receives a second data packet sent by the first internet of things IOT terminal, the second IOT terminal analyzes the second data packet according to a link protocol to obtain a first data packet, wherein the IOT equipment communication interface is generated based on an IOT terminal object model, the IOT terminal object model is defined based on an object model description language TSL, and the link protocol corresponds to a current transmission link layer;
The second IOT terminal decodes the first data packet according to a target coding format to obtain communication protocol data, wherein the target coding format is determined according to a transmission bandwidth of a current transmission link layer.
Optionally, in a possible implementation manner of the second aspect, the target encoding format includes a JSON encoding format or a Protobuf encoding format;
When the transmission bandwidth of the current transmission link layer is high bandwidth, the target coding format is a JSON coding format;
When the transmission bandwidth of the current transmission link layer is low bandwidth, the target coding format is a Protobuf coding format.
Optionally, in a possible implementation manner of the second aspect, the decoding, by the second IOT terminal, the first data packet according to the target coding format to obtain communication protocol data includes:
when the transmission bandwidth of the current transmission link layer is high bandwidth, the second IOT terminal parses the first data packet into a binary byte stream according to a high bandwidth communication transmission protocol;
the second IOT terminal deserializes the binary byte stream into a JSON object through an RPC frame code library, the RPC frame code library is generated according to the IOT device communication interface, and the JSON object corresponds to the JSON encoding format;
and the second IOT terminal decodes the JSON object through the RPC frame code library to obtain communication protocol data.
Optionally, in a possible implementation manner of the second aspect, the decoding, by the second IOT terminal, the first data packet according to the target coding format to obtain communication protocol data includes:
When the transmission bandwidth of the current transmission link layer is low bandwidth, the second IOT terminal analyzes the first data packet into a binary byte stream according to a low bandwidth communication transmission protocol;
The second IOT terminal deserializes the binary byte stream into a Protobuf object through an RPC frame code library, wherein the RPC frame code library is generated according to an IOT equipment communication interface, and the Protobuf object corresponds to a Protobuf coding format;
The second IOT terminal converts the Protobuf object into a JSON object through an RPC frame code library;
and the second IOT terminal decodes the JSON object through the RPC frame code library to obtain communication protocol data.
In a third aspect, the present application provides an IOT terminal, where the IOT terminal is a first IOT terminal and includes: the device comprises a detection module, a coding module, a packaging module and a communication module;
The detection module detects a sending request for calling an IOT equipment communication interface, wherein the sending request is used for indicating to send communication protocol data to a second internet of things IOT terminal, the IOT equipment communication interface is generated based on an object model of the IOT terminal, and the object model of the IOT terminal is defined based on an object model description language TSL;
aiming at a sending request, the coding module codes communication protocol data according to a target coding format to obtain a first data packet, wherein the target coding format is determined according to the transmission bandwidth of the current transmission link layer;
The encapsulation module encapsulates the first data packet according to a link protocol, generates an encapsulated second data packet, and the link protocol corresponds to the current transmission link layer;
And the communication module sends a second data packet to the second IOT terminal through the IOT equipment communication interface.
In a fourth aspect, the present application provides an IOT terminal, where the IOT terminal is a second IOT terminal, comprising: the device comprises a detection module, an analysis module and a decoding module;
Under the condition that the detection module detects that the IOT equipment communication interface receives a second data packet sent by a first IOT terminal, the analysis module analyzes the second data packet according to a link protocol to obtain the first data packet, wherein the IOT equipment communication interface is generated based on an object model of the IOT terminal, the object model of the IOT terminal is defined based on an object model description language TSL, and the link protocol corresponds to a current transmission link layer;
the decoding module decodes the first data packet according to a target coding format to obtain communication protocol data, wherein the target coding format is determined according to the transmission bandwidth of the current transmission link layer.
In a fifth aspect, the present application provides an IOT terminal, where the IOT terminal is a first IOT terminal and includes:
a processor; and
A memory having executable code stored thereon, which when executed by a processor causes the processor to perform the internet of things communication method as in the first aspect and any implementation thereof described above.
In a sixth aspect, the present application further provides an IOT terminal, where the IOT terminal is a second IOT terminal, and the IOT terminal comprises:
a processor; and
And a memory having executable code stored thereon, which when executed by the processor causes the processor to perform the internet of things communication method as in the second aspect and any implementation thereof described above.
In a seventh aspect, the present application provides a computer readable storage medium having executable code stored thereon, which when executed by a processor of an electronic device, causes the processor to perform the internet of things communication method as in the first aspect and any implementation thereof described above.
In an eighth aspect, the present application also provides a computer readable storage medium having executable code stored thereon, which when executed by a processor of an electronic device, causes the processor to perform the internet of things communication method as in the second aspect and any implementation thereof.
The technical scheme provided by the application has the following beneficial effects:
according to the technical scheme, firstly, a first IOT terminal detects a sending request for calling an IOT equipment communication interface, secondly, aiming at the sending request, the first IOT terminal codes communication protocol data according to a target coding format to obtain a first data packet, and finally, the first IOT terminal passes through the IOT equipment communication interface generated according to an object model of the IOT equipment. Because the communication interface of the IOT equipment is uniformly defined for the object model of the IOT equipment based on TSL definition, the uniform communication interface of the IOT equipment can be compatible with different coding formats to carry out coding transmission on the data packet, and the service expansion and service realization capacity of the IOT equipment can be improved.
Further, the first IOT terminal uses an RPC frame code library to determine that the target coding format is a Protobuf or JSON coding mode according to the transmission bandwidth of the current transmission link, and the RPC frame code library is generated according to the IOT device communication interface. Because the unified communication interface of the IOT equipment can be compatible with different coding formats to carry out coding transmission on the data packet, the RPC frame code library generated based on the communication interface of the IOT equipment can be compatible with multi-terminal equipment and multiple programming languages, the maintainability of a developer on the communication interface of the IOT equipment can be improved, and the development period of project codes can be shortened.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application as claimed.
Drawings
The foregoing and other objects, features and advantages of the application will be apparent from the following more particular descriptions of exemplary embodiments of the application as illustrated in the accompanying drawings wherein like reference numbers generally represent like parts throughout the exemplary embodiments of the application.
Fig. 1 is a schematic flow diagram corresponding to a transmission flow in an internet of things communication method according to an embodiment of the present application;
FIG. 2 is a schematic diagram of an IOT device communication interface generated based on an object model of an intelligent light in an embodiment of the application;
fig. 3 is a schematic flow diagram corresponding to a receiving flow in the communication method of the internet of things according to an embodiment of the present application;
FIG. 4 is a flow chart of an embodiment of an RPC framework code library according to an embodiment of the present application;
Fig. 5 is a schematic structural diagram of a first IOT terminal in an embodiment of the present application;
FIG. 6 is a schematic diagram illustrating a second IOT terminal according to one embodiment of the application;
Fig. 7 is another schematic structural diagram of a first IOT terminal in an embodiment of the present application;
Fig. 8 is a schematic diagram of another architecture of a second internet of things IOT terminal in an embodiment of the present application.
Detailed Description
Embodiments of the present application will be described in more detail below with reference to the accompanying drawings. While embodiments of the present application are illustrated in the drawings, it should be understood that the present application 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 application to those skilled in the art.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any or all possible combinations of one or more of the associated listed items.
It should be understood that although the terms "first," "second," "third," etc. may be used herein to describe various information, these information should not be limited by these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the application. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include one or more such feature. In the description of the present application, the meaning of "a plurality" is two or more, unless explicitly defined otherwise.
In order to facilitate understanding of the technical scheme of the application, the method is suitable for the internet of things (internet of thing, IOT) communication technology, a new communication interface and a remote procedure call (remote procedure call, RPC) framework code library are defined by an object model of the IOT device defined by an object model description language (THING SPECIAL language, TSL), service expansion and service realization capability of the internet of things device can be improved, maintainability of a developer on the communication interface is improved, and development period of project codes is shortened.
In order to facilitate understanding of the technical scheme of the application, the communication method of the Internet of things in the application is described in detail below with reference to the accompanying drawings.
Fig. 1 is a schematic flow diagram corresponding to a transmission flow in an internet of things communication method according to an embodiment of the present application.
As shown in fig. 1, an embodiment of the present application corresponding to a transmission flow in an internet of things communication method includes:
101. The first IOT terminal detects a send request that invokes the IOT device communication interface.
The sending request is used for indicating to send communication protocol data to the second internet of things IOT terminal, the IOT device communication interface is generated based on an object model of the IOT terminal, and the object model of the IOT terminal is defined based on an object model description language TSL.
The communication protocol data is transmission data between the first IOT terminal and the second IOT terminal, and specifically, the communication data includes, but is not limited to, request data or response data. For example, the first IOT terminal sends the request data to the second IOT terminal, and after receiving the request data, the second IOT terminal sends the corresponding response data to the first IOT terminal.
The object model defined by the TSL is formed by digitally representing entities in physical space from three dimensions of attributes, services and events, wherein the entities can comprise intelligent lamps, sensors, vehicle-mounted devices and the like.
By taking an intelligent lamp as an example, the generation of the communication interface of the IOT device based on the object model of the IOT terminal is described as follows:
FIG. 2 is a schematic diagram of an IOT device communication interface generated based on an object model of a smart lamp in an embodiment of the application.
As shown in fig. 2, the intelligent lamp is input into the IOT device model, the IOT device model obtains the object model of the intelligent lamp through the TSL description definition in three aspects of device attribute, device action and device event, and finally a unified interface, namely, the IOT device communication interface, is generated according to the object model of the intelligent lamp defined by the TSL description. It should be understood that for a smart light, a device service is the device action of the smart light. For example:
describing the device attributes of the intelligent light by the TSL includes: 1. a switch, 2, brightness;
Describing the device actions of the intelligent light through the TSL includes: 1. setting a switch attribute, 2, reading the switch attribute, 3, setting a brightness attribute, and 4, reading the brightness attribute;
Describing the device event of the intelligent light through the TSL includes: 1. trademark switch changes, 2, reporting brightness changes.
Further, the unified interface generated based on the intelligent lamp object model described by the TSL includes: 1. the method comprises the steps of requesting to set a switch attribute, 2 responding to set the switch attribute, 3 requesting to set a brightness attribute, 4 responding to set the brightness attribute, 5 requesting to report a switch change, 6 responding to report the switch change, 7 requesting to report the brightness change, 8 responding to report the brightness change.
102. And aiming at the sending request, the first IOT terminal codes the communication protocol data according to the target coding format to obtain a first data packet.
The encoding format is used to encode data for transmission. The target encoding format may include, but is not limited to, a JS object profile (javascript object notation, JSON) encoding format or a protocol buffer (protocol buffer) encoding format of a cross-platform serialized data structure.
The two further coding modes Protobuf and JSON are essentially different for the coding modes of data: 1. for the data coding mode of Protobuf, after the data structure object is serialized into binary data, the binary size is more economical than that of the JSON coding mode, and is usually 15% -70% of the binary data obtained by the JSON coding mode. 2. For the JSON data coding mode, binary data after the serialization of the data structure object is plaintext, which is more friendly to APP or Web development, and the analysis of the JSON data is more convenient in the debugging stage.
Due to the coding characteristics of the JSON coding format and the Protobuf coding format, the application discovers that the JSON coding format is suitable for coding communication protocol data transmitted by high-bandwidth communication technologies such as Wi-Fi or 4G-LTE, and the Protobuf coding format is suitable for coding communication protocol data transmitted by low-bandwidth communication technologies such as Bluetooth BLE or Zigbee, so that the communication transmission efficiency and reliability can be effectively ensured.
Optionally, in an implementation manner of the embodiment of the present application, when a transmission bandwidth of a current transmission link layer is a high bandwidth, the target encoding format is a JSON encoding format; when the transmission bandwidth of the current transmission link layer is low bandwidth, the target coding format is a Protobuf coding format.
The specific implementation manner of the first IOT terminal for encoding the communication protocol data according to the target coding format to obtain the first data packet is different due to the different target coding formats. The above operations may be implemented in the present application by an RPC framework code library generated according to an IOT device communication interface. Specifically, after detecting the sending request, the first IOT terminal invokes an IOT device communication interface in the RPC framework code library through a calling function, and then encodes communication protocol data according to a target encoding format to obtain a first data packet. Optionally, the IOT device communication interface includes a request interface and a response interface.
Further specifically, in one implementation manner of the embodiment of the present application, when the transmission bandwidth of the current transmission link layer is a high bandwidth, the first IOT terminal encodes the communication protocol data according to the target encoding format to obtain the first data packet, and may specifically perform the following operations:
the first IOT terminal generates a JSON object according to communication protocol data through an RPC frame code library, wherein the JSON object is generated according to a JSON coding format, and the RPC frame code library is generated according to an IOT device communication interface;
Under the condition that the target coding format is determined to be the JSON coding format, the first IOT terminal sequences the JSON object into a binary byte stream through an RPC frame code library;
The first IOT terminal packages the binary byte stream into a first data packet according to a high bandwidth communication transport protocol. From the above operation, it can be seen that in the case that the transmission bandwidth of the current transmission link layer is high, the JSON object generated by the communication protocol data is directly serialized into a binary byte stream through the RPC frame code library, and then the binary byte stream is packed into the first data packet.
Illustratively, when the current transport link layer is at a high bandwidth, the RPC frame code library directly sequences JSON objects into binary byte streams via the JSON serializer and deserializer, and then passes the binary byte streams of communication protocol data (e.g., request data or response data) to the protocol transport layer, which packages the binary byte streams into complete first packets. The RPC frame code library comprises the program codes corresponding to the JSON serializer and the anti-serializer.
Further specifically, in one implementation manner of the embodiment of the present application, when the transmission bandwidth of the current transmission link layer is a low bandwidth, the first IOT terminal encodes the communication protocol data according to the target encoding format to obtain the first data packet, and may specifically perform the following operations:
The first IOT terminal generates a JSON object according to communication protocol data through an RPC frame code library, wherein the JSON object is generated according to a JSON coding format, and the RPC frame code library is generated according to an IOT device communication interface;
Under the condition that the target coding format is determined to be the Protobuf coding format, the first IOT terminal converts the JSON object into the Protobuf object through an RPC frame code library, wherein the Protobuf object corresponds to the Protobuf coding format;
the first IOT terminal sequences the Protobuf object into a binary byte stream through an RPC frame code library;
The first IOT terminal packages the binary byte stream into a first data packet according to a low bandwidth communication transport protocol.
Similarly, as can be seen from the above operation, in the case that the transmission bandwidth of the current transmission link layer is low, firstly, the JSON object generated by the communication protocol data is converted into a Protobuf object through the RPC frame code library, secondly, the Protobuf object is serialized into a binary byte stream, and finally, the binary byte stream is packed into the first data packet.
For example, when the current transmission link layer is in a low bandwidth condition, the RPC framework code library firstly converts JSON objects of communication protocol data (such as request data or response data) into Protobuf objects through a JSON and Protobuf inter-converter; secondly, the Protobuf object is serialized into a binary byte stream through the Protobuf serialization and deserializer, and finally, the binary byte stream of the communication protocol data is transferred to a protocol transmission layer, and the protocol transmission layer packages the binary byte stream into a complete first data packet. The RPC frame code library comprises the JSON and Protobuf interconverter and the Protobuf serialization and inverse serialization program codes corresponding to the inverse serializer.
The RPC frame code library can uniformly manage the transmission link interfaces of the bottom layer, and select a specific current transmission link interface according to the availability of the transmission link, so that the RPC frame code library can obtain the transmission bandwidth of the current transmission link. For example, currently configured to the RPC framework are three underlying transport links, wi-Fi, 4G-LTE and BLE; when 4G-LTE (high bandwidth) is off, the RPC framework selects Wi-Fi (high bandwidth), and when Wi-Fi is also off, the RPC framework selects BLE (low bandwidth).
It should be appreciated that the above-described packing of the binary byte stream into the first data packet by the first IOT terminal according to the high or low bandwidth communication transport protocol is accomplished at the transport protocol layer.
103. And the first IOT terminal encapsulates the first data packet according to the link protocol to generate an encapsulated second data packet.
The link protocol corresponds to the current transmission link layer and is used for packaging the data packet so as to ensure the reliability of data transmission. Specifically, the first IOT terminal sequences the first data packet according to the current transmission link layer and packages the first data packet into a second data packet of a complete corresponding link protocol.
Specifically, in the case of high bandwidth transmission, the first IOT terminal transmits the first packet sequence through a transmission link layer and packages the first packet sequence into a complete second packet corresponding to a link protocol of the low bandwidth communication technology such as Wi-Fi or 4G-LTE.
In the case of low bandwidth transmission, the transmission is performed through a low bandwidth communication technology such as BLE or Zigbee, at this time, the first IOT terminal packages the first data packet sequence into a complete second data packet corresponding to the link protocol of the low bandwidth communication technology such as BLE or Zigbee through the transmission link layer.
104. And the first IOT terminal sends a second data packet to the second IOT terminal through the IOT equipment communication interface.
After the second data packet is obtained through packaging, the first IOT terminal sends the second data packet to the second IOT terminal through the IOT device communication interface.
Specifically, when the current transmission link is high bandwidth, the first terminal uses a Wi-Fi or 4G-LTE high bandwidth communication technology and sends the second data packet to the second IOT terminal through the IOT device communication interface.
Similarly, when the current transmission link is low bandwidth, the first terminal uses a low bandwidth communication technology such as BLE or Zigbee, and sends the second data packet to the second IOT terminal through the IOT device communication interface.
In summary, in the embodiment of the present application, firstly, the first IOT terminal detects a transmission request for calling the IOT device communication interface, secondly, for the transmission request, the first IOT terminal encodes communication protocol data according to a target encoding format to obtain a first data packet, and finally, the first IOT terminal passes through the IOT device communication interface generated according to the object model of the IOT device. Because the communication interface of the IOT equipment is uniformly defined for the object model of the IOT equipment based on TSL definition, the uniform communication interface of the IOT equipment can be compatible with different coding formats to carry out coding transmission on the data packet, and the service expansion and service realization capacity of the IOT equipment can be improved.
Further, the first IOT terminal uses an RPC frame code library to determine that the target coding format is a Protobuf or JSON coding mode according to the transmission bandwidth of the current transmission link, and the RPC frame code library is generated according to the IOT device communication interface. Because the unified communication interface of the IOT equipment can be compatible with different coding formats to carry out coding transmission on the data packet, the RPC frame code library generated based on the communication interface of the IOT equipment can be compatible with multi-terminal equipment and multiple programming languages, the maintainability of a developer on the communication interface of the IOT equipment can be improved, and the development period of project codes can be shortened.
It should be understood that in the embodiment corresponding to fig. 1, the first IOT terminal is used as a transmitting end, and the second IOT terminal is used as a receiving end to describe the communication mode of the internet of things in the present application, specifically, the embodiment corresponding to fig. 1 is described in terms of the transmitting end, and the technical scheme of the receiving end will be described with reference to the accompanying drawings.
Fig. 3 is a schematic flow diagram corresponding to a receiving flow in the communication method of the internet of things according to an embodiment of the present application.
As shown in fig. 3, an embodiment of the present application corresponding to a receiving flow in an internet of things communication method includes:
301. and under the condition that the detection module detects that the communication interface of the IOT equipment receives the second data packet sent by the IOT terminal of the first Internet of things, the second IOT terminal analyzes the second data packet according to the link protocol to obtain the first data packet.
The communication interface of the IOT device is generated based on an object model of the IOT terminal, the object model of the IOT terminal is defined based on an object model description language TSL, and the link protocol corresponds to the current transmission link layer.
Specifically, the second IOT terminal parses the second data packet according to the link protocol corresponding to the current transmission link layer to obtain the first data packet. Further, the parsed first data packet enters the protocol transport layer.
Under the condition of high-bandwidth transmission, the second IOT terminal transmits through a high-bandwidth communication technology such as Wi-Fi or 4G-LTE, and at the moment, the second IOT terminal analyzes the second data packet through a transmission link layer according to a link protocol of the high-bandwidth communication technology such as Wi-Fi or 4G-LTE to obtain the first data packet.
In the case of low bandwidth transmission, the second IOT terminal performs transmission through low bandwidth communication technologies such as BLE or Zigbee, and at this time, the second IOT terminal analyzes the second data packet through the transmission link layer according to the link protocol of the low bandwidth communication technologies such as BLE or Zigbee to obtain the first data packet.
302. And the second IOT terminal decodes the first data packet according to the target coding format to obtain communication protocol data.
After the parsed first data packet enters the protocol transmission layer, the second IOT terminal decodes the first data packet according to the target coding format to obtain communication protocol data.
Specifically, the target encoding format may include, but is not limited to: JSON coding format or Protobuf coding format. The difference between these two coding formats is detailed in the description of the relevant part in step 102, and will not be repeated here.
Corresponding to the sending flow, the second IOT terminal in the present application may also implement the above operation through an RPC framework code library, where the RPC framework code library is generated according to the IOT device communication interface. Specifically, the second IOT terminal may call the IOT device communication interface in the RPC framework code library by calling a function, and then decode the first data packet according to the target encoding format to obtain the communication protocol data. Also optionally, the IOT device communication interface includes a request interface and a response interface.
Similarly, in one implementation of the embodiment of the present application, when the transmission bandwidth of the current transmission link layer is a high bandwidth, the target encoding format is a JSON encoding format; when the transmission bandwidth of the current transmission link layer is low bandwidth, the target coding format is a Protobuf coding format.
Further specifically, in one implementation manner of the embodiment of the present application, when the transmission bandwidth of the current transmission link layer is a high bandwidth, the second IOT terminal decodes the first data packet according to the target coding format to obtain the communication protocol data, and may specifically perform the following operations:
when the transmission bandwidth of the current transmission link layer is high bandwidth, the second IOT terminal parses the first data packet into a binary byte stream according to a high bandwidth communication transmission protocol;
the second IOT terminal deserializes the binary byte stream into a JSON object through an RPC frame code library, the RPC frame code library is generated according to the IOT device communication interface, and the JSON object corresponds to the JSON encoding format;
and the second IOT terminal decodes the JSON object through the RPC frame code library to obtain communication protocol data.
Illustratively, when the current transmission link layer is in a high bandwidth condition, first, the second IOT terminal parses the first data packet into a binary byte stream according to a high bandwidth communication transmission protocol (e.g., wi-Fi or 4G-LTE); secondly, the second IOT terminal uses a calling function to call a JSON serialization and deserializer in the RPC frame code library to deserialize the binary byte stream into a JSON object; and finally, the second IOT terminal uses the calling function to call codes in the RPC framework code library to decode the JSON object to obtain communication protocol data.
Further specifically, in one implementation manner of the embodiment of the present application, when the transmission bandwidth of the current transmission link layer is a low bandwidth, the second IOT terminal decodes the first data packet according to the target coding format to obtain the communication protocol data, and may specifically perform the following operations:
When the transmission bandwidth of the current transmission link layer is low bandwidth, the second IOT terminal analyzes the first data packet into a binary byte stream according to a low bandwidth communication transmission protocol;
The second IOT terminal deserializes the binary byte stream into a Protobuf object through an RPC frame code library, wherein the RPC frame code library is generated according to an IOT equipment communication interface, and the Protobuf object corresponds to a Protobuf coding format;
The second IOT terminal converts the Protobuf object into a JSON object through an RPC frame code library;
and the second IOT terminal decodes the JSON object through the RPC frame code library to obtain communication protocol data.
Illustratively, when the current transmission link layer is in a low bandwidth condition, first, the second IOT terminal parses the first data packet into a binary byte stream according to a high bandwidth communication transmission protocol (e.g., wi-Fi or 4G-LTE); secondly, the second IOT terminal uses a calling function to call a Protobuf serialization and deserializer in an RPC frame code library to deserialize the binary byte stream into a Protobuf object; thirdly, the second IOT terminal uses the calling function to call a JSON and Protobuf inter-converter in the RPC frame code library to convert the Protobuf object into a JSON object; and finally, the second IOT terminal uses the calling function to call codes in the RPC framework code library to decode the JSON object to obtain communication protocol data.
To sum up, in the embodiment of the present application, first, when the second internet of things IOT terminal detects that the IOT device communication interface receives the second data packet sent by the first internet of things IOT terminal, the second IOT terminal parses the second data packet according to the current transmission link layer to obtain the first data packet, and finally, the second IOT terminal decodes the first data packet according to the target coding format to obtain the communication protocol data. Because the communication interface of the IOT equipment is uniformly defined for the object model of the IOT equipment based on TSL definition, the uniform communication interface of the IOT equipment can be compatible with different coding formats to carry out coding transmission on the data packet, and the service expansion and service realization capacity of the IOT equipment can be improved.
Further, the second IOT terminal uses an RPC frame code library to determine that the target coding format is a Protobuf or JSON coding mode according to the transmission bandwidth of the current transmission link, and further the second IOT terminal decodes the first data packet according to the target coding format to obtain communication protocol data, and the RPC frame code library is generated according to the communication interface of the IOT device. Because the unified communication interface of the IOT equipment can be compatible with different coding formats to carry out coding transmission on the data packet, the RPC frame code library generated based on the communication interface of the IOT equipment can be compatible with multi-terminal equipment and multiple programming languages, the maintainability of a developer on the communication interface of the IOT equipment can be improved, and the development period of project codes can be shortened.
As can be seen from the embodiments described in fig. 1 and fig. 3, the first IOT terminal encodes the communication protocol data according to the target encoding format to obtain the first data packet, and the second IOT terminal decodes the first data packet according to the target encoding format to obtain the communication protocol data, which may be implemented by using the RPC frame code library, which will be described below.
Fig. 4 is a flowchart of an embodiment of an RPC frame code library according to an embodiment of the present application.
As shown in fig. 4, the RPC framework code library in the embodiment of the present application includes: the interface transmission data packaging module, the request function module and the response function module, wherein the three modules comprise corresponding function modules, and the function modules can be realized through program codes.
The RPC framework code library is generated from the IOT communication device interface. Illustratively, as shown in fig. 4, generating a unified interface based on the object model of the intelligent lamp in fig. 2 to generate the RPC frame code library shown in fig. 4, where the object model of the intelligent lamp generates the unified interface includes: 1. setting a switch attribute interface, wherein the interface specifically is used for requesting to set a switch attribute and responding to set the switch attribute in fig. 2; 2. a set brightness attribute interface, which specifically sets brightness attributes for the request and sets brightness attributes in response to the request in fig. 2; 3. reporting switch attribute interfaces, specifically the request reporting switch changes and the response reporting switch changes in fig. 2; 4. the reporting brightness change interface is specifically the request reporting brightness change and response reporting brightness change in fig. 2.
The interface transmission data packaging module comprises the following functional units: JSON data structure diagram Schema, protobuf data structures diagram Schema, JSON and Protobuf interconverter, JSON serializer and deserializer, and Protobuf serializer and deserializer. The method comprises the steps that a JSON Schema is used for generating a JSON object, a Protobuf Schema is used for generating a Protobuf object, a JSON-Protobuf inter-converter is used for converting the JSON object into the Protobuf object or converting the Protobuf object into the JSON object, a JSON serialization and anti-serialization device is used for serializing the JSON object into a binary byte stream or anti-serializing the binary byte stream into the JSON object, and a Protobuf serialization and anti-serialization device is used for serializing the Protobuf object into the binary byte stream or anti-serializing the binary byte stream into the Protobuf object.
Under the condition that a function call request interface is called, the request function module generates a corresponding JSON object (namely the request data JSON object) from the request data, and then the request data JSON object is transmitted to a protocol transmission layer or directly transmitted to the protocol transmission layer in a mode that the JSON and Protobuf interconverter is converted into the Protobuf object.
Similarly, under the condition that the corresponding interface is called by calling a function, the response function module generates a corresponding JSON object (namely the response data JSON object) from the response data, and then the response data JSON object is transmitted to a protocol transmission layer or directly transmitted to the protocol transmission layer in a mode of converting the response data JSON object into the Protobuf object through a JSON and Protobuf inter-converter.
The following describes the transmission and reception process of the request data and the transmission and reception process of the request data, respectively, with reference to fig. 4, specifically as follows:
1. the first IOT terminal sends request data to the second IOT terminal by calling a function call request interface
The first IOT terminal detects a transmission request for calling the communication interface of the IOT device, and for the transmission request, the first IOT terminal executes the following transmission flow of request data by calling a function to call a request interface in a request function module in an RPC framework code library, specifically as follows:
1. when the first IOT terminal invokes the request interface, the request data is generated into request data JSON objects using JSON Schema in the RPC framework code library.
Selecting whether to convert the request data JSON object into a Protobuf object through a JSON and Protobuf inter-converter or directly transmit the request data JSON object to a protocol transmission layer by using an RPC frame code library according to the bandwidth condition of the current transmission link layer:
2.1, when the current transmission link layer is in a low bandwidth condition, converting the request data JSON object into the request data Protobuf object by using a JSON and Protobuf inter-converter in the RPC framework.
2.1.1, Using Protobuf serialization and anti-serialization device to serialize the request data Protobuf object into binary byte stream, then transferring the binary byte stream of the request data to protocol transmission layer, and packaging into complete protocol data packet, i.e. first request data packet.
2.2, When the current transmission link layer is in a high bandwidth condition, directly serializing the request data JSON object into a binary byte stream by using a JSON serialization and deserializer in an RPC frame code library, then transmitting the binary byte stream of the request data to a protocol transmission layer, and packaging the binary byte stream into a complete protocol data packet, namely a first request data packet, at the protocol transmission layer.
3. And serializing the first request data packet by using a protocol transmission layer in an RPC frame code library, and packaging the serialized first request data packet into a second request data packet which corresponds to a link protocol in a transmission link layer.
4. And transmitting the second request data packet to the second IOT terminal through Wi-Fi or BLE by using a transmission link layer in the RPC frame code library.
Specifically, wi-Fi is used for high bandwidth transmission, and BLE is used for low bandwidth transmission.
2. The second IOT terminal receives request data sent by the first IOT terminal by calling a function call response interface
Under the condition that the second internet of things IOT terminal detects that the IOT equipment communication interface receives a second request data packet sent by the first internet of things IOT terminal, the second IOT terminal calls a response interface in a response function module in an RPC frame code library through a calling function to execute the following request data receiving flow, wherein the receiving flow is specifically as follows:
5. and analyzing the second request data packet corresponding to the link protocol by using the transmission link layer of the response function module in the RPC frame code library to obtain a first request data packet, and returning the first request data packet to the protocol transmission layer of the response function module.
The first request packet is parsed into a binary byte stream of request data in a protocol transport layer.
The binary byte stream of the request data is de-serialized into a Protobuf object using a Protobuf serializer and a de-serializer in the RPC framework code library, or into a JSON object using a JSON serializer and a de-serializer in the RPC framework code library:
under the condition of low bandwidth transmission, the Protobuf serialization and anti-serialization device in the RPC frame code library is used for deserializing the binary byte stream of the request data into the request data Protobuf object.
6.1.1 Converting the request data Protobuf object into a request data JSON object using a JSON and Protobuf inter-converter in the RPC framework code library.
And 6.2, under the condition of high-bandwidth transmission, using a JSON serialization and deserializer in an RPC frame code library to deserialize a binary byte stream of the request data into a request data JSON object.
7. And the response interface in the RPC frame code library is used for calling back the request data JSON object to the second IOT terminal for processing.
And the second IOT terminal generates corresponding response data according to the request data.
3. The second IOT terminal executes the following transmission flow of response data by calling IOTRPC a response interface in a response function module in a framework code library, which is specifically as follows:
8. When the second IOT terminal invokes the response interface, the request data is generated into request data JSON objects using JSON Schema in the RPC framework code library.
Selecting whether response data JSON objects are converted into Protobuf objects through a JSON and Protobuf inter-converter or are directly transmitted to a protocol transmission layer by using an RPC frame code library according to the bandwidth condition of the current transmission link layer:
9.1, when the current transmission link layer is in a low bandwidth condition, converting the response data JSON object into a response data Protobuf object by using a JSON and Protobuf inter-converter in the RPC framework.
9.1.1, Using Protobuf serialization and anti-serialization device to serialize the response data Protobuf object into binary byte stream, then transferring the binary byte stream of the response data to the protocol transmission layer, and packaging the binary byte stream into complete protocol data packet, namely the first response data packet.
9.2, When the current transmission link layer is in a high bandwidth condition, directly serializing the response data JSON object into a binary byte stream by using a JSON serialization and anti-serialization device in an RPC frame code library, then transferring the binary byte stream of the response data to a protocol transmission layer, and packaging the binary byte stream into a complete protocol data packet, namely a first response data packet, at the protocol transmission layer.
10. And serializing the first response data packet by using a protocol transmission layer in an RPC frame code library, and packaging the serialized first response data packet into a second response data packet of a complete corresponding link protocol in a transmission link layer.
11. And transmitting the second data packet to the second IOT terminal through Wi-Fi or BLE by using a transmission link layer in the RPC frame code library.
Specifically, wi-Fi is used for high bandwidth transmission, and BLE is used for low bandwidth transmission.
4. The first IOT terminal receives response data sent by the second IOT terminal through calling a function call request interface
Under the condition that the first IOT terminal detects that the IOT equipment communication interface receives a second response data packet sent by the second IOT terminal, the first IOT terminal calls a request interface in a request function module in an RPC frame code library through a calling function to execute the following response data receiving flow, wherein the receiving flow is specifically as follows:
12. and analyzing the second response data packet corresponding to the link protocol by using the transmission link layer of the request function module in the RPC frame code library to obtain a first response data packet, and returning the first response data packet to the protocol transmission layer of the request function module.
The first response data packet is parsed into a binary byte stream of response data in the protocol transport layer.
The binary byte stream of the response data is de-serialized into a Protobuf object using a Protobuf serializer and a de-serializer in the RPC framework code library, or into a JSON object using a JSON serializer and a de-serializer in the RPC framework code library:
Under the condition of low bandwidth transmission, the Protobuf serialization and anti-serialization device in the RPC frame code library is used for deserializing the binary byte stream of the response data into the response data Protobuf object.
13.1.1 Converting the response data Protobuf object into a response data JSON object by using a JSON and Protobuf inter-converter in the RPC frame code library.
Under the condition of high bandwidth transmission, the binary byte stream of response data is deserialized into a response data JSON object by using a JSON serialization and deserializer in an RPC frame code library.
14. And (3) using a response interface in the RPC frame code library to call back the response data JSON object to the first IOT terminal for processing.
The first IOT terminal processes response data by decoding the response data JSON object.
Corresponding to the embodiment of the application function implementation method, the application also provides a related terminal and a corresponding embodiment.
Fig. 5 is a schematic structural diagram of a first IOT terminal in an embodiment of the present application.
As shown in fig. 5, in an embodiment of the present application, a first IOT terminal 50 includes: a detection module 501, an encoding module 502, a packaging module 503 and a communication module 504;
The detection module 501 detects a sending request for calling an IOT device communication interface, where the sending request is used to instruct sending of communication protocol data to a second internet of things IOT terminal, the IOT device communication interface is generated based on an object model of the IOT terminal, and the object model of the IOT terminal is defined based on an object model description language TSL;
For a transmission request, the encoding module 502 encodes communication protocol data according to a target encoding format to obtain a first data packet, wherein the target encoding format is determined according to the transmission bandwidth of the current transmission link layer;
the encapsulation module 503 encapsulates the first data packet according to a link protocol, and generates an encapsulated second data packet, where the link protocol corresponds to the current transmission link layer;
Communication module 504 sends the second data packet to the second IOT terminal via the IOT device communication interface.
Optionally, in an implementation manner of the embodiment of the present application, the target encoding format includes a JSON encoding format or a Protobuf encoding format;
When the transmission bandwidth of the current transmission link layer is high bandwidth, the target coding format is a JSON coding format;
When the transmission bandwidth of the current transmission link layer is low bandwidth, the target coding format is a Protobuf coding format.
Optionally, in an implementation manner of the embodiment of the present application, the encoding module 502 encodes the communication protocol data according to the target encoding format to obtain the first data packet, and the encoding module 502 may specifically perform the following operations:
Firstly, generating a JSON object according to communication protocol data through an RPC frame code library, wherein the JSON object is generated according to a JSON coding format, and the RPC frame code library is generated according to an IOT device communication interface;
Secondly, under the condition that the target coding format is determined to be the JSON coding format, serializing the JSON object into a binary byte stream through an RPC frame code library;
Finally, the binary byte stream is packetized into a first data packet according to a high bandwidth communication transport protocol.
Optionally, in an implementation manner of the embodiment of the present application, the encoding module 502 encodes the communication protocol data according to the target encoding format to obtain the first data packet, and the encoding module 502 may further perform the following operations:
Firstly, generating a JSON object according to communication protocol data through an RPC frame code library, wherein the JSON object is generated according to a JSON coding format, and the RPC frame code library is generated according to an IOT device communication interface;
Secondly, under the condition that the target coding format is determined to be the Protobuf coding format, converting the JSON object into the Protobuf object through an RPC frame code library, wherein the Protobuf object corresponds to the Protobuf coding format;
Thirdly, serializing the Protobuf object into a binary byte stream through an RPC frame code library;
finally, the binary byte stream is packetized into a first data packet according to a low bandwidth communication transport protocol.
Fig. 6 is a schematic structural diagram of a second internet of things IOT terminal in an embodiment of the present application.
As shown in fig. 6, in the embodiment of the present application, the second internet of things IOT terminal 60 includes: a detection module 601, an analysis module 602 and a decoding module 603;
when the detection module 601 detects that the IOT device communication interface receives a second data packet sent by a IOT terminal of the first internet of things, the analysis module 602 analyzes the second data packet according to a link protocol to obtain the first data packet, wherein the IOT device communication interface is generated based on an object model of the IOT terminal, the object model of the IOT terminal is defined based on an object model description language TSL, and the link protocol corresponds to a current transmission link layer;
the decoding module 603 decodes the first data packet according to a target coding format to obtain communication protocol data, where the target coding format is determined according to a transmission bandwidth of a current transmission link layer.
Optionally, in an implementation manner of the embodiment of the present application, the target encoding format includes a JSON encoding format or a Protobuf encoding format;
When the transmission bandwidth of the current transmission link layer is high bandwidth, the target coding format is a JSON coding format;
When the transmission bandwidth of the current transmission link layer is low bandwidth, the target coding format is a Protobuf coding format.
Optionally, in an implementation manner of the embodiment of the present application, the decoding module 603 decodes the first data packet according to the target encoding format to obtain the communication protocol data, and the decoding module 603 may specifically perform the following operations:
Firstly, when the transmission bandwidth of the current transmission link layer is high bandwidth, analyzing a first data packet into a binary byte stream according to a high bandwidth communication transmission protocol;
secondly, the binary byte stream is deserialized into a JSON object through an RPC frame code library, the RPC frame code library is generated according to an IOT device communication interface, and the JSON object corresponds to a JSON coding format;
finally, decoding the JSON object through the RPC frame code library to obtain communication protocol data.
Optionally, in an implementation manner of the embodiment of the present application, the decoding module 603 decodes the first data packet according to the target encoding format to obtain the communication protocol data, and the decoding module 603 may further perform the following operations:
Firstly, when the transmission bandwidth of the current transmission link layer is low bandwidth, analyzing a first data packet into a binary byte stream according to a low bandwidth communication transmission protocol;
Secondly, the binary byte stream is deserialized into a Protobuf object through an RPC frame code library, wherein the RPC frame code library is generated according to an IOT device communication interface, and the Protobuf object corresponds to a Protobuf coding format;
Thirdly, converting the Protobuf object into a JSON object through an RPC frame code library;
finally, decoding the JSON object through the RPC frame code library to obtain communication protocol data.
In summary, in the IOT terminal in the embodiment of the present application, because the IOT device communication interface is defined uniformly for a TSL-defined object model of the IOT device, the uniform IOT device communication interface is compatible with different coding formats to perform coding transmission on the data packet, so that the service expansion and service implementation capabilities of the IOT device can be improved.
Furthermore, the IOT terminal uses an RPC frame code library, which is generated according to the IOT device communication interface, to determine that the target coding format is a Protobuf or JSON coding mode according to the transmission bandwidth of the current transmission link. Because the unified communication interface of the IOT equipment can be compatible with different coding formats to carry out coding transmission on the data packet, the RPC frame code library generated based on the communication interface of the IOT equipment can be compatible with multi-terminal equipment and multiple programming languages, the maintainability of a developer on the communication interface of the IOT equipment can be improved, and the development period of project codes can be shortened.
The specific manner in which the various modules perform the operations described above with respect to the apparatus of the fig. 5 or fig. 6 embodiment have been described in detail with respect to the method embodiment and will not be described in detail herein.
Fig. 7 is another schematic structural diagram of the IOT terminal in the first internet of things according to an embodiment of the present application.
As shown in fig. 7, in an embodiment of the present application, the first IOT terminal 70 includes a memory 701 and a processor 702. The memory has stored thereon executable code which, when executed by the processor, causes the processor to perform the method of any of the embodiments described above.
The Processor 702 may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (DIGITAL SIGNAL Processor, DSP), application SPECIFIC INTEGRATED Circuit (ASIC), field-Programmable gate array (Field-Programmable GATE ARRAY, FPGA) or other Programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Memory 701 may include various types of storage units, such as system memory, read Only Memory (ROM), and persistent storage. Where the ROM may store static data or instructions that are required by the processor 702 or other modules of the computer. The persistent storage may be a readable and writable storage. The persistent storage may be a non-volatile memory device that does not lose stored instructions and data even after the computer is powered down. In some embodiments, the persistent storage device employs a mass storage device (e.g., magnetic or optical disk, flash memory) as the persistent storage device. In other embodiments, the persistent storage may be a removable storage device (e.g., diskette, optical drive). The system memory may be a read-write memory device or a volatile read-write memory device, such as dynamic random access memory. The system memory may store instructions and data that are required by some or all of the processors at runtime. Furthermore, memory 701 may comprise any combination of computer-readable storage media including various types of semiconductor memory chips (DRAM, SRAM, SDRAM, flash memory, programmable read-only memory), magnetic and/or optical disks may also be employed. In some embodiments, memory 701 may include a readable and/or writable removable storage device such as a Compact Disc (CD), a read-only digital versatile disc (e.g., DVD-ROM, dual layer DVD-ROM), a read-only blu-ray disc, an super-density optical disc, a flash memory card (e.g., SD card, min SD card, micro-SD card, etc.), a magnetic floppy disk, and so forth. The computer readable storage medium does not contain a carrier wave or an instantaneous electronic signal transmitted by wireless or wired transmission.
The memory 701 has stored thereon executable code that, when processed by the processor 702, can cause the processor 702 to perform some or all of the methods described above.
Fig. 8 is a schematic diagram of another architecture of a second internet of things IOT terminal in an embodiment of the present application.
As shown in fig. 8, second internet of things terminal 80 in an embodiment of the application includes a memory 801 and a processor 802. The memory has stored thereon executable code which, when executed by the processor, causes the processor to perform the method of any of the embodiments described above.
The processor 802 may be a CPU, but may also be other general purpose processors, DSP, ASIC, FPGA or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 801 may include various types of storage units such as system memory, read Only Memory (ROM), and persistent storage. Where the ROM may store static data or instructions that are required by the processor 802 or other modules of the computer. The persistent storage may be a readable and writable storage. The persistent storage may be a non-volatile memory device that does not lose stored instructions and data even after the computer is powered down. In some embodiments, the persistent storage device employs a mass storage device (e.g., magnetic or optical disk, flash memory) as the persistent storage device. In other embodiments, the persistent storage may be a removable storage device (e.g., diskette, optical drive). The system memory may be a read-write memory device or a volatile read-write memory device, such as dynamic random access memory. The system memory may store instructions and data that are required by some or all of the processors at runtime. Furthermore, memory 801 may include any combination of computer-readable storage media including various types of semiconductor memory chips (DRAM, SRAM, SDRAM, flash memory, programmable read-only memory), magnetic disks, and/or optical disks may also be employed. In some embodiments, memory 801 may include readable and/or writable removable storage devices such as Compact Discs (CDs), digital versatile discs (e.g., DVD-ROM, dual layer DVD-ROM), blu-ray discs read only, super-density discs, flash memory cards (e.g., SD cards, min SD cards, micro-SD cards, etc.), magnetic floppy disks, and the like. The computer readable storage medium does not contain a carrier wave or an instantaneous electronic signal transmitted by wireless or wired transmission.
The memory 801 has stored thereon executable code that, when processed by the processor 802, can cause the processor 802 to perform some or all of the methods described above.
Furthermore, the method according to the application may also be implemented as a computer program or computer program product comprising computer program code instructions for performing part or all of the steps of the above-described method of the application.
Or the application may also be embodied as a computer-readable storage medium (or machine-readable storage medium) having stored thereon executable code (or a computer program, or computer instruction code) which, when executed by a processor of an IOT terminal (or an electronic device, a server, etc.), causes the processor to perform some or all of the steps of the above-described method according to the application.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Those skilled in the art may implement the described functionality using different approaches for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. The software modules may be disposed in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
Finally, it is further noted that, in this document, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms include, comprise, or any other variation is intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be embodied essentially or in part or all of the technical solution or in part in the form of a software product stored in a storage medium, including instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present application.
The foregoing description of embodiments of the application has been presented for purposes of illustration and description, and is not intended to be exhaustive or limited to the embodiments disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the various embodiments described. The terminology used herein was chosen in order to best explain the principles of the embodiments, the practical application, or the improvement of technology in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein.

Claims (12)

1. The communication method of the Internet of things is characterized by comprising the following steps of:
the method comprises the steps that a first IOT terminal detects a sending request for calling an IOT equipment communication interface, wherein the sending request is used for indicating to send communication protocol data to a second IOT terminal, the IOT equipment communication interface is generated based on an IOT terminal object model, and the IOT terminal object model is defined based on an object model description language TSL;
Aiming at the sending request, the first IOT terminal encodes the communication protocol data according to a target encoding format to obtain a first data packet, wherein the target encoding format is determined by the first IOT terminal according to the transmission bandwidth of the current transmission link layer;
The first IOT terminal encapsulates the first data packet according to a link protocol, and generates an encapsulated second data packet, wherein the link protocol corresponds to the current transmission link layer;
and the first IOT terminal sends the second data packet to the second IOT terminal through the IOT equipment communication interface.
2. The internet of things communication method according to claim 1, wherein the target encoding format comprises JSON encoding format or Protobuf encoding format;
When the transmission bandwidth of the current transmission link layer is high bandwidth, the target coding format is the JSON coding format;
and when the transmission bandwidth of the current transmission link layer is low bandwidth, the target coding format is the Protobuf coding format.
3. The internet of things communication method according to claim 2, wherein the encoding the communication protocol data by the first IOT terminal according to the target encoding format to obtain a first data packet comprises:
the first IOT terminal generates a JSON object according to the communication protocol data through an RPC frame code library, wherein the JSON object is generated according to the JSON encoding format, and the RPC frame code library is generated according to the IOT device communication interface;
Under the condition that the target coding format is determined to be the JSON coding format, the first IOT terminal sequences the JSON object into a binary byte stream through the RPC frame code library;
and the first IOT terminal packages the binary byte stream into the first data packet according to a high-bandwidth communication transmission protocol.
4. The internet of things communication method according to claim 2, wherein the encoding the communication protocol data by the first IOT terminal according to the target encoding format to obtain a first data packet comprises:
The first IOT terminal generates a JSON object according to the communication protocol data through an RPC frame code library, wherein the JSON object is generated according to the JSON encoding format, and the RPC frame code library is generated according to the IOT device communication interface;
Under the condition that the target coding format is determined to be a Protobuf coding format, the first IOT terminal converts the JSON object into a Protobuf object through the RPC frame code library, wherein the Protobuf object corresponds to the Protobuf coding format;
The first IOT terminal sequences the Protobuf object into a binary byte stream through the RPC frame code library;
and the first IOT terminal packages the binary byte stream into the first data packet according to a low-bandwidth communication transmission protocol.
5. The communication method of the Internet of things is characterized by comprising the following steps of:
Under the condition that the second internet of things IOT terminal detects that an IOT device communication interface receives a second data packet sent by a first internet of things IOT terminal, the second IOT terminal analyzes the second data packet according to a link protocol to obtain a first data packet, wherein the IOT device communication interface is generated based on an IOT terminal object model, the IOT terminal object model is defined based on an object model description language TSL, and the link protocol corresponds to a current transmission link layer;
And the second IOT terminal decodes the first data packet according to a target coding format to obtain communication protocol data, wherein the target coding format is determined by the first IOT terminal according to the transmission bandwidth of the current transmission link layer.
6. The internet of things communication method according to claim 5, wherein the target encoding format comprises JSON encoding format or Protobuf encoding format;
When the transmission bandwidth of the current transmission link layer is high bandwidth, the target coding format is the JSON coding format;
and when the transmission bandwidth of the current transmission link layer is low bandwidth, the target coding format is the Protobuf coding format.
7. The internet of things communication method of claim 6, wherein the second IOT terminal decodes the first data packet according to a target encoding format to obtain communication protocol data, comprising:
When the transmission bandwidth of the current transmission link layer is high bandwidth, the second IOT terminal analyzes the first data packet into a binary byte stream according to a high bandwidth communication transmission protocol;
The second IOT terminal deserializes the binary byte stream into a JSON object through an RPC frame code library, the RPC frame code library is generated according to the IOT device communication interface, and the JSON object corresponds to a JSON encoding format;
And the second IOT terminal decodes the JSON object through the RPC frame code library to obtain the communication protocol data.
8. The internet of things communication method of claim 6, wherein the second IOT terminal decodes the first data packet according to a target encoding format to obtain communication protocol data, comprising:
when the transmission bandwidth of the current transmission link layer is low bandwidth, the second IOT terminal analyzes the first data packet into a binary byte stream according to a low bandwidth communication transmission protocol;
The second IOT terminal deserializes the binary byte stream into a Protobuf object through an RPC frame code library, wherein the RPC frame code library is generated according to the IOT device communication interface, and the Protobuf object corresponds to a Protobuf coding format;
The second IOT terminal converts the Protobuf object into a JSON object through the RPC frame code library;
And the second IOT terminal decodes the JSON object through the RPC frame code library to obtain the communication protocol data.
9. The IOT terminal is characterized in that the IOT terminal is a first IOT terminal and comprises: the device comprises a detection module, a coding module, a packaging module and a communication module;
The detection module detects a sending request for calling an IOT equipment communication interface, wherein the sending request is used for indicating to send communication protocol data to a second internet of things IOT terminal, the IOT equipment communication interface is generated based on an object model of the IOT terminal, and the object model of the IOT terminal is defined based on an object model description language TSL;
aiming at the sending request, the coding module codes the communication protocol data according to a target coding format to obtain a first data packet, wherein the target coding format is that the first IOT terminal determines according to the transmission bandwidth of the current transmission link layer;
The encapsulation module encapsulates the first data packet according to a link protocol, and generates an encapsulated second data packet, wherein the link protocol corresponds to the current transmission link layer;
And the communication module sends the second data packet to the second IOT terminal through the IOT equipment communication interface.
10. The IOT terminal is characterized in that the IOT terminal is a second IOT terminal, and comprises: the device comprises a detection module, an analysis module and a decoding module;
When the detection module detects that an IOT equipment communication interface receives a second data packet sent by a first IOT terminal, the analysis module analyzes the second data packet according to a link protocol to obtain a first data packet, wherein the IOT equipment communication interface is generated based on an object model of the IOT terminal, the object model of the IOT terminal is defined based on an object model description language TSL, and the link protocol corresponds to a current transmission link layer;
The decoding module decodes the first data packet according to a target coding format to obtain communication protocol data, wherein the target coding format is determined by the first IOT terminal according to the transmission bandwidth of the current transmission link layer.
11. The IOT terminal is characterized by comprising:
A processor and a memory;
The memory having executable code stored thereon which, when executed by the processor, causes the processor to perform the internet of things communication method of any of claims 1-4; or when executed by the processor, causes the processor to perform the internet of things communication method of any of claims 5-8.
12. A computer readable storage medium having executable code stored thereon, which when executed by a processor of an electronic device, causes the processor to perform the internet of things communication method of any of claims 1-4; or when executed by a processor of an electronic device, causes the processor to perform the internet of things communication method of any of claims 5-8.
CN202210549525.5A 2022-05-20 2022-05-20 Internet of things communication method, related terminal and storage medium Active CN114979296B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210549525.5A CN114979296B (en) 2022-05-20 2022-05-20 Internet of things communication method, related terminal and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210549525.5A CN114979296B (en) 2022-05-20 2022-05-20 Internet of things communication method, related terminal and storage medium

Publications (2)

Publication Number Publication Date
CN114979296A CN114979296A (en) 2022-08-30
CN114979296B true CN114979296B (en) 2024-05-10

Family

ID=82986027

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210549525.5A Active CN114979296B (en) 2022-05-20 2022-05-20 Internet of things communication method, related terminal and storage medium

Country Status (1)

Country Link
CN (1) CN114979296B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117395142B (en) * 2023-12-12 2024-03-12 江西飞尚科技有限公司 Object model abstract control method, system, storage medium and computer
CN117978668B (en) * 2024-04-01 2024-06-04 北京大学 Heterogeneous Internet of things information transmission method and device and nonvolatile storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110073301A (en) * 2017-08-02 2019-07-30 强力物联网投资组合2016有限公司 The detection method and system under data collection environment in industrial Internet of Things with large data sets
CN112068817A (en) * 2020-08-19 2020-12-11 天翼物联科技有限公司 Code generation method, system, device and medium for terminal side of Internet of things
CN112235326A (en) * 2020-12-15 2021-01-15 长沙树根互联技术有限公司 Internet of things equipment data analysis method and device and electronic equipment
CN113364882A (en) * 2021-06-25 2021-09-07 京东方科技集团股份有限公司 Internet of things terminal, data transmission method thereof and related equipment
CN113391791A (en) * 2020-03-12 2021-09-14 腾讯科技(深圳)有限公司 Data processing method, device and storage medium
CN214429551U (en) * 2021-03-29 2021-10-19 南京工程学院 Internet of things data acquisition terminal

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10324773B2 (en) * 2015-09-17 2019-06-18 Salesforce.Com, Inc. Processing events generated by internet of things (IoT)
US20200225655A1 (en) * 2016-05-09 2020-07-16 Strong Force Iot Portfolio 2016, Llc Methods, systems, kits and apparatuses for monitoring and managing industrial settings in an industrial internet of things data collection environment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110073301A (en) * 2017-08-02 2019-07-30 强力物联网投资组合2016有限公司 The detection method and system under data collection environment in industrial Internet of Things with large data sets
CN113391791A (en) * 2020-03-12 2021-09-14 腾讯科技(深圳)有限公司 Data processing method, device and storage medium
CN112068817A (en) * 2020-08-19 2020-12-11 天翼物联科技有限公司 Code generation method, system, device and medium for terminal side of Internet of things
CN112235326A (en) * 2020-12-15 2021-01-15 长沙树根互联技术有限公司 Internet of things equipment data analysis method and device and electronic equipment
CN214429551U (en) * 2021-03-29 2021-10-19 南京工程学院 Internet of things data acquisition terminal
CN113364882A (en) * 2021-06-25 2021-09-07 京东方科技集团股份有限公司 Internet of things terminal, data transmission method thereof and related equipment

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Energy efficient method of data transmission in a heterogeneous network of the Internet of Things for remote areas;I.I.Lysogor;《2019 International Siberian Conference on Control and Communications》;20190606;全文 *
智慧管廊系统服务调用中间件的设计与实现;李腾飞;《中国优秀硕士学位论文全文数据库信息科技辑》;20210515;全文 *

Also Published As

Publication number Publication date
CN114979296A (en) 2022-08-30

Similar Documents

Publication Publication Date Title
CN114979296B (en) Internet of things communication method, related terminal and storage medium
JP7284528B2 (en) Transmission method and server of OPC UA message by CoAP
CN111818136B (en) Data processing method, device, electronic equipment and computer readable medium
TWI699988B (en) Information processing method, device, equipment and system
US10817460B2 (en) RDMA data sending and receiving methods, electronic device, and readable storage medium
CN110324405B (en) Message sending method, device, system and computer readable storage medium
CN109217983B (en) Industrial Internet of things operation terminal communication protocol design method
US8375399B2 (en) Method, apparatus and computer program to perform dynamic selection of serialization processing schemes
CN109327435B (en) Media resource acquisition method and device and gateway equipment
CN114020272A (en) Serialized encoding and decoding methods and devices and electronic equipment
CN111930531A (en) Data processing method, data production method, data consumption method, data production device, data consumption device and data consumption medium
CN107040613B (en) Message transmission method and system
CN111431770A (en) Terminal protocol consistency test system and method for 5G communication
CN113992644B (en) Internet of things system based on no-service technology and data processing method thereof
US8190975B2 (en) Transparent envelope for XML messages
CN113595966A (en) Serial port communication control, configuration and test method and device, electronic equipment and storage medium
CN112953547A (en) Data processing method, device and system
CN107483399B (en) Information packaging method and device in remote procedure call
CN113918245A (en) Data calling method, device, equipment and computer readable storage medium
CN105681892A (en) Differential data transmission method, device and system
CN113133107B (en) Method and device for synchronizing information
CN111800510A (en) Data processing method and device based on long connection between nodes and readable storage medium
CN114172897B (en) Method and system for transmitting files of PC (personal computer) end and Android end
CN113542412B (en) Data transmission method, device, electronic equipment and storage medium
CN101420768B (en) Adaptive parsing method for network management monitoring protocol of repeater

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