A TCP device access method, system, terminal and storage medium

By enabling direct connection and data interaction between devices and the cloud through the TCP protocol, the complexity of device-cloud interaction is solved, and interaction efficiency, as well as the integrity and security of data transmission, are improved.

CN118714206BActive Publication Date: 2024-11-22深圳开鸿数字产业发展有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411187310.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-28
Publication Date
2024-11-22
Estimated Expiration
2044-08-28

AI Technical Summary

Technical Problem

In existing technologies, when devices with simple components and limited bandwidth interact with the cloud, the use of application layer protocols such as HTTP, MQTT, and CoAP is relatively complex, resulting in low interaction efficiency.

Method used

The device establishes a communication connection with the cloud via the TCP protocol, performs packet splitting, parsing, and format conversion, and controls the device to execute specified events, thus avoiding the complexity of application layer protocols.

Benefits of technology

It improves the efficiency of device-cloud interaction, simplifies the device access process, reduces reliance on protocol plugins, and enhances the integrity and security of data transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118714206B_ABST
    Figure CN118714206B_ABST
Patent Text Reader

Abstract

The present invention discloses a TCP device access method, system, terminal and storage medium, the method comprising: when receiving a TCP connection instruction, establishing a communication connection with a TCP device; when receiving message data uploaded by a TCP device, performing a sticking and unpacking process on the message data to obtain sticking and unpacking message data; performing a parsing process and a format conversion process on the sticking and unpacking message data to obtain target message data; performing a property change process on the attribute data in the target message data to obtain changed attribute data, and sending the changed attribute data to a TCP device to control the TCP device to complete a specified event according to the changed attribute data. The present invention adopts the lowest connection layer protocol TCP to build the communication interaction between the cloud and the device, solves the problems of large application layer protocol messages, complex interactions, and the need to embed protocol plug-ins into devices, and effectively improves the interaction efficiency between the cloud and the device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a TCP device access method, system, terminal and computer-readable storage medium. Background Art

[0002] At present, most IoT cloud platform devices access the Internet of Things through application layer protocols such as http (Hypertext Transfer Protocol), mqtt (Message Queuing Telemetry Transport), and coap (Constrained Application Protocol), which requires the device to have a cloud connection method for the protocol. However, the application layer protocol message is large and the interaction is complex. At the same time, an additional layer of protocol parsing plug-in or jar package (Java Archive File, java format package) is required to obtain the final report information of the device. The same is true for sending instructions from the cloud to the device. It needs to be converted into the standard format of the application layer protocol before the instruction can be sent.

[0003] For devices with simple components and limited traffic, the use of application layer protocols such as HTTP, MQTT, and CoAP in the process of interacting with the cloud is relatively complex, and the interaction efficiency between the end and the cloud is low.

[0004] Therefore, the prior art still needs to be improved and developed. Summary of the invention

[0005] The main purpose of the present invention is to provide a TCP device access method, system, terminal and computer-readable storage medium, aiming to solve the problem in the prior art that the application layer protocols such as HTTP, MQTT, CoAP, etc. are relatively complex when devices with simple components and limited traffic interact with the cloud, resulting in low interaction efficiency between the end and the cloud.

[0006] To achieve the above object, the present invention provides a TCP device access method, the TCP device access method comprising the following steps:

[0007] When receiving a TCP connection instruction, establishing a communication connection with a TCP device according to the TCP connection instruction;

[0008] When receiving the message data uploaded by the TCP device, the message data is subjected to a gluing and unpacking process to obtain gluing and unpacking message data;

[0009] The message data is parsed and format converted to obtain target message data;

[0010] Attribute data in the target message data are subjected to attribute change processing to obtain changed attribute data, and the changed attribute data are sent to the TCP device to control the TCP device to complete a specified event according to the changed attribute data.

[0011] Optionally, the TCP device access method, wherein when a TCP connection instruction is received, establishing a communication connection with the TCP device according to the TCP connection instruction, specifically includes:

[0012] When a TCP connection instruction is received, a TCP connection gateway is created according to the TCP connection instruction;

[0013] Set up port monitoring, and when receiving a connection request instruction from the TCP device, establish a communication connection with the TCP device according to the TCP connection gateway.

[0014] Optionally, in the TCP device access method, the sticky and split message data includes separated message data or segmented message data;

[0015] When the message data uploaded by the TCP device is received, the message data is subjected to a gluing and unpacking process to obtain the gluing and unpacking message data, which specifically includes:

