Dynamic encryption communication control method and device, equipment, medium and program product

By dynamically adjusting the encryption algorithm and key between the upper and lower computers, the packet loss problem caused by platform differences in smart home devices is solved, ensuring the reliable transmission and execution of control instructions, and improving user experience and system reliability.

CN120358034APending Publication Date: 2025-07-22GREE ELECTRIC APPLIANCE INC OF ZHUHAI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510729087.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-03
Publication Date
2025-07-22

AI Technical Summary

Technical Problem

Due to the inconsistent encapsulation format of BLE broadcast packets by Android and iOS systems, the lower computer discards the packet when the data length does not match, affecting the execution of control commands of smart home devices, causing functional missing functions, affecting user experience and system reliability.

Method used

The encryption algorithm is dynamically adjusted between the upper and lower computers, and multiple encryption algorithms are managed using a key table, detecting the duplicate data of the data packet and switching the keys, forming a new control packet to ensure the adaptation of the encryption protocol and packet integrity.

Benefits of technology

It realizes the reliable transmission and execution of smart home control instructions, improves user experience and system reliability, and avoids packet loss and decryption failure caused by platform differences.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120358034A_ABST
    Figure CN120358034A_ABST
Patent Text Reader

Abstract

The invention discloses a dynamic encryption communication control method and device, equipment, a medium and a program product. The method is applied to an upper computer, a key table is stored in the upper computer, and each key in the key table corresponds to one encryption algorithm. The method comprises the following steps: judging whether a control data packet has duplicated data, if the control data packet has duplicated data, sending a switching key data packet to a lower computer, if a switching key response packet returned by the lower computer is received, encrypting a control command by using a new key and a corresponding encryption algorithm, and sending the encrypted control command to the lower computer; and a new control data packet is sent to the lower computer. According to the scheme, the encryption algorithm can be automatically adjusted, reliable transmission and execution of the smart home control instruction are ensured, and the user experience and the system reliability are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of smart home technology, and specifically relates to a control method, device, equipment, storage medium and computer program product for dynamic encrypted communication. Background Art

[0002] With the rapid development of smart home technology, Bluetooth Low Energy (BLE) has become one of the core technologies for controlling smart devices in a local area network due to its low energy consumption and short-distance communication characteristics. BLE transmits control instructions through a broadcast channel, but there are significant differences in the encapsulation mechanism of broadcast data packets between different mobile operating systems (such as Android and iOS). For example, the iOS system encapsulates broadcast data in a specific UUID field, and when there are repeated UUID groups in the broadcast data packet, iOS will automatically remove redundant data and retain only one group, resulting in the actual transmission of The broadcast data length is compressed. However, the lower computer (such as smart home devices) usually presets strict data packet length verification rules. When the received data length does not meet expectations due to platform differences, the packet loss mechanism will be triggered. Since the encryption algorithm and interaction protocol remain fixed between the upper and lower computers, the truncated data packets cannot be decrypted or parsed due to format damage, resulting in continuous failure of control instructions, and ultimately causing functional omissions (such as device failure to respond, state synchronization failure, etc.), affecting user experience and system reliability.

[0003] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention

[0004] The purpose of the present invention is to provide a control method, device, equipment, storage medium and computer program product for dynamic encrypted communication to solve the problems of functional omissions in related solutions that affect user experience and system reliability. When there is duplicate data in the control data packet, the control command is encrypting using a new key and a corresponding encryption algorithm to form a new control data packet. The encryption algorithm can be automatically adjusted to ensure the reliable transmission and execution of smart home control instructions, thereby improving user experience and system reliability.

[0005] The present invention provides a control method for dynamic encrypted communication, the method is applied to a host computer, the host computer stores a key table, the key table has more than two keys, the key table records the state of each key, and each key corresponds to an encryption algorithm; the method comprises:

[0006] Receive the control command sent by the user, encrypt the control command using the current key and its corresponding encryption algorithm to form a control data packet; wherein, the current key refers to the key with an active state used by the host computer at the current moment.

[0007] Determine whether there is duplicate data in the control data packet. If there is duplicate data in the control data packet, select a new key in the key table, form a switching key data packet based on the new key, and send the switching key data packet to the lower computer.

[0008] If the switching key response packet returned by the lower computer is received, encrypt the control command using the new key and its corresponding encryption algorithm to form a new control data packet, and send the new control data packet to the lower computer.

[0009] In some embodiments, determining whether there is duplicate data in the control data packet includes:

[0010] Detect whether there are two adjacent bytes that appear repeatedly in the control data packet.

[0011] If there are two adjacent bytes that appear repeatedly, determine that there is duplicate data in the control data packet.

[0012] In some embodiments, each key in the key table corresponds to a key ID.

[0013] The step of selecting a new key in the key table and forming a switching key data packet based on the new key includes:

[0014] Search the key table to find the current key, mark the status of the current key as abnormal, and record the reason for the abnormality of the current key.

[0015] Select an available new key in the key table based on the priority or polling mechanism.

[0016] Fill the key ID corresponding to the new key into the switching key data packet.

[0017] In some embodiments, after receiving the switching key response packet returned by the lower computer and before encrypting the control command using the new key and its corresponding encryption algorithm, it further includes:

[0018] Generate a test instruction, encrypt the test instruction using the new key and its corresponding encryption algorithm to form a test data packet, and send the test data packet to the lower computer.

[0019] If a successful confirmation packet for the switched key returned by the slave computer is received, mark the status of the new password as active, and encrypt the control command using the new key and its corresponding encryption algorithm.

[0020] The present invention also provides a control method for dynamic encrypted communication, which is applied to a slave computer. The slave computer stores a key table, and there are more than two keys in the key table. The status of each key is recorded in the key table, and each key corresponds to a decryption algorithm. The method includes:

[0021] When a communication connection is established between the slave computer and the master computer, receive a data packet sent by the master computer;

[0022] Judge whether the data packet is a key-switching data packet or a control data packet according to the length of the data packet;

[0023] If the data packet is a control data packet, decrypt the control data packet using the current key and its corresponding decryption algorithm to obtain the control instruction, and execute the control instruction; where the current key refers to the key whose status is active used by the slave computer at the current moment;

[0024] If the data packet is a key-switching data packet, obtain a new key based on the key-switching data packet, and send a key-switching response packet to the master computer.

[0025] In some embodiments, the judging whether the data packet is a key-switching data packet or a control data packet according to the length of the data packet includes:

[0026] If the length of the data packet is a preset first length, judge that the data packet is a control data packet;

[0027] If the length of the data packet is a preset second length, judge that the data packet is a key-switching data packet; where the first length is greater than the second length.

[0028] In some embodiments, each key in the key table corresponds to a key ID; the obtaining of the new key based on the key-switching data packet includes:

[0029] Obtain the key ID and the decryption algorithm from the key-switching data packet;

[0030] Search the key table to find the new key corresponding to the key ID, and mark the status of the new key as active.

[0031] In some embodiments, after sending the key-switching response packet to the master computer, it further includes:

[0032] Receive the test data packet sent by the host computer;

[0033] Use the new key and the decryption algorithm to decrypt the test data packet;

[0034] If the decryption is successful, return a successful key switch confirmation packet to the host computer.

[0035] Matched with the above method, on the other hand, the present invention provides a control device for dynamic encryption communication. The device is applied to a host computer, and the host computer stores a key table. There are more than two keys in the key table. The status of each key is recorded in the key table, and each key corresponds to an encryption algorithm. The control device includes:

[0036] A control unit, configured to receive a control command sent by a user, encrypt the control command using the current key and its corresponding encryption algorithm to form a control data packet; wherein, the current key refers to the key whose status is active and used by the host computer at the current moment;

[0037] The control unit is further configured to determine whether there is duplicate data in the control data packet. If there is duplicate data in the control data packet, select a new key in the key table, form a key switch data packet based on the new key, and send the key switch data packet to the lower computer;

[0038] The control unit is further configured to, if receiving a key switch response packet returned by the lower computer, encrypt the control command using the new key and its corresponding encryption algorithm to form a new control data packet, and send the new control data packet to the lower computer.

[0039] In some embodiments, the control unit determines whether there is duplicate data in the control data packet, including:

[0040] Detect whether there are two adjacent bytes that appear repeatedly in the control data packet;

[0041] If there are two adjacent bytes that appear repeatedly, determine that there is duplicate data in the control data packet.

[0042] In some embodiments, each key in the key table corresponds to a key ID; the control unit selects a new key in the key table and forms a key switch data packet based on the new key, including:

[0043] Search the key table to find the current key, mark the status of the current key as abnormal, and record the reason for the abnormality of the current key;

[0044] Select an available new key in the key table based on the priority or polling mechanism;

[0045] Fill the key ID corresponding to the new key into the switching key data packet.

[0046] In some embodiments, the control unit is further configured to, after receiving the switching key response packet returned by the lower computer, before encrypting the control command using the new key and its corresponding encryption algorithm,

[0047] Generate a test instruction, encrypt the test instruction using the new key and its corresponding encryption algorithm to form a test data packet, and send the test data packet to the lower computer;

[0048] If the switching key success confirmation packet returned by the lower computer is received, mark the status of the new password as the active state, and encrypt the control command using the new key and its corresponding encryption algorithm.

[0049] Matched with the above method, on the other hand, the present invention provides a control device for dynamic encryption communication. The device is applied to a lower computer, and the lower computer stores a key table. There are more than two keys in the key table. The key table records the status of each key, and each key corresponds to a decryption algorithm. The control device includes:

[0050] A control unit configured to receive a data packet sent by the upper computer when the lower computer establishes a communication connection with the upper computer;

[0051] The control unit is further configured to determine whether the data packet is a switching key data packet or a control data packet according to the length of the data packet;

[0052] The control unit is further configured to, if the data packet is a control data packet, decrypt the control data packet using the current key and its corresponding decryption algorithm to obtain the control instruction, and execute the control instruction; wherein, the current key refers to the key whose status is the active state used by the lower computer at the current moment;

[0053] The control unit is further configured to, if the data packet is a switching key data packet, obtain a new key based on the switching key data packet, and send a switching key response packet to the upper computer.

[0054] In some embodiments, the control unit determines whether the data packet is a switching key data packet or a control data packet according to the length of the data packet, including:

[0055] If the length of the data packet is a preset first length, determine that the data packet is a control data packet;

[0056] If the length of the data packet is a preset second length, it is determined that the data packet is a switching key data packet; wherein the first length is greater than the second length.

[0057] In some embodiments, each key in the key table corresponds to a key ID; the control unit obtains a new key based on the switching key data packet, including:

[0058] Obtain the key ID and decryption algorithm from the switching key data packet;

[0059] Search the key table to find the new key corresponding to the key ID, and mark the status of the new key as active.

[0060] In some embodiments, the control unit is further configured to, after sending the switching key response packet to the host computer:

[0061] Receive the test data packet sent by the host computer;

[0062] Decrypt the test data packet using the new key and the decryption algorithm;

[0063] If the decryption is successful, return a switching key success confirmation packet to the host computer.

[0064] Matched with the above device, another aspect of the present invention provides a device, including: the control device for dynamic encryption communication described above.

[0065] In some embodiments, the device is an air conditioner.

[0066] Matched with the above method, another aspect of the present invention provides a storage medium, the storage medium includes a stored program, wherein, when the program runs, it controls the device where the storage medium is located to execute the control method for dynamic encryption communication described above.

