Device control method, electronic device, and readable storage medium
Patent Information
- Application Number
- CN202611051285.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-15
- Publication Date
- 2026-10-16
AI Technical Summary
[0004]本申请实施例提供了一种设备控制方法、电子设备及可读存储介质,用于解决,网关对多个设备进行设备控制时,存在网关资源消耗过多、设备控制效率低下的问题
通过响应于接收上位机通过物模型发送的指令包,通过预设的通信接口向上位机发送第一指令标识,由于指令包包括上位机为指令包分配的第一指令标识和指令包指示网关向绑定的至少一个设备发送控制指令,实现了网关在接收到指令包时,自动根据解析得到第一指令标识来请求获取需要发送的控制指令。
Smart Images

Figure CN122933705A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Internet of Things (IoT) technology, and more specifically, to a device control method, an electronic device, and a readable storage medium. Background Technology
[0002] In the field of IoT device control, gateways, as core control nodes, play a crucial role in information interaction, command issuance, and status feedback with multiple sub-devices, and are widely used in smart home, industrial control, and other scenarios.
[0003] However, in related technologies, when a gateway controls multiple devices, there are problems such as excessive gateway resource consumption and low device control efficiency. Summary of the Invention
[0004] This application provides a device control method, an electronic device, and a readable storage medium to solve the problems of excessive gateway resource consumption and low device control efficiency when a gateway controls multiple devices.
[0005] According to a first aspect of the embodiments of this application, a device control method is provided, applied to a gateway, the method comprising: in response to receiving an instruction packet sent by a host computer through a device model, sending a first instruction identifier to the host computer through a preset communication interface; the instruction packet includes a first instruction identifier assigned by the host computer to the instruction packet, and instructing the gateway to send a control instruction to at least one bound device; The system receives at least one control instruction returned by the host computer through the communication interface; the at least one control instruction is obtained by the host computer based on the first instruction identifier and the pre-stored correspondence between control instructions and instruction identifiers. For each of the at least one devices, determine the corresponding control instruction for the device from at least one control instruction according to the instruction packet, and send the corresponding control instruction to the device.
[0006] In one possible implementation, the issuance of control commands and the receipt of control results are executed asynchronously by the gateway, and the control result is the result of the corresponding device executing the control command; if the control result is determined to be an execution failure, the total number of control failures of the gateway is updated. If the total number of attempts exceeds the preset threshold, an exception message is sent to the host computer to instruct it to stop sending command packets to the gateway.
[0007] In one possible implementation, the instruction packet also includes a control sequence of at least one device; at least one control instruction received through the communication interface is arranged according to the control sequence of at least one device; for each of the at least one device, the control sequence of the device is determined according to the instruction packet, and the corresponding control instruction of the device is obtained from the at least one control instruction according to the control sequence; According to the control sequence, the corresponding control command is sent to each of the at least one device in turn.
[0008] In one possible implementation, if it is determined that at least one control instruction corresponding to the first instruction identifier is not cached, the first instruction identifier is sent to the host computer through the communication interface; if it is determined that at least one control instruction corresponding to the first instruction identifier is cached, for each of the at least one devices, the corresponding control instruction for the device is determined from the at least one control instruction according to the instruction packet, and the corresponding control instruction is sent to the device.
[0009] According to a second aspect of the embodiments of this application, a device control method is provided, applied to a host computer, the method comprising: Generate at least one instruction packet and at least one control instruction corresponding to each instruction packet; the instruction packet includes a first instruction identifier assigned by the host computer to the instruction packet, and the instruction packet is used to instruct the gateway to send control instructions to at least one bound device; For each instruction packet, store the correspondence between at least one control instruction corresponding to the instruction packet and the first instruction identifier of the instruction packet, and send the instruction packet to the gateway indicated by the instruction packet; The system receives a first instruction identifier sent by the gateway through a preset communication interface. Based on the first instruction identifier, it obtains at least one control instruction from the correspondence between at least one control instruction and the first instruction identifier. The system then sends at least one control instruction to the gateway through the communication interface, so that the gateway sends a corresponding control instruction to each of the at least one devices.
[0010] In one possible implementation, when a control command is used to instruct the retrieval of status information for any device bound to the gateway, at least one control command is generated in the following manner: When a control is triggered in response to the display function of the control page of any bound gateway, at least one control command is generated; status information of each bound device is received from the gateway. The gateway's control page is updated based on the status information of each device to ensure that the status information of each device displayed on the control page is consistent with the corresponding status information received. The status information of any device within each device is sent to the gateway by the device after receiving the control command.
[0011] In one possible implementation, the instruction package also includes the control sequence for each device; Identify at least one device to be controlled, and group the devices according to the gateways that each device is bound to, to obtain a device group; the device group includes the device identifier of at least one device bound to a gateway; For each device group, determine the control sequence of each device in the group, and generate the corresponding instruction package for the group based on the device identifier and control sequence of each device.
[0012] In one possible implementation, for each instruction packet, a trigger condition corresponding to the instruction packet is stored; in response to any pre-stored trigger condition, the instruction packet corresponding to the trigger condition is obtained; and the instruction packet is sent to the gateway indicated by the instruction packet through the object model. According to a third aspect of the embodiments of this application, a device control apparatus is provided, applied to a gateway, the apparatus comprising: The response module is used to respond to the instruction packet sent by the host computer through the object model, and send a first instruction identifier to the host computer through a preset communication interface; the instruction packet includes the first instruction identifier assigned by the host computer and instructs the gateway to send control instructions to at least one bound device; The receiving module is used to receive at least one control instruction returned by the host computer through a communication interface; the at least one control instruction is obtained by the host computer based on a first instruction identifier and a pre-stored correspondence between control instructions and instruction identifiers; The first sending module is configured to, for each of the at least one devices, determine the corresponding control instruction for the device from at least one control instruction according to the instruction packet, and send the corresponding control instruction to the device.
[0013] According to a fourth aspect of the embodiments of this application, a device control apparatus is provided, applied to a host computer, the apparatus comprising: The generation module is used to generate at least one instruction package and at least one control instruction corresponding to each instruction package; the instruction package includes a first instruction identifier assigned by the host computer to the instruction package, and the instruction package is used to instruct the gateway to send control instructions to at least one bound device; The storage module is used to store the correspondence between at least one control instruction corresponding to each instruction packet and the first instruction identifier of the instruction packet, and to send the instruction packet to the gateway indicated by the instruction packet through the object model; The second sending module is used to receive a first instruction identifier sent by the gateway through a preset communication interface, obtain at least one control instruction from the correspondence between at least one control instruction and the first instruction identifier according to the first instruction identifier, and send at least one control instruction to the gateway through the communication interface, so that the gateway sends a corresponding control instruction to each of the at least one devices.
[0014] According to a fifth aspect of the present application, an electronic device is provided, the electronic device including a memory, a processor and a computer program stored in the memory, wherein the processor executes the program to implement the steps of the method provided in the first aspect.
[0015] According to a sixth aspect of the embodiments of this application, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps of the method provided in the first aspect.
[0016] According to a seventh aspect of the present application, a computer program product is provided, the computer program product including computer instructions stored in a computer-readable storage medium, wherein when a processor of a computer device reads the computer instructions from the computer-readable storage medium, the processor executes the computer instructions, causing the computer device to perform steps implementing the method provided in the first aspect.
[0017] The beneficial effects of the technical solutions provided in this application are: In response to receiving the instruction packet sent by the host computer through the object model, the gateway sends a first instruction identifier to the host computer through a preset communication interface. Since the instruction packet includes the first instruction identifier assigned by the host computer and the instruction packet instructing the gateway to send control commands to at least one bound device, the gateway can automatically request to obtain the control commands to be sent based on the parsed first instruction identifier when it receives the instruction packet.
[0018] The gateway receives at least one control command returned by the host computer through the communication interface. Since the host computer obtains the at least one control command based on the first command identifier and the pre-stored correspondence between control commands and command identifiers, the gateway obtains data packets indicating the sending of control commands and control commands for controlling devices from two communication paths respectively. This enables the gateway to quickly wake up the command packets to retrieve control commands, while ensuring that batches of control commands can also be obtained through a single communication interface call. This eliminates the need to be limited by character length and obtain control commands one by one, reducing the consumption of gateway resources and improving gateway processing efficiency.
[0019] For each of the at least one devices, the corresponding control instruction for the device is determined from at least one control instruction according to the instruction packet, and the corresponding control instruction is sent to the device. This realizes that control instructions are sent to the devices one by one during the control instruction sending stage, without having to send control instructions to another device based on the information received from the device feedback. This greatly saves the gateway's communication and processing resources and improves the overall efficiency of device control. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below.
[0021] Figure 1 A flowchart illustrating a device control method applied to a gateway, provided as an embodiment of this application; Figure 2 A flowchart illustrating a device control method applied to a host computer, provided as an embodiment of this application; Figure 3 This is a schematic diagram of the interaction process in a device control method provided in an embodiment of this application; Figure 4 This is a schematic diagram of the structure of a gateway provided in an embodiment of this application; Figure 5 This is a schematic diagram of the structure of a host computer provided in an embodiment of this application; Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0022] The embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the embodiments described below with reference to the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions of the embodiments of this application.
[0023] Those skilled in the art will understand that, unless otherwise stated, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the terms “comprising” and “including” as used in embodiments of this application mean that the corresponding feature can be implemented as the presented feature, information, data, step, operation, element, and / or component, but do not exclude implementation as other features, information, data, step, operation, element, component, and / or combinations thereof supported by the art. It should be understood that when we say that an element is “connected” or “coupled” to another element, the one element can be directly connected or coupled to the other element, or it can mean that the one element and the other element establish a connection relationship through an intermediate element. Furthermore, “connected” or “coupled” as used herein can include wireless connection or wireless coupling. The term “and / or” as used herein indicates at least one of the items defined by the term; for example, “A and / or B” can be implemented as “A,” or as “B,” or as “A and B.”
[0024] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0025] The relevant technologies are explained below: In related technologies, the interaction process between the gateway and sub-devices is roughly as follows: the gateway receives multi-device control requests from the host computer, generates individual control commands for each sub-device sequentially, and sends them to the corresponding sub-devices one by one; after each sub-device receives and executes the command, it sends a control success signal back to the gateway. The gateway confirms receipt of the feedback before sending commands to the next sub-device, until all sub-devices have been controlled. This control method does not require special packaging of control commands, making its technical implementation relatively simple, and most IoT gateway devices currently use this interaction mode.
[0026] However, the relevant technologies have the following problems: 1. Excessive Hardware Load: When controlling multiple sub-devices, the gateway needs to perform both "command issuance" and "feedback reception" operations simultaneously, and each sub-device needs to be processed individually. This causes the gateway's processor and communication module to operate under high load for extended periods. Especially when there are many sub-devices (e.g., more than 4), the gateway needs to frequently switch interaction objects, exacerbating timing conflicts between command issuance and feedback reception. This can easily lead to command stuttering, delays, or even gateway crashes, severely impacting control stability.
[0027] 2. Significant resource waste: The gateway must receive a successful control response from each sub-device before it can confirm the completion of control for that sub-device and proceed with the control of the next device. However, in real-world applications, the probability of sub-device control failure is extremely low, and in most scenarios, it is not necessary to obtain the feedback status of individual sub-devices in real time. This "must wait for feedback" mechanism consumes a large amount of the gateway's communication bandwidth and processing resources, resulting in resource waste and also prolonging the time required for the entire batch control process.
[0028] 3. Low control efficiency: Due to the adoption of the "one-by-one dispatch and feedback" mode, the total time for batch control of multiple sub-devices is positively correlated with the number of sub-devices. The more sub-devices there are, the longer the control time will be, which cannot meet the needs of rapid batch control of multiple devices.
[0029] In response to at least one of the aforementioned technical problems or areas requiring improvement in related technologies, this application proposes a device control method. This method, in response to receiving an instruction packet sent by a host computer through a physical model, sends a first instruction identifier to the host computer via a preset communication interface. Since the instruction packet includes a first instruction identifier assigned by the host computer and an instruction packet instructing the gateway to send control commands to at least one bound device, the gateway automatically requests and obtains the control commands to be sent based on the parsed first instruction identifier when it receives the instruction packet.
[0030] The gateway receives at least one control command returned by the host computer through the communication interface. Since the host computer obtains the at least one control command based on the first command identifier and the pre-stored correspondence between control commands and command identifiers, the gateway obtains data packets indicating the sending of control commands and control commands for controlling devices from two communication paths respectively. This enables the gateway to quickly wake up the command packets to retrieve control commands, while ensuring that batches of control commands can also be obtained through a single communication interface call. This eliminates the need to be limited by character length and obtain control commands one by one, reducing the consumption of gateway resources and improving gateway processing efficiency.
[0031] For each of the at least one devices, the corresponding control instruction for the device is determined from at least one control instruction according to the instruction packet, and the corresponding control instruction is sent to the device. This realizes that control instructions are sent to the devices one by one during the control instruction sending stage, without having to send control instructions to another device based on the information received from the device feedback. This greatly saves the gateway's communication and processing resources and improves the overall efficiency of device control.
[0032] The technical solutions of this application and their effects are described below through several exemplary embodiments. It should be noted that the following embodiments can be referenced, borrowed from, or combined with each other. Identical terms, similar features, and similar implementation steps in different embodiments will not be repeated.
[0033] Those skilled in the art will understand that the number of terminals described above can be more or less. For example, there may be only one terminal, or there may be dozens or hundreds of terminals, or even more. This application does not limit the number of terminals or the type of device.
[0034] This application provides a device control method for a gateway, such as... Figure 1 As shown, the method includes: S101, in response to receiving the instruction packet sent by the host computer through the object model, sends the first instruction identifier to the host computer through a preset communication interface.
[0035] In this embodiment, the host computer is used to interact with the gateway and instruct the gateway to control the bound devices. The host computer can be a mobile terminal, an intelligent control platform, or other upper-layer computing entity.
[0036] In this embodiment of the application, the instruction packet includes a first instruction identifier assigned by the host computer to the instruction packet, and instructs the gateway to send control instructions to at least one bound device.
[0037] In this embodiment of the application, when the host computer needs to control multiple devices on the same gateway, it will instruct the gateway to send control commands to at least one bound device by sending instruction packets to the gateway.
[0038] In this embodiment, the host computer sends instruction packets to the gateway through the object model of the IoT platform. The instruction packets adopt the standard JSON format, which is easy for the gateway to parse and implement. No major modifications to the gateway hardware are required. Only the software logic of the gateway needs to be optimized to adapt to most existing IoT gateway devices.
[0039] In this embodiment, the object model acts as a communication bridge between the gateway and the host computer, responsible for the transmission and parsing of instruction packets, ensuring the stability and accuracy of instruction packet transmission, and avoiding instruction packet loss or corruption.
[0040] In this embodiment, the instruction received by the gateway includes a first instruction identifier assigned to the instruction packet by the host computer. The first instruction identifier is used to obtain the control instruction corresponding to the instruction packet. That is, the instruction packet sent by the host computer is used to give device control instructions to the gateway. The instruction packet does not include the control instruction to be sent to the device. The gateway obtains the control instruction through the first instruction identifier in the instruction packet. Therefore, the gateway sends the first instruction identifier to the host computer through a preset communication interface to request to obtain all the control instructions corresponding to the instruction packet. The communication interface is a dedicated communication interface between the gateway and the host computer, used to obtain control instructions in batches.
[0041] In this embodiment, after receiving the instruction packet, the gateway parses the instruction packet to obtain the first instruction identifier, and obtains all control instructions corresponding to the instruction packet from the gateway according to the first instruction identifier. This eliminates the need to obtain the instructions of each sub-device one by one, reducing communication interaction during the instruction acquisition process.
[0042] S102 receives at least one control command returned by the host computer through the communication interface.
[0043] In this embodiment of the application, at least one control instruction is obtained by the host computer based on the first instruction identifier and the pre-stored correspondence between control instructions and instruction identifiers. That is, before sending the instruction packet to the gateway, the host computer will store the correspondence between the first instruction identifier and at least one control instruction in the Redis cache.
[0044] In this embodiment of the application, after the host computer receives the first instruction identifier through the dedicated communication interface between the host computer and the gateway, it retrieves at least one control instruction corresponding to the first instruction identifier from the Redis cache. Since the first instruction identifier is an identifier assigned by the host computer to the instruction package, it can also be understood as retrieving at least one control instruction corresponding to the instruction package.
[0045] In this embodiment, after the host computer obtains at least one corresponding control instruction, it sends at least one control instruction to the gateway through the communication interface, so that the gateway receives at least one control instruction returned by the host computer through the communication interface. That is to say, the communication paths of the host computer sending instruction packets and control instructions to the gateway are completely different. The instruction packets are sent by the host computer to the gateway through the object model of the Internet of Things platform, while the control instructions are sent by the host computer to the gateway through a dedicated communication interface between the host computer and the gateway.
[0046] In this embodiment, since the content sent through the IoT platform has a character length limit, the host computer does not carry control commands when sending instruction packets through the IoT platform. Instead, it carries a first control identifier, instructing the gateway to obtain control commands through the first control identifier. The gateway obtains control commands through the communication interface between the gateway and the host computer. This solves the problem of the character length limit of the IoT platform. It can not only retrieve all control commands at once, but also avoid the problem of gateway congestion caused by the host computer pushing multiple control commands at once through the IoT platform. This improves the gateway's processing efficiency and reduces the gateway's load.
[0047] S103, for each of the at least one devices, determine the corresponding control instruction for the device from at least one control instruction according to the instruction packet, and send the corresponding control instruction to the device.
[0048] In this embodiment of the application, after obtaining at least one control instruction, the corresponding control instruction for the device can be determined from the at least one control instruction pulled up according to the control attribute parameters of each control operation to be performed by the device indicated in the instruction package.
[0049] In this embodiment of the application, the corresponding control instruction for the device can also be determined from the at least one control instruction retrieved, based on the order of the control operations to be performed by each device in the instruction package and the order of each instruction in the at least one control instruction.
[0050] In this embodiment, after determining the corresponding operation of each device to be controlled, the gateway sends control commands to each device one by one. When issuing control commands, the gateway sends the control command to the currently controlled device and then directly sends control commands to another device. That is, it does not need to wait for the device that has already issued the control command to return the control result before it can directly send control commands to another device. Since receiving feedback information of control commands consumes a lot of the gateway's communication bandwidth and processing resources, this application directly assumes that the device is successfully controlled and does not need to receive feedback information from the device. This saves the time required for batch control of multiple devices.
[0051] The device control method for gateways provided in this application, in response to receiving a command packet sent by a host computer, sends a first command identifier to the host computer through a preset communication interface. Since the command packet includes a first command identifier assigned by the host computer and an instruction from the command packet to the gateway to send control commands to at least one bound device, the gateway can automatically request and obtain the control commands to be sent based on the parsed first command identifier when it receives the command packet.
[0052] The gateway receives at least one control command returned by the host computer through the communication interface. Since the host computer obtains the at least one control command based on the first command identifier and the pre-stored correspondence between control commands and command identifiers, the gateway obtains data packets indicating the sending of control commands and control commands for controlling devices from two communication paths respectively. This enables the gateway to quickly wake up the command packets to retrieve control commands, while ensuring that batches of control commands can also be obtained through a single communication interface call. This eliminates the need to be limited by character length and obtain control commands one by one, reducing the consumption of gateway resources and improving gateway processing efficiency.
[0053] For each of the at least one devices, the corresponding control instruction for the device is determined from at least one control instruction according to the instruction packet, and the corresponding control instruction is sent to the device. This realizes that control instructions are sent to the devices one by one during the control instruction sending stage, without having to send control instructions to another device based on the information received from the device feedback. This greatly saves the gateway's communication and processing resources and improves the overall efficiency of device control.
[0054] Based on the above embodiments, as an optional embodiment, the control command issuance operation and the control result reception operation are executed asynchronously by the gateway, and the control result is the result of the corresponding device executing the control command.
[0055] In this embodiment, the operation of the gateway sending control commands to the device is decoupled from the operation of the gateway receiving the control results fed back by the corresponding device according to the control commands, so that the sending of control commands and the receiving of control results are not completed in the same control response cycle, but can be completed in time-sharing.
[0056] In this embodiment, after the gateway sends a control command to the device, it continues to send control commands to other devices. After all control commands have been sent, it receives the control results sent by the devices, or actively polls the devices to obtain the control results.
[0057] In this embodiment, since the success rate of device control is usually high in practical applications, waiting for feedback on the control result before sending the control command to the next device would result in the gateway's hardware resources being inefficiently occupied. Therefore, this application proposes that the control command issuance operation and the control result reception operation be executed asynchronously by the gateway. During the control command issuance process, the default control result is that the control is successful, and there is no need to receive the control result feedback from the device. This eliminates the steps of receiving, parsing, and processing the control result, greatly saving the gateway's communication and processing resources, allowing the gateway to use more resources for core control functions and improving overall operating efficiency.
[0058] In this embodiment of the application, if the control result is determined to be an execution failure, the total number of control failures of the gateway is updated; if the total number is determined to be greater than a preset threshold, an exception message is sent to the host computer to instruct the host computer to stop sending instruction packets to the gateway.
[0059] In this embodiment of the application, after the gateway obtains the control result, if it determines that the execution result is a control failure, it updates the total number of control failures. If it determines that the total number of control failures is greater than a preset threshold, it means that the current batch device control has failed too many times and is not suitable to continue batch device control. Therefore, it sends an abnormal message to the host computer to instruct the host computer to stop sending instruction packets to the gateway and stop batch control of the devices to avoid large-scale control failures.
[0060] Based on the above embodiments, as an optional embodiment, the instruction package also includes a control sequence of at least one device; at least one control instruction received through the communication interface is arranged according to the control sequence of at least one device.
[0061] In this embodiment of the application, the instruction packet also indicates the control order of each device to be controlled. At least one control instruction obtained from the host computer through the communication interface is arranged according to the control order of each device. That is, if the control order of device A is 1, then the corresponding control instruction of device A is in the first place among the at least one control instruction.
[0062] In this embodiment of the application, for each of the at least one device, the control sequence of the device is determined according to the instruction packet, and the corresponding control instruction of the device is obtained from at least one control instruction according to the control sequence; according to the control sequence, the corresponding control instruction of the device is sent to each of the at least one device one by one.
[0063] In this embodiment of the application, since the instruction packet indicates the control sequence of each device to be controlled, and each instruction in at least one control instruction is arranged according to the control sequence of the corresponding device, the corresponding control instruction of each device is obtained one by one from at least one control instruction according to the control sequence of the device.
[0064] In the above scheme, by adding the control sequence of each controlled device to the instruction packet by the host computer, it is possible to indicate the devices that need to be controlled first. The gateway will execute the control devices at the top of the control sequence in order of priority, adapting to the control needs of different scenarios.
[0065] In one example, the command packet uses a fixed JSON format. The command packet contains a first command identifier, gateway information, and control parameters for multiple devices. The specific JSON format is as follows: { "commandPackagingId": 6626, "productKey": "DUH682KS9O", "deviceName": "869955064429173", "actions": [ { "actionType": "device", "targetId": "DDE7D6JBQC_FF040000BE9C", "sort": 1, "actionParam": "{\"powerSwitch\":0}" }, { "actionType": "device", "targetId": "DDE7D6JBQC_FF040000BEC6", "sort": 2, "actionParam": "{\"powerSwitch\":0}" }, { "actionType": "device", "targetId": "DDE7D6JBQC_FF040000BF06", "sort": 3, "actionParam": "{\"powerSwitch\":0}" }, { "actionType": "device", "targetId": "DDE7D6JBQC_FF040000BFB8", "sort": 4, "actionParam": "{\"powerSwitch\":0}" } ] } commandPackagingId: A unique identifier for the command packet, which is an integer. It is used by the gateway to identify different command packets, ensuring the accuracy of command acquisition. The identifiers of different command packets are not duplicated. productKey: The product key corresponding to the gateway, used to verify the legitimacy of the command packet, prevent the issuance of illegal commands, and ensure control security; deviceName: Gateway device name, used to locate the target gateway and ensure that the command packet is sent to the correct gateway device; actions: An array of device control instructions, containing control information for multiple devices, with each array element corresponding to the control parameters of one device; actionType: Operation type, which is fixed here as "device", indicating a control operation for the device; targetId: A unique identifier for the device, used by the gateway to locate the device to be controlled, ensuring that commands are accurately sent to the target device; sort: Device control order, an integer, used to specify the control order of multiple devices. The gateway will execute control operations according to this control order. actionParam: Device control attribute parameter, in JSON string format, containing the specific control operation that the device needs to perform (e.g., in the example above, "powerSwitch":0" means controlling the device to turn off the power).
[0066] Based on the above embodiments, as an optional embodiment, if it is determined that at least one control instruction corresponding to the first instruction identifier is not cached, the first instruction identifier is sent to the host computer through the communication interface; if it is determined that at least one control instruction corresponding to the first instruction identifier is cached, for each of the at least one devices, the corresponding control instruction for the device is determined from the at least one control instruction according to the instruction packet, and the corresponding control instruction is sent to the device.
[0067] In this embodiment, after the gateway obtains at least one control instruction, it caches the correspondence between the first instruction identifier and the at least one control instruction locally. When an instruction packet is received, it first determines whether the first instruction identifier carried in the instruction packet has been cached locally with the corresponding control instruction. If it is determined that at least one control instruction corresponding to the first instruction identifier has been cached, it does not need to request the host computer to obtain it, and directly sends the corresponding control instruction to each device. If it is determined that the control box corresponding to the first instruction identifier is not cached, it means that it needs to be obtained from the host computer. Therefore, the first instruction identifier is sent to the host computer.
[0068] In this embodiment, when the gateway obtains the instruction packet containing the first control identifier again, it directly calls the locally cached control instructions to perform batch control on the device, further reducing communication interaction, saving resources, and improving control speed; if there is no local cache, it obtains it through the communication interface, balancing speed and accuracy.
[0069] This application provides a device control method applied to a host computer, such as... Figure 2 As shown, the method includes: S201, generate at least one instruction package and at least one control instruction corresponding to each instruction package.
[0070] In this embodiment, the host computer packages the control instructions for multiple devices under the same gateway into an instruction package according to the control requirements of multiple devices, and determines the control instructions for the operation to be executed by each device according to the control requirements, thereby obtaining at least one control instruction corresponding to the instruction package.
[0071] In this embodiment of the application, the instruction packet includes a first instruction identifier assigned by the host computer, and the instruction packet is used to instruct the gateway to send control instructions to at least one bound device.
[0072] In this embodiment of the application, when generating an instruction packet, a first instruction identifier is assigned to the instruction packet. The instruction packet includes the first instruction identifier. An instruction packet is used to instruct a gateway to send control instructions to at least one bound device.
[0073] S202, for each instruction packet, store the correspondence between at least one control instruction corresponding to the instruction packet and the first instruction identifier of the instruction packet, and send the instruction packet to the gateway indicated by the instruction packet through the object model.
[0074] In this embodiment of the application, since there is a character length limitation when communicating with the gateway through the object model of the Internet of Things platform, the correspondence between at least one control instruction corresponding to the generated instruction packet and the first instruction identifier of the instruction packet is stored in the Redis cache, instead of adding all control instructions to the instruction packet and sending them to the gateway together.
[0075] In this embodiment, the host computer sends instruction packets to the gateway through the object model of the Internet of Things platform. The instruction packets adopt the standard JSON format, which is easy for the gateway to parse and implement.
[0076] S203: Receive a first instruction identifier sent by the gateway through a preset communication interface; based on the first instruction identifier, obtain at least one control instruction from the correspondence between at least one control instruction and the first instruction identifier; and send at least one control instruction to the gateway through the communication interface, so that the gateway sends a corresponding control instruction to each of the at least one devices.
[0077] In this embodiment of the application, after receiving the instruction packet, the gateway parses the instruction packet to obtain the first instruction identifier, and sends the first instruction identifier to the host computer through a preset communication interface. Therefore, the host computer receives the first instruction identifier sent by the gateway through the communication interface.
[0078] In this embodiment, since the host computer pre-stores the correspondence between the first instruction identifier and at least one control instruction corresponding to the instruction package in the Redis cache, the gateway obtains at least one control instruction corresponding to the instruction package from the stored correspondence based on the first instruction identifier, and sends all the obtained control instructions to the gateway through the communication interface, so that the gateway sends the corresponding control instructions to each device to be controlled after receiving the control instructions.
[0079] In this embodiment, since the content sent through the IoT platform has a character length limit, the host computer does not carry control commands when sending command packets through the IoT platform. Instead, it instructs the gateway to obtain control commands by carrying a first control identifier. When the gateway requests at least one control command corresponding to the command packet through the first command identifier, the host computer sends the control command to the gateway through a dedicated communication interface. This solves the problem of the character length limit of the IoT platform. Furthermore, by instructing the gateway to obtain control commands through the IoT platform, fast, reliable, and low-cost gateway wake-up is achieved. The control commands are retrieved by the gateway through a dedicated communication interface, reducing operating costs.
[0080] The device control method applied to a host computer provided in this application generates at least one instruction packet and at least one control instruction corresponding to each instruction packet. For each instruction packet, the correspondence between the at least one control instruction corresponding to the instruction packet and the first instruction identifier of the instruction packet is stored. The instruction packet is then sent to the gateway indicated by the instruction packet. This achieves the separation of the instruction information for the gateway from the specific control instructions, avoiding the situation where the instruction packet and control instructions are sent to the gateway together through the IoT platform, which would cause network congestion due to a large number of such transmissions. This reduces the consumption of gateway resources and improves the gateway processing efficiency.
[0081] The system receives a first instruction identifier sent by the gateway through a preset communication interface. Based on the first instruction identifier, it obtains at least one control instruction from the correspondence between at least one control instruction and the first instruction identifier. It then sends at least one control instruction to the gateway through the communication interface, enabling the gateway to send the corresponding control instruction to each of the at least one devices. This solves the problem of character length limitations in IoT platforms. Furthermore, by having the IoT platform instruct the gateway to obtain control instructions, it ensures that batches of control instructions can be obtained through a single communication interface call, without being limited by character length or requiring individual acquisition of control instructions. This reduces gateway resource consumption while improving gateway processing efficiency.
[0082] Based on the above embodiments, as an optional embodiment, when the gateway omits receiving control results, the host computer cannot update the status of each device on the gateway's control page in real time based on the control results fed back by the gateway. Therefore, in order to ensure that the device status displayed on the gateway's control page is consistent with the actual device status, when the user opens the gateway control page through the APP, that is, when the control of the gateway's control page display function is triggered, a read instruction for the status information of the devices bound to the gateway is automatically generated and sent to the gateway. After receiving the instruction, the gateway reads the status information of all bound devices in batches and feeds back the status information to the host computer in real time, ensuring that the actual status of the devices bound to the gateway is synchronized with the device status displayed on the control page.
[0083] In this embodiment of the application, the above solution eliminates the need to receive device feedback during batch device control, thus avoiding increased gateway load. By triggering actions on the gateway control page, it ensures that the device status information seen by the user is consistent with the actual status, effectively avoiding status information display deviations caused by omitting control result feedback from device control. This balances control efficiency and reliability, meeting the status verification requirements in practical applications.
[0084] Based on the above embodiments, as an optional embodiment, the control instruction is used to indicate that when the status information of any device bound to the gateway is obtained, the control of the control page of any bound gateway is triggered to generate at least one control instruction.
[0085] In this embodiment, the device control method of this application can also be applied to the process of obtaining device information of the gateway. That is, the gateway is instructed to obtain the status information of each bound device through the instruction packet. The gateway obtains the control instruction that instructs each device to provide feedback status information through the dedicated communication interface between the gateway and the host computer. The gateway does not need to obtain the control instruction one by one, which further reduces the hardware load of the gateway. Therefore, the control that responds to the display function of the control page of any bound gateway is triggered, generating at least one control instruction. The number of control instructions is the same as the number of devices bound to the gateway.
[0086] In this embodiment, the status information of each bound device returned by the gateway is received; the control page of the gateway is updated according to the status information of each device so that the status information of each device displayed on the control page is consistent with the corresponding status information received; wherein, the status information of any device in each device is sent to the gateway by the device after receiving the control command.
[0087] In this embodiment of the application, after receiving the status information of each bound device returned by the gateway, the status information of each device in the gateway's control page is replaced with the status information of each device currently received, thus completing the update of the control page and realizing the synchronization between the actual status information of the device and the status information displayed on the control page.
[0088] In the above scheme, the gateway is instructed to obtain all control commands in batches by issuing command packets, and all devices are instructed to report status information. This eliminates the need for the gateway to obtain control commands one by one, further reducing the hardware load on the gateway.
[0089] Based on the above embodiments, as an optional embodiment, the instruction package also includes the control order of each device, determining at least one device to be controlled, grouping the devices according to the gateways bound to each device in the at least one device to obtain a device group; the device group includes the device identifier of at least one device bound to a gateway; for each device group, determining the control order of each device in the device group, and generating the instruction package corresponding to the device group according to the device identifier and control order of each device in the device group.
[0090] In this embodiment of the application, at least one device to be instructed is determined. Since one instruction packet can only be sent to one gateway, if the device to be controlled involves multiple gateways, the corresponding instruction packets need to be generated separately. Therefore, the devices are grouped according to the gateway currently bound to each of the at least one device, that is, devices bound to the same gateway are divided into the same device group.
[0091] In this embodiment of the application, each device group corresponds to a gateway. Therefore, by generating an instruction packet, the gateway can be instructed to send control instructions to any bound device. Thus, the control order of each device in the device group is determined. Priorities can be pre-stored between devices, and devices with higher priorities are controlled earlier.
[0092] In this embodiment of the application, since the instruction packet also includes the control sequence, a device group can be generated based on the known gateway corresponding to the current instruction packet, the device identifier of the device to be controlled that the gateway is bound to, and the control sequence of each device.
[0093] Based on the above embodiments, as an optional embodiment, for each instruction packet, the triggering condition corresponding to the instruction packet is stored; in response to any pre-stored triggering condition, the instruction packet corresponding to the triggering condition is obtained; and the instruction packet is sent to the gateway indicated by the instruction packet through the object model.
[0094] In this embodiment of the application, the instruction packet can also be bound to a trigger condition. The trigger condition can be that a certain time has arrived, or that a certain device has reached a specific state, such as a door lock being opened.
[0095] In this embodiment of the application, when the correspondence between the pre-defined instruction packet and the triggering condition is established, the instruction packet to be sent can be automatically confirmed when the triggering condition is triggered, and the instruction packet can be sent based on the gateway indicated by the instruction packet.
[0096] In this embodiment, by combining instruction packets with timing control and condition control functions, timed batch control of multiple devices can be achieved, for example, timed batch turning off of multiple lights.
[0097] In this application embodiment, an interactive flow diagram of a device control method is also provided, such as... Figure 3 As shown, the specific content is as follows: S301. The host computer generates at least one instruction package and at least one control instruction corresponding to each instruction package based on the control requirements of multiple devices to be controlled for the same gateway, and assigns a first instruction identifier to the instruction package. S302. The host computer stores the correspondence between at least one control instruction and the first instruction identifier in the Redis cache.
[0098] S303, The host computer sends an instruction packet containing the first instruction identifier to the gateway through the Internet of Things platform; S304. The gateway parses the command packet to obtain the first command identifier; S305. The gateway sends the first instruction identifier to the host computer through the communication interface with the host computer; S306. The host computer obtains at least one control instruction from the correspondence between the first instruction identifier and at least one control instruction stored in the Redis cache, based on the first instruction identifier. S307. The host computer sends at least one control command to the gateway through the communication interface; S308: The gateway determines the corresponding control command for each device based on the command packet and at least one control command. S309. The gateway sends the corresponding control command to the device A to be controlled. S310, The gateway sends the corresponding control command to the device B to be controlled.
[0099] The device control method provided in this application allows the gateway to obtain all control commands corresponding to the instruction packet through a single communication interface call, eliminating the need for frequent switching of interaction objects and omitting the feedback receiving stage. This reduces the gateway's operational pressure, effectively lowers the gateway's hardware load, avoids gateway lag and crashes, and improves gateway operational stability. Actual testing shows that when controlling four or more devices, the gateway's hardware load can be reduced by more than 60%. Furthermore, the gateway can control devices in batches, reducing batch control time by more than 50%, enabling rapid response to multi-device batch control needs and improving user experience.
[0100] The device control method provided in this application is applied to multi-device control scenarios of IoT gateways, and is particularly suitable for scenarios that require rapid batch control of multiple sub-devices and have limited gateway hardware resources. Specific application areas include: 1. Smart Home Applications: Applicable to centralized batch control of multiple smart home sub-devices such as smart clothes dryers, smart curtains, smart lights, and smart sockets, enabling users to control multiple devices with a single click and improving user experience; 2. Industrial control field: It can be applied to the batch control of multiple sensors, actuators and other sub-devices in industrial scenarios, such as batch start-up and shutdown of workshop equipment, batch parameter adjustment, etc., to improve industrial control efficiency; 3. IoT terminal equipment field: It can be extended to smart gateways, edge computing devices, etc., and is suitable for all terminal scenarios that require centralized control of multiple sub-devices and have strict control over hardware resources; 4. Smart Community Sector: It can be applied to the batch control of sub-devices such as smart access control, monitoring equipment, and public lighting within the community, reducing gateway maintenance costs and improving the efficiency of intelligent community management.
[0101] This application provides a device control apparatus applied to a gateway, such as... Figure 4 As shown, the device control unit 40 may include: a response module 401, a receiving module 402, and a first sending module 403.
[0102] Specifically, the response module 401 is used to respond to the instruction packet sent by the host computer through the object model, and send a first instruction identifier to the host computer through a preset communication interface; the instruction packet includes the first instruction identifier assigned by the host computer to the instruction packet, and instructs the gateway to send control instructions to at least one bound device; The receiving module 402 is used to receive at least one control instruction returned by the host computer through the communication interface; the at least one control instruction is obtained by the host computer based on a first instruction identifier and a pre-stored correspondence between control instructions and instruction identifiers; The first sending module 403 is configured to, for each of the at least one devices, determine the corresponding control instruction for the device from at least one control instruction according to the instruction packet, and send the corresponding control instruction to the device.
[0103] The device control device for a gateway provided in this application embodiment, in response to receiving an instruction packet sent by a host computer through a physical model, sends a first instruction identifier to the host computer through a preset communication interface. Since the instruction packet includes a first instruction identifier assigned by the host computer and an instruction packet instructing the gateway to send control instructions to at least one bound device, the gateway can automatically request and obtain the control instructions to be sent based on the parsed first instruction identifier when it receives the instruction packet.
[0104] The gateway receives at least one control command returned by the host computer through the communication interface. Since the host computer obtains the at least one control command based on the first command identifier and the pre-stored correspondence between control commands and command identifiers, the gateway obtains data packets indicating the sending of control commands and control commands for controlling devices from two communication paths respectively. This enables the gateway to quickly wake up the command packets to retrieve control commands, while ensuring that batches of control commands can also be obtained through a single communication interface call. This eliminates the need to be limited by character length and obtain control commands one by one, reducing the consumption of gateway resources and improving gateway processing efficiency.
[0105] For each of the at least one devices, the corresponding control instruction for the device is determined from at least one control instruction according to the instruction packet, and the corresponding control instruction is sent to the device. This realizes that control instructions are sent to the devices one by one during the control instruction sending stage, without having to send control instructions to another device based on the information received from the device feedback. This greatly saves the gateway's communication and processing resources and improves the overall efficiency of device control.
[0106] The apparatus in this application embodiment can execute the method provided in this application embodiment, and the implementation principle is similar. The actions performed by each module in the apparatus of each embodiment of this application correspond to the steps in the method of each embodiment of this application. For detailed functional descriptions of each module of the apparatus, please refer to the descriptions in the corresponding methods shown above, which will not be repeated here.
[0107] This application provides a device control apparatus, applied to a host computer, such as... Figure 5 As shown, the device control unit 50 may include: a generation module 501, a storage module 502, and a second transmission module 503.
[0108] Specifically, the generation module 501 is used to generate at least one instruction packet and at least one control instruction corresponding to each instruction packet; the instruction packet includes a first instruction identifier assigned by the host computer to the instruction packet, and the instruction packet is used to instruct the gateway to send control instructions to at least one bound device; The storage module 502 is used to store the correspondence between at least one control instruction corresponding to each instruction packet and the first instruction identifier of the instruction packet, and to send the instruction packet to the gateway indicated by the instruction packet through the object model. The second sending module 503 is used to receive a first instruction identifier sent by the gateway through a preset communication interface, obtain at least one control instruction from the correspondence between at least one control instruction and the first instruction identifier according to the first instruction identifier, and send at least one control instruction to the gateway through the communication interface, so that the gateway sends a corresponding control instruction to each of the at least one devices.
[0109] The device control device applied to the host computer provided in this application embodiment realizes the separation of the instruction information for the gateway from the specific control commands. This avoids sending the instruction packets and control commands to the gateway together through the Internet of Things platform, which would cause network congestion due to a large number of requests. This reduces the consumption of gateway resources and improves the gateway processing efficiency.
[0110] The system receives a first instruction identifier sent by the gateway through a preset communication interface. Based on the first instruction identifier, it obtains at least one control instruction from the correspondence between at least one control instruction and the first instruction identifier. It then sends at least one control instruction to the gateway through the communication interface, enabling the gateway to send the corresponding control instruction to each of the at least one devices. This solves the problem of character length limitations in IoT platforms. Furthermore, by having the IoT platform instruct the gateway to obtain control instructions, it ensures that batches of control instructions can be obtained through a single communication interface call, without being limited by character length or requiring individual acquisition of control instructions. This reduces gateway resource consumption while improving gateway processing efficiency.
[0111] This application provides an electronic device (computer device / equipment / system) including a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the steps of the device control method. Compared with related technologies, it can achieve the following: in response to receiving an instruction packet sent by a host computer, a first instruction identifier is sent to the host computer through a preset communication interface. Since the instruction packet includes a first instruction identifier assigned by the host computer and an instruction packet instructing the gateway to send control instructions to at least one bound device, the gateway can automatically request to obtain the control instructions to be sent based on the parsed first instruction identifier when it receives the instruction packet.
[0112] The gateway receives at least one control command returned by the host computer through the communication interface. Since the host computer obtains the at least one control command based on the first command identifier and the pre-stored correspondence between control commands and command identifiers, the gateway obtains data packets indicating the sending of control commands and control commands for controlling devices from two communication paths respectively. This enables the gateway to quickly wake up the command packets to retrieve control commands, while ensuring that batches of control commands can also be obtained through a single communication interface call. This eliminates the need to be limited by character length and obtain control commands one by one, reducing the consumption of gateway resources and improving gateway processing efficiency.
[0113] For each of the at least one devices, the corresponding control instruction for the device is determined from at least one control instruction according to the instruction packet, and the corresponding control instruction is sent to the device. This realizes that control instructions are sent to the devices one by one during the control instruction sending stage, without having to send control instructions to another device based on the information received from the device feedback. This greatly saves the gateway's communication and processing resources and improves the overall efficiency of device control.
[0114] In one alternative embodiment, an electronic device is provided, such as Figure 6 As shown, Figure 6 The illustrated electronic device 4000 includes a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, for example, via a bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004, which can be used for data interaction between the electronic device and other electronic devices, such as sending and / or receiving data. It should be noted that in practical applications, the transceiver 4004 is not limited to one type, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of this application.
[0115] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 4001 may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.
[0116] Bus 4002 may include a pathway for transmitting information between the aforementioned components. Bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Bus 4002 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 6 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0117] The memory 4003 may be ROM (Read Only Memory) or other types of static storage devices capable of storing static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices capable of storing information and instructions, or EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium capable of carrying or storing computer programs and capable of being read by a computer, without limitation herein.
[0118] The memory 4003 stores computer programs that execute embodiments of this application, and its execution is controlled by the processor 4001. The processor 4001 executes the computer programs stored in the memory 4003 to implement the steps shown in the foregoing method embodiments.
[0119] The electronic device package may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital radio receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), and in-vehicle terminals (such as in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 6 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments disclosed herein.
[0120] This application provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program can implement the steps and corresponding content of the aforementioned method embodiments. Compared with the prior art, it achieves the following: since the instruction packet includes a first instruction identifier assigned by the host computer and an instruction packet instructing the gateway to send control commands to at least one bound device, the gateway automatically requests and obtains the control commands to be sent based on the parsed first instruction identifier when it receives the instruction packet.
[0121] The gateway receives at least one control command returned by the host computer through the communication interface. Since the host computer obtains the at least one control command based on the first command identifier and the pre-stored correspondence between control commands and command identifiers, the gateway obtains data packets indicating the sending of control commands and control commands for controlling devices from two communication paths respectively. This enables the gateway to quickly wake up the command packets to retrieve control commands, while ensuring that batches of control commands can also be obtained through a single communication interface call. This eliminates the need to be limited by character length and obtain control commands one by one, reducing the consumption of gateway resources and improving gateway processing efficiency.
[0122] For each of the at least one devices, the corresponding control instruction for the device is determined from at least one control instruction according to the instruction packet, and the corresponding control instruction is sent to the device. This realizes that control instructions are sent to the devices one by one during the control instruction sending stage, without having to send control instructions to another device based on the information received from the device feedback. This greatly saves the gateway's communication and processing resources and improves the overall efficiency of device control.
[0123] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium, a computer-readable medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0124] This application also provides a computer program product, including a computer program that, when executed by a processor, can implement the steps and corresponding content of the aforementioned method embodiments. Compared with the prior art, it can achieve: In response to receiving a command packet from the host computer, the gateway sends a first command identifier to the host computer through a preset communication interface. Since the command packet includes a first command identifier assigned by the host computer and an instruction from the command packet to the gateway to send control commands to at least one bound device, the gateway can automatically request and obtain the control commands to be sent based on the parsed first command identifier when it receives the command packet.
[0125] The gateway receives at least one control command returned by the host computer through the communication interface. Since the host computer obtains the at least one control command based on the first command identifier and the pre-stored correspondence between control commands and command identifiers, the gateway obtains data packets indicating the sending of control commands and control commands for controlling devices from two communication paths respectively. This enables the gateway to quickly wake up the command packets to retrieve control commands, while ensuring that batches of control commands can also be obtained through a single communication interface call. This eliminates the need to be limited by character length and obtain control commands one by one, reducing the consumption of gateway resources and improving gateway processing efficiency.
[0126] For each of the at least one devices, the corresponding control instruction for the device is determined from at least one control instruction according to the instruction packet, and the corresponding control instruction is sent to the device. This realizes that control instructions are sent to the devices one by one during the control instruction sending stage, without having to send control instructions to another device based on the information received from the device feedback. This greatly saves the gateway's communication and processing resources and improves the overall efficiency of device control.
[0127] The terms "first," "second," "third," "fourth," "1," "2," etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in a sequence other than that shown in the illustrations or text descriptions.
[0128] It should be understood that although arrows indicate various operation steps in the flowcharts of this application's embodiments, the order in which these steps are implemented is not limited to the order indicated by the arrows. Unless explicitly stated herein, in some implementation scenarios of this application's embodiments, the implementation steps in each flowchart can be executed in other orders as required. Furthermore, some or all steps in each flowchart, based on the actual implementation scenario, may include multiple sub-steps or multiple stages. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage can also be executed at different times. In scenarios where execution times differ, the execution order of these sub-steps or stages can be flexibly configured according to requirements, and this application's embodiments do not limit this.
[0129] The above are only optional implementation methods for some implementation scenarios of this application. It should be noted that for those skilled in the art, other similar implementation methods based on the technical concept of this application, without departing from the technical concept of this application, also fall within the protection scope of the embodiments of this application.
Claims
1. A device control method, characterized in that, Applied to gateways, including: In response to receiving an instruction packet sent by a host computer through a physical model, the gateway sends a first instruction identifier to the host computer through a preset communication interface; the instruction packet includes the first instruction identifier assigned by the host computer to the instruction packet, and instructs the gateway to send control commands to at least one bound device; The system receives at least one control instruction returned by the host computer through the communication interface; the at least one control instruction is obtained by the host computer based on the first instruction identifier and the pre-stored correspondence between control instructions and instruction identifiers. For each of the at least one device, a corresponding control instruction for the device is determined from the at least one control instruction according to the instruction packet, and the corresponding control instruction is sent to the device.
2. The method according to claim 1, characterized in that, The issuance of control commands and the receipt of control results are executed asynchronously by the gateway, and the control result is the result of the corresponding device executing the control command. If the control result is determined to be an execution failure, then update the total number of control failures for the gateway. If the total number of attempts is determined to be greater than a preset threshold, an exception message is sent to the host computer to instruct the host computer to stop sending instruction packets to the gateway.
3. The method according to claim 1, characterized in that, The instruction packet also includes the control order of the at least one device; the at least one control instruction received through the communication interface is arranged according to the control order of the at least one device; For each of the at least one device, determining the corresponding control instruction for that device from the at least one control instruction according to the instruction packet, and sending the corresponding control instruction to the device, including: For each of the at least one device, the control sequence of the device is determined according to the instruction packet, and the corresponding control instruction of the device is obtained from the at least one control instruction according to the control sequence; According to the control sequence, the corresponding control command of the device is sent to each of the at least one device in turn.
4. The method according to claim 1, characterized in that, Sending the first instruction identifier to the host computer through a preset communication interface includes: If it is determined that at least one control instruction corresponding to the first instruction identifier is not cached, then the first instruction identifier is sent to the host computer through the communication interface; The method further includes: If it is determined that at least one control instruction corresponding to the first instruction identifier has been cached, then for each of the at least one devices, the corresponding control instruction for the device is determined from the at least one control instruction according to the instruction packet, and the corresponding control instruction is sent to the device.
5. A device control method, characterized in that, Applications in host computers include: Generate at least one instruction packet and at least one control instruction corresponding to each instruction packet; the instruction packet includes a first instruction identifier assigned by the host computer to the instruction packet, and the instruction packet is used to instruct the gateway to send control instructions to at least one bound device; For each instruction packet, the correspondence between at least one control instruction corresponding to the instruction packet and the first instruction identifier of the instruction packet is stored, and the instruction packet is sent to the gateway indicated by the instruction packet through the object model; The system receives a first instruction identifier sent by the gateway through a preset communication interface. Based on the first instruction identifier, it obtains the at least one control instruction from the correspondence between the at least one control instruction and the first instruction identifier. The system then sends the at least one control instruction to the gateway through the communication interface, so that the gateway sends a corresponding control instruction to each of the at least one devices.
6. The method according to claim 5, characterized in that, When the control command is used to instruct the acquisition of status information of any device bound to the gateway, the at least one control command is generated in the following manner: When a control on the control page of any bound gateway is triggered, at least one control command is generated. Sending the at least one control command to the gateway via the communication interface, followed by: Receive the status information of each bound device returned by the gateway; The gateway's control page is updated based on the status information of each device, so that the status information of each device displayed on the control page is consistent with the corresponding status information received. The status information of any device in each of the devices is sent to the gateway by the device after receiving the control command.
7. The method according to claim 5, characterized in that, The instruction package also includes the control sequence for each device; The generation of at least one instruction packet includes: Identify at least one device to be controlled, and group the devices according to the gateway to which each device is bound, to obtain a device group; the device group includes the device identifier of at least one device bound to a gateway; For each device group, determine the control order of each device in the device group, and generate the instruction packet corresponding to the device group based on the device identifier and control order of each device in the device group.
8. The method according to claim 5, characterized in that, The method further includes: For each instruction packet, store the triggering condition corresponding to the instruction packet; Sending the instruction packet to the gateway indicated by the instruction packet via the object model includes: In response to any pre-stored trigger condition, the instruction packet corresponding to the trigger condition is obtained; The instruction packet is sent to the gateway indicated by the instruction packet via the object model.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the method according to any one of claims 1-8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1-8.