[0016] When receiving the message data uploaded by the TCP device, obtaining each complete information in the message data, and setting a specific separator after each complete information;

[0017] The message data is subjected to complete information separation processing according to the specific separator to obtain the separated message data.

[0018] Optionally, the TCP device access method, wherein when the message data uploaded by the TCP device is received, it further includes:

[0019] A preset data length is set, and the message data is segmented according to the preset data length to obtain segmented message data.

[0020] Optionally, the TCP device access method, wherein the parsing and format conversion of the sticky and tearing message data to obtain the target message data, specifically includes:

[0021] Parsing the sticky and tearing message data to obtain first byte data in the sticky and tearing message data, and determining a data packet type of the sticky and tearing message data according to the first byte data;

[0022] The first format conversion process is performed on the pasted and disassembled message data according to the data packet type to obtain target message data that meets preset requirements.

[0023] Optionally, the TCP device access method, wherein the parsing and processing of the sticky and teardown message data further comprises:

[0024] Obtaining an identifier carried in the sticky / unsticky message data, and performing authentication processing on the TCP device according to the identifier;

[0025] Obtaining a preset identifier, and if the identifier is consistent with the preset identifier, determining that the TCP device authentication is passed;

[0026] If the identifier is inconsistent with the preset identifier, it is determined that the TCP device authentication fails, and the communication connection with the TCP device is disconnected.

[0027] Optionally, the TCP device access method, wherein the attribute data in the target message data is subjected to attribute change processing to obtain changed attribute data, and the changed attribute data is sent to the TCP device to control the TCP device to complete a specified event according to the changed attribute data, specifically includes:

[0028] Acquire the attribute data in the target message data, and perform attribute change processing on the attribute data according to preset requirements to obtain changed attribute data;

[0029] Performing a second format conversion process on the modified attribute data to obtain target attribute data;

[0030] The target attribute data is sent to the TCP device to control the TCP device to complete the specified event according to the target attribute data, and receive the specified event execution result uploaded by the TCP device.

[0031] In addition, to achieve the above object, the present invention further provides a TCP device access system, wherein the TCP device access system comprises:

[0032] A communication connection establishing module, configured to establish a communication connection with a TCP device according to the TCP connection instruction when a TCP connection instruction is received;

[0033] A packet sticking and unpacking processing module, configured to perform a packet sticking and unpacking process on the packet data when receiving the packet data uploaded by the TCP device, so as to obtain the packet sticking and unpacking packet data;

[0034] The parsing and conversion module is used to parse and convert the message data to obtain target message data;

[0035] The attribute change module is used to perform attribute change processing on the attribute data in the target message data to obtain changed attribute data, and send the changed attribute data to the TCP device to control the TCP device to complete a specified event according to the changed attribute data.

[0036] In addition, to achieve the above-mentioned purpose, the present invention also provides a terminal, wherein the terminal includes: a memory, a processor, and a TCP device access program stored in the memory and executable on the processor, and when the TCP device access program is executed by the processor, the steps of the TCP device access method described above are implemented.

[0037] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a TCP device access program, and when the TCP device access program is executed by a processor, the steps of the TCP device access method described above are implemented.

[0038] In the present invention, when a TCP connection instruction is received, a communication connection with a TCP device is established according to the TCP connection instruction; when message data uploaded by the TCP device is received, the message data is subjected to a sticking and unpacking process to obtain sticking and unpacking message data; the sticking and unpacking message data is subjected to a parsing process and a format conversion process to obtain target message data; the attribute data in the target message data is subjected to an attribute change process to obtain changed attribute data, and the changed attribute data is sent to the TCP device to control the TCP device to complete a specified event according to the changed attribute data. The present invention is suitable for device connections with simple components and limited traffic. By using the lowest connection layer protocol TCP to perform cloud operations on the device and receiving execution instructions issued by the cloud to complete the instruction execution of the device, the present invention effectively solves the problems of large application layer protocol messages, complex interactions, and the need to embed protocol plug-ins into devices, and greatly improves the interaction efficiency between TCP devices and the cloud. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 It is a flow chart of a preferred embodiment of the TCP device access method of the present invention;

[0040] Figure 2 It is a schematic diagram of the overall architecture of the interaction between the TCP device and the Internet of Things cloud platform of a preferred embodiment of the TCP device access method of the present invention;

[0041] Figure 3 It is a structural diagram of a preferred embodiment of the TCP device access system of the present invention;

