Instruction interaction method and system of intelligent equipment
By combining instruction caching and an MQTT server, the problems of instruction loss and increased power consumption in smart devices during sleep mode are solved, realizing a low-power and high-efficiency instruction interaction method and extending battery life.
Patent Information
- Application Number
- CN202510986095.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-17
- Publication Date
- 2025-11-07
AI Technical Summary
Smart devices cannot receive server commands when in sleep mode, resulting in command loss, while long-term connection methods will significantly increase power consumption and shorten battery life.
A batch of instructions is cached using an instruction caching server. The system connects to the smart device via an MQTT server and forwards instructions according to priority. The smart device executes the instructions upon wake-up. QoS settings of the MQTT protocol are used to reduce power consumption.
Without maintaining a persistent connection, it ensures that commands are not lost, reduces device power consumption, extends battery life, and achieves low-power, high-efficiency command interaction.
Smart Images

Figure CN120915822A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of Internet of Things, and particularly to a command interaction method and system of intelligent devices. BACKGROUND
[0002] With the rapid development of Internet of Things technology, intelligent devices are increasingly widely used in daily life. However, the intelligent devices may not be able to receive server instructions when processing the sleep state, resulting in lost instructions. At the same time, if the intelligent devices maintain a long connection with the server, the power consumption of the intelligent devices will be greatly increased, shortening the battery life.
[0003] That is, when the intelligent devices process the sleep state, the server instructions cannot be received, and the issued instructions will be lost. However, if the intelligent devices and the server use a long connection mode, the power consumption of the intelligent devices will be greatly increased, resulting in rapid use of the battery power.
[0004] Therefore, the prior art still needs to be improved and developed. SUMMARY
[0005] The main purpose of the present application is to provide a command interaction method and system of intelligent devices, which aims to solve the problem that the intelligent devices cannot receive server instructions when processing the sleep state in the prior art, resulting in lost instructions. However, if the intelligent devices and the server use a long connection mode, the power consumption of the intelligent devices will be greatly increased, resulting in rapid use of the battery power.
[0006] To achieve the above purpose, the present application provides a command interaction method of intelligent devices, which comprises the following steps:
[0007] The platform issues batch instructions to the instruction cache server, and waits for the intelligent devices to connect to the MQTT server;
[0008] When the first intelligent device is connected to the MQTT server, the MQTT server notifies the instruction cache server and the platform of the first connection result;
[0009] The instruction cache server issues instructions to the MQTT server according to the priority, and the MQTT server forwards them to the first intelligent device, which executes the instructions sent by the MQTT server;
[0010] The first intelligent device sends the execution result of the executed instructions to the MQTT server, and the MQTT server sends the execution result to the instruction cache server;
[0011] The second intelligent device is connected with the MQTT server, the MQTT server notifies the instruction cache server and the platform of a second connection result, the instruction cache server sends instructions to the MQTT server according to priorities, and the sending is completed until all instructions are sent.
[0012] Optionally, the instruction interaction method of the intelligent device, wherein the platform sends batch instructions to the instruction cache server, and waits for the intelligent device to connect the MQTT server, and the method specifically comprises the following steps:
[0013] The platform establishes a connection with the instruction cache server, and the platform sends batch instructions to the instruction cache server.
[0014] The instruction cache server caches the batch instructions sent by the platform, and waits for the intelligent device to connect the MQTT server.
[0015] Optionally, the instruction interaction method of the intelligent device, wherein after the first intelligent device is connected with the MQTT server, the MQTT server notifies the instruction cache server and the platform of a first connection result, and the method specifically comprises the following steps:
[0016] The first intelligent device is connected with the MQTT server through the MQTT protocol, a QoS is set to zero, and a first connection result is generated.
[0017] The MQTT server establishes a connection with the instruction cache server, the MQTT server notifies the instruction cache server of the first connection result, and the instruction cache server forwards the first connection result to the platform.
[0018] Optionally, the instruction interaction method of the intelligent device, wherein the instruction cache server sends instructions to the MQTT server according to priorities, the MQTT server forwards the instructions to the first intelligent device, the first intelligent device executes the instructions sent by the MQTT server, and the method specifically comprises the following steps:
[0019] The instruction cache server sends instructions to the MQTT server according to priorities.
[0020] The MQTT server forwards the instructions sent by the instruction cache server to the first intelligent device.
[0021] The first intelligent device executes the instructions sent by the MQTT server, and generates an execution result corresponding to the instructions.
[0022] Optionally, the instruction interaction method of the intelligent device, wherein the first intelligent device sends the execution result after executing the instructions to the MQTT server, and the MQTT server sends the execution result to the instruction cache server, and the method specifically comprises the following steps:
[0023] The first smart device sends an execution result after executing the instruction to the MQTT server, and the execution result includes execution success and execution failure;
[0024] The MQTT server sends the execution result of the execution success or the execution failure to the instruction cache server.
[0025] Optionally, the instruction interaction method of the smart device, wherein the second smart device is connected with the MQTT server, the MQTT server notifies the instruction cache server and the platform of a second connection result, the instruction cache server issues instructions to the MQTT server according to the priority until all instructions are sent, and the method specifically comprises:
[0026] The second smart device is connected with the MQTT server through the MQTT protocol, a QoS is set to zero, and a second connection result is generated;
[0027] The MQTT server notifies the instruction cache server of the second connection result, and the instruction cache server forwards the second connection result to the platform;
[0028] The instruction cache server issues the instructions to the MQTT server according to the priority until all instructions are sent.
[0029] Optionally, the instruction interaction method of the smart device, wherein the instruction interaction method of the smart device further comprises:
[0030] The time effectiveness of the instruction is set, and the instruction is effective within a valid period.
[0031] Optionally, the instruction interaction method of the smart device, wherein the instruction interaction method of the smart device further comprises:
[0032] The platform sends a clear-all-cache instruction to the instruction cache server, and the instruction cache server clears all cached instructions of the smart device according to the clear-all-cache instruction.
[0033] Optionally, the instruction interaction method of the smart device, wherein the instruction interaction method of the smart device further comprises:
[0034] The first smart device or the second smart device waits for a preset time, and if the first smart device or the second smart device does not receive the instruction within the preset time, the first smart device or the second smart device enters a sleep state.
[0035] In addition, to achieve the above object, the application further provides an instruction interaction system of a smart device, wherein the instruction interaction system of the smart device comprises:
[0036] The instruction interaction system of the smart device comprises a smart device, an MQTT server, an instruction cache server and a platform, the smart device comprises a first smart device and a second smart device;
[0037] The platform issues batch instructions to the instruction cache server;
[0038] The instruction cache server caches the batch instructions issued by the platform and waits for the smart device to connect to the MQTT server;
[0039] The first smart device is connected to the MQTT server through the MQTT protocol;
[0040] The MQTT server notifies the instruction cache server and the platform of the first connection result;
[0041] The instruction cache server issues instructions to the MQTT server according to the priority;
[0042] The MQTT server forwards the instructions sent by the instruction cache server to the first smart device;
[0043] The first smart device executes the instructions sent by the MQTT server;
[0044] The first smart device sends the execution result after executing the instructions to the MQTT server;
[0045] The MQTT server sends the execution result to the instruction cache server;
[0046] The second smart device is connected to the MQTT server through the MQTT protocol;
[0047] The MQTT server notifies the instruction cache server and the platform of the second connection result;
[0048] The instruction cache server issues instructions to the MQTT server according to the priority until all instructions are sent.
[0049] In addition, to achieve the above purpose, the application also provides a terminal, wherein the terminal comprises a memory, a processor and an instruction interaction program of a smart device stored in the memory and executable on the processor, and the instruction interaction program of the smart device is executed by the processor to realize the steps of the instruction interaction method of the smart device.
[0050] In addition, to achieve the above purpose, the application also provides a computer readable storage medium, wherein the computer readable storage medium stores an instruction interaction program of a smart device, and the instruction interaction program of the smart device is executed by a processor to realize the steps of the instruction interaction method of the smart device.
[0051] In the present application, the platform issues batch instructions to the instruction cache server, and waits for the smart device to connect to the MQTT server; when the first smart device connects to the MQTT server, the MQTT server notifies the instruction cache server and the platform of the first connection result; the instruction cache server issues instructions to the MQTT server according to the priority, the MQTT server forwards the instructions to the first smart device, and the first smart device executes the instructions sent by the MQTT server; the first smart device sends the execution result of the executed instructions to the MQTT server, and the MQTT server sends the execution result to the instruction cache server; the second smart device connects to the MQTT server, the MQTT server notifies the instruction cache server and the platform of the second connection result, the instruction cache server issues instructions to the MQTT server according to the priority, and the process is repeated until all instructions are sent. The present application caches user instructions, and when the smart device is woken up next time, the corresponding operation of the instructions is executed, which can not only ensure that the instructions are not lost, but also does not need to maintain a long connection, so that the device power consumption can be reduced and the battery life can be prolonged. BRIEF DESCRIPTION OF DRAWINGS
[0052] Figure 1 is a flow chart of a preferred embodiment of the instruction interaction method of the smart device of the present application;
[0053] Figure 2 is a schematic diagram of the principle of communication interaction of each end in a preferred embodiment of the instruction interaction system of the smart device of the present application. DETAILED DESCRIPTION
[0054] In order to make the purpose, technical scheme and advantages of the present application more clear and definite, the present application will be further described in detail below with reference to the drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application, and are not used to limit the present application.
[0055] The instruction interaction method of the smart device according to the preferred embodiment of the present application, as shown in Figure 1 and Figure 2 , the instruction interaction method of the smart device comprises the following steps:
[0056] Step S10, the platform issues batch instructions to the instruction cache server, and waits for the smart device to connect to the MQTT server.
[0057] Specifically, the platform (i.e. business system) establishes a connection with the instruction cache server (a cache system specially used for storing and quickly providing computer program instructions (codes), aiming to optimize the access speed of instructions and reduce the waiting time of processors or computing units, the instruction cache server optimizes the execution efficiency of computationally intensive tasks by centralizing and caching code instructions, and is especially suitable for modern computing architectures with distribution and high concurrency), the platform issues batch instructions to the instruction cache server; the instruction cache server caches the batch instructions issued by the platform to ensure that the instructions are not lost, and waits for the smart device to connect to the MQTT server (MQTT Broker is the core component of the lightweight Internet of Things communication protocol MQTT (Message Queuing Telemetry Transport), responsible for receiving, forwarding and scheduling messages between devices (clients), and realizes an efficient, low-power publish / subscribe (Pub / Sub) communication mode), the MQTT server is the "central nerve" of Internet of Things communication, decoupling the dependence between devices through the publish / subscribe mode, and taking into account low power consumption and high real-time performance.
[0058] Step S20, when the first smart device is connected to the MQTT server, the MQTT server notifies the instruction cache server and the platform of the first connection result.
[0059] Specifically, the first smart device connects to the MQTT server through the MQTT protocol, the MQTT protocol (Message Queuing Telemetry Transport) is a lightweight and efficient publish / subscribe (Pub / Sub) message transmission protocol specially designed for the Internet of Things (IoT) and low-bandwidth environments, which is based on TCP / IP and suitable for communication scenarios between devices with low power consumption, high latency or unreliable networks, the MQTT protocol has become a de facto standard for Internet of Things communication due to its lightweight, efficient and flexible nature, and sets QoS (Quality of Service) to zero to reduce power consumption, QoS0 is the best effort delivery, which does not guarantee message delivery, when the MQTT client publishes with QoS1, the MQTT broker does not confirm receipt, and the message is not stored and re-sent by the sender, QoS0 is usually referred to as "fire and forget", which provides the same guarantee as the underlying TCP protocol; then generate the first connection result; the MQTT server establishes a connection with the instruction cache server, the MQTT server notifies the instruction cache server of the first connection result, and the instruction cache server forwards it to the platform.
[0060] Step S30, the instruction cache server sends instructions to the MQTT server according to the priority, the MQTT server forwards to the first smart device, and the first smart device executes the instructions sent by the MQTT server.
[0061] Specifically, the instruction cache server sends instructions to the MQTT server according to the priority; the MQTT server forwards the instructions sent by the instruction cache server to the first smart device; the first smart device executes the instructions sent by the MQTT server to generate the execution result corresponding to the instructions, and each instruction execution will have a corresponding execution result.
[0062] Step S40, the first smart device sends the execution result after executing the instructions to the MQTT server, and the MQTT server sends the execution result to the instruction cache server.
[0063] Specifically, the first smart device sends the execution result after executing the instructions to the MQTT server, and the execution result includes execution success and execution failure; the MQTT server sends the execution result of execution success or execution failure to the instruction cache server, and if the first smart device reply timeout or reply failure, the next instruction is sent. The instruction execution result is recorded to the MySQL database (a widely used open source relational database management system) to realize persistent storage.
[0064] Step S50, the second smart device is connected with the MQTT server, the MQTT server notifies the instruction cache server and the platform of the second connection result, and the instruction cache server sends instructions to the MQTT server according to the priority until all instructions are sent.
[0065] Specifically, the second smart device is connected with the MQTT server through the MQTT protocol, sets the QoS to zero, generates the second connection result; the MQTT server notifies the instruction cache server of the second connection result, and the instruction cache server forwards to the platform; the instruction cache server sends instructions to the MQTT server according to the priority, continues to execute the instructions according to the process of the first smart device executing the instructions until all instructions are sent.
[0066] The first smart device and the second smart device are indirectly connected with the platform in one machine and one secret mode to ensure data security.
[0067] The time effectiveness of the instructions is set, and the instructions are effective within the valid period, for example, the remote unlocking instruction is valid for 3 minutes.
[0068] The platform sends a clear all cache instruction to the instruction cache server, and the instruction cache server clears all cached instructions of the smart device according to the clear all cache instruction, that is, the platform can issue a clear all cache instruction to the instruction cache server, and the part of the instruction is not executed on the smart device, such as all the instruction caches of the smart device before the user binds the smart device are cleared, to ensure that the smart device is restored to execute the binding after leaving the factory, so as to prevent historical data from causing interference.
[0069] The smart device is woken up daily for receiving instructions, and the completeness of the instructions is supplemented; after the platform issues an instruction, the instruction is stored in the instruction cache server, but has a time limit, for example, the instruction of issuing a password is valid within 24 hours, the smart device can be manually woken up to quickly receive relevant instructions, but can also wait for the smart device to be woken up at a regular time, such as woken up once every 8 hours to receive instructions, to prevent the loss of instructions due to invalidation.
[0070] For example, the first smart device or the second smart device waits for a preset time, and if the first smart device or the second smart device does not receive an instruction within the preset time, the first smart device or the second smart device enters a sleep state.
[0071] The smart device executes active connection to the server through a specific panel instruction, such as #5555, pulls the server instruction, and compensates the completeness of the data (the data is the result after the instruction is executed, for example, the device platform has 5 password records, and only 4 are locked on the surface, and the missing data is supplemented by synchronizing with the platform data).
[0072] The smart device reports relevant time directly into the RabbmitMQ queue, RabbmitMQ is a kind of message middleware, which is a container for storing messages, and the device reports time is not fixed, in order to ensure that the reported data will not be lost, so it is stored in this middleware first, and then the related business is executed, such as reporting the opening event, and storing it in the database table of the opening and closing record, the server asynchronously executes the business logic, such instruction cannot be responded in time, and the final response result can be known only after the smart device executes and reports, so as to reduce the waiting of the device and prolong the service life of the battery.
[0073] In the present application, the instruction cache server stores user instructions through caching, and when the smart device is woken up next time, the corresponding operation of the server instruction is executed, a compromise point between power consumption and real-time performance is selected, which can ensure that the instruction is not lost, without maintaining a long connection, and can also reduce the power consumption of the smart device and prolong the service life of the battery.
[0074] The technical effects that can be brought by the present application are as follows:
[0075] (1) Reduce power consumption: cache user instructions, and execute the specific operation process of the instructions when the smart device is woken up, which realizes the core mechanism of reducing power consumption, and ensures that the device can still effectively receive and execute instructions in a low-power state.
[0076] (2) Application of MQTT protocol: the MQTT protocol adopted between the smart device and the MQTT server, including the setting of QoS value, ensures that the device can still receive instructions in a low-power mode.
[0077] (3) Device wake-up strategy: the smart device wakes up regularly to receive MQTT server instructions, which helps to reduce overall power consumption.
[0078] (4) Security and data integrity: one-to-one encryption connection method and security measures for platform connection to ensure data integrity and security during instruction issuance and device response process.
[0079] Further, as shown in Figure 2 Based on the above instruction interaction method of the smart device, the present application also correspondingly provides an instruction interaction system of a smart device, wherein the instruction interaction system of the smart device comprises: a smart device, an MQTT server, an instruction cache server and a platform, the smart device comprises a first smart device and a second smart device, the platform and the instruction cache server are connected, the instruction cache server is connected with the MQTT server, and the MQTT server is connected with the first smart device and the second smart device.
[0080] The interaction process between each device is as follows:
[0081] 1. The platform issues batch instructions to the instruction cache server;
[0082] 2. The instruction cache server caches the batch instructions issued by the platform, and waits for the smart device to connect to the MQTT server;
[0083] 3. The first smart device connects to the MQTT server through the MQTT protocol;
[0084] 4. The MQTT server notifies the instruction cache server and the platform of the first connection result;
[0085] 5. The instruction cache server issues instructions to the MQTT server according to the priority;
[0086] 6. The MQTT server forwards the instructions sent by the instruction cache server to the first smart device;
[0087] 7. The first smart device executes the instructions sent by the MQTT server;
[0088] 8. The first smart device sends the execution result after executing the instructions to the MQTT server;
[0089] 9. The MQTT server sends the execution result to the instruction cache server;
[0090] 10. The second smart device connects with the MQTT server through the MQTT protocol;
[0091] 11. The MQTT server notifies the second connection result to the instruction cache server and the platform;
[0092] 12. The instruction cache server issues the instructions to the MQTT server according to the priority until all the instructions are sent.
[0093] In summary, the application provides a kind of instruction interaction method and system of smart device, the method includes: platform issues batch instruction to instruction cache server, and waits for smart device to connect MQTT server;When first smart device is connected with MQTT server, MQTT server notifies first connection result to instruction cache server and platform;Instruction cache server issues instruction to MQTT server according to priority, and MQTT server is forwarded to first smart device, and first smart device executes the instruction sent by MQTT server;First smart device sends the execution result after executing instruction to MQTT server, and MQTT server sends the execution result to instruction cache server;Second smart device is connected with MQTT server, and MQTT server notifies second connection result to instruction cache server and platform, and instruction cache server issues instruction to MQTT server according to priority, until all the instructions are sent.The application stores user instruction by cache, when smart device is waken up next time, executes the corresponding operation of instruction, can guarantee that instruction is not lost, also need not to keep long connection, can reduce device power consumption, prolongs battery service life.
[0094] It should be noted that in this document, the terms "comprises", "comprising", or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element preceded by "comprises... a" does not, without more constraints, foreclose the existence of additional identical elements in the process, method, article, or apparatus that comprises the recited element.
[0095] Of course, those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing relevant hardware (such as a processor, a controller, etc.) through a computer program. The program can be stored in a computer-readable computer-readable storage medium, 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.
[0096] It should be understood that the application is not limited to the above examples, and those skilled in the art can make improvements or changes according to the above description, and all these improvements and changes shall belong to the protection scope of the appended claims of the application.
Claims
1. A method for instruction interaction of an intelligent device, characterized in that, The instruction interaction method of the intelligent device comprises: The platform sends batch instructions to the instruction cache server and waits for the intelligent device to connect to the MQTT server; When the first intelligent device connects to the MQTT server, the MQTT server notifies the instruction cache server and the platform of the first connection result; The instruction cache server sends instructions to the MQTT server according to the priority, the MQTT server forwards the instructions to the first intelligent device, and the first intelligent device executes the instructions sent by the MQTT server; The first intelligent device sends the execution result of the executed instructions to the MQTT server, and the MQTT server sends the execution result to the instruction cache server; The second intelligent device connects to the MQTT server, the MQTT server notifies the instruction cache server and the platform of the second connection result, and the instruction cache server sends instructions to the MQTT server according to the priority until all instructions are sent. 2.The method of claim 1, wherein, The platform sends batch instructions to the instruction cache server and waits for the intelligent device to connect to the MQTT server, and specifically comprises: The platform establishes a connection with the instruction cache server, and the platform sends batch instructions to the instruction cache server; The instruction cache server caches the batch instructions sent by the platform and waits for the intelligent device to connect to the MQTT server. 3.The method of claim 1, wherein, When the first intelligent device connects to the MQTT server, the MQTT server notifies the instruction cache server and the platform of the first connection result, and specifically comprises: The first intelligent device connects to the MQTT server through the MQTT protocol and sets the QoS to zero to generate the first connection result; The MQTT server establishes a connection with the instruction cache server, the MQTT server notifies the instruction cache server of the first connection result, and the instruction cache server forwards the first connection result to the platform. 4.The method of claim 1, wherein, The instruction cache server sends instructions to the MQTT server according to the priority, the MQTT server forwards the instructions to the first intelligent device, and the first intelligent device executes the instructions sent by the MQTT server, and specifically comprises: The instruction cache server sends instructions to the MQTT server according to the priority; The MQTT server forwards the instructions sent by the instruction cache server to the first intelligent device; The first intelligent device executes the instructions sent by the MQTT server to generate the execution result corresponding to the instructions. 5.The method of claim 1, wherein, The first intelligent device sends the execution result of the executed instructions to the MQTT server, and the MQTT server sends the execution result to the instruction cache server, and specifically comprises: The first intelligent device sends the execution result of the executed instructions to the MQTT server, and the execution result includes execution success and execution failure; The MQTT server sends the execution result of the execution success or the execution failure to the instruction cache server. 6.The method of claim 1, wherein, The second intelligent device connects to the MQTT server, the MQTT server notifies the instruction cache server and the platform of the second connection result, the instruction cache server sends instructions to the MQTT server according to the priority, and all instructions are sent, and specifically comprises: The second intelligent device connects to the MQTT server through the MQTT protocol and sets the QoS to zero to generate the second connection result; The MQTT server notifies the instruction cache server of the second connection result, and the instruction cache server forwards the notification to the platform; The instruction cache server sends the instructions to the MQTT server according to the priority, until all the instructions are sent. 7.The method of claim 1, wherein, The instruction interaction method of the smart device further includes: The time effectiveness of the instruction is set, and the control instruction is effective within the effective period. 8.The method of claim 1, wherein, The instruction interaction method of the smart device further includes: The platform sends the empty all cache instruction to the instruction cache server, and the instruction cache server clears all the cached instructions of the smart device according to the empty all cache instruction. 9.The method of claim 1, wherein, The instruction interaction method of the smart device further includes: The first smart device or the second smart device waits for a preset time, and if the first smart device or the second smart device does not receive the instruction within the preset time, the first smart device or the second smart device enters the sleep state.
10. An instruction interaction system of a smart device, characterized by, The instruction interaction system of the smart device includes a smart device, an MQTT server, an instruction cache server and a platform, the smart device includes a first smart device and a second smart device; The platform sends the batch instructions to the instruction cache server; The instruction cache server caches the batch instructions sent by the platform, and waits for the smart device to connect the MQTT server; The first smart device connects the MQTT server through the MQTT protocol; The MQTT server notifies the instruction cache server and the platform of the first connection result; The instruction cache server sends the instructions to the MQTT server according to the priority; The MQTT server forwards the instructions sent by the instruction cache server to the first smart device; The first smart device executes the instructions sent by the MQTT server; The first smart device sends the execution result after executing the instructions to the MQTT server; The MQTT server sends the execution result to the instruction cache server; The second smart device connects the MQTT server through the MQTT protocol; The MQTT server notifies the instruction cache server and the platform of the second connection result; The instruction cache server sends the instructions to the MQTT server according to the priority, until all the instructions are sent.
Citation Information
Cited By
Low-power-consumption equipment control instruction issuing method and system based on cache queue
CN121645431A