Data communication method and system of Internet of Things, and electronic equipment
By adopting a data communication method with a custom data format in IoT devices, the device development process of the ZigBee protocol stack is simplified, the development difficulty problem caused by the complexity of the protocol in the existing technology is solved, and the development efficiency is improved.
Patent Information
- Application Number
- CN202510246800.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-03
- Publication Date
- 2025-06-03
AI Technical Summary
The existing ZigBee protocol stack is complex, which leads to the need to transplant ZCL documents when developing devices, which increases the learning time cost and development difficulty.
Provide a data communication method applied to the Internet of Things, which simplifies the device development process by defining the load header and data part of a custom data format, parsing and executing command operations to realize business functions.
It reduces the learning cost and development difficulty of developers. Through custom function identification and effective data fields, it is flexibly set according to development needs, improving the efficiency of equipment development.
Smart Images

Figure CN120091076A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Internet of Things technologies, and in particular, to a data communication method, system, and electronic device applied to the Internet of Things. Background Art
[0002] In wireless communication protocols, taking the ZigBee protocol as an example, ZCL (Zigbee Cluster Library Specification) is part of the ZigBee protocol stack and defines the application layer communication between devices. ZCL ensures interoperability between devices of different manufacturers through standardized clusters and attributes.
[0003] All standard clusters, attributes, commands, and device types are described in detail in the ZCL specification document. However, this also makes the entire protocol relatively complex. If a device compliant with the ZCL specification document (such as a Light device) needs to be developed on another protocol stack (such as the Bluetooth protocol stack), all clusters and attributes related to the lamp in the ZCL document need to be ported. For a developer without Zigbee-related knowledge and development experience, it takes a lot of time to understand some terms and definitions in the ZCL specification document before development, and the protocol porting is difficult, which greatly increases the learning time cost and development difficulty.
[0004] Therefore, there is an urgent need to propose a simple data communication method to solve the problems of complex existing protocol content and difficult device development. Summary of the Invention
[0005] The purpose of this application is to provide a data communication method for the Internet of Things that is convenient for developers to understand, port, and develop devices.
[0006] In a first aspect, this application provides a data communication method applied to the Internet of Things, which is applied to a receiving-end device. The method includes:
[0007] In response to receiving a message sent by a sending-end device, parsing and obtaining the payload in the message, where the data format of the payload is a custom data format, and the payload includes a payload header and a data part;
[0008] Parsing the payload to obtain at least one data structure in the command identification field and the data part field in the payload header. The data structure includes at least a function identification field and a valid data field. The command identification field indicates the command operation to be executed by the receiving-end device, the function identification field indicates the service function implemented by the data structure, and the command operation is related to the service function;
[0009] Execute corresponding command operations according to the command identification field, function identification field, and valid data field to implement corresponding business functions.
[0010] Furthermore, execute corresponding command operations according to the command identification field and valid data field to implement corresponding business functions, including:
[0011] Determine the command operation according to the value of the command identification field, and the command operation is one of the following: read request command, read request response command, write request command, write request response command, execute command, execute response command, report command;
[0012] Determine the corresponding business function according to the value of the function identification field, and implement the corresponding business function based on the command operation.
[0013] Furthermore, the business functions include: device and gateway function information, group operations, scenario operations, and file downloads. Among them, the device and gateway function information includes device ID, device MAC address, device version number, device type, device function description, device capability value, device logical address, gateway MAC address. Group operations include adding a group, deleting a group, querying the group list, and querying the number of groups. Scenario operations include creating a scenario action, creating a scenario group, deleting a scenario and the corresponding scenario group, and executing a scenario. File downloads include file download, file download response, file request, file request response, and download file status report.
[0014] Furthermore, the payload header also includes a service identification field, a sequence number field, a frame control field, a status field, and a data structure quantity field. The service identification field indicates the service type sent or received by the receiving device. The sequence number field indicates the sequence number of the operation. The frame control field indicates whether a default response is required. The status field indicates the status of the command operation indicated by the command identification field. The data structure quantity field indicates the number of data structures.
[0015] Furthermore, the status of the command operation indicated by the status field and the command identification field includes:
[0016] If the value of the command identification field indicates one of the following statuses: read request command, write request command, execute command, the value of the status field is set to a fixed value;
[0017] If the value of the command identification field indicates one of the following statuses: read request response command, write request response command, execute response command, when the value of the status field is 0, it indicates that the response command is successful. When the value of the status field is non-zero, determine the corresponding response error type according to different values. Among them, the response error types include not supported, not writable, not executable, not readable, data format exception, memory shortage, and resource shortage;
[0018] If the value of the command identification field indicates that the reporting type corresponding to the status of the reporting command is determined according to different values, where the reporting types include: normal operation reporting, power-on reporting, disconnection and reconnection reporting, periodic heartbeat reporting, local scenario execution reporting, local group execution reporting, and network formation success reporting.
[0019] Furthermore, the data structure further includes a type field and a length field. The type field indicates the type of the data structure, and the length field indicates the number of bytes of the valid data field.
[0020] Furthermore, the function identification field is used to indicate key exchange, and the key exchange includes:
[0021] The gateway generates a first message and sends it to the receiving device. Among them, the payload in the first message includes a payload header and a data structure. The value of the command identification field in the payload header indicates an execution command. The function identification field of the data structure is set to a first numerical value, and the first numerical value indicates the key exchange function. The valid data field of the data structure includes the public key of the gateway;
[0022] The receiving device parses the first message, generates a first shared key based on the obtained public key of the gateway and the private key of the receiving device itself, and generates a first response message and sends it to the gateway. Among them, the payload in the first response message includes a payload header and a data structure. The value of the command identification field in the payload header indicates the executed response command. The function identification field of the data structure is set to a first numerical value, and the first numerical value indicates the key exchange function. The valid data field of the data structure includes the public key of the receiving device;
[0023] The gateway parses the first response message, generates a second shared key based on the obtained public key of the receiving device and the private key of the gateway itself, generates a link key based on the first shared key and the second shared key, and generates a second message to the receiving device. The payload in the second message includes a payload header and a data structure. The value of the command identification field in the payload header indicates an execution command. The function identification field of the data structure is set to a second numerical value, and the second numerical value indicates the key update function. The valid data field of the data structure includes the link key encrypted with the second shared key;
[0024] The receiving device parses the second message, decrypts the encrypted link key using the first shared key to obtain the decrypted link key, and generates a second response message. Among them, the payload in the second response message includes a payload header and a data structure. The value of the command identification field in the payload header indicates the executed response command. The function identification field of the data structure is set to a second numerical value, and the second numerical value indicates the key update function. The valid data field of the data structure includes the response information for successfully obtaining the link key.
[0025] Further, the key exchange further includes:
[0026] The valid data field of the data structure in the second message further includes a first count value, and the first count value is used to indicate the number of times the gateway initiates the key exchange;
[0027] The valid data field of the data structure in the second response message further includes a second count value, and the second value is used to indicate the number of times the receiving device responds to the key exchange;
[0028] The gateway receives the second response message, obtains and stores the second count value in the second response message, performs a subtraction operation on the second count value and the second count value received last time to obtain a first difference. If the first difference is less than a threshold, it is determined that the receiving device is a legal device; otherwise, the gateway reinitiates the key exchange process;
[0029] The receiving device receives the second message, obtains and stores the first count value in the second message, performs a subtraction operation on the first count value and the first count value received last time to obtain a second difference. If the second difference is less than the threshold, it is determined that the count is abnormal and the gateway is notified.
[0030] In a second aspect, the present application further provides a data communication method applied to the Internet of Things, which is applied to a sending device, and the method includes:
[0031] Generate a message, the message includes a payload, wherein the data format of the payload is a custom data format, the payload includes a payload header and a data part, the payload header at least includes a command identification field, and the command identification field indicates the command operation to be performed by the receiving device. The data part field includes at least one data structure, and the data structure at least includes a function identification field and a valid data field. The function identification field indicates the service function implemented by the data structure, and the command operation is related to the service function;
[0032] Send the message to the receiving device.
[0033] In a third aspect, the present application further provides a receiving device applied to the Internet of Things, and the device includes:
[0034] A first parsing module, configured to, in response to receiving a message sent by a sending device, parse and obtain the payload in the message, wherein the data format of the payload is a custom data format, and the payload includes a payload header and a data part;
[0035] A second parsing module, configured to parse the payload, obtain the command identification field in the payload header and at least one data structure in the data part field, and the data structure at least includes a function identification field and a valid data field, wherein the command identification field indicates the command operation to be performed by the receiving device, and the function identification field indicates the service function implemented by the data structure, and the command operation is related to the service function;
[0036] An execution module, configured to perform corresponding command operations according to a command identification field, a function identification field, and a valid data field, so as to implement corresponding service functions.
[0037] In a fourth aspect, the present application further provides a sending device, which is applied to the Internet of Things. The device includes:
[0038] A generation module, configured to generate a message, where the message includes a payload. The data format of the payload is a custom data format. The payload includes a payload header and a data part. The payload header at least includes a command identification field, and the command identification field indicates a command operation to be performed by the receiving device. The data part field includes at least one data structure, and the data structure at least includes a function identification field and a valid data field. The function identification field indicates a service function implemented by the data structure, and the command operation is related to the service function.
[0039] A sending module, configured to send the message to the receiving device.
[0040] In a fifth aspect, the present application further provides a data communication system applied to the Internet of Things. The system includes the receiving device in the third aspect and the sending device in the fourth aspect.
[0041] In the present application, by setting a data part field that can be customized, during the development process, by rewriting the data structure in the data part field, the function identification in the data structure corresponds to the valid data field. When the function identification and the valid data field in the valid data field are determined based on the command identification field, corresponding command operations are performed to implement corresponding service functions. It can reduce the learning cost of developers, and since the function identification and the valid data field can be customized according to development requirements, the development difficulty in the device development process is reduced. Description of the Drawings
[0042] Figure 1 is the first flowchart of the data communication method for the Internet of Things provided by the embodiment of the present application;
[0043] Figure 2 is a schematic diagram of the payload header and the data part field provided by the embodiment of the present application;
[0044] Figure 3 is the second flowchart of the data communication method for the Internet of Things provided by the embodiment of the present application;
[0045] Figure 4 is the first flowchart of the process of key exchange provided by the embodiment of the present application;
[0046] Figure 5It is the second flowchart of the key exchange process provided by the embodiments of the present application;
[0047] Figure 6 It is the third flowchart of the data communication method for the Internet of Things provided by the embodiments of the present application;
[0048] Figure 7 It is a schematic diagram of a receiving end device provided by the embodiments of the present application;
[0049] Figure 8 It is a schematic diagram of a sending end device provided by the embodiments of the present application. Detailed implementation manners
[0050] The following will describe the present application in detail in conjunction with the specific implementation manners shown in the drawings. However, these implementation manners do not limit the present application, and any structural, method, or functional transformation made by those of ordinary skill in the art based on these implementation manners is included in the protection scope of the present application.
[0051] In this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the phrase "including a..." does not exclude the existence of additional identical elements in the process, method, article or device including the element.
[0052] Please refer to Figure 1 , in a first aspect, the present application provides a data communication method applied to the Internet of Things. This method is applied to a receiving end device and specifically includes the following steps:
[0053] S101: In response to receiving a message sent by a sending end device, parse and obtain the payload in the message. Among them, the data format of the payload is a custom data format, and the payload includes a payload header and a data part.
[0054] Exemplarily, the sending end device includes but is not limited to a mobile terminal and a fixed terminal. For example, smart home devices (gateways, lights, air conditioners, etc.) receive messages sent by a mobile terminal and parse the received messages to obtain the payload (Aps payload) in the messages.
[0055] S102: Analyze the payload to obtain at least one data structure in the command identification field and the data part field in the payload header. The data structure includes at least a function identification field and a valid data field. The command identification field indicates the command operation to be performed by the receiving device. The function identification field indicates the service function implemented by the data structure, and the command operation is related to the service function.
[0056] See Figure 2 , taking the APS communication frame format as an example, the payload header includes CMD (command identification field, indicating the operation type of the data frame). The data structure includes Dp value list / Dpid list (data structure, a set of values of multiple data points / a set of multiple data point IDs). Customize the corresponding relationship between the command identification field and the function identification field and the valid data field in the data structure. When responding to the message sent by the sending device, the receiving device determines the service function implemented by the data structure indicated by the function identification field based on the command identification field.
[0057] S103: According to the command identification field, the function identification field, and the valid data field, perform the corresponding command operation to implement the corresponding service function.
[0058] Through the above method, during the development process, by rewriting the data structure in the data part field, the function identification in the data structure corresponds to the valid data field. When the function identification and the valid data field are determined based on the command identification field, perform the corresponding command operation to implement the corresponding service function. It can reduce the learning cost of developers, and since the function identification and the valid data field can be customized according to the development requirements, the development difficulty in the device development process is reduced.
[0059] For example Figure 3 As shown, as an implementation method, during the process of performing the corresponding command operation according to the command identification field and the valid data field to implement the corresponding service function, it specifically includes the following steps:
[0060] S1031: Determine the command operation according to the value of the command identification field. The command operation is one of the following: read request command, read request response command, write request command, write request response command, execute command, execute response command, report command.
[0061] Exemplarily, the command identification field is shown in the first column of the following table, and each column of the command identification field corresponds to a different command operation.
[0062]
[0063] All business functions are filled within the valid data fields, and the data that can be read and written is presented in the form of Dp. For example: Writing Dp: Writing Dp means modifying a certain Dp value and performing the corresponding physical effect; Reading Dp: Dp has the meaning of storage status and returns the Dp value; Executing Dp: This Dp itself has no storage unit and is not readable. The Dp itself is equivalent to a command; Reporting Dp: Status quantities and instantaneous quantities can be reported.
[0064] See Figure 2 , as an implementation method, the payload header also includes a service identification field (Dp data id), a sequence number field (Dp data seq), a frame control field (Dp frame control), a status field (Status), and a quantity field of the data structure (Dp numbers). The service identification field indicates the service type sent or received by the receiving device. The sequence number field indicates the sequence number of the operation. The frame control field indicates whether a default response is required. The status field commands the status of the command operation indicated by the identification field. The quantity field of the data structure indicates the number of data structures.
[0065] Among them, several fields in the payload header are in a custom data format. Taking the status field as an example, the status of the command operation indicated by the status field and the command identification field includes:
[0066] If the value of the command identification field indicates one of the following statuses: read request command, write request command, execute command, the value of the status field is set to a fixed value.
[0067] If the value of the command identification field indicates one of the following statuses: read request response command, write request response command, execute response command, when the value of the status field is 0, it indicates that the response command is successful. When the value of the status field is non-zero, the corresponding response error type is determined according to different values. Among them, the response error types include not supported, not writable, not executable, not readable, data format exception, memory shortage, resource shortage.
[0068]
[0069]
[0070] For the response command in the status field, the specific meaning represented when the value of the status field is non-zero is shown in the following error code table:
[0071] Error code Explanation 0x00 Success 0x01 Dp not supported 0x02 Dp not writable 0x03 Dp not executable 0x04 Dp not readable 0x05 Data format exception 0x06 Insufficient memory 0x07 Insufficient resources
[0072] If the value of the command identification field indicates that the reporting type corresponding to the status of the reporting command is determined according to different values, where the reporting types include: normal operation reporting, power-on reporting, disconnection and reconnection reporting, timed heartbeat reporting, local scenario execution reporting, local group execution reporting, and successful network formation reporting.
[0073] Exemplarily, the value of the command identification field can refer to the reporting reason code table in the following table:
[0074]
[0075]
[0076] S1032: Determine the corresponding service function according to the value of the function identification field, and implement the corresponding service function based on the command operation.
[0077] Exemplarily, the service functions include: device and gateway function information, group operations, scenario operations, and file downloads.
[0078] Among them, the device and gateway function information includes device ID, device MAC address, device version number, device type, device function description, device capability value, device logical address, and gateway MAC address.
[0079] Group operations include adding a group, deleting a group, querying the group list, and querying the number of groups.
[0080] Scenario operations include creating a scenario action, creating a scenario group, deleting a scenario and the corresponding group of that scenario, and executing a scenario.
[0081] File downloads include file download, file download response, file request, file request response, and download file status reporting.
[0082] In the embodiment of the present application, the data structure further includes a type field (Dp type) and a length field (len). The type field indicates the type of the data structure, and the length field indicates the number of bytes of the valid data field.
[0083] Exemplarily, taking a data structure as an example, the service function corresponding to this data structure represents device and gateway function information. Its function identification field can be custom-set according to development requirements. The data structure is at least composed of a function identification field (Dpid), a length field (len), a type field (Dp type), and a valid data field (Value). Specifically, refer to the following comparison table of service functions and data structures:
[0084]
[0085]
[0086]
[0087]
[0088] It should be noted that the above are only the service functions corresponding to the device and gateway function information. For group operations, scenario operations, and file downloads, the function identification field (Dp id) can also be customized. Just ensure that the values of the function identification fields (Dp id) defined on the device side and the gateway side are consistent and globally unique. Execute the corresponding service function according to the message containing the above-mentioned customized function identification field (Dp id) sent by the sending end.
[0089] As Figure 4 shown, as an implementation method, the function identification field is used to indicate key exchange. The process of key exchange includes the following steps:
[0090] S201: The gateway generates a first message and sends it to the receiving device.
[0091] Among them, the payload in the first message includes a payload header and a data structure. The value of the command identification field in the payload header indicates the execution command. The function identification field of the data structure is set to a first value, and the first value indicates the key exchange function. The valid data field of the data structure includes the public key of the gateway.
[0092] S202: The receiving device parses the first message, generates a first shared key based on the obtained public key of the gateway and the private key of the receiving device itself, and generates a first response message and sends it to the gateway.
[0093] Among them, the payload in the first response message includes a payload header and a data structure. The value of the command identification field in the payload header indicates the executed response command. The function identification field of the data structure is set to a first value, and the first value indicates the key exchange function. The valid data field of the data structure includes the public key of the receiving device.
[0094] S203: The gateway parses the first response message, generates a second shared key based on the obtained public key of the receiving device and the private key of the gateway itself, generates a link key based on the first shared key and the second shared key, and generates a second message to the receiving device. The payload in the second message includes a payload header and a data structure. The value of the command identification field in the payload header indicates the execution command. The function identification field of the data structure is set to a second value, and the second value indicates the key update function. The valid data field of the data structure includes the link key encrypted with the second shared key.
[0095] S204: The receiving device parses the second message, decrypts the encrypted link key using the first shared key to obtain the decrypted link key, and generates a second response message.
[0096] Among them, the payload in the second response message includes a payload header and a data structure. The value of the command identifier field in the payload header indicates the response command to be executed. The function identifier field of the data structure is set to a second value, and the second value indicates the key update function. The valid data field of the data structure includes the response information for successfully obtaining the link key.
[0097] As Figure 5 shown, further, the key exchange further includes:
[0098] S301: The valid data field of the data structure in the second message further includes a first count value, and the first count value is used to indicate the number of times the gateway initiates the key exchange.
[0099] S302: The valid data field of the data structure in the second response message further includes a second count value, and the second value is used to indicate the number of times the receiving device responds to the key exchange.
[0100] S303: The gateway receives the second response message, obtains and stores the second count value in the second response message, performs a subtraction operation on the second count value and the second count value received last time to obtain a first difference. If the first difference is less than a threshold, it is determined that the receiving device is a legal device; otherwise, the gateway reinitiates the key exchange process.
[0101] S304: The receiving device receives the second message, obtains and stores the first count value in the second message, performs a subtraction operation on the first count value and the first count value received last time to obtain a second difference. If the second difference is less than the threshold, it is determined that the count is abnormal and the gateway is notified.
[0102] As Figure 6 shown, on the second aspect, the present application further provides a data communication method applied to the Internet of Things, which is applied to the sending device. The method includes:
[0103] S401: Generate a message, where the message includes a payload. Among them, the data format of the payload is a custom data format. The payload includes a payload header and a data part. The payload header at least includes a command identifier field, and the command identifier field indicates the command operation to be executed by the receiving device. The data part field includes at least one data structure, and the data structure at least includes a function identifier field and a valid data field. The function identifier field indicates the service function implemented by the data structure, and the command operation is related to the service function.
[0104] S402: Send the message to the receiving device.
[0105] AsFigure 7 As shown in the figure, in the third aspect, the present application also provides a receiving-end device, which is applied to the Internet of Things. The receiving-end device includes:
[0106] A first parsing module 11, configured to, in response to receiving a message sent by a sending-end device, parse and obtain the payload in the message, where the data format of the payload is a custom data format, and the payload includes a payload header and a data part.
[0107] A second parsing module 12, configured to parse the payload to obtain at least one data structure in the command identification field in the payload header and the data part field, and the data structure at least includes a function identification field and a valid data field, where the command identification field indicates the command operation to be executed by the receiving-end device, the function identification field indicates the service function implemented by the data structure, and the command operation is related to the service function.
[0108] An execution module 13, configured to execute a corresponding command operation according to the command identification field, the function identification field, and the valid data field to implement a corresponding service function.
[0109] In the fourth aspect, the present application also provides a sending-end device, which is applied to the Internet of Things. The sending-end device includes:
[0110] A generating module 21, configured to generate a message, where the message includes a payload, the data format of the payload is a custom data format, the payload includes a payload header and a data part, the payload header at least includes a command identification field, the command identification field indicates the command operation to be executed by the receiving-end device, the data part field includes at least one data structure, the data structure at least includes a function identification field and a valid data field, the function identification field indicates the service function implemented by the data structure, and the command operation is related to the service function.
[0111] A sending module 22, configured to send the message to the receiving-end device.
[0112] In the fifth aspect, the present application also provides a data communication system applied to the Internet of Things. The system includes the receiving-end device in the third aspect and the sending-end device in the fourth aspect.
[0113] Although the preferred embodiments of the present application have been disclosed for illustrative purposes, those of ordinary skill in the art will realize that various improvements, additions, and substitutions are possible without departing from the scope and spirit of the present application disclosed by the appended claims.
Claims
1. A data communication method applied to the Internet of Things, characterized in that: Applied to a receiving device, the method comprises: In response to receiving a message sent by a sending end device, parsing and acquiring a payload in the message, wherein the data format of the payload is a custom data format, and the payload includes a payload header and a data part; Parsing the payload, acquiring at least one data structure in a command identification field and a data part field in the payload header, wherein the data structure at least includes a function identification field and a valid data field, wherein the command identification field indicates a command operation to be performed by the receiving end device, and the function identification field indicates a service function implemented by the data structure, and the command operation is related to the service function; According to the command identification field, the function identification field and the valid data field, a corresponding command operation is performed to implement a corresponding business function.
2. The data communication method applied to the Internet of Things according to claim 1, characterized in that: According to the command identification field and the valid data field, a corresponding command operation is performed to implement a corresponding business function, including: Determine the command operation according to the value of the command identification field, the command operation being one of the following: a read request command, a read request response command, a write request command, a write request response command, an execute command, an execute response command, or a report command; The corresponding business function is determined according to the value of the function identification field, and the corresponding business function is implemented based on the command operation.
3. The data communication method applied to the Internet of Things as claimed in claim 2, characterized in that: The business functions include: device and gateway function information, group operations, scene operations and file downloads, wherein the device and gateway function information includes device ID, device MAC address, device version number, device type, device function description, device capability value, device logical address, gateway MAC address; the group operations include adding groups, deleting groups, querying group lists, and querying the number of groups; the scene operations include creating scene actions, creating scene groups, deleting scenes and corresponding groups of the scenes, and executing scenes; the file download includes file download, file download response, file request, file request response, and reporting of downloaded file status.
4. The data communication method applied to the Internet of Things as claimed in claim 2, characterized in that: The payload header also includes a service identification field, a sequence number field, a frame control field, a status field, and a data structure quantity field. The service identification field indicates the type of service sent or received by the receiving device, the sequence number field indicates the sequence number of the operation, the frame control field indicates whether a default response is required, the status field indicates the status of the command operation indicated by the command identification field, and the data structure quantity field indicates the number of the data structures.
5. The data communication method applied to the Internet of Things as claimed in claim 4, characterized in that: The status field indicates the status of the command operation indicated by the command identification field, including: If the value of the command identification field indicates one of the following states: a read request command, a write request command, or an execute command, the value of the status field is set to a fixed value; If the value of the command identification field indicates one of the following states: a read request response command, a write request response command, or an executed response command, when the value of the status field is 0, it indicates that the response command is successful, and when the value of the status field is non-0, the type of the corresponding response error is determined according to different values, wherein the response error types include unsupported, unwritable, unexecutable, unreadable, abnormal data format, insufficient memory, and insufficient resources; If the value of the command identification field indicates that the status of the reporting command is determined according to different values, the corresponding reporting type is determined, wherein the reporting types include: normal operation reporting, power-on reporting, disconnection and reconnection reporting, timed heartbeat reporting, local scene execution reporting, local group execution reporting, and networking success reporting.
6. The data communication method applied to the Internet of Things according to claim 1, characterized in that: The data structure further includes a type field and a length field, wherein the type field indicates the type of the data structure, and the length field indicates the number of bytes of the valid data field.
7. The data communication method applied to the Internet of Things according to claim 1, characterized in that: The function identification field is used to indicate a key exchange, and the key exchange includes: The gateway generates a first message and sends it to the receiving device, wherein the payload in the first message includes a payload header and a data structure, the value of the command identification field of the payload header indicates an execution command, the function identification field of the data structure is set to a first value, the first value indicates a key exchange function, and the valid data field of the data structure includes the public key of the gateway; The receiving device parses the first message, generates a first shared key based on the obtained public key of the gateway and the private key of the receiving device itself, and generates a first response message and sends it to the gateway, wherein the payload in the first response message includes a payload header and a data structure, the value of the command identification field of the payload header indicates the executed response command, the function identification field of the data structure is set to a first value, the first value indicates a key exchange function, and the valid data field of the data structure includes the public key of the receiving device; The gateway parses the first response message, generates a second shared key based on the acquired public key of the receiving end device and the private key of the gateway itself, generates a link key based on the first shared key and the second shared key, and generates a second message to the receiving end device, wherein the payload in the second message includes a payload header and a data structure, the value of the command identification field of the payload header indicates an execution command, the function identification field of the data structure is set to a second value, the second value indicates a key update function, and the valid data field of the data structure includes the link key encrypted by the second shared key; The receiving device parses the second message, uses the first shared key to decrypt the encrypted link key to obtain the decrypted link key, and generates a second response message, wherein the payload in the second response message includes a payload header and a data structure, the value of the command identification field of the payload header indicates the executed response command, the function identification field of the data structure is set to a second numerical value, the second numerical value indicates a key update function, and the valid data field of the data structure includes response information to the successful acquisition of the link key.
8. The data communication method applied to the Internet of Things according to claim 7, characterized in that: The key exchange further includes: The valid data field of the data structure in the second message further includes a first count value, where the first count value is used to indicate the number of times the gateway initiates key exchange; The valid data field of the data structure in the second response message further includes a second count value, where the second count value is used to indicate the number of times the receiving device responds to the key exchange; The gateway receives the second response message, obtains and stores the second count value in the second response message, performs a subtraction operation on the second count value and the second count value received last time to obtain a first difference value, and if the first difference value is less than a threshold value, determines that the receiving device is a legitimate device, otherwise, the gateway re-initiates the key exchange process; The receiving device receives the second message, obtains and stores the first count value in the second message, subtracts the first count value from the first count value received last time to obtain a second difference, and if the second difference is less than the threshold, determines that the count is abnormal, and notifies the gateway.
9. A data communication method applied to the Internet of Things, characterized in that: Applied to a transmitting device, the method comprises: Generate a message, the message including a payload, wherein the data format of the payload is a custom data format, the payload includes a payload header and a data part, the payload header includes at least a command identification field, the command identification field indicates a command operation to be performed by a receiving end device, the data part field includes at least one data structure, the data structure includes at least a function identification field and a valid data field, the function identification field indicates a service function implemented by the data structure, and the command operation is related to the service function; The message is sent to a receiving device.
10. A receiving device, characterized in that: Applied to the Internet of Things, the device includes: A first parsing module, configured to parse and obtain a payload in a message sent by a sending end device in response to receiving the message, wherein the data format of the payload is a custom data format, and the payload includes a payload header and a data part; A second parsing module is configured to parse the payload and obtain at least one data structure in a command identification field and a data part field in the payload header, wherein the data structure at least includes a function identification field and a valid data field, wherein the command identification field indicates a command operation to be performed by the receiving end device, and the function identification field indicates a service function implemented by the data structure, and the command operation is related to the service function; The execution module is used to execute the corresponding command operation according to the command identification field, function identification field and valid data field to realize the corresponding business function.
11. A transmitting end device, characterized in that: Applied to the Internet of Things, the device includes: A generating module, configured to generate a message, wherein the message includes a payload, wherein the data format of the payload is a user-defined data format, the payload includes a payload header and a data portion, the payload header includes at least a command identification field, the command identification field indicates a command operation to be performed by a receiving end device, the data portion field includes at least one data structure, the data structure includes at least a function identification field and a valid data field, the function identification field indicates a service function implemented by the data structure, and the command operation is related to the service function; The sending module is used to send the message to the receiving device.
12. A data communication system applied to the Internet of Things, characterized in that: The system comprises the receiving device as claimed in claim 10 and the sending device as claimed in claim 11.