[0042] Figure 4 It is a structural diagram of a preferred embodiment of the terminal of the present invention. DETAILED DESCRIPTION

[0043] In order to make the purpose, technical solution and advantages of the present invention clearer and more specific, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0044] At present, most IoT cloud platform devices access the Internet of Things through application layer protocols such as HTTP, MQTT, and CoAP, which requires the device to have a cloud connection method for the protocol. However, the application layer protocol message is large, the interaction is complex, and an additional layer of protocol parsing plug-in or jar (Java Archive File, java format package) package is required to obtain the final report information. The same is true for sending instructions from the cloud to the device, which needs to be converted into the specification of the application layer protocol before the instruction can be sent.

[0045] The present invention directly uses the lowest connection layer protocol TCP to perform cloud operations on the device and receive execution instructions from the cloud to complete the device's instruction issuance and execution, which can effectively solve complex operations such as large application layer protocol messages, complex interactions, and the need to embed protocol plug-ins into devices. It is suitable for connecting devices with simple components and limited traffic.

[0046] To solve the above problems, this method sets up a TCP device access method, which can connect TCP devices to the Internet of Things platform for command data interaction. The entire interaction process is mainly completed through TCP protocol connection, sticky unpacking processing, command parsing, device authentication, and execution and distribution.

[0047] The TCP device access method described in the preferred embodiment of the present invention is as follows: Figure 1 As shown, the TCP device access method includes the following steps:

[0048] Step S10: When a TCP connection instruction is received, a communication connection with a TCP device is established according to the TCP connection instruction.

[0049] The present invention determines that the target device is a device with simple components and limited traffic, and can use the TCP protocol for data transmission, thereby avoiding the problems of large messages, complex interactions, and the need to embed protocol plug-ins into devices in traditional data interaction using application layer protocols. Therefore, the present invention builds a TCP gateway based on the TCP protocol to achieve data interaction between TCP devices and the cloud.

[0050] Specifically, when a TCP connection instruction is received, a TCP connection gateway is created according to the TCP connection instruction; port monitoring is set, and when a connection request instruction of the TCP device is received, a communication connection is established with the TCP device according to the TCP connection gateway.

[0051] like Figure 2 As shown in the figure, if a TCP device wants to access the IoT platform, it must first create a TCP connection gateway in the cloud according to the TCP protocol. After the gateway is created, the cloud will open a port monitor and wait for the device to connect. For security reasons, it is necessary to specify the connection password in the gateway configuration. When the device reports a message for the first time, it carries the agreed password. The cloud parses and verifies the message information uploaded by the device. Establishing a long connection between the cloud and the TCP device can enable the cloud and the TCP device to maintain communication, which is conducive to the rapid response between the cloud and the TCP device.

[0052] Among them, TCP (Transmission Control Protocol) is a connection-oriented transport layer communication protocol based on byte streams. Before the client and the server communicate and exchange data, a TCP connection will be established before data can be transmitted to each other, and functions such as timeout retransmission, discarding duplicate data, checking data, and flow control are provided to ensure that data can be transmitted from one end to the other. At the same time, there are also requirements for network communication quality. The communication data format of the TCP protocol is defined as: the first 36 bytes are used to store the authentication ID, which is used for cloud platform authentication verification; when it is less than 36 bytes, the front end uses 0 to fill it; 4 bytes are used to store the message body length value; when it is less than 4 bytes, the front end uses 0 to fill it.

[0053] Step S20: When receiving the message data uploaded by the TCP device, the message data is subjected to a gluing and unpacking process to obtain gluing and unpacking message data, wherein the gluing and unpacking message data includes separated message data or segmented message data.

[0054] In the process of data interaction between the cloud and the device, the transmitted data is often stuck together or separated, which can easily lead to incomplete received data. In order to solve this problem, a strategy is set in the present invention to perform sticking and unpacking processing on the message data to ensure the integrity of the message information.

[0055] like Figure 2As shown, TCP packet sticking and unpacking are common problems in network programming, especially when using the TCP protocol for data transmission. They indicate that data is stuck together or unpacked during transmission. Among them, sticking and unpacking will occur in the process of sending data from the cloud platform to the device and in the process of uploading data from the device to the cloud platform. Generally, before communication, the end and the cloud will agree on the processing method. To solve this problem, the present invention sets four strategy modes to handle sticking and unpacking.