[0067] Matched with the above method, another aspect of the present invention provides a computer program product, the computer program product includes a computer program, and when the computer program product is processed and executed, it implements the steps of the above control method.

[0068] The solution of the present invention, by encrypting the control command with a new key and its corresponding encryption algorithm in the case of duplicate data in the control data packet to form a new control data packet, can automatically adjust the encryption algorithm, ensuring the reliable transmission and execution of smart home control instructions, and improving the user experience and system reliability.

[0069] Other features and advantages of the present invention will be described in the subsequent specification, and, in part, will be obvious from the specification, or will be understood by implementing the present invention.

[0070] The technical solutions of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Description of the Drawings

[0071] Figure 1 It is a schematic flowchart of an embodiment of the control method for dynamic encrypted communication of the present invention;

[0072] Figure 2 It is a schematic flowchart of another embodiment of the control method for dynamic encrypted communication of the present invention;

[0073] Figure 3 It is a schematic flowchart of another embodiment of the control method for dynamic encrypted communication of the present invention;

[0074] Figure 4 It is a schematic flowchart of another embodiment of the control method for dynamic encrypted communication of the present invention. Detailed Embodiments

[0075] To make the objectives, technical solutions, and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below in conjunction with the specific embodiments of the present invention and the corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without making creative efforts shall fall within the protection scope of the present invention.

[0076] In the related art, due to the inconsistent encapsulation formats of BLE broadcast data packets between the Android and iOS systems (especially the automatic deduplication mechanism for duplicate UUID data in iOS), the length of the data packets transmitted to the lower computer is dynamically reduced. When the lower computer performs verification and decryption based on a preset fixed length and encryption protocol, the data packets are directly discarded due to the inconsistent length, and due to the lack of dynamic adaptation of the encryption logic, the same control instructions will repeatedly fail due to continuous encapsulation errors. To solve the above problems, according to the embodiments of the present invention, a control method for dynamic encrypted communication is provided. The upper computer stores a key table, and there are more than two keys in the key table. The status of each key is recorded in the key table, and each key corresponds to an encryption algorithm. The real algorithm has been written in the code, and the key table corresponds to the algorithm in the code; the keys (Key) in the key table are parameters used for encrypting and decrypting data. For example Figure 1Flow schematic diagram of an embodiment of the method of the present invention. The control method for dynamic encryption communication may include: step S110 to step S130. In the smart home control scenario, the upper computer (such as a mobile App or a small program) is responsible for sending control commands, and the lower computer (such as home appliance products like air conditioners, refrigerators, fans, etc.) receives and executes these commands. For example, the user sends instructions through the mobile phone App (upper computer): turn on, heating mode, set to 26°C. The air conditioner host (lower computer) needs to safely receive and execute the instructions.

[0077] When the user initiates an operation, the upper computer needs to detect the operating system type (Android / iOS) of the current device in real time, and trigger a dynamic adaptation encryption mechanism according to the system differences to ensure the integrity of the data packet and avoid packet loss of the lower computer due to platform differences.

[0078] During application initialization, the upper computer can load an encryption algorithm library from a preset resource or a security server. The encryption algorithm library includes multiple different encryption algorithms, such as encryption algorithm 1, encryption algorithm 2, encryption algorithm 3, etc. The encryption algorithms can be symmetric / non-symmetric, hash algorithms, MD5, etc. The upper computer maintains a key table in memory. Each key in the key table corresponds to a key ID and an encryption algorithm, and the binding relationship between the key and the algorithm is fixed (such as key1→AES-GCM). The key table records the status of each key (such as active / abnormal) and the abnormal events of the key, so as to support dynamically switching the encryption algorithm according to the abnormal detection result.

[0079] In the pairing stage, synchronize the entire key table between the upper computer and the lower computer for subsequent communication using different keys and algorithms. The user can trigger the pairing mode through the App / small program interface (such as the Bluetooth device enters the discoverable state).

[0080] In step S110, receive the control command sent by the user, and encrypt the control command using the current key and the corresponding encryption algorithm to form a control data packet; wherein, the current key refers to the key whose state is active and used by the upper computer at the current moment.

[0081] The control data packet is a binary data stream composed of a series of bytes (Byte) according to the protocol specification. Taking the air conditioner control instruction as an example, the instruction: turn on (Power On)+heating mode (Heat Mode)+temperature 26°C. The data packet format: [start symbol][instruction type][mode][temperature][check code][end symbol], example byte stream: 02 01 02 8E 15 62 36 36 2052 69...7E.

[0082] First, receive the control command sent by the user and convert the control command sent by the user (such as "turn on the air conditioner") into a standardized data packet format. Then, encrypt the control command using the current key and its corresponding encryption algorithm. Among them, the key is a string of random bits, which is an input parameter of the algorithm. The algorithm (such as AES-GCM) defines the mathematical process of encryption, and the data is encrypted through the steps defined by the algorithm (such as round function, confusion and diffusion).

[0083] At step S120, determine whether there is duplicate data in the control data packet. If there is duplicate data in the control data packet, select a new key in the key table, form a switching key data packet based on the new key, and send the switching key data packet to the lower computer.

[0084] The switching key is a mechanism used to update the key in the encryption protocol. The upper computer forms a switching key data packet and sends the switching key data packet to the lower computer to support the dynamic replacement of the encryption / decryption algorithm. In some embodiments, in step S120, determining whether there is duplicate data in the control data packet includes:

[0085] Detect whether there are two adjacent bytes that appear repeatedly in the control data packet.

[0086] Regard every two adjacent bytes in the data packet as a group (such as 02 03 as a group), and traverse all possible combinations in order. If there are two adjacent bytes that appear repeatedly, it is determined that there is duplicate data in the control data packet.

