Interface state updating method and device, storage medium and electronic device
Patent Information
- Application Number
- CN202210004827.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-04
- Publication Date
- 2026-10-23
- Estimated Expiration
- 2042-01-04
AI Technical Summary
[0004]本发明实施例提供了一种接口状态的更新方法和装置、存储介质及电子装置,以至少解决相关技术中,目前云端不支持这种低功耗模式的维护等问题
[0015]在本发明实施例中,确定休眠网关中是否存在与第一心跳数据一致的第二心跳数据,其中,所述第一心跳数据为目标设备发送的数据,所述第一心跳数据中包括:目标设备的设备信息;在所述休眠网关中不存在与所述第一心跳数据一致的第二心跳数据的情况下,将所述目标设备的设备信息保存至所述休眠网关;在根据所述设备信息确定所述目标设备在所述休眠网关上线的情况下,将所述休眠网关中所述目标设备对应的接口状态更新为连接状态;采用上述技术方案,解决了目前云端不支持这种低功耗模式的维护等问题,本发明实施例中,通过获取目标设备发送的心跳数据,维护休眠网关中目标设备对应的接口状态,进而维护所述目标设备处于低功耗模式时的接口状态。
Smart Images

Figure CN116437378B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communications, and more specifically, to a method and apparatus for updating interface status, a storage medium, and an electronic device. Background Technology
[0002] Most existing IoT devices are powered by electricity, so there's no need to worry about power issues affecting their normal operation. However, doorbells are special devices. If a doorbell's normal operation heavily relies on electricity, such as being connected to the user's home power supply, it might be impossible to unlock the door if the user's home loses power. Therefore, doorbells need to be battery powered to break free from dependence on the user's home power supply. In this low-power mode, the doorbell device still maintains a connection to the cloud, but currently, the cloud does not support maintenance in this low-power mode.
[0003] Regarding the maintenance issues related to the lack of cloud support for this low-power mode, no effective solution has yet been proposed. Summary of the Invention
[0004] This invention provides a method and apparatus for updating interface status, a storage medium, and an electronic device to at least address issues in the related art, such as the current lack of cloud support for maintaining this low-power mode.
[0005] According to one embodiment of the present invention, a method for updating an interface state is provided, comprising: determining whether there is second heartbeat data consistent with first heartbeat data in a hibernation gateway, wherein the first heartbeat data is data sent by a target device and includes device information of the target device; if there is no second heartbeat data consistent with the first heartbeat data in the hibernation gateway, saving the device information of the target device to the hibernation gateway; and if it is determined from the device information that the target device is online in the hibernation gateway, updating the interface state corresponding to the target device in the hibernation gateway to a connected state.
[0006] In an exemplary embodiment, before determining whether there is second heartbeat data consistent with the first heartbeat data in the hibernation gateway, the method further includes: caching the original data received by the hibernation gateway to obtain buffered data, and determining whether the data length of the buffered data is greater than a preset threshold; if the data length of the buffered data is greater than the preset threshold, parsing the buffered data to obtain hibernation packet data; and if it is determined that the data length of the hibernation packet data is within a preset range, determining that the buffered data is the first heartbeat data.
[0007] In one exemplary embodiment, after updating the interface state corresponding to the target device in the hibernation gateway to a connected state, the method further includes at least one of the following: when the target device sends service data to the hibernation gateway for the first time, updating the interface state corresponding to the target device from the connected state to an open state; when the server corresponding to the target device sends request data to the target device through the hibernation gateway, updating the interface state corresponding to the target device from the connected state to a temporarily closed state.
[0008] In an exemplary embodiment, after updating the interface status corresponding to the target device in the hibernation gateway to a connected state, the method further includes: obtaining a shutdown list from the hibernation gateway whose interface status is completely closed, wherein the shutdown list stores a correspondence between interfaces and interface statuses; determining a first clearing order for the interfaces in the shutdown list and a second clearing order for the interface statuses; sequentially clearing the interfaces in the shutdown list according to the first clearing order, and sequentially clearing the interface statuses in the shutdown list according to the second clearing order, wherein the first clearing order and the second clearing order may be the same or different.
[0009] In one exemplary embodiment, determining the target device after it comes online on the hibernation gateway based on the device information includes: updating the status information of the target device in the hibernation gateway to an online state; determining a first state duration of the target device, and updating the status information of the target device to an offline state if the first state duration exceeds a first preset duration, wherein the first state duration is used to indicate the duration between the last time the hibernation gateway received heartbeat data sent by the target device and the current time; determining a second state duration of the offline state of the target device, and deleting the device information of the target device in the hibernation gateway if the second state duration exceeds a second preset duration.
[0010] In an exemplary embodiment, before updating the status information of the target device to an offline state, the method further includes: obtaining a device information list in the hibernation gateway, wherein the device information list includes at least: the identification information of the target device; obtaining the status duration of the status information of each device in the device information list; determining whether to update the status information of any one device based on the relationship between the status duration of the status information of each device and a preset duration, until it is determined whether to update the status information of all devices in the device information list.
[0011] In one exemplary embodiment, after determining whether to update all device status information in the device information list, the method further includes: obtaining an offline device list in the hibernation gateway, wherein the offline device list is used to indicate devices whose status information is offline; determining an offline device identifier in the offline device list; and sending offline information carrying the offline device identifier to a server, so that the server determines that the target device is offline on the hibernation gateway.
[0012] According to another embodiment of the present invention, an interface state update apparatus is also provided, comprising: a determining module, configured to determine whether there is second heartbeat data consistent with first heartbeat data in a hibernation gateway, wherein the first heartbeat data is data sent by a target device and includes device information of the target device; a saving module, configured to save the device information of the target device to the hibernation gateway when there is no second heartbeat data consistent with the first heartbeat data in the hibernation gateway; and an updating module, configured to update the interface state corresponding to the target device in the hibernation gateway to a connected state when it is determined from the device information that the target device is online in the hibernation gateway.
[0013] According to another aspect of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored therein, wherein the computer program is configured to execute the above-described interface state update method at runtime.
[0014] According to another aspect of the present invention, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the interface state update method described above through the computer program.
[0015] In this embodiment of the invention, it is determined whether there is second heartbeat data in the hibernation gateway that is consistent with the first heartbeat data. The first heartbeat data is data sent by the target device and includes device information of the target device. If there is no second heartbeat data consistent with the first heartbeat data in the hibernation gateway, the device information of the target device is saved to the hibernation gateway. If it is determined that the target device is online in the hibernation gateway based on the device information, the interface status corresponding to the target device in the hibernation gateway is updated to a connected state. This technical solution solves the problem that the cloud currently does not support the maintenance of this low-power mode. In this embodiment of the invention, by obtaining the heartbeat data sent by the target device, the interface status corresponding to the target device in the hibernation gateway is maintained, thereby maintaining the interface status of the target device when it is in low-power mode. Attached Figure Description
[0016] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0017] Figure 1 This is a hardware structure block diagram of a computer terminal for an interface state update method according to an embodiment of the present invention.
[0018] Figure 2 This is a flowchart of an interface state update method according to an embodiment of the present invention;
[0019] Figure 3 This is a schematic diagram illustrating the interaction between a low-power device and a gateway according to an embodiment of the present invention;
[0020] Figure 4 This is a diagram showing the operating mode transitions of a low-power device according to an embodiment of the present invention;
[0021] Figure 5 This is a schematic diagram (a) of an interface state update method according to an embodiment of the present invention;
[0022] Figure 6 This is a schematic diagram (II) of an interface state update method according to an embodiment of the present invention;
[0023] Figure 7 This is a schematic diagram (iii) of an interface state update method according to an embodiment of the present invention;
[0024] Figure 8 This is a schematic diagram (IV) of an interface state update method according to an embodiment of the present invention;
[0025] Figure 9 This is a schematic diagram (V) of an interface state update method according to an embodiment of the present invention;
[0026] Figure 10 This is a schematic diagram (six) of an interface state update method according to an embodiment of the present invention;
[0027] Figure 11 This is a structural block diagram of an interface state update device according to an embodiment of the present invention. Detailed Implementation
[0028] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0029] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0030] The methods and embodiments provided in this application can be executed on a mobile terminal, a computer terminal, or a similar computing device. Taking running on a computer terminal as an example, Figure 1 This is a hardware structure block diagram of a computer terminal for an interface state update method according to an embodiment of the present invention. For example... Figure 1 As shown, a computer terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. In one exemplary embodiment, the computer terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the computer terminal described above. For example, the computer terminal may also include components that are more complex than those described above. Figure 1 The more or fewer components shown, or having the same Figure 1 Equivalent functions or ratios shown Figure 1 The functions shown have more different configurations.
[0031] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the interface state update method in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to a computer terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0032] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider for the computer terminal. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module used for wireless communication with the Internet.
[0033] This embodiment provides a method for updating the interface status, applied to the aforementioned computer terminal, specifically a hibernation gateway. Figure 2 This is a flowchart of an interface state update method according to an embodiment of the present invention, the process including the following steps:
[0034] Step S202: Determine whether there is second heartbeat data in the hibernation gateway that is consistent with the first heartbeat data, wherein the first heartbeat data is data sent by the target device and includes: device information of the target device;
[0035] Step S204: If there is no second heartbeat data in the hibernation gateway that matches the first heartbeat data, save the device information of the target device to the hibernation gateway;
[0036] Step S206: If it is determined from the device information that the target device is online in the hibernation gateway, update the interface status of the target device in the hibernation gateway to a connected status.
[0037] Through the above steps, it is determined whether there is second heartbeat data in the hibernation gateway that is consistent with the first heartbeat data. The first heartbeat data is data sent by the target device and includes the target device's device information. If there is no second heartbeat data consistent with the first heartbeat data in the hibernation gateway, the target device's device information is saved to the hibernation gateway. If it is determined that the target device is online in the hibernation gateway based on the device information, the interface status corresponding to the target device in the hibernation gateway is updated to a connected state. This solves the problem that the cloud currently does not support the maintenance of this low-power mode in related technologies. In this embodiment of the invention, by obtaining the heartbeat data sent by the target device, the interface status corresponding to the target device in the hibernation gateway is maintained, thereby maintaining the interface status of the target device when it is in low-power mode.
[0038] In an exemplary embodiment, before determining whether there is second heartbeat data consistent with the first heartbeat data in the hibernation gateway, the original data received by the hibernation gateway is cached to obtain buffered data, and it is determined whether the data length of the buffered data is greater than a preset threshold; if the data length of the buffered data is greater than the preset threshold, the buffered data is parsed to obtain hibernation packet data; if it is determined that the data length of the hibernation packet data is within a preset range, the buffered data is determined to be the first heartbeat data.
[0039] Specifically, this invention describes a method for decoding raw data sent by a target device, the specific steps of which are as follows:
[0040] Step 1: Receive raw data sent by the target device;
[0041] Step 2: Cache the original data in the cache area;
[0042] Step 3: Decode the original data to obtain buffered data;
[0043] Step 4: Determine whether the length of the buffered data is greater than a preset threshold. If the length of the buffered data is greater than the preset threshold, proceed to step 5; otherwise, repeat steps 2-4.
[0044] It should be noted that step 4 is to determine whether the complete original data has been received;
[0045] Step 5: Parse the buffered data to obtain the hibernation packet data, and determine whether the data length of the hibernation packet data is within a preset range. If the data length of the hibernation packet data is within the preset range, proceed to step 6; otherwise, proceed to step 7.
[0046] Step 6: Check if there is heartbeat data in the hibernation gateway that matches the first heartbeat data;
[0047] Step 7: Clear the data in the cache;
[0048] Step 8: Close the interface corresponding to the target device.
[0049] In one exemplary embodiment, after updating the interface state corresponding to the target device in the hibernation gateway to a connected state, the method further includes at least one of the following: when the target device sends service data to the hibernation gateway for the first time, updating the interface state corresponding to the target device from the connected state to an open state; when the server corresponding to the target device sends request data to the target device through the hibernation gateway, updating the interface state corresponding to the target device from the connected state to a temporarily closed state.
[0050] It should be noted that the interface state conversion method of the target device in the hibernation gateway also includes the following situations: when the server corresponding to the target device sends the request data to the target device through the hibernation gateway, the interface state of the target device is updated from the temporarily closed state to the open state; when the hibernation gateway determines that the connection state or the open state of the interface has lasted for more than a second preset time, the interface state of the target device is updated to the completely closed state.
[0051] In an exemplary embodiment, after updating the interface status corresponding to the target device in the hibernation gateway to a connected state, the method further includes: obtaining a shutdown list from the hibernation gateway whose interface status is completely closed, wherein the shutdown list stores a correspondence between interfaces and interface statuses; determining a first clearing order for the interfaces in the shutdown list and a second clearing order for the interface statuses; sequentially clearing the interfaces in the shutdown list according to the first clearing order, and sequentially clearing the interface statuses in the shutdown list according to the second clearing order, wherein the first clearing order and the second clearing order may be the same or different.
[0052] It should be noted that the hibernation gateway will periodically start a task to clean up the interfaces. The hibernation gateway first obtains the interface list corresponding to all interfaces. It should be noted that different interfaces correspond to different devices. It determines whether the interface status information of all interfaces in the interface list needs to be updated. After judging the interface status information of all interfaces, it obtains the shutdown list of interfaces with a completely closed status from the hibernation gateway and clears the interfaces and interface status according to the preset clearing order.
[0053] Specifically, determining whether the interface status information of all interfaces in the interface list needs to be updated includes: when the interface status information is completely closed, closing the interface and saving the interface and its status information in the closed list; when the interface status information is open, determining the duration for which the interface remains open, and closing the interface and its status information if the duration exceeds a fourth preset threshold; and when the interface status information is open, determining the duration for which the interface remains open, and closing the interface and its status information if the duration exceeds a fifth preset threshold.
[0054] In one exemplary embodiment, determining the target device after it comes online on the hibernation gateway based on the device information includes: updating the status information of the target device in the hibernation gateway to an online state; determining a first state duration of the target device, and updating the status information of the target device to an offline state if the first state duration exceeds a first preset duration, wherein the first state duration is used to indicate the duration between the last time the hibernation gateway received heartbeat data sent by the target device and the current time; determining a second state duration of the offline state of the target device, and deleting the device information of the target device in the hibernation gateway if the second state duration exceeds a second preset duration.
[0055] In other words, when the target device comes online in the hibernation gateway, the device status information of the target device in the hibernation gateway is updated to online. During the process of the target device coming online in the hibernation gateway, the target device will send heartbeat data to the hibernation gateway at preset time intervals to enable the hibernation gateway to determine whether the target device is still online. When the hibernation gateway receives the heartbeat data sent by the target device, it updates the timestamp corresponding to the target device cached in the hibernation gateway, where the timestamp is used to indicate the time when the hibernation gateway received the heartbeat data. If the time between the last time the hibernation gateway received the heartbeat data sent by the target device and the current time exceeds a first preset time, the status information of the target device is updated to offline. If the offline status of the target device exceeds a second preset time, it is determined that the target device is offline or online in the hibernation gateway, and the device information of the target device in the hibernation gateway is deleted.
[0056] In an exemplary embodiment, before updating the status information of the target device to an offline state, the method further includes: obtaining a device information list in the hibernation gateway, wherein the device information list includes at least: the identification information of the target device; obtaining the status duration of the status information of any device in the device information list; determining whether to update the status information of each device based on the relationship between the status duration of the status information of each device and a preset duration, until it is determined whether to update the status information of all devices in the device information list.
[0057] It should be noted that for a hibernation gateway, it is necessary to determine the device status information of all devices that are online in the hibernation gateway in order to update the device status information of all devices.
[0058] In one exemplary embodiment, after determining whether to update the status information of all devices in the device information list, an offline device list in the hibernation gateway is obtained, wherein the offline device list is used to indicate devices whose status information is offline; an offline device identifier in the offline device list is determined; and offline information carrying the offline device identifier is sent to the server so that the server determines that the target device is offline on the hibernation gateway.
[0059] In other words, the hibernation gateway can synchronize information about the target device with the server, including its online and offline status. Furthermore, the hibernation gateway can synchronize information about all devices with the server. Specifically, when a device is offline, it sends the offline device identifier to the server; when a device is online, it sends the online device identifier to the server.
[0060] To better understand the process of updating the interface state described above, the implementation flow of updating the interface state will be further explained below with reference to optional embodiments, but this is not intended to limit the technical solution of the embodiments of the present invention.
[0061] Low-power devices (such as door locks) are typically battery powered. To reduce the power consumption of low-power devices, some support a sleep mode. Figure 3 This is a schematic diagram illustrating the interaction between a low-power device and a gateway according to an embodiment of the present invention, such as... Figure 3 As shown:
[0062] Low-power devices (such as door locks) (equivalent to the target devices in the above embodiments): The main control chip consumes a lot of power. In order to save power, the door lock will automatically power off after a period of non-use. It can be woken up by the low-power function. (The low-power device and the WIFI module are powered independently, that is, the low-power function can still operate even when the low-power device is powered off. Although the low-power device is powered off, it can still receive a wake-up command (an electrical signal) to be powered on again, similar to pressing the keyboard to wake up a computer after it has gone into hibernation).
[0063] SDK: Low-power device access SDK, developed by the terminal team;
[0064] WIFI Function Module: In low-power devices, it is equivalent to a network card and can receive and transmit data transparently (so the arrow passes directly through the [WIFI Function Module]).
[0065] Low-power module: It is a simple data pass-through microcontroller that can pass through data but cannot add processing logic, that is, it parses data according to the protocol;
[0066] Normal mode: Low-power functions of low-power devices are not working, but Wi-Fi functionality is working (low-power devices can receive remote control commands via the Wi-Fi module);
[0067] Sleep mode: Only low-power functions are working, and the WIFI function is not working (although the WIFI module is not powered off, it will not send or receive any data through the WIFI function because the low-power device is powered off).
[0068] Hibernation Gateway: A gateway that only handles hibernation and wake-up functions;
[0069] Control commands: Commands sent to the WIFI function to control changes in the attributes of low-power devices, such as powering on and off;
[0070] Wake-up command: A command sent to a low-power function to make the low-power device switch from sleep mode to normal mode.
[0071] This invention provides a method for switching the operating mode of a low-power device. Figure 4 This is a diagram showing the operating mode transitions of a low-power device according to an embodiment of the present invention, such as... Figure 4 As shown:
[0072] When a low-power device is started, it enters non-sleep mode (i.e., normal mode). When a low-power device has not been used for a long time, it enters sleep mode. At this time, the low-power device connects to the sleep gateway. When the low-power device receives a wake-up command through the sleep gateway, it is woken up so that the low-power device enters non-sleep mode.
[0073] This embodiment provides a method for updating the state of an interface. Figure 5 This is a schematic diagram (a) of an interface state update method according to an embodiment of the present invention, as shown below. Figure 5 As shown, the specific steps are as follows:
[0074] Step S301: Begin;
[0075] Step S302: The hibernation gateway parses the raw data sent by the low-power device as the first heartbeat data;
[0076] Step S303: Determine whether there is heartbeat data in the hibernation gateway that is the same as the first heartbeat data. If there is no heartbeat data in the hibernation gateway that is the same as the first heartbeat data, proceed to steps S304-S308. If there is no heartbeat data in the hibernation gateway that is the same as the first heartbeat data, proceed to steps S309-S313.
[0077] Step S304: Create and save the device information corresponding to the low-power device;
[0078] Step S305: The low-power device goes online on the M2M (equivalent to the hibernation gateway in the above embodiment);
[0079] Step S306: Determine whether the low-power device has successfully gone online on M2M; if the low-power device has successfully gone online on M2M, proceed to step S307; if the low-power device has not successfully gone online on M2M, proceed to step S308.
[0080] Step S307: Update the launch timestamp;
[0081] Step S308: Close the socket corresponding to the low-power device (equivalent to the target interface in the above embodiment);
[0082] Step S309: Update the socket corresponding to the low-power device;
[0083] Step S310: Update the device information cached in the hibernation gateway;
[0084] Step S311: Determine whether device information needs to be cached in the server core; if device information needs to be cached in the server core, proceed to steps S312-S313; if device information does not need to be cached in the server core, proceed to step S314.
[0085] Step S312: Construct a synchronization task;
[0086] Step S313: Execute the synchronization task;
[0087] Step S314: End.
[0088] This embodiment provides a method for operating a custom decoder on a hibernation gateway, such as... Figure 6 As shown, Figure 6 This is a schematic diagram (II) of an interface state update method according to an embodiment of the present invention, specifically comprising the following steps:
[0089] Step S401: Receive the raw byte array (equivalent to the raw data in the above embodiment) sent by the low-power device;
[0090] Step S402: Cache the original byte array into the cache area;
[0091] Step S403: Decode the original data to obtain buffered data;
[0092] Step S404: Determine whether the length of the buffered data is greater than a preset threshold. If the length of the buffered data is greater than the preset threshold, proceed to step S405; otherwise, repeat steps S402-S404.
[0093] It should be noted that step S404 is to determine whether the complete raw data has been received;
[0094] Step S405: Parse the buffered data to obtain hibernation packet data, and determine whether the data length of the hibernation packet data is within a preset range. If the data length of the hibernation packet data is within the preset range, proceed to step S406; otherwise, proceed to step S407.
[0095] Step S406: The original Netty normal packet data processing flow;
[0096] Step S407: Clear the data in the buffer;
[0097] Step S408: Close the socket corresponding to the low-power device.
[0098] This embodiment provides a method for reversing the interface state of a hibernating gateway socket, such as... Figure 7 As shown, Figure 7 This is a schematic diagram (III) of an interface state update method according to an embodiment of the present invention, as detailed below:
[0099] 1) When a low-power device comes online on the hibernation gateway, the channel is activated, and the Socket interface status is "connected".
[0100] 2) When a low-power device sends service data to a low-power gateway for the first time, the interface state of the Socket is updated from the connected state to the receiving state.
[0101] 3) When the server sends request data to the low-power device through the low-power gateway, the interface state of the Socket is updated from the connected state to the temporarily closed locked state.
[0102] 4) When the server sends completion request data to the low-power device through the low-power gateway, the interface state of the Socket is updated from the temporarily closed locked state to the open receiving state.
[0103] 5) When the server sends the completion request data to the low-power device again through the low-power gateway, the interface state of the Socket is updated from the receiving state to the temporarily closed locked state.
[0104] 6) When the hibernation gateway has a scheduled interface cleanup task enabled, determine whether the interface status is in the receiving state and / or the connected state has timed out. If it has timed out, update the Socket interface status from the receiving state and / or the connected state to the closed state.
[0105] 7) In the event of an error in the business processing of the hibernation gateway, call the close method to update the interface status of the Socket to the closed state.
[0106] This embodiment provides a method for reversing device state information in a low-power device, such as... Figure 8 As shown, Figure 8 This is a schematic diagram (four) of an interface state update method according to an embodiment of the present invention, as detailed below:
[0107] 1) When a low-power device comes online in the hibernation gateway, update the device status information of the low-power device in the hibernation gateway to the online status.
[0108] 2) During the process of the target gateway coming online in the hibernation gateway, the low-power device will send heartbeat data to the hibernation gateway at preset time intervals so that the hibernation gateway can determine whether the low-power device is still online. When the hibernation gateway receives the heartbeat data sent by the low-power device, it updates the timestamp corresponding to the low-power device cached in the hibernation gateway. The timestamp is used to indicate the time when the hibernation gateway received the heartbeat data. If the time between the last time the hibernation gateway received the heartbeat data sent by the low-power device and the current time exceeds a first preset time, the status information of the low-power device is updated to offline.
[0109] 3) If the offline state of the low-power device exceeds the second preset time, determine whether the low-power device is online or offline in the hibernation gateway, and delete the device information of the low-power device in the hibernation gateway;
[0110] 4) If the offline information of the low-power device is successfully sent to the server core, delete the device information of the low-power device in the hibernation gateway.
[0111] This embodiment provides a method for clearing device information of timed-out devices, such as... Figure 9 As shown, Figure 9 This is a schematic diagram (V) of the interface state update method according to an embodiment of the present invention. The specific steps are as follows:
[0112] Step S901: Start the scheduled cleanup task for device information;
[0113] Step S902: Obtain the cache device information table;
[0114] Step S903: Determine if there is a next one in the cache device information table. If there is, proceed to steps S904-S912. If not, proceed to steps S913-S915.
[0115] Step S904: Determine whether the device status information is new. If the device status information is new, execute steps S905-S906. If the device status is not new, execute steps S907-S912.
[0116] Step S905: Determine whether the duration of the low-power device in the new state exceeds the first duration. If the duration of the low-power device in the new state exceeds the first duration, proceed to step S906. If the duration of the low-power device in the new state does not exceed the first duration, proceed to step S903.
[0117] Step S906: Remove device information and proceed to step S903;
[0118] Step S907: Determine whether the device status information is online. If the device status information is online, proceed to steps S908-S909. If the device status is not new, proceed to steps S910-S912.
[0119] Step S908: Determine whether the duration of the low-power device being in the online state exceeds the second duration. If the duration of the low-power device being in the online state exceeds the second duration, proceed to step S909. If the duration of the low-power device being in the online state does not exceed the second duration, proceed to step S903.
[0120] Step S909: Save device information to the offline device list, then proceed to step S903;
[0121] Step S910: Determine whether the device status information is offline. If the device status information is offline, execute steps S911-S912. If the device status is not offline, execute step S903.
[0122] Step S911: Determine whether the duration of the low-power device being in the offline state exceeds the third duration. If the duration of the low-power device being in the offline state exceeds the third duration, proceed to step S909. If the duration of the low-power device being in the offline state does not exceed the third duration, proceed to step S903.
[0123] Step S912: Remove device information and proceed to step S903;
[0124] Step S913: Iterate through the device information in the offline device list;
[0125] Step S914: Determine if there is a next device in the offline device list. If not, end the execution; if there is, proceed to step S915.
[0126] Step S915: Send offline information to the core.
[0127] This embodiment provides a method for cleaning up timeout sockets, such as... Figure 10 As shown, Figure 10 This is a schematic diagram (six) of an interface state update method according to an embodiment of the present invention. The specific steps are as follows:
[0128] Step S1001: Start the timed cleanup task for timed-out sockets;
[0129] Step S1002: Obtain all socket information;
[0130] Step S1003: Determine if there is a next socket in all socket information. If there is, execute steps S1004-S1011. If not, execute steps S1012-S1014.
[0131] Step S1004: Determine whether the interface status information is closed. If the interface status information is closed, execute steps S1005-S1006. If the device status is not closed, execute steps S1007-S1011.
[0132] Step S1005: Determine whether the duration of the socket in the closed state exceeds the fourth duration. If the duration of the socket in the closed state exceeds the fourth duration, execute steps S1006-1007. If the duration of the socket in the closed state does not exceed the fourth duration, execute step S1003.
[0133] Step S1006: Close the socket;
[0134] Step S1007: Save the socket to the offline interface list list, and then execute step S1003;
[0135] Step S1008: Determine whether the interface status information is in the connected state. If the interface status information is in the connected state, proceed to step S1009. If the device status is not in the connected state, proceed to steps S1010-S1011.
[0136] Step S1009: Determine whether the duration of the socket in the connected state exceeds the fifth duration. If the duration of the socket in the connected state exceeds the fifth duration, proceed to step S1007. If the duration of the socket in the connected state does not exceed the fifth duration, proceed to step S1003.
[0137] Step S1010: Determine whether the interface status information is in the receiving state. If the interface status information is in the receiving state, proceed to step S1011. If the device status is not in the receiving state, proceed to step S1003.
[0138] Step S1011: Determine whether the duration of the socket in the receiving state exceeds the sixth duration. If the duration of the socket in the offline state exceeds the sixth duration, proceed to step S1007. If the duration of the socket in the offline state does not exceed the sixth duration, proceed to step S1003.
[0139] Step S1012: Traverse the interface information in the offline interface list;
[0140] Step S1013: Determine if there is a next one in the offline interface list. If not, end the execution; if there is, proceed to step S1014.
[0141] Step S1014: Record the cleaned-up socket information in the log, and then proceed to step S1012.
[0142] Through the above embodiments, it is determined whether there is second heartbeat data in the hibernation gateway that is consistent with the first heartbeat data. The first heartbeat data is data sent by the target device and includes device information of the target device. If there is no second heartbeat data consistent with the first heartbeat data in the hibernation gateway, the device information of the target device is saved to the hibernation gateway. If it is determined that the target device is online in the hibernation gateway based on the device information, the interface status corresponding to the target device in the hibernation gateway is updated to a connected state. This solves the problem in related technologies where the cloud currently does not support the maintenance of this low-power mode. In this embodiment of the invention, by obtaining the heartbeat data sent by the target device, the interface status corresponding to the target device in the hibernation gateway is maintained, thereby maintaining the interface status of the target device when it is in low-power mode.
[0143] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods of the various embodiments of the present invention.
[0144] This embodiment also provides an interface state updating device, which is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, hardware implementations, or a combination of software and hardware, are also possible and contemplated.
[0145] Figure 11 This is a structural block diagram of an interface state update device according to an embodiment of the present invention; as shown below. Figure 11 As shown, it includes:
[0146] The determining module 1102 is used to determine whether there is second heartbeat data in the hibernation gateway that is consistent with the first heartbeat data, wherein the first heartbeat data is data sent by the target device and includes: device information of the target device;
[0147] The storage module 1104 is used to save the device information of the target device to the hibernation gateway when there is no second heartbeat data that matches the first heartbeat data in the hibernation gateway;
[0148] The update module 1106 is used to update the interface status of the target device in the hibernation gateway to a connected status when it is determined from the device information that the target device is online in the hibernation gateway.
[0149] The aforementioned device determines whether a second heartbeat data matching the first heartbeat data exists in the hibernation gateway. The first heartbeat data is data sent by the target device and includes the target device's device information. If no second heartbeat data matching the first heartbeat data exists in the hibernation gateway, the target device's device information is saved to the hibernation gateway. If the target device is determined to be online on the hibernation gateway based on the device information, the interface status corresponding to the target device in the hibernation gateway is updated to a connected state. This solves the problem in related technologies where the cloud currently does not support the maintenance of this low-power mode.
[0150] In an exemplary embodiment, the determining module 1102 is further configured to cache the original data received by the hibernation gateway to obtain buffered data, and determine whether the data length of the buffered data is greater than a preset threshold; if the data length of the buffered data is greater than the preset threshold, parse the buffered data to obtain hibernation packet data; if the data length of the hibernation packet data is determined to be within a preset range, determine the buffered data as first heartbeat data.
[0151] In one exemplary embodiment, the update module 1106 is further configured to: update the interface state corresponding to the target device from the connected state to the open state when the target device sends service data to the hibernation gateway for the first time; update the interface state corresponding to the target device from the connected state to the temporarily closed state when the server corresponding to the target device sends request data to the target device through the hibernation gateway.
[0152] In an exemplary embodiment, the update module 1106 is further configured to obtain a shutdown list of interfaces with a completely closed state from the hibernation gateway, wherein the shutdown list stores a correspondence between interfaces and interface states; determine a first clearing order of interfaces in the shutdown list and a second clearing order of interface states; clear the interfaces in the shutdown list in the first clearing order and clear the interface states in the shutdown list in the second clearing order, wherein the first clearing order and the second clearing order are the same or different.
[0153] In an exemplary embodiment, the update module 1106 is further configured to update the status information of the target device in the hibernation gateway to an online state; determine a first state duration of the target device, and if the first state duration exceeds a first preset duration, update the status information of the target device to an offline state, wherein the first state duration is used to indicate the duration between the last time the hibernation gateway received heartbeat data sent by the target device and the current time; determine a second state duration of the offline state of the target device, and if the second state duration exceeds a second preset duration, delete the device information of the target device in the hibernation gateway.
[0154] In an exemplary embodiment, the update module 1106 is further configured to obtain a device information list in the hibernation gateway, wherein the device information list includes at least: identification information of the target device; obtain the status duration of the status information of each device in the device information list; determine whether to update the status information of any device based on the relationship between the status duration of the status information of each device and a preset duration, until it is determined whether to update the status information of all devices in the device information list.
[0155] In one exemplary embodiment, the above apparatus further includes: a sending module, configured to obtain an offline device list in the hibernation gateway, wherein the offline device list is used to indicate devices whose status information is offline; determine an offline device identifier in the offline device list; and send offline information carrying the offline device identifier to a server, so that the server determines that the target device is offline on the hibernation gateway.
[0156] Embodiments of the present invention also provide a storage medium comprising a stored program, wherein the program, when executed, performs any of the methods described above.
[0157] Optionally, in this embodiment, the storage medium may be configured to store program code for performing the following steps:
[0158] S1, determine whether there is second heartbeat data in the hibernation gateway that is consistent with the first heartbeat data, wherein the first heartbeat data is data sent by the target device, and the first heartbeat data includes: device information of the target device;
[0159] S2, if there is no second heartbeat data in the hibernation gateway that matches the first heartbeat data, the device information of the target device is saved to the hibernation gateway;
[0160] S3, if it is determined from the device information that the target device is online in the hibernation gateway, update the interface status of the target device in the hibernation gateway to the connected status.
[0161] Embodiments of the present invention also provide an electronic device including a memory and a processor, the memory storing a computer program and the processor being configured to run the computer program to perform the steps in any of the above method embodiments.
[0162] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0163] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0164] S1, determine whether there is second heartbeat data in the hibernation gateway that is consistent with the first heartbeat data, wherein the first heartbeat data is data sent by the target device, and the first heartbeat data includes: device information of the target device;
[0165] S2, if there is no second heartbeat data in the hibernation gateway that matches the first heartbeat data, the device information of the target device is saved to the hibernation gateway;
[0166] S3, if it is determined from the device information that the target device is online in the hibernation gateway, update the interface status of the target device in the hibernation gateway to the connected status.
[0167] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0168] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated here.
[0169] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0170] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for updating interface state, characterized in that, include: Determine whether there is second heartbeat data in the hibernation gateway that is consistent with the first heartbeat data, wherein the first heartbeat data is data sent by the target device and includes: device information of the target device; If no second heartbeat data matching the first heartbeat data exists in the hibernation gateway, the device information of the target device is saved to the hibernation gateway; If the target device is determined to be online on the hibernation gateway based on the device information, the interface status corresponding to the target device in the hibernation gateway is updated to a connected status; Specifically, after updating the interface status of the target device in the hibernation gateway to a connected state, the interface status is converted according to the following four conversion rules: When the target device sends service data to the hibernation gateway for the first time, the interface status corresponding to the target device is updated from the connected state to the open state; When the server corresponding to the target device sends request data to the target device through the hibernation gateway, the interface status corresponding to the target device is updated from the connected state to the temporarily closed state. When the server corresponding to the target device sends the request completion data to the target device through the hibernation gateway, the interface status of the target device is updated from the temporarily closed state to the open state. If the hibernation gateway determines that the connection status or open status of the interface has been maintained for more than a second preset duration, the interface status of the target device will be updated to a completely closed status.
2. The method for updating the interface state according to claim 1, characterized in that, Before determining whether there is second heartbeat data in the hibernation gateway that matches the first heartbeat data, the method further includes: The original data received by the hibernation gateway is cached to obtain buffered data, and it is determined whether the data length of the buffered data is greater than a preset threshold. If the length of the buffered data exceeds a preset threshold, the buffered data is parsed to obtain the hibernation packet data; If the length of the hibernation packet data is determined to be within a preset range, the buffered data is determined to be the first heartbeat data.
3. The method for updating the interface state according to claim 1, characterized in that, After updating the interface status of the target device in the hibernation gateway to a connected status, the method further includes: Obtain a list of interfaces that are completely shut down from the hibernation gateway, wherein the list of shut-down interfaces stores the correspondence between interfaces and interface states; Determine the first clearing order and the second clearing order of the interface status in the closed list; The interfaces in the shutdown list are cleared sequentially according to the first clearing order, and the interface statuses in the shutdown list are cleared sequentially according to the second clearing order, wherein the first clearing order and the second clearing order may be the same or different.
4. The method for updating the interface state according to claim 1, characterized in that, Determining the target device after it comes online on the hibernation gateway based on the device information includes: Update the status information of the target device in the hibernation gateway to online status; The first state duration of the target device is determined. If the first state duration exceeds a first preset duration, the state information of the target device is updated to offline state. The first state duration is used to indicate the duration between the last time the hibernation gateway received heartbeat data sent by the target device and the current time. The second state duration of the offline state of the target device is determined. If the second state duration exceeds a second preset duration, the device information of the target device in the hibernation gateway is deleted.
5. The method for updating the interface state according to claim 4, characterized in that, Before updating the status information of the target device to offline status, the method further includes: Obtain the device information list in the hibernation gateway, wherein the device information list includes at least: the identification information of the target device; Obtain the status duration of each device in the device information list; Based on the relationship between the status duration of each device's status information and a preset duration, it is determined whether to update the status information, until it is determined whether to update the status information of all devices in the device information list.
6. The method for updating the interface state according to claim 5, characterized in that, After determining whether to update the status information of all devices in the device information list, the method further includes: Obtain the list of offline devices in the hibernation gateway, wherein the list of offline devices is used to indicate devices whose status information is offline; Determine the offline device identifier in the offline device list; Send offline information carrying the offline device identifier to the server so that the server determines that the target device is offline on the hibernation gateway.
7. An interface state update device, characterized in that, include: The determination module is used to determine whether there is second heartbeat data in the hibernation gateway that is consistent with the first heartbeat data, wherein the first heartbeat data is data sent by the target device and includes: device information of the target device; The storage module is used to save the device information of the target device to the hibernation gateway when there is no second heartbeat data that matches the first heartbeat data in the hibernation gateway; The update module is used to update the interface status of the target device in the hibernation gateway to a connected status when it is determined from the device information that the target device is online in the hibernation gateway. The update module is further configured to update the interface status of the target device from the connection status to the open status when the target device sends service data to the hibernation gateway for the first time. When the server corresponding to the target device sends request data to the target device through the hibernation gateway, the interface status corresponding to the target device is updated from the connected state to the temporarily closed state. When the server corresponding to the target device sends the request completion data to the target device through the hibernation gateway, the interface status of the target device is updated from the temporarily closed state to the open state. If the hibernation gateway determines that the connection status or open status of the interface has been maintained for more than a second preset duration, the interface status of the target device will be updated to a completely closed status.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program, when executed, performs the method described in any one of claims 1 to 6.
9. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 6 through the computer program.
Citation Information
Patent Citations
Smart hotel management system
CN111127255A
Information processing method and device, storage medium and electronic device
CN112751907A