[0056] Specifically, when receiving the message data uploaded by the TCP device, each complete information in the message data is obtained, and a specific separator is set after each complete information; the message data is separated into complete information according to the specific separator to obtain the separated message data. Further, a preset data length is set, and the message data is segmented according to the preset data length to obtain the segmented message data.

[0057] The packet sticking and unpacking processing methods set in the present invention include four types: delimiter, custom script, fixed length and length field. 1. Set the delimiter: The sending end adds a specific delimiter at the end of each message, and the receiving end uses the delimiter to distinguish different messages. 2. Set the custom script: Use a specific script to handle the packet sticking and unpacking problem, which can be tested in the PipePayloadParserTest test class of the back-end code. 3. Set the fixed length: The sending end divides the data into fixed lengths, and the receiving end receives and splices them according to the same length. 4. Length field: Add a field indicating the length of the data in the data packet, which is usually stored in a fixed byte format. The receiving end first reads the length field, and then reads the data according to the length indicated by the length field.

[0058] Step S30: parse and convert the pasted and unpasted message data to obtain target message data.

[0059] After receiving the message data from the TCP device, the present invention needs to parse and convert the message data uploaded by the TCP device in order to enable it to be successfully received by the cloud.

[0060] Specifically, the pasted and disassembled message data is parsed to obtain the first byte data in the pasted and disassembled message data, and the data packet type of the pasted and disassembled message data is determined according to the first byte data; the pasted and disassembled message data is converted into a first format according to the data packet type to obtain target message data that meets preset requirements.

[0061] The corresponding sticky and tearing message data sent by the TCP device is obtained, the sticky and tearing message data is encoded and / or encrypted, and sent to the cloud. The encoding process can effectively improve the transmission efficiency and save the transmission time; at the same time, the encryption process can effectively improve the security and avoid the cracking and tampering of important data.

[0062] like Figure 2 As shown, after processing the sticky and unpacked packets, the command is parsed. In this method, TCP access distinguishes the type of message based on the first byte of the byte stream, and then converts it into a common command for the IoT cloud platform (the command parsing is distinguished based on the first byte. For example, if the first byte of the sticky and unpacked message data is 1, the cloud platform considers it to be an online operation; if the byte is 2, the cloud platform considers it to be a response message; if the byte is 3, the cloud platform considers it to be a device reporting attributes to the platform).

[0063] The following is an analysis of the meaning of the bytes in the byte stream during instruction parsing:

[0064] byte[] bytes = Buffer.buffer()

[0065] .appendByte(b) / / The first byte: type, 1 means online; according to the type agreed upon above

[0066] .appendLong(System.currentTimeMillis()) / / long is 8 bytes, indicating the timestamp

[0067] .appendShort(s) / / 2 bytes represent the message sequence

[0068] .appendShort(len) / / 2 bytes represent the length of the device id

[0069] .appendBytes(deviceId.getBytes()) / / Convert device id to bytes

[0070] .appendShort((short) token.length()) / / 2 bytes represent the length of the token. Because it is an online operation, token verification is required

[0071] .appendBytes(token.getBytes()) / / Convert token to bytes

[0072] .getBytes()

[0073] Furthermore, an identifier carried in the sticky / detachable message data is obtained, and the TCP device is authenticated according to the identifier; a preset identifier is obtained, and if the identifier is consistent with the preset identifier, it is determined that the TCP device authentication is successful; if the identifier is inconsistent with the preset identifier, it is determined that the TCP device authentication has failed, and the communication connection with the TCP device is disconnected.

[0074] In addition, if the TCP device has an abnormal network connection, the TCP device can cyclically send network requests to the cloud to restore the network connection to normal through repeated attempts to connect. Furthermore, when the number of reconnection requests is greater than 3, the time interval for the TCP device to send reconnection requests to the cloud (i.e., the period of the above-mentioned cyclic network request operation) can be increased.

[0075] like Figure 2 As shown in the figure, after the above analysis is completed, the device authentication part compares the obtained token (string) with the token defined in the platform gateway. If they are consistent, it means that the authentication is successful. Otherwise, it means that the authentication fails and the cloud disconnects the TCP connection with the device.

[0076] Step S40: Perform attribute change processing on the attribute data in the target message data to obtain changed attribute data, and send the changed attribute data to the TCP device to control the TCP device to complete a specified event according to the changed attribute data.

[0077] When the cloud obtains the user's property change request, the property data uploaded by the TCP device will be changed and issued according to the user's needs, so as to control the TCP device to complete the specified event.