[0087] If the same group of bytes (such as 02 03) appears twice or more in the data packet, it is determined that there is duplicate data in the control data packet. For example: if 4a 5b 4a 5b appears in the data packet, the repeated content is 4a5b; according to the uuid rule, remove a group of 4a 5b.

[0088] In some embodiments, in step S120, the specific process of selecting a new key in the key table and forming a switching key data packet based on the new key includes steps S210-S230.

[0089] Step S210, search the key table, find the current key, mark the status of the current key as abnormal, and record the reason for the abnormality of the current key.

[0090] When there is duplicate data in the control data packet formed using the current key, mark the current key as abnormal and record the specific reason as data duplication. This can enable the upper computer to respond quickly to switch to a more secure key.

[0091] For example, find the key key1 in the key table, mark the current key key1 as abnormal, and record the reason for the abnormality of the current key key1 as data duplication.

[0092] After the current key is marked as abnormal, it is necessary to select an available new key to replace it to avoid the continuous failure of the control instruction due to the encryption algorithm and the interaction protocol remaining fixed between the upper and lower computers.

[0093] Step S220, select an available new key in the key table based on the priority or polling mechanism.

[0094] A priority (priority) field can be recorded for each key record in the key table, and the smaller the value, the higher the priority (e.g., 1>2>3). The priority of the key can consider the following factors: the encryption strength of the key, the number of uses, the remaining validity period, the number of historical anomalies, etc.

[0095] It is also possible to maintain a global counter or pointer to record the position of the key used last time. Traverse the available key list in the order of key ID or randomly. For example, the available key order is: key2→key3→key2... The current index is 0 (key2), and the next index is 1 (key3).

[0096] Step S230, fill the key ID corresponding to the new key into the switching key data packet. Among them, no key is transmitted during the transmission process, only the relevant key identifier such as the key ID is transmitted, and the real algorithm has been written in the code.

[0097] The switching key data packet can be encrypted with the old key. Since the information of the new key is encrypted with the old key, after the lower computer receives the switching key data packet, it decrypts it with the old key to confirm the ID and algorithm of the new key, so that the new key is used for subsequent communication, maintaining the continuity and security of the communication. If there are multiple historical keys, the corresponding key can be quickly found through the ID to avoid decrypting with the wrong key. If the key tables of the upper and lower computers are completely synchronized, then the corresponding algorithm can be found through the key ID. However, if there is a synchronization delay or error, the lower computer may not have the latest key table. At this time, sending the encryption algorithm can be used as redundant information to help the lower computer correctly parse. Since the protocol allows dynamic replacement of the algorithm, the upper computer tells the lower computer which algorithm should be used to decrypt or verify the data later, so that both parties can smoothly switch to the new algorithm to ensure the security and correctness of the key switching process.

[0098] In some embodiments, it is determined whether there is duplicate data in the control data packet. If there is no duplicate data in the control data packet, that is, the control data packet meets the requirements, the Bluetooth interface is directly called to send the control data packet.

[0099] At step S130, if a switching key response packet returned by the lower computer is received, the control command is encrypted using the new key and its corresponding encryption algorithm to form a new control data packet, and the new control data packet is sent to the lower computer.

[0100] When the upper computer receives the switching key response packet returned by the lower computer, it indicates that the lower computer has received the new key and the new algorithm. At this time, the upper computer re-encrypts the control command using the new key and its corresponding encryption algorithm to form a new control data packet. Thus, the problem of continuous invalidation of control instructions and resulting functional omissions is overcome, ensuring the reliable transmission and execution of smart home control instructions, and improving the user experience and system reliability.

[0101] In some embodiments, after receiving the switching key response packet returned by the lower computer and before encrypting the control command using the new key and its corresponding encryption algorithm, it further includes:

[0102] Generating a test instruction, encrypting the test instruction using the new key and its corresponding encryption algorithm to form a test data packet, and sending the test data packet to the lower computer.

[0103] After the upper computer receives the switching key response packet returned by the lower computer, the new key may not be correctly synchronized, and directly sending the control data packet may cause decryption failure. Therefore, a test data packet is formed to verify the effectiveness of the new key before it is officially used and ensure the consistency of the encryption link.

[0104] If a switching key success confirmation packet returned by the lower computer is received, the status of the new password is marked as the active state, and the control command is encrypted using the new key and its corresponding encryption algorithm.

[0105] Figure 3 It is a flowchart of another embodiment of the control method for dynamic encryption communication of the present invention. As Figure 3 shown, the method includes:

[0106] The upper computer sends a switching key packet (encrypted with the old key) to the lower computer;

[0107] The lower computer returns a switching response packet to the upper computer;

[0108] The upper computer sends a test data packet (encrypted with the new key) to the lower computer;

[0109] The lower computer returns a test confirmation packet to the upper computer;

[0110] The upper computer sends a formal control instruction (encrypted with the new key) to the lower computer.

[0111] Among them, considering that packet loss may occur, multiple handshakes can be performed to confirm the successful key switch before using the new key for encryption.

[0112] Although the host computer has received the key-switching response packet returned by the slave computer, it is also possible that the new key has not been correctly synchronized. Directly sending a control instruction may cause the slave computer to decrypt the packet incorrectly and discard it. Encrypt the test instruction using the new key and its corresponding encryption algorithm to form a test data packet. After receiving the successful key-switch confirmation packet returned by the slave computer, encrypt the control command using the new key and its corresponding encryption algorithm, so as to intercept anomalies in advance during the test phase, reduce invalid transmissions, and ensure the end-to-end consistency of the encrypted link.

