Method and device for detecting online status of equipment
By judging the reception status within the data reporting period in the ZigBee device and sending heartbeat query instructions, the problem of device offline status detection delay is solved, the device online status is timely and accurately detected and user controlled, and the user experience and device life are improved. ability.
Patent Information
- Application Number
- CN202111064214.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-10
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2041-09-10
AI Technical Summary
After the ZigBee device goes offline, the gateway cannot detect changes in the device status in real time, causing the user terminal to display the uncontrollable illusion of the device's online status. The problem of how to detect the device's online status in a timely manner needs to be solved.
By determining whether data from the target device has been received within the data reporting waiting time, if not, a heartbeat query command is sent, and the online status of the device is analyzed based on the response and device type, including the processing methods of monitoring type and query type.
It achieves timely and accurate detection of the online status of the device, reduces network congestion and data packet loss rate, and improves the battery life and user experience of low-power devices.
Smart Images

Figure CN115801645B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of intelligent devices, and in particular to a method and device for detecting an online state of a device. Background Art
[0002] At present, many smart home products use ZigBee wireless communication technology, such as ZigBee gateways, ZigBee switches, ZigBee sensors and other terminal products that use ZigBee protocol communication. ZigBee gateways need to transfer and parse cloud data instructions, manage devices, monitor device attribute value changes and report them to the cloud. The online status of the device depends on the heartbeat detection mechanism, that is, the online status of the device is determined by detecting whether the data reported by the device is received within a heartbeat cycle.
[0003] However, practice has found that due to the limitations of current ZigBee products, the gateway cannot know in real time that the device's status has changed after the device is offline (such as the device loses power). It often needs to wait for a heartbeat cycle before it can discover and report the device's offline status. This can easily cause the user terminal to still display the device's status as online and uncontrollable. Therefore, it is particularly important to propose a solution for how to detect the device's online status in a timely manner in order to accurately control the device. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a method and device for detecting the online status of a device, which can detect the online status of the device in time so as to accurately control the device.
[0005] In order to solve the above technical problems, the first aspect of the present invention discloses a method for detecting an online state of a device, the method comprising:
[0006] When it is determined that the online status of the target device needs to be determined, determining whether the data reported by the target device is received within a time period of a data reporting waiting time period that matches the target device, the starting time of the data reporting waiting time period being the time when it is determined that the online status of the target device needs to be determined;
[0007] When it is determined that no data reported by the target device is received, sending a target heartbeat query instruction to the target device;
[0008] Acquire the response status fed back by the target device within a first preset time period, and analyze the online status of the target device according to the response status fed back by the target device and the type of the target device, wherein the type of the target device includes a monitoring type or a query type.
[0009] As an optional implementation manner, in the first aspect of the present invention, after determining that the data reported by the target device is not received, the method further includes:
[0010] When the type of the target device is the monitoring type, the value of the heartbeat counter of the target device is decremented to a preset value of 0 at every second preset time interval;
[0011] During the process of the heartbeat counter value of the target device decreasing to 0, it is determined whether data reported by the target device is received. When it is determined that the data reported by the target device is not received, the operation of sending a target heartbeat query instruction to the target device is executed.
[0012] As an optional implementation manner, in the first aspect of the present invention, analyzing the online status of the target device according to the response status fed back by the target device and the type of the target device includes:
[0013] When the type of the target device is the query type and when the response status fed back by the target device is used to indicate that the response information of the target device is received within the first preset time period, the current state of the target device is marked as an online state.
[0014] As an optional embodiment, in the first aspect of the present invention, the method further comprises:
[0015] When the type of the target device is the query type and when the response status fed back by the target device is used to indicate that no response information of the target device has been received within the first preset time period, determining the number of times the target heartbeat query instruction is sent to the target device as of the current moment in the process of detecting the online status of the target device;
[0016] When determining whether the number of times is greater than or equal to the determined number of times threshold, when the determination result is yes, determining that the current state of the target device is in an offline state;
[0017] And, the method further comprises:
[0018] When it is determined that the number is less than the number threshold, the operation of sending the target heartbeat query instruction to the target device is re-executed.
[0019] As an optional implementation manner, in the first aspect of the present invention, when the type of the target device is the monitoring type, analyzing the online status of the target device according to the response status fed back by the target device and the type of the target device includes:
[0020] When the response status fed back by the target device indicates that the response information of the target device is received within the first preset time period, marking the current state of the target device as an online state;
[0021] When the type of the target device is the monitoring type and when the response status fed back by the target device is used to indicate that no response information of the target device is received within the first preset time period, it is determined that the current state of the target device is offline.
[0022] As an optional embodiment, in the first aspect of the present invention, the method further comprises:
[0023] When the type of the target device is the monitoring type, determining the heartbeat cycle of the target device to be a data reporting waiting time length that matches the target device;
[0024] When the type of the target device is the query type, the heartbeat query duration of the target device is generated according to the heartbeat cycle of the target device, and the heartbeat query duration is determined to be the data reporting waiting duration that matches the target device, and the heartbeat query duration is greater than or equal to the third preset duration and less than the fourth preset duration, wherein the third preset duration and the fourth preset duration are both less than the heartbeat cycle of the target device.
[0025] As an optional embodiment, in the first aspect of the present invention, the method further comprises:
[0026] When it is determined that the data reported by the target device is received, marking the current state of the target device as an online state;
[0027] Determine whether the current state of the target device is reversed, and when it is determined that the current state of the target device is reversed, send information that the target device is in an online state to the determined user terminal;
[0028] The operation of sending information that the target device is in an online state to the determined user terminal includes:
[0029] Sending information that the target device is online to the determined user terminal; and / or
[0030] Sending information that the target device is in an online state to a cloud server, and triggering the cloud server to send information that the target device is in an online state to the determined user terminal;
[0031] Furthermore, before executing the operation of sending information that the target device is in an online state to the determined user terminal, the method further includes:
[0032] Determine whether the current state of the target device is reversed, and when it is determined that the current state of the target device is reversed, execute the step of sending information that the target device is in an online state to the determined user terminal.
[0033] As an optional embodiment, in the first aspect of the present invention, the method further comprises:
[0034] Broadcasting a heartbeat query instruction to each of the devices in the device information table, wherein the heartbeat query instruction is used to query the heartbeat data of each of the devices in the device information table;
[0035] Determine the response of each of the devices in the device information table to the heartbeat query instruction, and based on the response of each of the devices in the device information table to the heartbeat query instruction, determine whether there is a response status indicating a device that has not responded to the heartbeat query instruction among all the devices in the device information table;
[0036] When it is determined that the device does not exist, marking the current state of each device in the device information table as an online state;
[0037] When it is determined that there is at least one response situation indicating that the device has not responded to the heartbeat query instruction, determine the query times for each device whose response situation indicates that the device has not responded to the heartbeat query instruction, and determine whether the query times for each device whose response situation indicates that the device has not responded to the heartbeat query instruction is greater than or equal to the determined query times threshold. When the judgment result is yes, mark the current state of each device whose response situation indicates that the device has not responded to the heartbeat query instruction as an offline state. When the judgment result is yes, rebroadcast the heartbeat query instruction separately to each device whose response situation indicates that the device has not responded to the heartbeat query instruction.
[0038] As an optional embodiment, in the first aspect of the present invention, the method further comprises:
[0039] When a query request for the online status of a certain device sent by a user terminal is detected, it is determined that the online status of a target device needs to be determined, and the certain device is the target device; or
[0040] It is determined whether the current moment is in the query time period of the online status of a certain device determined in the device list. When the result of the determination is yes, it is determined that the online status of the target device needs to be determined, and the certain device is the target device.
[0041] A second aspect of the present invention discloses an online status detection device for a device, the device comprising:
[0042] A determination module, for determining, when it is determined that the online status of the target device needs to be determined, whether the data reported by the target device is received within a time period of a data reporting waiting time period that matches the target device, wherein the starting time of the data reporting waiting time period is the time when it is determined that the online status of the target device needs to be determined;
[0043] A sending module, configured to send a target heartbeat query instruction to the target device when the judging module determines that no data reported by the target device is received;
[0044] An acquisition module, used for acquiring a response condition fed back by the target device within a first preset time period;
[0045] The analysis module is used to analyze the online status of the target device according to the response status fed back by the target device and the type of the target device, wherein the type of the target device includes a monitoring type or an inquiry type.
[0046] As an optional implementation, in the second aspect of the present invention, the device further includes:
[0047] A decrementing module, configured to decrement the value of the heartbeat counter of the target device to a preset value of 0 at intervals of a second preset time length after the judging module determines that no data reported by the target device is received and when the type of the target device is the monitoring type;
[0048] The judgment module is also used to judge whether the data reported by the target device is received when the value of the heartbeat counter of the target device decreases to 0. When it is judged that the data reported by the target device is not received, the sending module is triggered to execute the operation of sending the target heartbeat query instruction to the target device.
[0049] As an optional implementation, in the second aspect of the present invention, the analysis module includes:
[0050] The marking submodule is used to mark the current state of the target device as an online state when the type of the target device is the query type and when the response status fed back by the target device is used to indicate that the response information of the target device is received within the first preset time period.
[0051] As an optional implementation, in the second aspect of the present invention, the analysis module further includes:
[0052] The marking submodule is further used to determine the number of times the target heartbeat query instruction is sent to the target device as of the current moment during the process of detecting the online status of the target device, when the type of the target device is the query type and when the response status fed back by the target device is used to indicate that the response information of the target device has not been received within the first preset time period;
[0053] A judging submodule, used to judge whether the number is greater than or equal to a determined number threshold;
[0054] The marking submodule is further configured to determine that the current state of the target device is offline when the judgment result is yes;
[0055] The sending module is further configured to re-execute the operation of sending the target heartbeat query instruction to the target device when the judging submodule judges that the number is less than the number threshold.
[0056] As an optional implementation, in the second aspect of the present invention, when the type of the target device is the monitoring type, the analysis module analyzes the online status of the target device according to the response feedback from the target device and the type of the target device in the following manner:
[0057] When the response status fed back by the target device indicates that the response information of the target device is received within the first preset time period, marking the current state of the target device as an online state;
[0058] When the type of the target device is the monitoring type and when the response status fed back by the target device is used to indicate that no response information of the target device is received within the first preset time period, it is determined that the current state of the target device is offline.
[0059] As an optional implementation, in the second aspect of the present invention, the device further includes:
[0060] A first determination module, configured to, when the type of the target device is the monitoring type, determine the heartbeat cycle of the target device to be a data reporting waiting time length that matches the target device;
[0061] A generating module, used for generating a heartbeat query duration of the target device according to the heartbeat cycle of the target device when the type of the target device is the query type;
[0062] The first determination module is also used to determine that the heartbeat query duration is the data reporting waiting duration that matches the target device, and the heartbeat query duration is greater than or equal to a third preset duration and less than a fourth preset duration, wherein the third preset duration and the fourth preset duration are both less than the heartbeat cycle of the target device.
[0063] As an optional implementation, in the second aspect of the present invention, the device further includes:
[0064] A first marking module, configured to mark the current state of the target device as an online state when the judging module determines that the data reported by the target device is received;
[0065] The sending module is further used to execute the operation of sending information that the target device is in an online state to the determined user terminal;
[0066] The specific manner in which the sending module performs the operation of sending the information that the target device is in an online state to the determined user terminal is:
[0067] Sending information that the target device is online to the determined user terminal; and / or
[0068] Sending information that the target device is in an online state to a cloud server, and triggering the cloud server to send information that the target device is in an online state to the determined user terminal;
[0069] The judgment module is also used to judge whether the current state of the target device is reversed before the sending module executes the operation of sending the information that the target device is in an online state to the determined user terminal; when it is determined that the current state of the target device is reversed, the sending module is triggered to execute the operation of sending the information that the target device is in an online state to the determined user terminal.
[0070] As an optional implementation, in the second aspect of the present invention, the sending module is further used to broadcast a heartbeat query instruction to each of the devices in all the devices in the device information table, and the heartbeat query instruction is used to query the heartbeat data of each of the devices in the device information table;
[0071] And, the device further comprises:
[0072] A second determination module is used to determine the response of each device in the device information table to the heartbeat query instruction;
[0073] The judging module is further configured to judge, based on the response of each device in the device information table to the heartbeat query instruction, whether there is a device in all the devices in the device information table whose response status indicates that the device has not responded to the heartbeat query instruction;
[0074] A second marking module, for marking the current state of each of the devices as an online state in the device information table when it is determined that the device does not exist;
[0075] The second determination module is further configured to determine the query times of each device that has not responded to the heartbeat query instruction when it is determined that there is at least one response situation indicating that the device has not responded to the heartbeat query instruction;
[0076] The judging module is further used to judge whether the response status indicates that the query number of each device that has not responded to the heartbeat query instruction is greater than or equal to the determined query number threshold;
[0077] The second marking module is further configured to, when the result of the determination is yes, mark the response status to indicate that the current status of each of the devices that have not responded to the heartbeat query instruction is an offline status;
[0078] The sending module is further configured to, when the judgment result is yes, rebroadcast the heartbeat query instruction separately to each of the devices whose response status indicates that the heartbeat query instruction has not been responded to.
[0079] As an optional implementation, in the second aspect of the present invention, the apparatus is further configured to, when detecting a query request for an online status of a certain device sent by a user terminal, determine that an online status of a target device needs to be determined, the certain device being the target device; or,
[0080] It is determined whether the current moment is in the query time period of the online status of a certain device determined in the device list. When the result of the determination is yes, it is determined that the online status of the target device needs to be determined, and the certain device is the target device.
[0081] The third aspect of the present invention discloses another device for detecting an online state of a device, the device comprising:
[0082] A memory storing executable program code;
[0083] a processor coupled to the memory;
[0084] The processor calls the executable program code stored in the memory to execute part or all of the steps in the online status detection method of the device disclosed in the first aspect of the present invention.
[0085] The fourth aspect of the present invention discloses a computer storage medium, which stores computer instructions. When the computer instructions are called, they are used to execute some or all of the steps in the online status detection method of the device disclosed in the first aspect of the present invention.
[0086] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0087] In an embodiment of the present invention, when it is determined that the online status of a target device needs to be determined, it is determined whether data reported by the target device is received within a time period of a data reporting waiting time that matches the target device, the type of the target device includes a monitoring type or a query type, and the starting time of the data reporting waiting time is the time when it is determined that the online status of the target device needs to be determined; when it is determined that the data reported by the target device is not received, a target heartbeat query instruction is sent to the target device, and a response status fed back by the target device received within a first preset time period is obtained; and the online status of the target device is analyzed based on the response status fed back by the target device and the type of the target device. It can be seen that the present invention automatically sends a target heartbeat query instruction to the target device when it is determined that the online status of the target device needs to be determined and when it is determined that no data reported by the target device has been received within the time length matching the target device, and automatically analyzes the online status of the target device according to the response feedback from the target device and the type of the target device. The real status (online status or offline status) of the target device can be accurately and timely detected without increasing the heartbeat detection frequency of the target device, which is beneficial for the user to know the real status of the target device before preparing to control the target device, so that the user can accurately control the target device and enhance the user experience; and by actively querying the online status of the device, it can reduce network congestion and increased data instruction packet loss rate when the online status detection device is equipped with multiple devices and needs to communicate with multiple devices, and is beneficial to improving the battery life of low-power devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0088] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0089] Figure 1 It is a flow chart of an online status detection method of a device disclosed in an embodiment of the present invention;
[0090] Figure 2 It is a flow chart of another method for detecting the online status of a device disclosed in an embodiment of the present invention;
[0091] Figure 3 It is a structural schematic diagram of an online status detection device for a device disclosed in an embodiment of the present invention;
[0092] Figure 4 It is a structural schematic diagram of another device online status detection apparatus disclosed in an embodiment of the present invention;
[0093] Figure 5 It is a structural schematic diagram of an online status detection device of another device disclosed in an embodiment of the present invention;
[0094] Figure 6 It is a structural schematic diagram of establishing a communication connection between an online status detection device and a device disclosed in an embodiment of the present invention;
[0095] Figure 7 It is a structural diagram of a plug-in homepage and a sub-device control plug-in page switching for a user terminal to request to query the online status of a device disclosed in an embodiment of the present invention;
[0096] Figure 8 It is a schematic diagram of the structure of a device information table disclosed in an embodiment of the present invention. DETAILED DESCRIPTION
[0097] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0098] The terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish different objects rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, device, product or end including a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units inherent to these processes, methods, products or ends.
[0099] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0100] The present invention discloses a device online status detection method and device, which can automatically send a target heartbeat query instruction to the target device when it is determined that the online status of the target device needs to be determined and when it is determined that the data reported by the target device is not received within the time length matching the target device, and automatically analyze the online status of the target device according to the response feedback from the target device and the type of the target device, and accurately and timely detect the real status (online status or offline status) of the target device without increasing the heartbeat detection frequency of the target device, which is beneficial for the user to know the real status of the target device before preparing to control the target device, so that the user can accurately control the target device and improve the user's experience; and by actively querying the online status of the device, it can reduce the occurrence of network congestion and increased data instruction packet loss rate when the online status detection device is equipped with multiple devices and needs to communicate with multiple devices, and is beneficial to improving the endurance of low-power devices. The following are detailed descriptions.
[0101] Embodiment 1
[0102] See also Figure 1 , Figure 1 1 is a flow chart of an online status detection method for a device disclosed in an embodiment of the present invention. Figure 1 The described method can be applied to an online status detection device, such as an online status detection gateway, wherein the online status detection device, the user terminal, and the cloud server can communicate with each other, wherein the user terminal includes at least one of the terminal target devices such as a smart phone (Android phone, iOS phone, etc.), a smart phone watch, a tablet computer, a PDA, a car computer, a desktop computer, a netbook, a personal digital assistant (PDA), a smart navigator, and a mobile Internet target device (MID), etc., and the embodiment of the present invention does not limit this. Figure 1 As shown, the online status detection method of the device may include the following operations:
[0103] 101. When it is determined that the online status of the target device needs to be determined, it is determined whether data reported by the target device is received within a period of a data reporting waiting time that matches the target device.
[0104] In the embodiment of the present invention, the target device is any product that uses ZigBee wireless technology, and the number of target devices is greater than or equal to 1. The types of target devices include monitoring type and query type. Among them, the monitoring type device is a device that can actively report data to the online status detection device, and the monitoring type device includes a device powered by a main power source (such as AC power) (such as: sockets, panels, lamps, etc.) and / or a low-power device powered by a battery (such as: smart door locks, temperature and humidity sensors, etc.); the query type device is a device that requires active access by the online status detection device to report data. Figure 6 As shown, Figure 6 A schematic diagram of establishing a communication connection between an online status detection device and a device is disclosed, such as Figure 6 As shown, the online status detection device communicates with the monitoring type device and the query type device respectively through the ZigBee coordinator. The number of the monitoring type device and the query type device is not limited. Figure 6 In the schematic diagram, six monitoring type devices (device 1, device 2, device 3, device 4, device 5 and device 6) and six query type devices (device 7, device 8, device 9, device 10, device 11 and device 12) are illustrated.
[0105] In the embodiment of the present invention, optionally, the data reported by the target device includes but is not limited to at least one of a heartbeat packet, an attribute packet, and other data packets.
[0106] 102. When it is determined that no data reported by the target device is received, a target heartbeat query instruction is sent to the target device, and a response feedback from the target device received within a first preset time period is obtained.
[0107] In the embodiment of the present invention, optionally, the starting time of the first preset duration is the time when the target heartbeat query instruction is sent to the target device and the first preset duration is the longest response duration for waiting for the target device to report data. Optionally, each target device has a corresponding first preset duration, and the first preset duration of each target device is a duration determined by the type of the target device and / or the heartbeat cycle of the target device and / or the timing accuracy of the target device, wherein the higher the timing accuracy of the target device, the closer the determined first preset duration is to the heartbeat cycle of the corresponding device, for example: the heartbeat cycle of the target device is 3 minutes, and the customization accuracy of the target device is 98%, then the first preset duration corresponding to the target device is 3.5 minutes. In this way, the longest response duration for waiting for the target device to report data is determined by multiple contents, which can improve the accuracy of determining the longest response duration, thereby improving the accuracy of the response received from the target device. Further optionally, different target devices can correspond to different heartbeat cycles, such as the heartbeat cycle of a device powered by the main power supply is 1 minute or 5 minutes, and the heartbeat cycle of a low-power device powered by a battery is 20 minutes or 1 hour.
[0108] 103. Analyze the online status of the target device according to the response feedback from the target device and the type of the target device, wherein the type of the target device includes a monitoring type or an inquiry type.
[0109] It can be seen that implementation Figure 1 The described method can automatically send a target heartbeat query instruction to the target device when it is determined that the online status of the target device needs to be determined and when it is determined that no data reported by the target device is received within a time period matching the target device, and automatically analyze the online status of the target device according to the response feedback from the target device and the type of the target device. The real status (online status or offline status) of the target device can be accurately and timely detected without increasing the heartbeat detection frequency of the target device, which is beneficial for the user to know the real status of the target device before preparing to control the target device, so that the user can accurately control the target device and improve the user experience; and by actively querying the online status of the device, it can reduce the occurrence of network congestion and increased data instruction packet loss rate when the online status detection device is equipped with multiple devices and needs to communicate with multiple devices, and is beneficial to improving the battery life of low-power devices.
[0110] In an optional embodiment, the method may further include the following operations:
[0111] When a query request for the online status of a certain device sent by a user terminal is detected, it is determined that the online status of the target device needs to be determined and the certain device is the target device; or,
[0112] It is determined whether the current moment is in the query time period of the online status of a certain device determined in the device list. When the result of the determination is yes, it is determined that the online status of the target device needs to be determined, and the certain device is the target device.
[0113] In this optional embodiment, if Figure 7 As shown, Figure 7 A schematic diagram of a plug-in homepage for a user terminal to request to query the online status of a device and a sub-device to control the switching of the plug-in page is disclosed. Figure 7 As shown, when it is detected that the device control application (including APP or applet) of the user terminal is started, the user terminal enters the plug-in homepage, obtains the device list from the cloud server and / or the online status detection device, and displays the device list on the plug-in homepage of the user terminal; detects the operation triggered by the user on a certain device (device 1) on the plug-in homepage, and the user terminal enters the sub-device control plug-in page of a certain device. When the current state of a certain device is displayed as offline on the sub-device control plug-in page, the user terminal disables the control button of a certain device (such as Figure 7 The switch channel 1) prompts the user that a certain device is offline and cannot be controlled; when the sub-device control plug-in page shows that the current status of a certain device is online, the user terminal sends a query request for the online status of a certain device to the online status detection device. Among them, the device list includes at least one device identification and the status of each device, Figure 7 In the schematic diagram of , the device list includes device 1, device 2, device 3, device 4, device 5, device 6, device 7, device 8, device 9 and device 10.
[0114] It can be seen that this optional embodiment can enrich the ways in which the online status of the device needs to be determined and increase the possibility of determining the online status of the device by determining that the online status of the device needs to be detected when it is determined that the user terminal sends a query request for the online status of the device or when it is detected that the device is currently in the query time period of the online status.
[0115] In another optional embodiment, after determining that the data reported by the target device is not received, the method may further include the following operations:
[0116] When the type of the target device is a monitoring type, the value of the heartbeat counter of the target device is decremented to a preset value of 0 at every second preset time interval;
[0117] When the value of the heartbeat counter of the target device decreases to 0, it is determined whether data reported by the target device is received. When it is determined that the data reported by the target device is not received, the above operation of sending a target heartbeat query instruction to the target device is executed.
[0118] In this optional embodiment, optionally, the second preset duration may be 1s or 2s, etc., and the preset value may be 1, 2, etc. For example, the value of the heartbeat counter of the target device is decremented to 1 every one second.
[0119] This optional embodiment, optionally, when it is determined that data reported by the target device is received, the current state of the target device is marked as an online state.
[0120] It can be seen that after this optional embodiment determines that no data reported by the target device is received, if the target device is a monitoring type target device, it further determines whether the data reported by the target device is received during the process of decrementing the value of the heartbeat counter of the target device; if no data reported by the target device is received, a target heartbeat query instruction is sent to the target device, which can improve the accuracy of the target heartbeat query instruction; if data reported by the target device is received, the current state of the target device is marked as online, which can improve the accuracy and efficiency of determining the online state of the target device.
[0121] In yet another optional embodiment, optionally, analyzing the online status of the target device according to the response feedback from the target device and the type of the target device includes:
[0122] When the type of the target device is a query type and when the response status fed back by the target device is used to indicate that the response information of the target device is received within a first preset time period, the current state of the target device is marked as an online state.
[0123] In this optional embodiment, the response information of the target device optionally includes but is not limited to at least one of the following information: the identification of the target device, the response time, the type of the target device, the size of the target device, the color of the target device, the receiving channel identification of the target heartbeat query instruction, and the appearance shape of the target device. It should be noted that the response information of the target device preferably includes the identification of the target device. In this way, when there are multiple devices whose online status needs to be determined, each device can be clearly distinguished by the content included in the response of each device, and the more content included in the response of the device, the more conducive it is to improve the regional accuracy of the device, thereby improving the accuracy and reliability of determining the online status of each device.
[0124] It can be seen that this optional embodiment can determine that the current state of the target device is an online state when it is judged that the response situation fed back by the target device of the query type is used to indicate that the response information reported by the target device is received within the specified time period, thereby improving the accuracy and flexibility of determining the online state of the target device.
[0125] In yet another optional embodiment, the method may further include the following operations:
[0126] When the type of the target device is a query type and when the response status fed back by the target device is used to indicate that no response information of the target device has been received within a first preset time period, determining the number of times a target heartbeat query instruction is sent to the target device during the process of detecting the online status of the target device as of the current moment;
[0127] Determine whether the number of times is greater than or equal to a determined number threshold, and when the determination result is yes, determine that the current state of the target device is offline;
[0128] And, the method may further include the following steps:
[0129] When it is determined that the number of times is less than the number threshold, the above operation of sending the target heartbeat query instruction to the target device is re-executed.
[0130] In this optional embodiment, the number threshold may be 1 time or 2 times, and this optional embodiment does not limit this.
[0131] It can be seen that when this optional embodiment determines that the response situation fed back by the target device of the query type is used to indicate that the response information reported by the target device has not been received within the specified time period, it further automatically determines whether the number of times the target device has been queried exceeds a determined number threshold. If so, the current state of the target device is marked as offline. If not, the target heartbeat query instruction is resent to determine the current state of the target device, which can improve the accuracy and reliability of determining the current state of the target device.
[0132] In yet another optional embodiment, analyzing the online status of the target device according to the response feedback from the target device and the type of the target device includes:
[0133] When the type of the target device is a monitoring type and when the response status fed back by the target device is used to indicate that the response information of the target device is received within the first preset time period, marking the current state of the target device as an online state;
[0134] When the type of the target device is a monitoring type and when the response status fed back by the target device is used to indicate that no response information of the target device is received within a first preset time period, it is determined that the current state of the target device is an offline state.
[0135] In this optional embodiment, the response information of the target device optionally includes but is not limited to at least one of the following information: the identification of the target device, the response time, the type of the target device, the size of the target device, the color of the target device, the receiving channel identification of the target heartbeat query instruction, and the appearance shape of the target device. It should be noted that the response information of the target device preferably includes the identification of the target device. In this way, when there are multiple devices whose online status needs to be determined, each device can be clearly distinguished by the content included in the response of each device, and the more content included in the response of the device, the more conducive it is to improve the regional accuracy of the device, thereby improving the accuracy and reliability of determining the online status of each device.
[0136] In this optional embodiment, optionally, after the current state of the target device is determined, the heartbeat counter of the target device is reset, and the above-mentioned operation of decreasing the value of the heartbeat counter of the target device to a preset value of 0 every second preset time interval is re-executed, so as to know the real-time status of the target device.
[0137] It can be seen that when this optional embodiment determines that the type of the target device is a monitoring type, it directly determines the current state of the target device based on the received response situation to indicate whether the response information reported by the target device is received or not received within a specified time period, which can improve the accuracy and efficiency of determining the current state of the target device.
[0138] In yet another optional embodiment, the method may further include the following steps:
[0139] When the type of the target device is a monitoring type, the heartbeat period of the target device is determined to be a data reporting waiting time that matches the target device;
[0140] When the type of the target device is a query type, a heartbeat query duration of the target device is generated according to the heartbeat cycle of the target device, and the heartbeat query duration is determined to be a data reporting waiting duration that matches the target device.
[0141] In this optional embodiment, optionally, the heartbeat query duration is greater than or equal to the third preset duration and less than the fourth preset duration, wherein the third preset duration and the fourth preset duration are both less than the heartbeat cycle of the target device. For example, the heartbeat query duration needs to be greater than or equal to half of the heartbeat cycle of the target device, and less than or equal to three quarters of the heartbeat cycle of the target device. In this way, by randomly generating the heartbeat query duration of the target device, it is beneficial to detect the online status of multiple target devices with the same heartbeat cycle at the same time (such as: there are 10 switch panels under the online status detection device, and their heartbeat cycles are all 1 minute). Separate inquiries can be made to reduce the possibility of data packet loss after the cutoff query time of the heartbeat query duration, thereby failing to accurately determine and distinguish the online status of each target device.
[0142] It can be seen that this optional embodiment determines the corresponding waiting time for data reporting by the type of different target devices, which can improve the accuracy of determining the waiting time for data reporting, thereby improving the accuracy of determining the online status of the corresponding target device.
[0143] In yet another optional embodiment, the method may further include the following operations:
[0144] When it is determined that the data reported by the target device is received, the current state of the target device is marked as an online state;
[0145] An operation of sending information that the target device is in an online state to the determined user terminal is executed;
[0146] In this optional embodiment, optionally, performing the operation of sending information that the target device is in an online state to the determined user terminal includes:
[0147] Sending information that the target device is online to the determined user terminal; and / or
[0148] The information that the target device is already in an online state is sent to the cloud server, and the cloud server is triggered to send the information that the target device is already in an online state to the determined user terminal.
[0149] It should be noted that this optional embodiment is applicable to the case where the current state of the target device is marked as online in any of the above embodiments. After the online state of the target device is marked, the online information of the target device can be directly sent to the cloud server.
[0150] It can be seen that when this optional embodiment determines that the current state of the target device is online, it directly sends the real information that the target device is online to the user terminal indirectly and / or directly through the cloud server for the user to know, so that the user can accurately control the target device, which is conducive to realizing intelligent and precise control of the target device and further enhancing the user experience.
[0151] In yet another optional embodiment, before performing the operation of sending information that the target device is in an online state to the determined user terminal, the method may further include the following operations:
[0152] It is determined whether the current state of the target device is reversed. When it is determined that the current state of the target device is reversed, the above-mentioned step of sending information indicating that the target device is online to the determined user terminal is executed.
[0153] In this optional embodiment, when the current state of the target device changes from an online state to an offline state or from an offline state to an online state, it is determined that the target device has flipped.
[0154] It can be seen that when this optional embodiment determines that the current state of the target device is online, it further determines whether the target device is flipped. If so, it sends real information that the target device is in an online state to the user terminal. This can reduce the heating of the online state detection device due to the real information that the device is online being sent too frequently, which affects the performance of the device, invalidly occupies the storage space of the user terminal, and reduces the occurrence of situations that affect the user's use of the user terminal.
[0155] In yet another optional embodiment, the method may further include the following operations:
[0156] When it is determined that the current state of the target device has not been flipped, information corresponding to the target device is collected, and the importance of the target device is analyzed based on the collected information corresponding to the target device;
[0157] Determine whether the importance of the target device is greater than or equal to the determined importance threshold. When it is determined that the importance threshold is greater than or equal to the importance threshold, execute the above-mentioned step of sending information that the target device is online to the determined user terminal.
[0158] In this optional embodiment, optionally, when it is determined that the importance is less than the threshold, the process ends.
[0159] In this optional embodiment, the information corresponding to the target device may include, but is not limited to, the frequency of use of the target device within a certain time period (such as 30 days before the current date), the use time of the target device within a certain time period, the degree of user dependence on the target device, and at least one of the current environmental information. The current environmental information includes one or more of the current ambient light intensity, the current ambient humidity, and the current ambient temperature. The degree of user dependence on the target device may be predetermined or determined based on the user's current situation, wherein the user's current situation includes the user's physical condition and / or the user's task schedule. In this way, the more content the information corresponding to the target device includes, the more conducive it is to improving the accuracy of the analysis of the importance of the target device, thereby improving the accuracy of sending the real information of the target device.
[0160] It can be seen that this optional embodiment, even if it is determined that the target device has not flipped, but when it is determined that the importance of the target device is relatively high, still sends real information that the target device is in an online state to the user terminal, so that the user can know the situation of the target device of concern and enrich the intelligent functions of the online status detection device, further facilitate the user to accurately control the target device, and further enhance the user experience.
[0161] Embodiment 2
[0162] See also Figure 2 , Figure 2 1 is a flow chart of another method for detecting the online status of a device disclosed in an embodiment of the present invention. Figure 2 The described method can be applied to an online status detection device, such as an online status detection gateway, wherein the online status detection device, the user terminal, and the cloud server can communicate with each other, wherein the user terminal includes at least one of the terminal target devices such as a smart phone (Android phone, iOS phone, etc.), a smart phone watch, a tablet computer, a PDA, a car computer, a desktop computer, a netbook, a personal digital assistant (PDA), a smart navigator, and a mobile Internet target device (MID), etc., and the embodiment of the present invention does not limit this. Figure 2 As shown, the online status detection method of the device may include the following operations:
[0163] 201. Broadcast a heartbeat query instruction to each device in all devices in the device information table. The heartbeat query instruction is used to query the heartbeat data of each device in the device information table.
[0164] In an embodiment of the present invention, optionally, the device information table is used to record the attribute information and heartbeat information of each device, wherein the heartbeat information of each device includes the heartbeat cycle, heartbeat counter, and heartbeat query time (time change corresponding to the first preset duration) of the device, and the attribute information of each device includes the online status or offline status of the device. Figure 8 A schematic diagram of the structure of a device information table is disclosed, such as Figure 8 As shown, the device information table lists device 1, device 2, device 3, device 4, device 5, ..., device n, each of which includes a heartbeat cycle, a heartbeat counter, a heartbeat query time and a status, wherein the status includes an online status or an offline status.
[0165] In the embodiment of the present invention, optionally, when the online status detection device is just powered on, step 201 is triggered to be executed.
[0166] 202. Determine the response status of each device in the device information table to the heartbeat query instruction, and based on the response status of each device in the device information table to the heartbeat query instruction, determine whether there is a response status among all the devices in the device information table that indicates a device that has not responded to the heartbeat query instruction; when it is determined that there is no response status, step 203 can be triggered; when it is determined that there is at least one response status that indicates a device that has not responded to the heartbeat query instruction, step 204 can be triggered.
[0167] 203 . Mark the current state of each device as online in the device information table, and trigger execution of step 207 .
[0168] 204. Determine the response status used to indicate the number of queries for each device that has not responded to the heartbeat query instruction, and judge whether the response status used to indicate the number of queries for each device that has not responded to the heartbeat query instruction is greater than or equal to the determined query number threshold. When the judgment result is yes, step 205 can be triggered; when the judgment result is yes, step 206 can be triggered.
[0169] In the embodiment of the present invention, each device has a corresponding query number threshold. Further, the query number threshold corresponding to each device may be the same or different.
[0170] 205 , marking the response status to indicate that the current state of each device that has not responded to the heartbeat query instruction is offline, and marking the response status to indicate that the current state of each device that has responded to the heartbeat query instruction is online, and triggering the execution of step 207 .
[0171] 206. Rebroadcast the heartbeat query command separately to each device whose response status indicates that the heartbeat query command has not been responded.
[0172] 207. When it is determined that the online status of the target device needs to be determined, a data reporting waiting time matching the target device is generated according to the type of the target device, and it is determined whether data reported by the target device is received within the data reporting waiting time.
[0173] 208. When it is determined that no data reported by the target device is received, a target heartbeat query instruction is sent to the target device, and a response feedback from the target device received within a first preset time period is obtained.
[0174] 209. Analyze the online status of the target device according to the response feedback from the target device and the type of the target device.
[0175] In the embodiment of the present invention, it should be noted that for the description of steps 207 to 209, please refer to the detailed description of steps 101 to 103 in the first embodiment, which will not be described in detail in the embodiment of the present invention.
[0176] It can be seen that the embodiment of the present invention can also perform initialization operations on all devices in the device information table first, which is beneficial to further improve the accuracy and reliability of determining the actual status (online status or offline status) of subsequent devices, thereby further improving the control accuracy and reliability of the devices; and when it is determined that there are some devices that have not responded to the heartbeat query instruction a small number of times, the heartbeat query instruction is re-sent to them, which is beneficial to improve the accuracy of device initialization.
[0177] It can be seen that implementation Figure 2 The described method can automatically send a target heartbeat query instruction to the target device when it is determined that the online status of the target device needs to be determined and when it is determined that no data reported by the target device is received within a time period matching the target device, and automatically analyze the online status of the target device according to the response feedback from the target device and the type of the target device. The real status (online status or offline status) of the target device can be accurately and timely detected without increasing the heartbeat detection frequency of the target device, which is beneficial for the user to know the real status of the target device before preparing to control the target device, so that the user can accurately control the target device and improve the user experience; and by actively querying the online status of the device, it can reduce the occurrence of network congestion and increased data instruction packet loss rate when the online status detection device is equipped with multiple devices and needs to communicate with multiple devices, and is beneficial to improving the battery life of low-power devices. In addition, it is also possible to initialize all devices in the device information table first, which is conducive to further improving the accuracy and reliability of determining the actual status (online status or offline status) of subsequent devices, thereby further improving the control accuracy and reliability of the equipment; and when it is determined that some devices have not responded to the heartbeat query instruction a small number of times, the heartbeat query instruction is re-sent to them, which is conducive to improving the accuracy of device initialization.
[0178] In an optional embodiment, the method may further include the following steps:
[0179] For each device that has been marked, query the attribute information of the device and report the target information of the device to the cloud server. The target information of the device includes the attribute information and online status of the device. Among them, all the marked devices include devices whose current status is marked as online and devices whose current status is marked as offline. The online status of each device includes the online status or offline status of the device. Different devices correspond to different attribute information, such as: for switch panels and LED lighting, their attribute information includes on / off attributes.
[0180] It can be seen that after marking the status of the device, this optional embodiment further reads its attribute information and reports the attribute information and online status to the cloud server, which is beneficial for subsequent users to have a preliminary understanding of the status of the device, so that users can operate the device accurately and further enhance the user experience.
[0181] Embodiment 3
[0182] See also Figure 3 , Figure 3 It is a structural diagram of an online status detection device of a device disclosed in an embodiment of the present invention. Among them, the online status detection device, the user terminal, and the cloud server can communicate with each other, and the user terminal includes at least one of the terminal target devices such as smart phones (Android phones, iOS phones, etc.), smart phone watches, tablet computers, PDAs, car computers, desktop computers, netbooks, personal digital assistants (PDA), smart navigators, and mobile Internet target devices (MID), etc., which are not limited in the embodiment of the present invention. Figure 3 As shown, the online status detection device of the device may include:
[0183] The determination module 301 is used to determine whether the data reported by the target device is received within a data reporting waiting time period matching the target device when it is determined that the online status of the target device needs to be determined.
[0184] The sending module 302 is used to send a target heartbeat query instruction to the target device when it is determined that no data reported by the target device is received.
[0185] The acquisition module 303 is used to acquire the response status fed back by the target device received within a first preset time period.
[0186] The analysis module 304 is used to analyze the online status of the target device according to the response status fed back by the target device and the type of the target device, wherein the type of the target device includes a monitoring type or a query type.
[0187] It can be seen that implementation Figure 3The described online status detection device can automatically send a target heartbeat query instruction to the target device when it is determined that the online status of the target device needs to be determined and when it is determined that no data reported by the target device has been received within a time period matching the target device, and automatically analyze the online status of the target device according to the response feedback from the target device and the type of the target device. The real status (online status or offline status) of the target device can be accurately and timely detected without increasing the heartbeat detection frequency of the target device, which is beneficial for the user to know the real status of the target device before preparing to control the target device, so that the user can accurately control the target device and enhance the user experience; and by actively querying the online status of the device, it can reduce network congestion and increased data instruction packet loss rate when the online status detection device is equipped with multiple devices and needs to communicate with multiple devices, and is beneficial to improving the battery life of low-power devices.
[0188] In an optional embodiment, if Figure 4 As shown, the device also includes:
[0189] The decrement module 305 is used to decrement the value of the heartbeat counter of the target device to a preset value of 0 at every second preset time interval when the determination module 301 determines that no data reported by the target device is received and the type of the target device is a monitoring type.
[0190] The judgment module 301 is also used to judge whether the data reported by the target device is received when the value of the heartbeat counter of the target device decreases to 0. When it is judged that the data reported by the target device is not received, the sending module 302 is triggered to execute the above-mentioned operation of sending the target heartbeat query instruction to the target device.
[0191] It can be seen that implementation Figure 4 The described online status detection device can, after determining that no data reported by the target device is received, further determine whether the data reported by the target device is received during the process of decrementing the value of the heartbeat counter of the target device if the target device is a monitoring type target device; if no data reported by the target device is received, send a target heartbeat query instruction to the target device, thereby improving the accuracy of the target heartbeat query instruction; if data reported by the target device is received, mark the current status of the target device as being online, thereby improving the accuracy and efficiency of determining the online status of the target device.
[0192] In another optional embodiment, Figure 4 As shown, the analysis module 304 includes:
[0193] The marking submodule 3041 is used to mark the current state of the target device as an online state when the type of the target device is a query type and when the response status fed back by the target device is used to indicate that the response information of the target device is received within a first preset time period.
[0194] It can be seen that implementation Figure 4 The described online status detection device can also determine that the current status of the target device is online when it is judged that the response status of the target device feedback of the query type is used to indicate that the response information reported by the target device is received within the specified time period, thereby improving the accuracy and flexibility of determining the online status of the target device.
[0195] In yet another optional embodiment, Figure 4 As shown, the analysis module 304 also includes;
[0196] The marking submodule 3041 is used to determine the number of target heartbeat query instructions sent to the target device as of the current moment during the process of detecting the online status of the target device when the type of the target device is a query type and when the response status fed back by the target device is used to indicate that no response information from the target device has been received within a first preset time period.
[0197] The judging submodule 3042 is used to judge whether the number of times is greater than or equal to the determined number of times threshold.
[0198] The marking submodule 3041 is further configured to determine that the current state of the target device is offline when the judgment result is yes.
[0199] The sending module 302 is further configured to re-execute the above-mentioned operation of sending the target heartbeat query instruction to the target device when the judging submodule 3043 judges that the number of times is less than the number threshold.
[0200] It can be seen that implementation Figure 4 The described online status detection device can also automatically determine whether the number of times the target device has been queried exceeds a determined number threshold when it determines that the response status of the target device feedback of the query type indicates that the response information reported by the target device has not been received within a specified time period. If so, the current state of the target device is marked as offline. If not, the target heartbeat query instruction is resent to determine the current state of the target device, which can improve the accuracy and reliability of determining the current state of the target device.
[0201] In yet another optional embodiment, Figure 4 As shown, when the type of the target device is the monitoring type, the analysis module 304 analyzes the online status of the target device according to the response feedback from the target device and the type of the target device in the following manner:
[0202] When the response status fed back by the target device is used to indicate that the response information of the target device is received within the first preset time period, the current state of the target device is marked as an online state;
[0203] When the type of the target device is a monitoring type and when the response status fed back by the target device is used to indicate that no response information of the target device is received within a first preset time period, it is determined that the current state of the target device is an offline state.
[0204] It can be seen that implementation Figure 4 When the described online status detection device determines that the type of the target device is a monitoring type, it directly determines the current status of the target device based on the received response situation to indicate whether the response information reported by the target device is received or not received within a specified time period, which can improve the accuracy and efficiency of determining the current status of the target device.
[0205] In yet another optional embodiment, Figure 4 As shown, the device also includes:
[0206] The first determining module 306 is configured to determine, when the type of the target device is a monitoring type, a heartbeat cycle of the target device as a data reporting waiting time period that matches the target device.
[0207] The generating module 307 is used to generate the heartbeat query duration of the target device according to the heartbeat cycle of the target device when the type of the target device is the query type.
[0208] The first determination module 306 is also used to determine the heartbeat query duration as the data reporting waiting duration that matches the target device, wherein the heartbeat query duration is greater than or equal to the third preset duration and less than the fourth preset duration, wherein the third preset duration and the fourth preset duration are both less than the heartbeat cycle of the target device.
[0209] In this optional embodiment, optionally, after the first determination module 306 completes the above-mentioned operation of determining that the heartbeat cycle of the target device is the data reporting waiting time that matches the target device or completes the above-mentioned operation of determining that the heartbeat query time is the data reporting waiting time that matches the target device, the judgment module 301 can be triggered to perform the above-mentioned operation of determining whether the data reported by the target device is received within the time period of the data reporting waiting time that matches the target device when it is determined that the online status of the target device needs to be determined.
[0210] It can be seen that implementation Figure 4 The described online status detection device can also determine the corresponding waiting time for data reporting according to the types of different target devices, which can improve the accuracy of determining the waiting time for data reporting, thereby improving the accuracy of determining the online status of the corresponding target device.
[0211] In yet another optional embodiment, Figure 4 As shown, the device also includes:
[0212] The first marking module 308 is configured to mark the current state of the target device as an online state when the judging module 301 judges that data reported by the target device is received.
[0213] The sending module 302 is further configured to send information indicating that the target device is online to the determined user terminal.
[0214] The specific manner in which the sending module 302 performs the operation of sending the information that the target device is in an online state to the determined user terminal is:
[0215] Sending information that the target device is online to the determined user terminal; and / or
[0216] The information that the target device is already in an online state is sent to the cloud server, and the cloud server is triggered to send the information that the target device is already in an online state to the determined user terminal.
[0217] Furthermore, the judgment module 301 is also used to judge whether the current state of the target device has been reversed before the sending module 302 executes the operation of sending information that the target device is in an online state to the determined user terminal; when it is determined that the current state of the target device has been reversed, the sending module 302 is triggered to execute the operation of sending information that the target device is in an online state to the determined user terminal.
[0218] It can be seen that implementation Figure 4 The described online status detection device can also indirectly and / or directly send the real information of the target device being online to the user terminal through the cloud server when judging that the current status of the target device is online, so that the user can know it, so that the user can accurately control the target device, which is conducive to realizing intelligent and precise control of the target device, and further improving the user experience. In addition, when judging that the current status of the target device is online, it can further determine whether the target device is flipped, and if so, send the real information of the target device being online to the user terminal, which can reduce the heating of the online status detection device due to the too frequent sending of the real information of the device being online, affecting the performance of the device, invalidly occupying the storage space of the user terminal, and reducing the occurrence of affecting the user's use of the user terminal.
[0219] In yet another optional embodiment, Figure 4 As shown, the device also includes:
[0220] The sending module 302 is further used to broadcast a heartbeat query instruction to each device in all the devices in the device information table, where the heartbeat query instruction is used to query the heartbeat data of each device in the device information table.
[0221] The second determination module 309 is used to determine the response status of each device in the device information table to the heartbeat query instruction.
[0222] The judgment module 301 is further used to judge whether there is a device in the device information table whose response status indicates that it has not responded to the heartbeat query instruction, based on the response status of each device in the device information table to the heartbeat query instruction.
[0223] The second marking module 310 is used to mark the current state of each device as an online state in the device information table when it is determined that the device does not exist.
[0224] The second determining module 309 is further configured to determine the query times of each device whose response situation indicates that the device has not responded to the heartbeat query instruction when it is determined that there is at least one device whose response situation indicates that the device has not responded to the heartbeat query instruction.
[0225] The judgment module 301 is further used to judge whether the query times of each device that has not responded to the heartbeat query instruction is greater than or equal to the determined query times threshold.
[0226] The second marking module 310 is further configured to mark the response status to indicate that the current status of each device that has not responded to the heartbeat query instruction is offline when the result of the determination is yes.
[0227] The sending module 302 is further configured to, when the judgment result is yes, rebroadcast the heartbeat query instruction separately to each device whose response status indicates that the heartbeat query instruction has not been responded.
[0228] It can be seen that implementation Figure 4 The described online status detection device can also first perform initialization operations on all devices in the device information table, which is conducive to further improving the accuracy and reliability of determining the actual status (online status or offline status) of subsequent devices, thereby further improving the control accuracy and reliability of the equipment; and when it is determined that some devices have not responded to the heartbeat query instruction a small number of times, the heartbeat query instruction is re-sent to them, which is conducive to improving the accuracy of device initialization.
[0229] In another optional embodiment, the apparatus is further configured to, when detecting a query request for an online status of a certain device sent by a user terminal, determine that an online status of a target device needs to be determined, and that the certain device is the target device; or,
[0230] It is determined whether the current moment is in the query time period of the online status of a certain device determined in the device list. When the result of the determination is yes, it is determined that the online status of the target device needs to be determined, and the certain device is the target device.
[0231] It can be seen that the optional online status detection device can also determine that the online status of the device needs to be detected when it is determined that the user terminal sends a query request for the online status of the device or when it is detected that the device is currently in the query time period of the online status. This can enrich the ways in which the online status of the device needs to be determined and increase the possibility of determining the online status of the device.
[0232] Embodiment 4
[0233] See also Figure 5 , Figure 5 It is a structural diagram of an online status detection device of another device disclosed in an embodiment of the present invention. Among them, the online status detection device, the user terminal, and the cloud server can communicate with each other, and the user terminal includes at least one of the terminal target devices such as smart phones (Android phones, iOS phones, etc.), smart phone watches, tablet computers, PDAs, car computers, desktop computers, netbooks, personal digital assistants (PDA), smart navigators, and mobile Internet target devices (MID), etc., which are not limited in the embodiment of the present invention. Figure 5 As shown, the device may include:
[0234] A memory 501 storing executable program codes;
[0235] a processor 502 coupled to the memory 501;
[0236] Furthermore, it may also include an input interface 503 and an output interface 504 coupled to the processor 502;
[0237] The processor 502 calls the executable program code stored in the memory 501 to execute part or all of the steps in the online status detection method of the device disclosed in the first or second embodiment of the present invention.
[0238] Embodiment 5
[0239] An embodiment of the present invention discloses a computer storage medium, which stores computer instructions. When the computer instructions are called, they are used to execute some or all of the steps in the online status detection method of the device disclosed in the first or second embodiment of the present invention.
[0240] The device embodiments described above are only illustrative, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, i.e., they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative work.
[0241] Through the specific description of the above embodiments, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on such an understanding, the above technical solution can be essentially or partly contributed to the prior art in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, and the storage medium includes a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable rewritable read-only memory (EEPROM), a compact disc (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.
[0242] Finally, it should be noted that the online status detection method and apparatus of a device disclosed in the embodiment of the present invention disclose only the preferred embodiments of the present invention, which are only used to illustrate the technical solution of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments can still be modified, or some of the technical features therein can be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for detecting an online state of a device, characterized in that: The method comprises: When it is determined that the online status of the target device needs to be determined, determining whether the data reported by the target device is received within a time period of a data reporting waiting time period that matches the target device, the starting time of the data reporting waiting time period being the time when it is determined that the online status of the target device needs to be determined; When it is determined that no data reported by the target device is received, sending a target heartbeat query instruction to the target device; Acquire a response situation fed back by the target device within a first preset time period, and analyze the online state of the target device according to the response situation fed back by the target device and the type of the target device, wherein the type of the target device includes a monitoring type or an inquiry type; The duration of the first preset duration segment is determined based on the type of the target device and / or the heartbeat cycle of the target device and / or the timing accuracy of the target device.
2. The method for detecting the online status of a device according to claim 1, characterized in that: After determining that the data reported by the target device is not received, the method further includes: When the type of the target device is the monitoring type, the value of the heartbeat counter of the target device is decremented to a preset value at every second preset time interval; During the process of the heartbeat counter value of the target device decreasing to the preset value, it is determined whether the data reported by the target device is received. When it is determined that the data reported by the target device is not received, the operation of sending a target heartbeat query instruction to the target device is executed.
3. The method for detecting the online status of a device according to claim 1, characterized in that: The analyzing the online status of the target device according to the response status fed back by the target device and the type of the target device includes: When the type of the target device is the query type and when the response status fed back by the target device is used to indicate that the response information of the target device is received within the first preset time period, the current state of the target device is marked as an online state.
4. The method for detecting the online status of a device according to claim 3, characterized in that: The method further comprises: When the type of the target device is the query type and when the response status fed back by the target device is used to indicate that no response information of the target device has been received within the first preset time period, determining the number of times the target heartbeat query instruction is sent to the target device as of the current moment in the process of detecting the online status of the target device; Determine whether the number of times is greater than or equal to a determined number threshold, and when the determination result is yes, determine that the current state of the target device is offline; And, the method further comprises: When it is determined that the number is less than the number threshold, the operation of sending the target heartbeat query instruction to the target device is re-executed.
5. The method for detecting the online status of a device according to claim 1, characterized in that: When the type of the target device is the monitoring type, analyzing the online state of the target device according to the response feedback from the target device and the type of the target device includes: When the response status fed back by the target device indicates that the response information of the target device is received within the first preset time period, marking the current state of the target device as an online state; When the type of the target device is the monitoring type and when the response status fed back by the target device is used to indicate that no response information of the target device is received within the first preset time period, it is determined that the current state of the target device is offline.
6. The method for detecting the online status of a device according to any one of claims 1 to 5, characterized in that: The method further comprises: When the type of the target device is the monitoring type, determining the heartbeat cycle of the target device to be a data reporting waiting time length that matches the target device; When the type of the target device is the query type, the heartbeat query duration of the target device is generated according to the heartbeat cycle of the target device, and the heartbeat query duration is determined to be the data reporting waiting duration that matches the target device, and the heartbeat query duration is greater than or equal to the third preset duration and less than the fourth preset duration, wherein the third preset duration and the fourth preset duration are both less than the heartbeat cycle of the target device.
7. The method for detecting the online status of a device according to claim 6, characterized in that: The method further comprises: When it is determined that the data reported by the target device is received, marking the current state of the target device as an online state; Performing an operation of sending information that the target device is in an online state to the determined user terminal; The operation of sending information that the target device is in an online state to the determined user terminal includes: Sending information that the target device is online to the determined user terminal; and / or Sending information that the target device is in an online state to a cloud server, and triggering the cloud server to send information that the target device is in an online state to the determined user terminal; Furthermore, before executing the operation of sending information that the target device is in an online state to the determined user terminal, the method further includes: Determine whether the current state of the target device is reversed, and when it is determined that the current state of the target device is reversed, execute the step of sending information that the target device is in an online state to the determined user terminal.
8. The method for detecting the online status of a device according to any one of claims 1 to 5, characterized in that: The method further comprises: Broadcasting a heartbeat query instruction to each of the devices in the device information table, wherein the heartbeat query instruction is used to query the heartbeat data of each of the devices in the device information table; Determine the response of each of the devices in the device information table to the heartbeat query instruction, and based on the response of each of the devices in the device information table to the heartbeat query instruction, determine whether there is a response status indicating a device that has not responded to the heartbeat query instruction among all the devices in the device information table; When it is determined that the device does not exist, marking the current state of each device in the device information table as an online state; When it is determined that there is at least one response situation indicating that the device has not responded to the heartbeat query instruction, determine the query times for each device whose response situation indicates that the device has not responded to the heartbeat query instruction, and determine whether the query times for each device whose response situation indicates that the device has not responded to the heartbeat query instruction is greater than or equal to the determined query times threshold. When the result of the determination is yes, mark the current state of each device whose response situation indicates that the device has not responded to the heartbeat query instruction as an offline state. When the result of the determination is yes, rebroadcast the heartbeat query instruction separately to each device whose response situation indicates that the device has not responded to the heartbeat query instruction.
9. The method for detecting the online status of a device according to claim 7, characterized in that: The method further comprises: When a query request for the online status of a certain device sent by a user terminal is detected, it is determined that the online status of a target device needs to be determined, and the certain device is the target device; or It is determined whether the current moment is in the query time period of the online status of a certain device determined in the device list. When the result of the determination is yes, it is determined that the online status of the target device needs to be determined, and the certain device is the target device.
10. An online status detection device for a device, characterized in that: The device comprises: A determination module, for determining, when it is determined that the online status of the target device needs to be determined, whether the data reported by the target device is received within a time period of a data reporting waiting time period that matches the target device, wherein the starting time of the data reporting waiting time period is the time when it is determined that the online status of the target device needs to be determined; A sending module, configured to send a target heartbeat query instruction to the target device when the judging module determines that no data reported by the target device is received; An acquisition module, used for acquiring a response condition fed back by the target device within a first preset time period; An analysis module, configured to analyze the online state of the target device according to the response feedback from the target device and the type of the target device, wherein the type of the target device includes a monitoring type or a query type; The duration of the first preset duration segment is determined based on the type of the target device and / or the heartbeat cycle of the target device and / or the timing accuracy of the target device.