[0078] The cloud sends the changed attribute data to the processor, which parses the received changed attribute data and then converts the parsed changed attribute data into a protocol format according to the pre-stored TCP protocol stack to obtain the corresponding CAN (Controller Area Network) data signal and sends it to the TCP device through the CAN network interface. The controller sends the CAN data signal to the TCP device, which parses it to obtain the data signal and performs corresponding actions according to the instructions to complete the specified event.

[0079] The attribute refers to one of the object models of the IoT platform. The object model defines the attributes, methods, and events of the device. The device and the cloud need to communicate according to the agreed rules to achieve the object model conversion. For example, if there is a temperature sensor, a temperature attribute can be defined for the device on the platform, and the device can report the value of the temperature attribute to the platform.

[0080] Specifically, the attribute data in the target message data is obtained, and the attribute data is subjected to attribute change processing according to preset requirements to obtain changed attribute data; the changed attribute data is subjected to second format conversion processing to obtain target attribute data; the target attribute data is sent down to the TCP device to control the TCP device to complete a specified event according to the target attribute data, and the specified event execution result uploaded by the TCP device is received.

[0081] Among them, when the target attribute data is sent to the designated TCP device, the TCP device will push a receipt data of the received information to the cloud after receiving the target attribute data, or display the online status of the underlying TCP device on the cloud. If the TCP device fails or the underlying TCP device is not powered, it will display an offline status. If the TCP device receives a large amount of data, or there are multiple devices in the cloud connected to the TCP device, it will display busy. When the TCP device receives multiple instructions, it will execute them according to the priority of the instructions and will receive a receipt of the execution status of the instructions.

[0082] The following is the interaction process between the TCP device and the cloud using the TCP protocol:

[0083] / / 0x01 Device online

[0084] online(DeviceOnlineMessage.class, BinaryDeviceOnlineMessage::new),

[0085] / / 0x02 Response message (the response message reported by the platform is used to send a heartbeat and maintain the TCP connection)

[0086] ack(AcknowledgeDeviceMessage.class, BinaryAcknowledgeDeviceMessage::new),

[0087] / / 0x03 Device->Platform attributes (IoT platform object model) report

[0088] reportProperty(ReportPropertyMessage.class,BinaryReportPropertyMessage::new),

[0089] / / 0x04 Platform->Device Get Properties

[0090] readProperty(ReadPropertyMessage.class, BinaryReadPropertyMessage::new),

[0091] / / 0x05 Device->Platform gets attribute reply

[0092] readPropertyReply(ReadPropertyMessageReply.class, BinaryReadPropertyMessageReply::new),

[0093] / / 0x06 Platform->Device sent attribute changes

[0094] writeProperty(WritePropertyMessage.class,BinaryWritePropertyMessage::new),

[0095] / / 0x06 Device->Platform sends attribute change reply

[0096] writePropertyReply(WritePropertyMessageReply.class,BinaryWritePropertyMessageReply::new),

[0097] / / 0x07 Platform->Device call function

[0098] function(FunctionInvokeMessage.class, BinaryFunctionInvokeMessage::new),

[0099] / / 0x08 Device->Platform call function reply

[0100] functionReply(FunctionInvokeMessageReply.class, BinaryFunctionInvokeMessageReply::new),

[0101] / / 0x09 Platform->Device reporting event

[0102] event(EventMessage.class, BinaryEventMessage::new);

[0103] like Figure 2 As shown, for the execution and delivery process of the instruction, the cloud converts the IoT platform operation into the agreed TCP byte message and delivers it, and the TCP device parses it according to the agreement to complete the instruction operation.

[0104] Regarding the sending of attribute change instructions: For example, the cloud adjusts the temperature of an air-conditioning device to 26 degrees, which means the cloud sends the temperature attribute to the device.

[0105] The cloud calls the function of the device: actions such as turning on the lights and the air conditioner can be defined as functions. The function must be responded to by the device, so there is a process of calling the function response. After turning on the air conditioner, the air conditioner device must send the information that the air conditioner is turned on to the cloud for receipt. Only then is the whole process completed.

[0106] The present invention receives information collected by a TCP device through a controller, converts it into a CAN data signal and sends it to a communication gateway, which then converts it into a corresponding IP data signal and sends it to the cloud. Alternatively, the communication gateway receives the IP data signal sent by the cloud, converts it into a corresponding CAN data signal according to a pre-stored TCP protocol stack, and sends it to the controller, so that the controller sends it to the TCP device, thereby realizing real-time data interaction and information processing between the TCP device and the cloud, and improving data transmission capacity and data processing efficiency.