[0113] In the case where there are duplicate data in the control data packet, this solution encrypts the control command using the new key and its corresponding encryption algorithm to form a new control data packet, which can automatically adjust the encryption algorithm, ensuring the reliable transmission and execution of smart home control instructions, and improving the user experience and system reliability.

[0114] According to an embodiment of the present invention, a control method for dynamic encryption communication is provided. The method is applied to a slave computer, and the slave computer stores a key table. There are more than two keys in the key table. The key table records the status of each key, and each key corresponds to a decryption algorithm. The method includes: as Figure 2 shown in the flowchart of an embodiment of the method of the present invention. This control method for dynamic encryption communication may include: step S310 to step S340.

[0115] In the pairing phase, the slave computer (such as home appliance products like air conditioners, refrigerators, fans, etc.) needs to cooperate with the host computer (App / small program) to complete key table synchronization to ensure that both parties have the same key and algorithm configuration. Each key in the key table corresponds to a key ID and a decryption algorithm, and the binding relationship between the key and the algorithm is fixed (such as key1→AES-GCM). The key table records the status of each key (such as activated / anomalous) and the anomalous events of the key, so as to support dynamically switching the decryption algorithm according to the anomaly detection result. After the slave computer and the host computer complete pairing, initialize the decryption algorithm library.

[0116] At step S310, when a communication connection is established between the slave computer and the host computer, receive the data packet sent by the host computer.

[0117] At step S320, judge whether the data packet is a key-switching data packet or a control data packet according to the length of the data packet.

[0118] Control data packets are used for instruction transmission, such as home appliance control commands. The switching key data packet is used to update or change the current decryption key and decryption algorithm. Quick classification according to the packet length can avoid the overhead of parsing the entire packet. In addition, different data packets adopt different processing flows.

[0119] In some embodiments, in step S320, the specific process of determining whether the data packet is a switching key data packet or a control data packet according to the length of the data packet includes:

[0120] If the length of the data packet is a preset first length, it is determined that the data packet is a control data packet;

[0121] If the length of the data packet is a preset second length, it is determined that the data packet is a switching key data packet; where the first length is greater than the second length.

[0122] The preset first length can be 39. If the length of the data packet is 39 bytes, it is determined that the data packet is a control data packet. For example, a control data packet with a length of 39 bytes: 02 01 02 8e 15 62 36 36 20 5269.....7e.

[0123] The preset second length can be 12. If the length of the data packet is 12 bytes, it is determined that the data packet is a switching key data packet. For example, a switching key data packet with a length of 12 bytes: 03 05 02 04 06 15 2145 64 00 33 55.

[0124] The structure of the control data packet (39 bytes) can be as follows: It includes a frame header (such as 2 bytes), a version number (1 byte), actual data (such as 32 bytes), and a check code (4 bytes, such as CRC32). The structure of the switching key data packet (12 bytes) can be as follows: It includes a frame header (2 bytes), a key ID (1 byte), an encryption algorithm (1 byte), a random number (4 bytes), and a check code (4 bytes). The data integrity of the switching key data packet (12 bytes) and the control data packet (39 bytes) can be verified through the check code to ensure that the information is not tampered with or damaged during transmission.

[0125] In step S330, if the data packet is a control data packet, the control data packet is decrypted using the current key and the corresponding decryption algorithm to obtain the control instruction, and the control instruction is executed; where the current key refers to the key whose state is active at the current moment used by the lower computer.

[0126] In step S340, if the data packet is a switching key data packet, a new key is obtained based on the switching key data packet, and a switching key response packet is sent to the upper computer.

[0127] If the host computer does not receive the switching key response packet, the slave computer will continue to send the switching key response packet until the host computer receives the switching key response packet.

[0128] In some embodiments, each key in the key table corresponds to a key ID. The specific process of obtaining a new key based on the switching key data packet in step S340 includes:

[0129] Obtain the key ID and decryption algorithm from the switching key data packet.

[0130] Search the key table to find the new key corresponding to the key ID, and mark the status of the new key as the active state.

[0131] The key ID is used to uniquely identify the key. The decryption algorithm ensures the use of the correct decryption method. Searching the key table is to verify the existence and legitimacy of the key, and activating the new key is for the security and correctness of the switching process.

[0132] In some embodiments, in step S340, after sending the switching key response packet to the host computer, it further includes:

[0133] Receive the test data packet sent by the host computer.

[0134] Use the new key and its corresponding decryption algorithm to decrypt the test data packet.

[0135] If the decryption is successful, return a switching key success confirmation packet to the host computer.

[0136] There are synchronization problems between the host computer and the slave computer during key switching, which may lead to decryption failures. After receiving the switching key response packet, the host computer sends a test instruction to ensure the correct synchronization of the new key, and then sends the formal control instruction. The slave computer receives the test packet, decrypts it with the new key, and returns a confirmation if successful. The test packet is used as a verification step to ensure the new key takes effect and avoid failures of formal data due to key asynchronization.

[0137] When the key is correct and the algorithm matches, the slave computer will return a switching key success confirmation packet to the host computer, thereby confirming that a reliable new key encryption channel has been established between the two parties, and ensuring the end-to-end trust of the encryption link through the "handshake" in the test phase.

[0138] This solution determines whether the data packet is a switching key data packet or a control data packet according to the data packet length, obtains the new key from the switching key data packet, obtains the control instruction from the control data packet and executes the control instruction, and completes the encryption and decryption switching through the handshake between the host computer and the slave computer, ensuring the reliable transmission and execution of the smart home control instruction, and improving the user experience and system reliability.

[0139] Figure 4 This is a schematic flowchart of another embodiment of the control method for dynamic encryption communication of the present invention (applied to the host computer and the slave computer). As Figure 4 shown, this method includes:

[0140] S01: Start.

[0141] S02: Pairing is successful, synchronize the key table.

