Equipment data synchronization method and device, equipment and storage medium
By receiving the device data of the smart device in the cloud server and storing it corresponding to the unique identifier, determining the hardware replacement event and synchronizing the previous data, the historical data loss problem caused by the change of the smart device MAC address is solved, and the data continuity and integrity are achieved.
Patent Information
- Application Number
- CN202411752413.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2044-12-02
AI Technical Summary
Changes in the MAC address of the smart device lead to the loss of historical device data, affecting the continuity and integrity of the data.
By receiving device data reported by smart devices at preset time periods in the cloud server and storing it corresponding to the unique identifier, it is determined whether a hardware replacement event has occurred. If a hardware replacement event occurs, synchronize the device data reported by the smart device before the hardware replacement.
It avoids historical data loss caused by MAC address changes after smart devices are replaced, and maintains data continuity and integrity.
Smart Images

Figure CN119583572A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of Internet of Things, and in particular to a method, apparatus, device and storage medium for synchronizing device data. Background Art
[0002] With the development of Internet of Things technology, users can use user terminals to remotely control and view the status of smart devices. In order to achieve this function, smart devices need to continuously report device data to the cloud server. Users can query the device data of smart devices from the cloud server, accurately grasp the current device status of smart devices, and remotely control the smart air conditioner through the cloud server according to the current device status of the smart air conditioner. Furthermore, since the Media Access Control Address (MAC) of the smart device is unique, in order to identify different smart devices, the cloud server uses the MAC address of the smart device as the only data to identify the smart device. After receiving the data reported by the smart device, the data reported by the smart device is stored in correspondence with the MAC address of the smart device, so that the data related to the smart device can be queried according to the MAC address later.
[0003] Although the MAC address is the hardware address of the communication module of the smart device, when the hardware of the smart device needs to be replaced, in most cases, the communication module needs to be replaced together, which will change the MAC address of the smart device. After the MAC address of the smart device is changed, after the cloud server receives the device data reported by the smart device again, the historical device data of the smart device cannot be queried using the changed MAC address, which leads to the loss of the historical device data of the smart device. This not only brings instability to the user, but also causes problems with the continuity and integrity of the device data of the smart device, weakening the experience and practicality of the smart device. Summary of the invention
[0004] The present application provides a method, apparatus, device and storage medium for synchronizing device data to solve the problem of loss of historical device data of a smart device due to a change in the MAC address of the smart device.
[0005] In view of the above technical problems, the technical solution of this application is solved by the following embodiments:
[0006] An embodiment of the present application provides a method for synchronizing device data, which is executed on a cloud server and includes: receiving device data reported by a smart device at preset time intervals; in the process of receiving the device data reported by the smart device, storing the received device data in correspondence with a unique identifier of the smart device, and determining whether a hardware replacement event has occurred in the smart device; when it is determined that a hardware replacement event has occurred in the smart device and a data synchronization request sent by the smart device is received, synchronizing the device data reported by the smart device before the hardware replacement event occurs to the smart device.
[0007] Among them, determining whether a hardware replacement event has occurred in the smart device includes: after the long connection between the smart device is disconnected, waiting to receive a long connection request sent by the smart device; after receiving the long connection request sent by the smart device, communicating with the user terminal bound to the smart device to perform device identity authentication on the smart device; in the process of performing device identity authentication on the smart device, obtaining the unique identifier and media access control address of the smart device reported by the user terminal; querying the media access control address corresponding to the unique identifier in the storage space; when the media access control address corresponding to the unique identifier is different from the media access control address of the smart device, determining that a hardware replacement event has occurred in the smart device.
[0008] Among them, determining whether a hardware replacement event has occurred in the smart device includes: querying the device data last reported by the smart device in the storage space; using the device data last reported by the smart device to detect whether the device data reported by the smart device this time has a data anomaly of a preset type; if it is determined that the device data reported by the smart device this time has a data anomaly of a preset type, determining that a hardware replacement event has occurred in the smart device.
[0009] Wherein, after determining that a hardware replacement event has occurred in the smart device, the method further includes: sending a data synchronization notification message to the smart device so that the smart device sends the data synchronization request to the cloud server according to the data synchronization notification message.
[0010] Among them, synchronizing the device data reported by the smart device before the hardware replacement event occurs to the smart device includes: querying the device data reported by the smart device before the hardware replacement event occurs in the storage space; mapping the device data reported by the smart device before the hardware replacement event occurs to the device data reported by the smart device after the hardware replacement event occurs; synchronizing the device data reported by the smart device before the hardware replacement event occurs to the smart device.
[0011] An embodiment of the present application also provides a method for synchronizing device data, which is executed on a smart device and includes: reporting device data to a cloud server once every preset time period; detecting a hardware replacement event during the process of reporting device data to the cloud server; after detecting the hardware replacement event, sending a data synchronization request to the cloud server and receiving device data that was reported to the cloud server before the hardware replacement event occurred and that was synchronized by the cloud server; and updating current device data based on the device data reported to the cloud server before the hardware replacement event occurred.
[0012] The detecting of the hardware replacement event includes: detecting whether a data synchronization notification message sent by the cloud server is received; and determining that the hardware replacement event occurs when the data synchronization notification message sent by the cloud server is received.
[0013] The embodiment of the present application also provides a device data synchronization device, comprising: the device data synchronization device set on the cloud server, comprising: a receiving module, used to receive device data reported by the smart device at preset time intervals; a storage and determination module, used to store the received device data in correspondence with the unique identifier of the smart device during the process of receiving the device data reported by the smart device, and determine whether a hardware replacement event occurs in the smart device; a synchronization module, used to synchronize the device data reported by the smart device before the hardware replacement event occurs to the smart device when it is determined that a hardware replacement event occurs in the smart device and a data synchronization request sent by the smart device is received; the device data synchronization device set on the smart device, comprising: a reporting module, used to report device data to the cloud server once every preset time interval; a detection module, used to detect a hardware replacement event during the process of reporting device data to the cloud server; a transceiver module, used to send a data synchronization request to the cloud server after detecting the hardware replacement event and receive the device data reported to the cloud server before the hardware replacement event occurs and synchronized by the cloud server; an update module, used to update the current device data according to the device data reported to the cloud server before the hardware replacement event occurs.
[0014] An embodiment of the present application also provides a device data synchronization device, comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; and at least one memory connected to the at least one bus, wherein the processor is configured to: execute a device data synchronization program stored in the memory to implement any of the above-mentioned device data synchronization methods executed on the cloud server, or to implement any of the above-mentioned device data synchronization methods executed on a smart device.
[0015] An embodiment of the present application also provides a computer-readable storage medium, which stores computer-executable instructions, and the computer-executable instructions are executed to implement any of the above-mentioned device data synchronization methods executed on the cloud server, or to implement any of the above-mentioned device data synchronization methods executed on the smart device.
[0016] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: In the method provided by the embodiment of the present application, the cloud server can receive the device data reported by the smart device at preset time intervals; in the process of receiving the device data reported by the smart device, the received device data is stored in correspondence with the unique identifier of the smart device, and it is determined whether a hardware replacement event has occurred in the smart device; when it is determined that a hardware replacement event has occurred in the smart device, and a data synchronization request sent by the smart device is received, the device data reported by the smart device before the hardware replacement event occurs is synchronized to the smart device. The embodiment of the present application makes the device data reported by the smart device correspond to the unique identifier of the smart device. Since the unique identifier will not change, it can avoid the problem that the MAC address of the smart device changes after the smart device replaces the hardware, and the historical device data of the smart device cannot be queried, resulting in the loss of historical device data, thereby maintaining the continuity and integrity of the data on the cloud server side. After determining that a hardware replacement event has occurred on a smart device and receiving a data synchronization request from the smart device, the embodiment of the present application synchronizes the device data reported before the hardware replacement event to the smart device so that the smart device updates the current device data. This avoids the problem of the smart device being unable to restore data due to the loss of historical device data after the hardware is replaced, thereby maintaining the continuity and integrity of the data on the smart device side. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0018] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0019] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0020] Figure 1 is a flow chart of a method for synchronizing device data executed on a cloud server according to an embodiment of the present application;
[0021] Figure 2 is a flow chart of a method for synchronizing device data executed on a smart device according to an embodiment of the present application;
[0022] Figure 3 A flowchart of the steps of device identity authentication according to an embodiment of the present application;
[0023] Figure 4 A flowchart of the steps for determining a hardware replacement event executed on a cloud server according to an embodiment of the present application;
[0024] Figure 5 A flowchart of the steps for determining a hardware replacement event executed on a cloud server according to another embodiment of the present application;
[0025] Figure 6 A flowchart of the steps of synchronizing device data from a cloud server to a smart device according to an embodiment of the present application;
[0026] Figure 7 A structural diagram of a device data synchronization apparatus provided in a cloud server according to an embodiment of the present application;
[0027] Figure 8 It is a structural diagram of a device data synchronization apparatus set in a smart device according to an embodiment of the present application;
[0028] Fig. 9 4 is a structural diagram of a device data synchronization device according to an embodiment of the present application. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0030] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0031] The present application embodiment provides a method for synchronizing device data executed on a cloud server. Figure 1 , which is a flowchart of a method for synchronizing device data executed on a cloud server according to an embodiment of the present application.
[0032] Step S110, receiving device data reported by the smart device at every preset time period.
[0033] Types of smart devices include but are not limited to: air conditioners, televisions, and washing machines.
[0034] Device data refers to data that needs to be stored in the cloud server.
[0035] Types of device data include, but are not limited to: statistical data of smart devices, and operating parameter data of smart devices. Statistical data, for example, are power statistics of smart devices within a preset statistical time period. Power statistics are used to reflect the energy consumption of smart devices. For example: the cumulative power used by smart devices in a month. Current operating parameters are used to reflect the operating status of smart devices. Current operating parameters are, for example, temperature, humidity, cooling, heating, etc.
[0036] In an embodiment of the present application, after the smart device and the cloud server establish a persistent connection, based on the persistent connection, the smart device can report device data once every preset time period.
[0037] Step S120, in the process of receiving the device data reported by the smart device, the received device data is stored correspondingly to the unique identifier of the smart device, and it is determined whether a hardware replacement event occurs in the smart device.
[0038] The unique identifier is an unchangeable unique identifier of a smart device. Furthermore, the types of unique identifiers include: a serial number of a smart device, and a user code of a smart device.
[0039] Hardware replacement events refer to hardware replacement of smart devices. Hardware replacement includes: replacement of communication modules, replacement of main control modules, replacement of display panels, etc.
[0040] When it is determined that no hardware replacement event occurs in the smart device, the cloud server normally receives the device data reported by the smart device and stores the received device data in correspondence with the unique identifier of the smart device.
[0041] Step S130: when it is determined that a hardware replacement event has occurred in the smart device and a data synchronization request sent by the smart device is received, the device data reported by the smart device before the hardware replacement event occurs is synchronized to the smart device.
[0042] The data synchronization request is used to request synchronization of device data reported by the smart device before the hardware replacement event occurs to the smart device.
[0043] In an embodiment of the present application, after determining that a hardware replacement event has occurred on a smart device, for the sake of data security, the device data reported by the smart device before the hardware replacement event occurs will not be synchronized to the smart device for the time being; after receiving a data synchronization request sent by the smart device, the device data reported by the smart device before the hardware replacement event occurs will be synchronized to the smart device so that the smart device can update the data.
[0044] In an embodiment of the present application, the cloud server can receive device data reported by the smart device every preset time period; in the process of receiving the device data reported by the smart device, the received device data is stored in correspondence with the unique identifier of the smart device, and it is determined whether a hardware replacement event occurs in the smart device; when it is determined that a hardware replacement event occurs in the smart device, and a data synchronization request sent by the smart device is received, the device data reported by the smart device before the hardware replacement event occurs is synchronized to the smart device. In the embodiment of the present application, the device data reported by the smart device corresponds to the unique identifier of the smart device. Since the unique identifier will not change, it can avoid the problem that the MAC address of the smart device changes after the smart device replaces the hardware, and the historical device data of the smart device cannot be queried, resulting in the loss of historical device data, thereby maintaining the continuity and integrity of the data on the cloud server side. In the embodiment of the present application, after determining that a hardware replacement event occurs on the smart device and receiving a data synchronization request sent by the smart device, the device data reported before the hardware replacement event is synchronized to the smart device, so that the smart device updates the current device data, thereby avoiding the problem that the smart device cannot restore the data due to the loss of historical device data after the smart device replaces the hardware, thereby maintaining the continuity and integrity of the data on the smart device side.
[0045] Based on the above-mentioned method for synchronizing device data executed on the cloud server, an embodiment of the present application also provides a method for synchronizing device data executed on a smart device. Figure 2 The present invention is a flowchart of a method for synchronizing device data executed on a smart device according to an embodiment of the present application.
[0046] Step S210: Report device data to the cloud server once every preset time period.
[0047] Types of equipment data include, but are not limited to, operating parameters and statistical data.
[0048] After establishing a persistent connection with the cloud server, the smart device reports device data to the cloud server once every preset time period based on the persistent connection.
[0049] Furthermore, the smart device has a built-in smart module, which is used to collect device data and report the device data to the cloud server through a preset encrypted communication protocol.
[0050] Step S220: Detect a hardware replacement event during the process of reporting device data to the cloud server.
[0051] Detecting the hardware replacement event includes: setting a button for triggering the generation of the hardware replacement event in the smart device, and after the button is triggered, the hardware replacement event is generated, and then the hardware replacement event can be detected. Of course, the way of detecting the hardware replacement event is not limited to this.
[0052] Step S230: after detecting the hardware replacement event, sending a data synchronization request to the cloud server and receiving the device data synchronized by the cloud server and reported to the cloud server before the hardware replacement event occurs.
[0053] Step S240: updating current device data according to the device data reported to the cloud server before the hardware replacement event occurs.
[0054] After the smart device replaces its hardware, the current device data of the smart device may be abnormal. The device data reported to the cloud server before the hardware replacement event can be used to update the current device data to ensure continuity and integrity between the current device data and the previous device data.
[0055] For example, when the smart device is an air conditioner, the temperature is set at 30°C before the main control module is replaced. After the main control module is replaced, the main control module sets the temperature to the initial temperature of 0°C. In this way, the temperature difference before and after the hardware replacement is large, and the user needs to adjust it by himself, which results in a poor user experience. To address this problem, the temperature before the main control module is replaced is used to update the temperature set after the main control module is replaced, that is, the initial temperature of 0°C is updated to 30°C, and the user does not need to adjust the temperature by himself.
[0056] For another example, when the smart device is an air conditioner, the power consumption statistics before the main control module is replaced are 90 kWh, and the power consumption statistics after the main control module is replaced are cleared to 0 kWh. Thus, the power consumption before and after the hardware replacement is quite different and does not conform to the power consumption logic. The power consumption statistics provided after the main control module is replaced do not provide any reference value. To address this problem, the power consumption statistics before the main control module is replaced are used to update the power consumption statistics set after the main control module is replaced, that is, 0 kWh is updated to 90 kWh, and the power consumption statistics continue to be accumulated on the basis of 90 kWh to maintain the continuity of the power consumption statistics.
[0057] In an embodiment of the present application, device data is reported to the cloud server once every preset time period; in the process of reporting device data to the cloud server, a hardware replacement event is detected; after detecting the hardware replacement event, a data synchronization request is sent to the cloud server and the device data synchronized by the cloud server and reported to the cloud server before the hardware replacement event occurs is received; according to the device data reported to the cloud server before the hardware replacement event occurs, the current device data is updated. The smart device of the embodiment of the present application reports device data to the cloud device once every preset time period. After detecting a hardware replacement event, in order to ensure the continuity and integrity of the device data on the smart device side and the device data before the hardware replacement, a data synchronization request is sent to the cloud server to obtain the device data before the hardware replacement from the cloud server, and the device data before the hardware replacement is used to update the current device data, thereby achieving the continuity and integrity of the data on the smart device side.
[0058] In order to make the method for synchronizing device data of the embodiment of the present application clearer, the method for synchronizing device data of the embodiment of the present application will be further described below.
[0059] In the embodiment of the present application, in the process of receiving the device data reported by the smart device, the cloud server not only needs to store the received device data corresponding to the unique identifier of the smart device, but also needs to determine whether a hardware replacement event occurs in the smart device. Two methods of determining whether a hardware replacement event occurs in a smart device are provided below.
[0060] Determination method 1:
[0061] When a smart device connects to a cloud server for the first time, the cloud server needs to authenticate the smart device through the user terminal bound to the smart device. After passing the device authentication, the cloud server allows the smart device to establish a long connection with the cloud server so that the smart device can report device data to the cloud server every preset time period based on the long connection. Furthermore, device authentication includes two parts: device authentication and identity authentication.
[0062] Figure 3 The present invention is a flowchart of the steps of device identity authentication according to an embodiment of the present application.
[0063] Step S310: The smart device sends a persistent connection request to the cloud server; wherein the persistent connection request carries the terminal data bound to the smart device.
[0064] The persistent connection request is used to request to establish a persistent connection with the cloud server.
[0065] For smart devices, you can pre-register them on the cloud server so that the cloud server can save the registration information of the smart device. The registration information at least includes: the unique identifier and MAC address of the smart device and the terminal data bound to the smart device. The terminal data is, for example, a mobile phone number.
[0066] Step S320: The cloud server sends an identity authentication request to the user terminal using the terminal data according to the terminal data carried in the persistent connection request.
[0067] The user terminal using the terminal data can be regarded as a user terminal bound to the smart device.
[0068] An authentication request is used to request verification of a user's identity.
[0069] The authentication request may carry data used to verify the user's identity. For example, a verification code may be carried in the authentication request.
[0070] Step S330: The user terminal sends identity authentication information to the cloud server according to the identity authentication request.
[0071] The authentication information carries the data entered by the user for verifying the user's identity.
[0072] For example, a user enters the verification code in the identity authentication request into the user terminal. After the user terminal collects the verification code, it is carried in the identity authentication information and sent to the cloud server.
[0073] In step S340, the cloud server determines whether the identity authentication is passed based on the identity authentication information; if yes, execute step S350; if not, execute step S390.
[0074] If the data used to verify the user's identity carried in the identity verification information is the same as the data used to verify the user's identity carried in the identity verification request, then the identity verification is determined to be successful; otherwise, the identity verification is determined to be unsuccessful.
[0075] For example: the cloud server verifies whether the verification code entered by the user in the user terminal is the same as the verification code sent by the cloud server to the user terminal; if they are the same, it is determined that the identity authentication is successful; otherwise, it is determined that the identity authentication is unsuccessful.
[0076] Step S350: The cloud server sends a device verification request to the user terminal.
[0077] In step S360, the user terminal collects basic device data of the smart device according to the device verification request, and sends the basic device data of the smart device to the cloud server.
[0078] The basic device data of the smart device includes, but is not limited to: a unique identifier of the smart device and a current MAC address of the smart device.
[0079] The basic device data of the smart device may be pre-stored in the user terminal, or the user may input the basic device data of the smart device into the user terminal after the user terminal receives the device verification request.
[0080] In step S370, the cloud server determines whether the basic device data sent by the user terminal meets the device verification pass condition; if yes, execute step S380; if not, execute step S390.
[0081] The cloud server extracts the unique identifier of the smart device from the device basic data, and compares the extracted unique identifier with the unique identifier in the registration information; if they are the same, it is determined that the device basic data sent by the user terminal meets the device verification pass conditions, and the device verification passes; otherwise, it is determined that the device basic data sent by the user terminal does not meet the device verification pass conditions, and the device verification fails.
[0082] Step S380: The cloud server determines that the device identity authentication has passed, and allows a persistent connection to be established between the smart device and the cloud server.
[0083] Step S390: The cloud server determines that the device identity authentication fails and prohibits establishing a long connection between the smart device and the cloud server.
[0084] During the use of a smart device, the hardware may fail, which may require replacement of the hardware so that the smart device can work properly.
[0085] When the smart device replaces its hardware, the long connection between the smart device and the cloud server is disconnected. After the smart device replaces its hardware, the smart device needs to re-request to establish a long connection with the cloud server and perform device identity authentication again. Among them, after the smart device replaces its hardware, the MAC address of the smart device may change. The embodiment of the present application utilizes the characteristic that the basic data of the device needs to be sent to the cloud server during the device identity authentication process to determine whether a hardware replacement event has occurred in the smart device.
[0086] Figure 4 The present invention is a flowchart of the steps for determining a hardware replacement event executed on a cloud server according to an embodiment of the present application.
[0087] Step S410: after the persistent connection with the smart device is disconnected, wait to receive a persistent connection request sent by the smart device.
[0088] Step S420: After receiving the persistent connection request sent by the smart device, perform device identity authentication on the smart device by communicating with the user terminal bound to the smart device.
[0089] The user terminal bound to the smart device refers to: a user terminal that is using the terminal data bound to the smart device.
[0090] Step S430: in the process of performing device identity authentication on the smart device, obtaining a unique identifier and a media access control address of the smart device reported by the user terminal.
[0091] Specifically, in the process of performing device identity authentication on the smart device through the user terminal, basic device data sent by the user terminal is received, from which a unique identifier and a MAC address (Media Access Control Address) of the smart device can be extracted.
[0092] After the device identity authentication performed on the smart device is passed, a persistent connection is established between the smart device and the cloud server. At this time, the smart device can send a data synchronization request to the cloud server based on the persistent connection.
[0093] Step S440: query the storage space for a media access control address corresponding to the unique identifier.
[0094] Since the unique identifier and MAC address of the smart device have been stored in the storage space of the cloud server during the smart device registration stage, after obtaining the unique identifier and MAC address of the smart device, the unique identifier of the smart device is used to query the corresponding MAC address in the storage space.
[0095] Step S450: When the media access control address corresponding to the unique identifier is different from the media access control address of the smart device, it is determined that a hardware replacement event has occurred in the smart device.
[0096] If the MAC address of the smart device reported by the user terminal is different from the MAC address of the smart device stored in the storage space, it is determined that a hardware replacement event has occurred in the smart device.
[0097] In some cases, even if the MAC address of the smart device reported by the user terminal is the same as the MAC address of the smart device stored in the storage space, a hardware replacement event may have occurred in the smart device. In other words, the smart device has replaced its hardware, and the replaced hardware will not cause the MAC address of the smart device to change, but it will cause the data corresponding to the hardware to be lost. In response to this situation, on the cloud server side, it is possible to determine whether a hardware replacement event has occurred in the smart device every preset inspection time period. Specifically, the following determination method 2 can be used to determine whether a hardware replacement event has occurred in the smart device.
[0098] Determination method 2:
[0099] Figure 5 The present invention is a flowchart of the steps for determining a hardware replacement event performed on a cloud server according to another embodiment of the present application.
[0100] Step S510: query the storage space for the device data previously reported by the smart device.
[0101] At each preset inspection time interval, the storage space is queried for the device data previously reported by the smart device. Furthermore, the cloud server can query the device data previously reported by the smart device in the storage space corresponding to the persistent connection.
[0102] Step S520: using the device data previously reported by the smart device, detecting whether the device data reported this time by the smart device has a data anomaly of a preset type.
[0103] The preset types of data anomalies include: for growth-type device data, the previously reported device data is greater than the currently reported device data; for reduction-type device data, the previously reported device data is less than the currently reported device data; for parameter-type device data, the difference between the previously reported device data and the currently reported device data is greater than the preset difference threshold.
[0104] Growth-type equipment data refers to the statistical data within the preset statistical time period. The value of the statistical data can only increase, not decrease. For example, within the statistical time period, the power statistics can only increase, not decrease. If the last reported value is 90 degrees, and the current reported value is 80 degrees, it means that the preset type of data anomaly has occurred.
[0105] Decreasing equipment data refers to the statistical data within the preset statistical time period. The value of the statistical data can only decrease, not increase.
[0106] Parameter device data refers to the operating parameters of smart devices. Generally speaking, the parameter values reported twice will not differ significantly.
[0107] Step S530: When it is determined that the device data reported by the smart device this time has a data anomaly of a preset type, it is determined that a hardware replacement event has occurred in the smart device.
[0108] In an embodiment of the present application, if it is determined that the device data reported by the smart device this time contains a data anomaly of a preset type, the device data reported by the smart device this time may be refused to be stored; if it is determined that the device data reported by the smart device this time does not contain a data anomaly of a preset type, the device data reported by the smart device this time may be stored in correspondence with the unique identifier of the smart device.
[0109] In an embodiment of the present application, after determining that a hardware replacement event has occurred in the smart device, the cloud server sends a data synchronization notification message to the smart device, so that the smart device sends the data synchronization request to the cloud server based on the data synchronization notification message.
[0110] Furthermore, the data synchronization notification message is used to notify the smart device to perform data synchronization.
[0111] In an embodiment of the present application, after determining that a hardware replacement event has occurred in the smart device, the process waits for receiving a data synchronization request sent by the smart device; after receiving the data synchronization request sent by the smart device, the device data reported by the smart device before the hardware replacement event occurs is synchronized to the smart device.
[0112] like Figure 6 , which is a flow chart of the steps of synchronizing device data from a cloud server to a smart device according to an embodiment of the present application.
[0113] Step S610: querying the storage space for device data reported by the smart device before the hardware replacement event occurs.
[0114] When the MAC address of a smart device changes, the smart device needs to re-establish a long connection with the cloud server. After the long connection is successfully established, the cloud server can query the storage space for the device data corresponding to the unique identifier of the smart device, and query the device data corresponding to the unique identifier for the device data reported by the smart device before the hardware replacement event occurs.
[0115] If the MAC address of the smart device has not changed, the smart device normally reports device data through the persistent connection. The cloud server receives the device data reported by the smart device based on the persistent connection and stores the device data in correspondence with the unique identifier of the smart device. After determining that a hardware replacement event has occurred in the smart device, the cloud server queries the storage space corresponding to the persistent connection for the device data reported by the smart device before the hardware replacement event occurs.
[0116] When querying the device data reported by the smart device before the hardware replacement event occurs, the cloud server can query the storage space for the device data reported by the smart device that has been stored before the time when the hardware replacement event occurs in the smart device, as the device data reported by the smart device before the hardware replacement event occurs.
[0117] Step S620: Map the device data reported by the smart device before the hardware replacement event occurs to the device data reported by the smart device after the hardware replacement event occurs.
[0118] Mapping refers to associating device data reported by the smart device before the hardware replacement event occurs with device data reported by the smart device after the hardware replacement event occurs.
[0119] When the smart device re-establishes a long connection with the cloud server, if the storage locations of the device data reported by the smart device before the hardware replacement event and the device data reported by the smart device after the hardware replacement event are different, the device data reported by the smart device before the hardware replacement event can be migrated to the storage location of the device data reported by the smart device after the hardware replacement event.
[0120] Step S630: Synchronize the device data reported by the smart device before the hardware replacement event occurs to the smart device.
[0121] The device data last reported by the smart device before the hardware replacement event occurs may be synchronized to the smart device; or the device data last reported by the smart device a preset number of times before the hardware replacement event occurs may be synchronized to the smart device.
[0122] In an embodiment of the present application, when the MAC address of the smart device has not changed, since the cloud server needs to re-authenticate the smart device, and the smart device needs to re-establish a long connection with the cloud server, after the cloud server passes the device authentication performed on the smart device and establishes a long connection with the smart device, if it is determined that a hardware replacement event has occurred in the smart device and a data synchronization request sent by the smart device is received, the device data reported by the smart device before the hardware replacement event occurs is synchronized to the smart device based on the re-established long connection.
[0123] In an embodiment of the present application, after the device data reported by the smart device before the hardware replacement event occurs is synchronized to the smart device, a data synchronization completion notification can be sent to the user terminal, and the device data reported by the smart device after the device data is updated can be sent to the user terminal, so that the user can use the user terminal to control the smart device.
[0124] In an embodiment of the present application, the smart device detects a hardware replacement event during the process of reporting device data to the cloud server, so as to send a data synchronization request to the cloud server after detecting the hardware replacement event. Two methods of detecting hardware replacement events are provided below.
[0125] Detection method 1:
[0126] A button for triggering the generation of a hardware replacement event is set in the smart device; after the hardware replacement of the smart device is completed, the button can be clicked to generate a hardware replacement event, and the hardware replacement event can be detected.
[0127] Detection method 2:
[0128] Detect whether a data synchronization notification message sent by the cloud server is received; if the data synchronization notification message sent by the cloud server is received, determine that the hardware replacement event has occurred. Further, if a data synchronization notification message is received from the cloud server, it means that the cloud server has determined that a hardware replacement event has occurred in the smart device. Since hardware replacement will cause data related to the hardware to be lost in the smart device, the smart device sends a data synchronization request to the cloud server after receiving the data synchronization notification message.
[0129] In an embodiment of the present application, after detecting a hardware replacement event, the smart device sends a data synchronization request to the cloud server and receives the device data synchronized by the cloud server that was reported to the cloud server before the hardware replacement event occurred.
[0130] In the case that the MAC address of a smart device changes, the smart device needs to first send a long connection request to the cloud server; in this way, the cloud server can communicate with the user terminal bound to the smart terminal based on the long connection request to perform device identity authentication on the smart device; after the device identity authentication is passed, the smart device can establish a long connection with the cloud server; based on the long connection, a data synchronization request is sent to the cloud server and the device data synchronized by the cloud server and reported to the cloud server before the hardware replacement event occurs is received.
[0131] In the embodiment of the present application, the cloud server does not rely on the traditional MAC address, and does not use the MAC address as the standard for identifying different smart devices. Instead, the cloud server uses the unique identifier of the smart device as the standard for identifying different smart devices, and uses the unique identifier of the smart device to associate the device data of the smart device. The unique identifier will not change, so even after the MAC address of the smart device changes, the historical device data of the smart device can be accurately found through the unique identifier of the smart device, maintaining the continuity and integrity of the data.
[0132] The present application also provides a device data synchronization apparatus provided in a cloud server. Figure 7 , which is a structural diagram of a device data synchronization apparatus set up in a cloud server according to an embodiment of the present application.
[0133] The device data synchronization device provided on the cloud server includes:
[0134] The receiving module 710 is used to receive device data reported by the smart device at every preset time period.
[0135] The storage and determination module 720 is used to store the received device data corresponding to the unique identifier of the smart device during the process of receiving the device data reported by the smart device, and determine whether a hardware replacement event occurs in the smart device.
[0136] The synchronization module 730 is used to synchronize the device data reported by the smart device before the hardware replacement event occurs to the smart device when it is determined that a hardware replacement event occurs in the smart device and a data synchronization request is received from the smart device.
[0137] The functions of the device described in the embodiment of the present application have been described in the above method embodiment. Therefore, for any details not provided in the description of this embodiment, please refer to the relevant descriptions in the above embodiment and will not be repeated here.
[0138] The present application also provides a device data synchronization apparatus set on a smart device. Figure 8, which is a structural diagram of a device data synchronization apparatus set in a smart device according to an embodiment of the present application.
[0139] The device data synchronization device provided in the smart device includes:
[0140] The reporting module 810 is used to report device data to the cloud server once every preset time period.
[0141] The detection module 820 is used to detect hardware replacement events during the process of reporting device data to the cloud server.
[0142] The transceiver module 830 is used to send a data synchronization request to the cloud server after detecting the hardware replacement event and receive the device data synchronized by the cloud server and reported to the cloud server before the hardware replacement event occurs.
[0143] The updating module 840 is used to update the current device data according to the device data reported to the cloud server before the hardware replacement event occurs.
[0144] The functions of the device described in the embodiment of the present application have been described in the above method embodiment. Therefore, for any details not provided in the description of this embodiment, please refer to the relevant descriptions in the above embodiment and will not be repeated here.
[0145] The present application also provides a device data synchronization device, such as Fig. 9 , which is a structural diagram of a device data synchronization device according to an embodiment of the present application.
[0146] The device data synchronization device includes: a processor 910, a communication interface 920, a memory 930 and a communication bus 940. The processor 910, the communication interface 920 and the memory 930 communicate with each other through the communication bus 940.
[0147] The memory 930 is used to store computer programs.
[0148] In one embodiment of the present application, the processor 910, when executing the program stored in the memory 930, implements the device data synchronization method provided by any one of the aforementioned method embodiments executed on the cloud server, including: receiving device data reported by a smart device at preset time intervals; in the process of receiving the device data reported by the smart device, storing the received device data in correspondence with the unique identifier of the smart device, and determining whether a hardware replacement event has occurred in the smart device; when it is determined that a hardware replacement event has occurred in the smart device and a data synchronization request sent by the smart device is received, synchronizing the device data reported by the smart device before the hardware replacement event occurs to the smart device.
[0149] Among them, determining whether a hardware replacement event has occurred in the smart device includes: after the long connection between the smart device is disconnected, waiting to receive a long connection request sent by the smart device; after receiving the long connection request sent by the smart device, communicating with the user terminal bound to the smart device to perform device identity authentication on the smart device; in the process of performing device identity authentication on the smart device, obtaining the unique identifier and media access control address of the smart device reported by the user terminal; querying the media access control address corresponding to the unique identifier in the storage space; when the media access control address corresponding to the unique identifier is different from the media access control address of the smart device, determining that a hardware replacement event has occurred in the smart device.
[0150] Among them, determining whether a hardware replacement event has occurred in the smart device includes: querying the device data last reported by the smart device in the storage space; using the device data last reported by the smart device to detect whether the device data reported by the smart device this time has a data anomaly of a preset type; if it is determined that the device data reported by the smart device this time has a data anomaly of a preset type, determining that a hardware replacement event has occurred in the smart device.
[0151] Wherein, after determining that a hardware replacement event has occurred in the smart device, the method further includes: sending a data synchronization notification message to the smart device so that the smart device sends the data synchronization request to the cloud server according to the data synchronization notification message.
[0152] Among them, synchronizing the device data reported by the smart device before the hardware replacement event occurs to the smart device includes: querying the device data reported by the smart device before the hardware replacement event occurs in the storage space; mapping the device data reported by the smart device before the hardware replacement event occurs to the device data reported by the smart device after the hardware replacement event occurs; synchronizing the device data reported by the smart device before the hardware replacement event occurs to the smart device.
[0153] In one embodiment of the present application, the processor 910, when executing the program stored in the memory 930, implements the device data synchronization method provided by any one of the aforementioned method embodiments executed on the smart device, including: reporting device data to the cloud server once every preset time period; detecting a hardware replacement event during the process of reporting device data to the cloud server; after detecting the hardware replacement event, sending a data synchronization request to the cloud server and receiving the device data reported to the cloud server before the hardware replacement event occurs and synchronized by the cloud server; updating the current device data according to the device data reported to the cloud server before the hardware replacement event occurs.
[0154] The detecting of the hardware replacement event includes: detecting whether a data synchronization notification message sent by the cloud server is received; and determining that the hardware replacement event occurs when the data synchronization notification message sent by the cloud server is received.
[0155] The embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, it implements the synchronization method of the device data executed on the cloud server as provided in any of the aforementioned method embodiments, or implements the steps of the synchronization method of the device data executed on the smart device as provided in any of the aforementioned method embodiments. Since the synchronization method of the device data executed on the cloud server and the synchronization method of the device data executed on the smart device have been described in detail above, for the details not fully described in the description of this embodiment, please refer to the relevant descriptions in the aforementioned embodiments, and no further description will be given here.
[0156] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0157] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0158] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.
[0159] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.
Claims
1. A method for synchronizing device data, characterized in that: Executed on the cloud server, including: Receive device data reported by smart devices at preset time intervals; In the process of receiving the device data reported by the smart device, the received device data is stored in correspondence with the unique identifier of the smart device, and it is determined whether a hardware replacement event occurs in the smart device; When it is determined that a hardware replacement event has occurred in the smart device and a data synchronization request sent by the smart device is received, the device data reported by the smart device before the hardware replacement event occurs is synchronized to the smart device.
2. The solution according to claim 1, characterized in that The determining whether a hardware replacement event occurs in the smart device includes: After the persistent connection with the smart device is disconnected, waiting to receive a persistent connection request sent by the smart device; After receiving the persistent connection request sent by the smart device, performing device identity authentication on the smart device by communicating with a user terminal bound to the smart device; In the process of performing device identity authentication on the smart device, obtaining a unique identifier and a media access control address of the smart device reported by the user terminal; In the storage space, query the media access control address corresponding to the unique identifier; When the media access control address corresponding to the unique identifier is different from the media access control address of the smart device, it is determined that a hardware replacement event has occurred in the smart device.
3. The method according to claim 1, characterized in that The determining whether a hardware replacement event occurs in the smart device includes: In the storage space, query the device data previously reported by the smart device; Using the device data previously reported by the smart device, detecting whether the device data reported by the smart device this time has a data anomaly of a preset type; When it is determined that the device data reported by the smart device this time has a data anomaly of a preset type, it is determined that a hardware replacement event has occurred in the smart device.
4. The method according to claim 1, characterized in that: After determining that a hardware replacement event has occurred in the smart device, the method further includes: A data synchronization notification message is sent to the smart device so that the smart device sends the data synchronization request to the cloud server according to the data synchronization notification message.
5. The method according to claim 1, characterized in that The step of synchronizing the device data reported by the smart device before the hardware replacement event occurs to the smart device includes: In the storage space, query the device data reported by the smart device before the hardware replacement event occurs; Mapping the device data reported by the smart device before the hardware replacement event occurs to the device data reported by the smart device after the hardware replacement event occurs; The device data reported by the smart device before the hardware replacement event occurs is synchronized to the smart device.
6. A method for synchronizing device data, characterized in that: Executed on smart devices, including: Report device data to the cloud server once every preset time period; In the process of reporting device data to the cloud server, detecting a hardware replacement event; After detecting the hardware replacement event, sending a data synchronization request to the cloud server and receiving device data synchronized by the cloud server and reported to the cloud server before the hardware replacement event occurs; The current device data is updated according to the device data reported to the cloud server before the hardware replacement event occurs.
7. The method according to claim 6, characterized in that The detecting of the hardware replacement event comprises: Detecting whether a data synchronization notification message sent by the cloud server is received; When the data synchronization notification message sent by the cloud server is received, it is determined that the hardware replacement event occurs.
8. A device for synchronizing device data, characterized in that: include: The device data synchronization device provided in the cloud server includes: A receiving module, used to receive device data reported by the smart device at preset time intervals; A storage and determination module, configured to store the received device data in correspondence with the unique identifier of the smart device during the process of receiving the device data reported by the smart device, and determine whether a hardware replacement event occurs in the smart device; a synchronization module, configured to, upon determining that a hardware replacement event has occurred in the smart device and receiving a data synchronization request sent by the smart device, synchronize the device data reported by the smart device before the hardware replacement event occurs to the smart device; The device data synchronization device provided in the smart device includes: The reporting module is used to report device data to the cloud server once every preset time period; A detection module, used to detect hardware replacement events during the process of reporting device data to the cloud server; a transceiver module, configured to, after detecting the hardware replacement event, send a data synchronization request to the cloud server and receive device data synchronized by the cloud server and reported to the cloud server before the hardware replacement event occurs; The updating module is used to update the current device data according to the device data reported to the cloud server before the hardware replacement event occurs.
9. A device for synchronizing device data, characterized in that: include: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor coupled to the at least one bus; At least one memory connected to the at least one bus, wherein the processor is configured to: execute a synchronization program for device data stored in the memory to implement the device data synchronization method of any one of claims 1-5 executed on the cloud server, or to implement the device data synchronization method of any one of claims 6-7 executed on the smart device.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are executed to implement the device data synchronization method executed on the cloud server according to any one of claims 1 to 5, or to implement the device data synchronization method executed on the smart device according to any one of claims 6 to 7.
Citation Information
Patent Citations
Intelligent terminal data configuration method and system based on cloud terminal
CN103533011A
Intelligent lighting system equipment replacement method, system and device and storage medium
CN113518501A
Method and device for synchronizing data
US20150058287A1