[0107] Furthermore, if Figure 3 As shown, based on the above-mentioned TCP device access method, the present invention also provides a TCP device access system accordingly, wherein the TCP device access system includes:

[0108] The communication connection establishing module 51 is used to establish a communication connection with a TCP device according to the TCP connection instruction when a TCP connection instruction is received;

[0109] The sticking and unpacking processing module 52 is used to perform sticking and unpacking processing on the message data when receiving the message data uploaded by the TCP device to obtain sticking and unpacking message data;

[0110] The parsing and conversion module 53 is used to parse and convert the pasted and unpasted message data to obtain target message data;

[0111] The attribute changing module 54 is used to perform attribute changing processing on the attribute data in the target message data to obtain changed attribute data, and send the changed attribute data to the TCP device to control the TCP device to complete a specified event according to the changed attribute data.

[0112] Furthermore, if Figure 4As shown, based on the above TCP device access method and system, the present invention also provides a terminal accordingly, and the terminal includes a processor 10, a memory 20 and a display 30. Figure 4 Only some components of the terminal are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.

[0113] In some embodiments, the memory 20 may be an internal storage unit of the terminal, such as a hard disk or memory of the terminal. In other embodiments, the memory 20 may also be an external storage device of the terminal, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the terminal. Further, the memory 20 may also include both an internal storage unit of the terminal and an external storage device. The memory 20 is used to store application software and various types of data installed on the terminal, such as the program code of the installation terminal. The memory 20 may also be used to temporarily store data that has been output or is to be output. In one embodiment, a TCP device access program 40 is stored on the memory 20, and the TCP device access program 40 can be executed by the processor 10, thereby realizing the TCP device access method in the present application.

[0114] In some embodiments, the processor 10 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run the program code or process data stored in the memory 20, such as executing the TCP device access method.

[0115] In some embodiments, the display 30 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 30 is used to display information on the terminal and to display a visual user interface. The components 10-30 of the terminal communicate with each other via a system bus.

[0116] In one embodiment, when the processor 10 executes the TCP device access program 40 in the memory 20, the following steps are implemented:

[0117] When receiving a TCP connection instruction, establishing a communication connection with a TCP device according to the TCP connection instruction;

[0118] When receiving the message data uploaded by the TCP device, the message data is subjected to a gluing and unpacking process to obtain gluing and unpacking message data;

[0119] The message data is parsed and format converted to obtain target message data;

[0120] Attribute data in the target message data are subjected to attribute change processing to obtain changed attribute data, and the changed attribute data are sent to the TCP device to control the TCP device to complete a specified event according to the changed attribute data.

[0121] Wherein, when a TCP connection instruction is received, establishing a communication connection with a TCP device according to the TCP connection instruction specifically includes:

[0122] When a TCP connection instruction is received, a TCP connection gateway is created according to the TCP connection instruction;

[0123] Set up port monitoring, and when receiving a connection request instruction from the TCP device, establish a communication connection with the TCP device according to the TCP connection gateway.

[0124] Wherein, the sticky and split message data includes separated message data or segmented message data;

[0125] When the message data uploaded by the TCP device is received, the message data is subjected to a gluing and unpacking process to obtain the gluing and unpacking message data, which specifically includes:

[0126] When receiving the message data uploaded by the TCP device, obtaining each complete information in the message data, and setting a specific separator after each complete information;

[0127] The message data is subjected to complete information separation processing according to the specific separator to obtain the separated message data.

[0128] Wherein, when the message data uploaded by the TCP device is received, it also includes:

[0129] A preset data length is set, and the message data is segmented according to the preset data length to obtain segmented message data.

[0130] The parsing and format conversion of the pasted and unpasted message data to obtain target message data specifically includes:

[0131] Parsing the sticky and tearing message data to obtain first byte data in the sticky and tearing message data, and determining a data packet type of the sticky and tearing message data according to the first byte data;

[0132] The first format conversion process is performed on the pasted and disassembled message data according to the data packet type to obtain target message data that meets preset requirements.

[0133] The step of parsing the attached and unattached message data further includes:

[0134] Obtaining an identifier carried in the sticky / unsticky message data, and performing authentication processing on the TCP device according to the identifier;

[0135] Obtaining a preset identifier, and if the identifier is consistent with the preset identifier, determining that the TCP device authentication is passed;

[0136] If the identifier is inconsistent with the preset identifier, it is determined that the TCP device authentication fails, and the communication connection with the TCP device is disconnected.