[0142] S03: User control and convert the instruction.

[0143] S04: Obtain the current key and encrypt the instruction.

[0144] S05: Determine whether there is duplicate data in the encrypted data.

[0145] S06: If there is duplicate data, switch the key, fill the new key ID and its corresponding encryption algorithm into the key-switching data packet, and send it to the slave computer.

[0146] S07: If there is no duplicate data, call the Bluetooth interface and send the control data packet.

[0147] S08: The slave computer determines the length of the data packet.

[0148] S09: If the length of the data packet is 39, decrypt the control data packet and execute the air conditioner control instruction.

[0149] S10: If the length of the data packet is 12, obtain the new key and send a key-switching response packet to the host computer.

[0150] S11: If the host computer receives the key-switching response packet, encrypt the control command using the new key and its corresponding encryption algorithm.

[0151] S12: If the length of the data packet is not 12, discard the data packet.

[0152] S13: After the slave computer executes the air conditioner control instruction or discards the data packet, it ends.

[0153] The above method will be introduced below in conjunction with specific embodiments:

[0154] Receive the control commands sent by the user, such as: power on, and control the temperature to increase from 25 degrees to 26 degrees in the heating mode. Encrypt the control commands using the current key and its corresponding encryption algorithm to form a control data packet. Determine whether there is duplicate data in the control data packet. If there is duplicate data in the control data packet, select a new key in the key table, form a switching key data packet based on the new key, and send the switching key data packet to the lower computer; the lower computer obtains the new key based on the switching key data packet and sends a switching key response packet to the upper computer. If the upper computer receives the switching key response packet returned by the lower computer, encrypt the control commands using the new key and its corresponding encryption algorithm to form a new control data packet, and send the new control data packet to the lower computer. The lower computer decrypts the control data packet using the new key and its corresponding decryption algorithm to obtain the control instruction and execute the control instruction. Finally, the air conditioner realizes the response of power on and 26 degrees in the heating mode. If the upper computer does not receive the switching key response packet, it keeps sending the switching key data packet to the lower computer. If there is no duplicate data in the control data packet, that is, the control data packet meets the requirements, directly call the Bluetooth interface to send the control data packet.

[0155] Adopting the technical solution of this embodiment, when there is duplicate data in the control data packet, the upper computer encrypts the control commands using the new key and its corresponding encryption algorithm to form a new control data packet, and can automatically adjust the encryption algorithm. The lower computer determines whether the data packet is a switching key data packet or a control data packet according to the data packet length, obtains the new key from the switching key data packet, and obtains the control instruction from the control data packet and executes the control instruction. Through the handshake between the upper computer and the lower computer to complete the encryption and decryption switching, it ensures the reliable transmission and execution of the smart home control instructions, and improves the user experience and system reliability.

[0156] According to an embodiment of the present invention, there is also provided a control device for dynamic encryption communication corresponding to the control method of dynamic encryption communication. The device is applied to the upper computer. The upper computer stores a key table, and there are more than two keys in the key table. The status of each key is recorded in the key table, and each key corresponds to an encryption algorithm; the control device includes:

[0157] A control unit, configured to receive the control commands sent by the user, encrypt the control commands using the current key and its corresponding encryption algorithm to form a control data packet; wherein, the current key refers to the key whose status is active used by the upper computer at the current moment;

[0158] The control unit is further configured to determine whether there is duplicate data in the control data packet. If there is duplicate data in the control data packet, select a new key in the key table, form a switching key data packet based on the new key, and send the switching key data packet to the lower computer;

[0159] The control unit is further configured to, if receiving the switching key response packet returned by the slave computer, encrypt the control command using the new key and its corresponding encryption algorithm to form a new control data packet, and send the new control data packet to the slave computer.

[0160] In some embodiments, the control unit determines whether there is duplicate data in the control data packet, including:

[0161] Detecting whether there are two adjacent bytes that appear repeatedly in the control data packet;

[0162] If there are two adjacent bytes that appear repeatedly, it is determined that there is duplicate data in the control data packet.

[0163] In some embodiments, each key in the key table corresponds to a key ID; the control unit selects a new key in the key table and forms a switching key data packet based on the new key, including:

[0164] Searching the key table to find the current key, marking the status of the current key as abnormal, and recording the reason for the abnormality of the current key;

[0165] Selecting an available new key in the key table based on the priority or polling mechanism;

[0166] Filling the key ID corresponding to the new key into the switching key data packet.

[0167] In some embodiments, the control unit is further configured to, after receiving the switching key response packet returned by the slave computer and before encrypting the control command using the new key and its corresponding encryption algorithm,

[0168] Generating a test instruction, encrypting the test instruction using the new key and its corresponding encryption algorithm to form a test data packet, and sending the test data packet to the slave computer;

[0169] If receiving the switching key success confirmation packet returned by the slave computer, marking the status of the new password as the active state, and encrypting the control command using the new key and its corresponding encryption algorithm.

[0170] Adopting the technical solution of the present invention, in the case where there is duplicate data in the control data packet, encrypting the control command using the new key and its corresponding encryption algorithm to form a new control data packet can automatically adjust the encryption algorithm, ensuring the reliable transmission and execution of the smart home control instruction, and improving the user experience and system reliability.

[0171] Since the processing and functions implemented by the device in this embodiment are basically corresponding to the embodiments, principles, and examples of the foregoing method, for the details not described in the description of this embodiment, reference may be made to the relevant descriptions in the foregoing embodiments, which will not be elaborated here.

[0172] According to an embodiment of the present invention, there is also provided a control device for dynamic encryption communication corresponding to the control method of dynamic encryption communication. The device is applied to a lower computer. The lower computer stores a key table, and there are two or more keys in the key table. The key table records the status of each key, and each key corresponds to a decryption algorithm. The control device includes:

[0173] A control unit configured to receive a data packet sent by the upper computer when the lower computer establishes a communication connection with the upper computer;

[0174] The control unit is further configured to determine whether the data packet is a key-switching data packet or a control data packet according to the length of the data packet;

[0175] The control unit is further configured to, if the data packet is a control data packet, decrypt the control data packet using the current key and the corresponding decryption algorithm to obtain the control instruction, and execute the control instruction; wherein the current key refers to the key whose status is active at the current moment used by the lower computer;

[0176] The control unit is further configured to, if the data packet is a key-switching data packet, obtain a new key based on the key-switching data packet, and send a key-switching response packet to the upper computer.

[0177] In some embodiments, the control unit determines whether the data packet is a key-switching data packet or a control data packet according to the length of the data packet, including:

[0178] If the length of the data packet is a preset first length, it is determined that the data packet is a control data packet;

[0179] If the length of the data packet is a preset second length, it is determined that the data packet is a key-switching data packet; wherein the first length is greater than the second length.

[0180] In some embodiments, each key in the key table corresponds to a key ID. The control unit obtains a new key based on the key-switching data packet, including:

[0181] Obtain the key ID and the decryption algorithm from the key-switching data packet;

[0182] Search the key table to find the new key corresponding to the key ID, and mark the status of the new key as active.

[0183] In some embodiments, the control unit is further configured to, after sending the switching key response packet to the host computer:

[0184] Receive a test data packet sent by the host computer;

[0185] Use the new key and the decryption algorithm to decrypt the test data packet;

[0186] If the decryption is successful, return a switching key success confirmation packet to the host computer.

[0187] Adopting the technical solution of the present invention, judging whether the data packet is a switching key data packet or a control data packet according to the data packet length, obtaining a new key from the switching key data packet, obtaining a control instruction from the control data packet and executing the control instruction, and completing the encryption and decryption switching through the handshake between the host computer and the lower computer, which ensures the reliable transmission and execution of the smart home control instruction, and improves the user experience and system reliability.

[0188] Since the processing and functions implemented by the device in this embodiment are basically corresponding to the embodiments, principles and examples of the foregoing method, for the details not described in the description of this embodiment, reference may be made to the relevant descriptions in the foregoing embodiments, and details will not be repeated here.

[0189] According to an embodiment of the present invention, there is also provided a device corresponding to the control device for dynamic encryption communication. The device may include: the control device for dynamic encryption communication applied to the lower computer as described above.

[0190] In some embodiments, the device may be a household appliance device such as an air conditioner, a refrigerator, a fan, etc.

[0191] Since the processing and functions implemented by the air conditioner in this embodiment are basically corresponding to the embodiments, principles and examples of the foregoing device, for the details not described in the description of this embodiment, reference may be made to the relevant descriptions in the foregoing embodiments, and details will not be repeated here.

[0192] Adopting the technical solution of the present invention, judging whether the data packet is a switching key data packet or a control data packet according to the data packet length, obtaining a new key from the switching key data packet, obtaining a control instruction from the control data packet and executing the control instruction, and completing the encryption and decryption switching through the handshake between the host computer and the lower computer, which ensures the reliable transmission and execution of the smart home control instruction, and improves the user experience and system reliability.

[0193] According to an embodiment of the present invention, there is also provided a storage medium corresponding to the control method for dynamic encryption communication. The storage medium includes a stored program, wherein when the program runs, it controls the device where the storage medium is located to execute the control method for dynamic encryption communication as described above.

[0194] Since the processing and functions implemented by the storage medium of this embodiment are basically corresponding to the embodiments, principles, and examples of the foregoing method, for the details not described in the description of this embodiment, reference may be made to the relevant descriptions in the foregoing embodiments, which will not be elaborated herein.

[0195] With the technical solution of this embodiment, when there are duplicate data in the control data packet, the host computer encrypts the control command using a new key and its corresponding encryption algorithm to form a new control data packet, and can automatically adjust the encryption algorithm. The slave computer determines whether the data packet is a key-switching data packet or a control data packet according to the data packet length, obtains the new key from the key-switching data packet, obtains the control instruction from the control data packet, and executes the control instruction. Through the handshake between the host computer and the slave computer, the encryption and decryption switching are completed, ensuring the reliable transmission and execution of the smart home control instruction, and improving the user experience and system reliability.

[0196] According to an embodiment of the present invention, there is also provided a computer program product corresponding to the control method of dynamic encryption communication. The computer program product includes a computer program, and when the computer program product is processed and executed, the steps of the above-mentioned control method of dynamic encryption communication are implemented.

[0197] Since the processing and functions implemented by the computer program product of this embodiment are basically corresponding to the embodiments, principles, and examples of the foregoing method, for the details not described in the description of this embodiment, reference may be made to the relevant descriptions in the foregoing embodiments, which will not be elaborated herein.

[0198] With the technical solution of this embodiment, when there are duplicate data in the control data packet, the host computer encrypts the control command using a new key and its corresponding encryption algorithm to form a new control data packet, and can automatically adjust the encryption algorithm. The slave computer determines whether the data packet is a key-switching data packet or a control data packet according to the data packet length, obtains the new key from the key-switching data packet, obtains the control instruction from the control data packet, and executes the control instruction. Through the handshake between the host computer and the slave computer, the encryption and decryption switching are completed, ensuring the reliable transmission and execution of the smart home control instruction, and improving the user experience and system reliability.

[0199] In summary, it is easy for those skilled in the art to understand that, on the premise of no conflict, the above-mentioned advantageous ways can be freely combined and superimposed.

[0200] The above description is only for the embodiments of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the scope of the claims of the present invention.

Claims