[0137] The performing of attribute change processing on the attribute data in the target message data to obtain changed attribute data, and sending the changed attribute data to the TCP device to control the TCP device to complete a specified event according to the changed attribute data, specifically includes:

[0138] Acquire the attribute data in the target message data, and perform attribute change processing on the attribute data according to preset requirements to obtain changed attribute data;

[0139] Performing a second format conversion process on the modified attribute data to obtain target attribute data;

[0140] The target attribute data is sent to the TCP device to control the TCP device to complete the specified event according to the target attribute data, and receive the specified event execution result uploaded by the TCP device.

[0141] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a TCP device access program, and when the TCP device access program is executed by a processor, the steps of the TCP device access method described above are implemented.

[0142] In summary, the present invention provides a TCP device access method, system, terminal and computer-readable storage medium, the method comprising: when receiving a TCP connection instruction, establishing a communication connection with a TCP device according to the TCP connection instruction; when receiving message data uploaded by the TCP device, performing a sticking and unpacking process on the message data to obtain sticking and unpacking message data; performing a parsing process and a format conversion process on the sticking and unpacking message data to obtain target message data; performing a property change process on the attribute data in the target message data to obtain changed attribute data, and sending the changed attribute data to the TCP device to control the TCP device to complete a specified event according to the changed attribute data. The present invention is suitable for device connections with simple components and limited traffic. By using the lowest connection layer protocol TCP to perform device cloud operations and receive execution instructions issued by the cloud to complete device instruction execution, the present invention effectively solves the problems of large application layer protocol messages, complex interactions, and the need to embed protocol plug-ins into devices, and greatly improves the interaction efficiency between TCP devices and the cloud.

[0143] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or terminal including the element.

[0144] Of course, those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware (such as a processor, a controller, etc.) through a computer program, and the program can be stored in a computer-readable storage medium that can be read by a computer, and the program can include the processes of the above-mentioned method embodiments when executed. The computer-readable storage medium can be a memory, a disk, an optical disk, etc.

[0145] It should be understood that the application of the present invention is not limited to the above examples. For ordinary technicians in this field, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.

Claims

1. A TCP device access method, It is characterized in that The TCP device access method comprises: When receiving a TCP connection instruction, establishing a communication connection with a TCP device according to the TCP connection instruction; When receiving the message data uploaded by the TCP device, the message data is subjected to a gluing and unpacking process to obtain gluing and unpacking message data; The sticky and unsticky message data includes separated message data or segmented message data; When the message data uploaded by the TCP device is received, the message data is subjected to a gluing and unpacking process to obtain the gluing and unpacking message data, which specifically includes: When receiving the message data uploaded by the TCP device, obtaining each complete information in the message data, and setting a specific separator after each complete information; The sender adds a specific delimiter at the end of each message, and the receiver uses the delimiter to distinguish different messages; Performing complete information separation processing on the message data according to the specific separator to obtain the separated message data; When the message data uploaded by the TCP device is received, the method further includes: Setting a preset data length, and segmenting the message data according to the preset data length to obtain segmented message data; The sending end divides the data into fixed lengths, and the receiving end receives and splices the data into the same lengths. The sticky unpacking process also includes setting a custom script and setting a length field; The setting of the custom script is to use a specific script to handle the sticky and unpacking problem, by testing it in the test class of the backend code; The setting of the length field is to add a field indicating the length of the data in the data packet, which is usually stored in a fixed byte manner. The receiving end first reads the length field, and then reads the data according to the length indicated by the length field; The message data is parsed and format converted to obtain target message data; The parsing and format conversion of the pasted and unpasted message data to obtain target message data specifically includes: Parsing the sticky and tearing message data to obtain first byte data in the sticky and tearing message data, and determining a data packet type of the sticky and tearing message data according to the first byte data; Performing a first format conversion process on the pasted and split message data according to the data packet type to obtain target message data that meets preset requirements; The parsing process of the sticky and unsticky message data further includes: Obtaining an identifier carried in the sticky / unsticky message data, and performing authentication processing on the TCP device according to the identifier; Obtaining a preset identifier, and if the identifier is consistent with the preset identifier, determining that the TCP device authentication is passed; If the identifier is inconsistent with the preset identifier, it is determined that the TCP device authentication fails, and the communication connection with the TCP device is disconnected; If the TCP device has an abnormal network connection, the TCP device will send network requests to the cloud in a loop to restore the network connection to normal through repeated connection attempts. If the number of reconnection requests is set to more than 3, the interval between TCP devices sending reconnection requests to the cloud increases; Attribute data in the target message data are subjected to attribute change processing to obtain changed attribute data, and the changed attribute data are sent to the TCP device to control the TCP device to complete a specified event according to the changed attribute data.

2. The TCP device access method according to claim 1, It is characterized in that When a TCP connection instruction is received, establishing a communication connection with a TCP device according to the TCP connection instruction specifically includes: When a TCP connection instruction is received, a TCP connection gateway is created according to the TCP connection instruction; Set up port monitoring, and when receiving a connection request instruction from the TCP device, establish a communication connection with the TCP device according to the TCP connection gateway.

3. The TCP device access method according to claim 1, It is characterized in that The performing attribute change processing on the attribute data in the target message data to obtain changed attribute data, and sending the changed attribute data to the TCP device to control the TCP device to complete a specified event according to the changed attribute data, specifically includes: Acquire the attribute data in the target message data, and perform attribute change processing on the attribute data according to preset requirements to obtain changed attribute data; Performing a second format conversion process on the modified attribute data to obtain target attribute data; The target attribute data is sent to the TCP device to control the TCP device to complete the specified event according to the target attribute data, and receive the specified event execution result uploaded by the TCP device.

4. A TCP device access system, It is characterized in that The TCP device access system comprises: A communication connection establishing module, configured to establish a communication connection with a TCP device according to the TCP connection instruction when a TCP connection instruction is received; A packet sticking and unpacking processing module, configured to perform a packet sticking and unpacking process on the packet data when receiving the packet data uploaded by the TCP device, so as to obtain the packet sticking and unpacking packet data; The sticky and unsticky message data includes separated message data or segmented message data; When the message data uploaded by the TCP device is received, the message data is subjected to a gluing and unpacking process to obtain the gluing and unpacking message data, which specifically includes: When receiving the message data uploaded by the TCP device, obtaining each complete information in the message data, and setting a specific separator after each complete information; The sender adds a specific delimiter at the end of each message, and the receiver uses the delimiter to distinguish different messages; Performing complete information separation processing on the message data according to the specific separator to obtain the separated message data; When the message data uploaded by the TCP device is received, the method further includes: Setting a preset data length, and segmenting the message data according to the preset data length to obtain segmented message data; The sending end divides the data into fixed lengths, and the receiving end receives and splices the data into the same lengths. The sticky unpacking process also includes setting a custom script and setting a length field; The setting of the custom script is to use a specific script to handle the sticky and unpacking problem, by testing it in the test class of the backend code; The setting of the length field is to add a field indicating the length of the data in the data packet, which is usually stored in a fixed byte manner. The receiving end first reads the length field, and then reads the data according to the length indicated by the length field; The parsing and conversion module is used to parse and convert the message data to obtain target message data; The parsing and format conversion of the pasted and unpasted message data to obtain target message data specifically includes: Parsing the sticky and tearing message data to obtain first byte data in the sticky and tearing message data, and determining a data packet type of the sticky and tearing message data according to the first byte data; Performing a first format conversion process on the pasted and split message data according to the data packet type to obtain target message data that meets preset requirements; The parsing process of the sticky and unsticky message data further includes: Obtaining an identifier carried in the sticky / unsticky message data, and performing authentication processing on the TCP device according to the identifier; Obtaining a preset identifier, and if the identifier is consistent with the preset identifier, determining that the TCP device authentication is passed; If the identifier is inconsistent with the preset identifier, it is determined that the TCP device authentication fails, and the communication connection with the TCP device is disconnected; If the TCP device has an abnormal network connection, the TCP device will send network requests to the cloud in a loop to restore the network connection to normal through repeated connection attempts. If the number of reconnection requests is set to more than 3, the interval between TCP devices sending reconnection requests to the cloud increases; The attribute change module is used to perform attribute change processing on the attribute data in the target message data to obtain changed attribute data, and send the changed attribute data to the TCP device to control the TCP device to complete a specified event according to the changed attribute data.

5. A terminal, It is characterized in that The terminal includes: a memory, a processor, and a TCP device access program stored in the memory and executable on the processor. When the TCP device access program is executed by the processor, the steps of the TCP device access method according to any one of claims 1 to 3 are implemented.

6. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a TCP device access program, and when the TCP device access program is executed by a processor, the steps of the TCP device access method according to any one of claims 1 to 3 are implemented.