1. A control method for dynamic encrypted communication, which is applied to a host computer, characterized in that, The host computer stores a key table, in which there are more than two keys. The status of each key is recorded in the key table, and each key corresponds to an encryption algorithm. The method includes: Receiving a control command sent by a user, and encrypting the control command using the current key and the corresponding encryption algorithm to form a control data packet. Here, the current key refers to the key whose status is active and is used by the host computer at the current moment; Judging whether there is duplicate data in the control data packet. If there is duplicate data in the control data packet, select a new key in the key table, form a key-switching data packet based on the new key, and send the key-switching data packet to the slave computer; If a key-switching response packet returned by the slave computer is received, encrypt the control command using the new key and the corresponding encryption algorithm to form a new control data packet, and send the new control data packet to the slave computer.

2. The control method for dynamic encryption communication according to claim 1, wherein The judging whether there is duplicate data in the control data packet includes: Detecting whether there are two adjacent bytes that appear repeatedly in the control data packet; If there are two adjacent bytes that appear repeatedly, it is determined that there is duplicate data in the control data packet.

3. The control method for dynamic encryption communication according to claim 1 or 2, characterized in that Each key in the key table corresponds to a key ID; The selecting a new key in the key table and forming a key-switching data packet based on the new key includes: Searching the key table to find the current key, marking the status of the current key as abnormal, and recording the reason for the abnormality of the current key; Selecting an available new key in the key table based on the priority or polling mechanism; Filling the key ID corresponding to the new key into the key-switching data packet.

4. The control method for dynamic encryption communication according to claim 3, characterized in that, After receiving the key-switching response packet returned by the slave computer and before encrypting the control command using the new key and the corresponding encryption algorithm, it further includes: Generating a test instruction, encrypting the test instruction using the new key and the corresponding encryption algorithm to form a test data packet, and sending the test data packet to the slave computer; If a key-switching success confirmation packet returned by the slave computer is received, mark the status of the new password as active, and encrypt the control command using the new key and the corresponding encryption algorithm.

5. A control method for dynamic encrypted communication, the method being applied to a lower computer, characterized in that, The slave computer stores a key table, in which there are more than two keys. The status of each key is recorded in the key table, and each key corresponds to a decryption algorithm. The method includes: Receiving a data packet sent by the host computer when a communication connection is established between the slave computer and the host computer; Judging whether the data packet is a key-switching data packet or a control data packet according to the length of the data packet; If the data packet is a control data packet, decrypt the control data packet using the current key and the corresponding decryption algorithm to obtain the control instruction, and execute the control instruction. Here, the current key refers to the key whose status is active and is used by the slave computer at the current moment; If the data packet is a handover key data packet, obtain a new key based on the handover key data packet, and send a handover key response packet to the host computer.

6. The control method for dynamic encryption communication according to claim 5, characterized in that, The judging that the data packet is a handover key data packet or a control data packet according to the length of the data packet includes: If the length of the data packet is a preset first length, judge that the data packet is a control data packet; If the length of the data packet is a preset second length, judge that the data packet is a handover key data packet; where the first length is greater than the second length.

7. The control method for dynamic encryption communication according to claim 5 or 6, characterized in that Each key in the key table corresponds to a key ID; the obtaining of the new key based on the handover key data packet includes: Obtain the key ID and decryption algorithm from the handover key data packet; Search the key table to find the new key corresponding to the key ID, and mark the status of the new key as the active state.

8. The control method for dynamic encryption communication according to claim 7, characterized in that After sending the handover key response packet to the host computer, further include: Receive the test data packet sent by the host computer; Decrypt the test data packet using the new key and the decryption algorithm; If the decryption is successful, return a handover key success confirmation packet to the host computer.

9. A control device for dynamic encrypted communication, the device is applied to a host computer, and is characterized in that The host computer stores a key table, there are more than two keys in the key table, the status of each key is recorded in the key table, and each key corresponds to an encryption algorithm; The control device includes: A control unit, configured to receive a control command sent by a user, encrypt the control command using the current key and its corresponding encryption algorithm to form a control data packet; wherein, the current key refers to the key whose status is active and used by the host computer at the current moment; The control unit is further configured to judge whether there is duplicate data in the control data packet. If there is duplicate data in the control data packet, select a new key in the key table, form a handover key data packet based on the new key, and send the handover key data packet to the lower computer; The control unit is further configured to, if receiving the handover key response packet returned by the lower computer, encrypt the control command using the new key and its corresponding encryption algorithm to form a new control data packet, and send the new control data packet to the lower computer.

10. A control device for dynamic encryption communication, the device being applied to a lower computer, characterized in that, The lower computer stores a key table, there are more than two keys in the key table, the status of each key is recorded in the key table, and each key corresponds to a decryption algorithm; the control device includes: A control unit, configured to receive the data packet sent by the host computer when the lower computer establishes a communication connection with the host computer; The control unit is further configured to judge whether the data packet is a handover key data packet or a control data packet according to the length of the data packet; The control unit is further configured to, if the data packet is a control data packet, decrypt the control data packet using the current key and its corresponding decryption algorithm to obtain the control instruction, and execute the control instruction; wherein, the current key refers to the key whose status is active and used by the lower computer at the current moment; The control unit is further configured to, if the data packet is a handover key data packet, obtain a new key based on the handover key data packet and send a handover key response packet to the host computer.

11. A device, characterized in that, including: The control device for dynamic encryption communication according to claim 10.

12. The device according to claim 11, characterized in that, The device is an air conditioner.

13. A storage medium, characterized in that, The storage medium includes a stored program, wherein when the program runs, it controls the device where the storage medium is located to execute the control method of dynamic encryption communication according to any one of claims 1 to 4 or any one of claims 5 to 8.

14. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4 or any one of claims 5 to 8.