Data synchronization method, device, electronic device and storage medium
By introducing home servers and task queue management into the smart home system, the applicability and accuracy issues of data synchronization methods are solved, and the accuracy of terminals obtaining the latest data and the improvement of system performance are achieved.
Patent Information
- Application Number
- CN202111658237.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-30
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2041-12-30
AI Technical Summary
In existing smart home systems, data synchronization methods have problems such as poor applicability and inaccurate data synchronization.
By introducing a home server into the smart home system, receiving data acquisition requests from the cloud and terminals, querying and sending the latest target data, and updating the data of home devices when necessary, using multi-threading to process data change signals between the cloud and home server, and using task queues to manage unsuccessful data synchronization tasks, the accuracy and timeliness of the data are ensured.
The applicability and accuracy of the data synchronization method are improved, ensuring that the terminal obtains the latest target data, reducing the load on the home server, and improving the system's operating performance and user experience.
Smart Images

Figure CN114297306B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of smart home technology, and in particular to a data synchronization method, device, electronic device and storage medium. Background Art
[0002] Smart home uses residence as a platform and utilizes integrated wiring technology, network communication technology, security technology, automatic control technology, and audio and video technology to integrate facilities related to home life, build an efficient management system for residential facilities and family schedule affairs, improve home safety, convenience, comfort, and artistry, and achieve an environmentally friendly and energy-saving living environment.
[0003] In existing smart home systems, users can access the cloud in the smart home system through a terminal to request and synchronously obtain relevant query data.
[0004] It can be seen that the existing data synchronization method is relatively simple, so the data obtained by the terminal often has the problem of being inaccurate. Summary of the Invention
[0005] The purpose of this application is to provide a data synchronization method, device, electronic device and storage medium to address the deficiencies in the above-mentioned prior art, which can improve the applicability of the data synchronization method and ensure the accuracy of the synchronized data.
[0006] To achieve the above objectives, the technical solutions adopted in the embodiments of the present application are as follows:
[0007] In a first aspect, the present invention provides a data synchronization method, which is applied to a home server in a smart home system, wherein the home server is communicatively connected to a terminal and a cloud in the smart home system, and the home server is communicatively connected to at least one home device. The data synchronization method comprises:
[0008] receiving a first data acquisition request sent by the cloud, where the first data acquisition request is sent by the terminal to the cloud in response to a data acquisition operation and forwarded by the cloud when it is determined that target data corresponding to the first data acquisition request is not the latest data, and the first data acquisition request includes a terminal identifier;
[0009] According to the first data acquisition request, query and acquire target data corresponding to the first data acquisition request;
[0010] The target data is sent to a terminal corresponding to the terminal identifier according to the terminal identifier.
[0011] In an optional embodiment, the method further comprises:
[0012] Receiving data change requests sent by terminals;
[0013] According to the data change request, updating the to-be-changed data corresponding to the data change request in the home server;
[0014] A data change response is sent to the terminal, where the data change response is used to indicate whether the update is successful.
[0015] In an optional implementation manner, after updating the to-be-changed data corresponding to the data change request according to the data change request, the method further includes:
[0016] Determining, according to the data change request, a data type corresponding to the data change request, and sending a data change signal to the cloud so that the cloud marks the data type corresponding to the data change signal as a first identifier according to the data change signal, wherein the data change signal includes: the data type corresponding to the data change request and a server identifier of the home server;
[0017] receiving a second data acquisition request sent by the cloud in response to the data change signal;
[0018] Sending change data to the cloud according to the second data acquisition request, so that the cloud updates the data to be changed in the cloud according to the change data, and then marking the data type corresponding to the data change signal as a second identifier.
[0019] In an optional embodiment, the sending a data change signal to the cloud includes:
[0020] If it is determined that the data change signal sent to the cloud is not sent successfully, storing the data change task corresponding to the data change signal in the first task queue;
[0021] According to a first preset time interval, a data change signal corresponding to the data change task is read from the first task queue, and the data change signal is resent to the cloud.
[0022] In an optional embodiment, the receiving the second data acquisition request sent by the cloud according to the data change signal includes:
[0023] Receive a second data acquisition request corresponding to the data synchronization task obtained from the second task queue and sent by the cloud according to a second preset time interval, wherein when the cloud determines that the second data acquisition request sent to the home server according to the data change signal is not successfully sent, the cloud stores the data synchronization task corresponding to the second data acquisition request in the second task queue.
[0024] In an optional implementation, if the cloud determines that the mark of the data type corresponding to the first data acquisition request is the first identifier, it is determined that the target data corresponding to the first data acquisition request is not the latest data.
[0025] In an optional implementation, the change data includes full data of the data type corresponding to the data change request.
[0026] In a second aspect, the present invention provides a data synchronization method, which is applied to a cloud in a smart home system, wherein the cloud is communicatively connected to a home server and a terminal in the smart home system, and the home server is communicatively connected to at least one home device. The data synchronization method includes:
[0027] receiving a first data acquisition request sent by a terminal in response to a data acquisition operation, wherein the first data acquisition request includes a terminal identifier;
[0028] If it is determined that the target data corresponding to the first data acquisition request is not the latest data, the first data acquisition request is forwarded to the home server, so that the home server obtains the target data according to the first data acquisition request and sends the target data to the terminal corresponding to the terminal identifier.
[0029] In an optional embodiment, the method further comprises:
[0030] If the cloud receives data change signals sent by multiple home servers, it uses multiple threads to send a second data acquisition request to each home server corresponding to the data change signal;
[0031] Receive the change data sent by each home server according to each second data acquisition request.
[0032] In a third aspect, the present invention provides a data synchronization method, which is applied to a terminal in a smart home system, wherein the terminal is communicatively connected to a home server and a cloud in the smart home system, and the home server is communicatively connected to at least one home device. The data synchronization method includes:
[0033] In response to the data acquisition operation, sending a first data acquisition request to the cloud, where the first data acquisition request includes a terminal identifier;
[0034] Receive the target data returned by the home server according to the first data acquisition request, wherein the cloud forwards the first data acquisition request to the home server when determining that the target data corresponding to the first data acquisition request sent by the terminal is not the latest data.
[0035] In a fourth aspect, an embodiment of the present application provides a data synchronization device, which is applied to a home server in a smart home system, wherein the home server is communicatively connected to a terminal and a cloud in the smart home system, and the home server is communicatively connected to at least one home device. The data synchronization device includes:
[0036] a receiving module, configured to receive a first data acquisition request sent by the cloud, the first data acquisition request being a data acquisition request sent by the terminal to the cloud in response to a data acquisition operation and forwarded by the cloud when determining that target data corresponding to the first data acquisition request is not the latest data, the first data acquisition request including a terminal identifier;
[0037] an acquisition module, configured to query and acquire target data corresponding to the first data acquisition request according to the first data acquisition request;
[0038] A sending module is used to send the target data to the terminal corresponding to the terminal identifier according to the terminal identifier.
[0039] In an optional embodiment, the data synchronization device further includes: a change module, configured to receive a data change request sent by a terminal;
[0040] According to the data change request, updating the to-be-changed data corresponding to the data change request in the home server;
[0041] A data change response is sent to the terminal, where the data change response is used to indicate whether the update is successful.
[0042] In an optional embodiment, the change module is further configured to determine, based on the data change request, a data type corresponding to the data change request, and send a data change signal to the cloud so that the cloud marks the data type corresponding to the data change signal as a first identifier based on the data change signal, wherein the data change signal includes: the data type corresponding to the data change request and the server identifier of the home server;
[0043] receiving a second data acquisition request sent by the cloud in response to the data change signal;
[0044] Sending change data to the cloud according to the second data acquisition request, so that the cloud updates the data to be changed in the cloud according to the change data, and then marking the data type corresponding to the data change signal as a second identifier.
[0045] In an optional embodiment, the changing module is specifically configured to store the data changing task corresponding to the data changing signal in the first task queue if it is determined that the data changing signal sent to the cloud is not sent successfully;
[0046] According to a first preset time interval, a data change signal corresponding to the data change task is read from the first task queue, and the data change signal is resent to the cloud.
[0047] In an optional embodiment, the change module is specifically used to receive a second data acquisition request corresponding to the data synchronization task obtained from the second task queue and sent by the cloud according to a second preset time interval, wherein when the cloud determines that the second data acquisition request sent to the home server according to the data change signal is not successfully sent, the cloud stores the data synchronization task corresponding to the second data acquisition request in the second task queue.
[0048] In an optional implementation, if the cloud determines that the mark of the data type corresponding to the first data acquisition request is the first identifier, it is determined that the target data corresponding to the first data acquisition request is not the latest data.
[0049] In an optional implementation, the change data includes full data of the data type corresponding to the data change request.
[0050] In a fifth aspect, the present invention provides a data synchronization device, which is applied to a cloud in a smart home system, wherein the cloud is communicatively connected to a home server and a terminal in the smart home system, respectively, and the home server is communicatively connected to at least one home device. The data synchronization device includes:
[0051] A receiving module, configured to receive a first data acquisition request sent by a terminal in response to a data acquisition operation, wherein the first data acquisition request includes a terminal identifier;
[0052] a forwarding module, configured to forward the first data acquisition request to the home server if it is determined that the target data corresponding to the first data acquisition request is not the latest data, so that the home server acquires the target data according to the first data acquisition request and sends the target data to the terminal corresponding to the terminal identifier.
[0053] In an optional embodiment, the data synchronization device further includes: an update module, configured to use multiple threads to send a second data acquisition request to each home server corresponding to each data change signal if the cloud receives data change signals sent by multiple home servers;
[0054] Receive the change data sent by each home server according to each second data acquisition request.
[0055] In a sixth aspect, the present invention provides a data synchronization device, which is applied to a terminal in a smart home system, wherein the terminal is communicatively connected to a home server and a cloud in the smart home system, respectively, and the home server is communicatively connected to at least one home device. The data synchronization device includes:
[0056] a response module, configured to send a first data acquisition request to the cloud in response to the data acquisition operation, wherein the first data acquisition request includes a terminal identifier;
[0057] A receiving module is used to receive the target data returned by the home server according to the first data acquisition request, wherein the cloud forwards the first data acquisition request to the home service when it is determined that the target data corresponding to the first data acquisition request sent by the terminal is not the latest data.
[0058] In a fourth aspect, the present invention provides an electronic device comprising: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the storage medium through the bus, and the processor executes the machine-readable instructions to perform the steps of the data synchronization method as described in any of the foregoing embodiments.
[0059] In a fifth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the data synchronization method as described in any of the aforementioned embodiments are executed.
[0060] The beneficial effects of this application are:
[0061] The data synchronization method, device, electronic device and storage medium provided in the embodiments of the present application can be applied to a home server in a smart home system. The home server is communicatively connected to a terminal and a cloud in the smart home system respectively, and the home server is communicatively connected to at least one home appliance. The data synchronization method includes: receiving a first data acquisition request sent by the cloud, the first data acquisition request being sent by the terminal to the cloud in response to a data acquisition operation and forwarded by the cloud when it determines that the target data corresponding to the first data acquisition request is not the latest data, the first data acquisition request including a terminal identifier; querying and acquiring the target data corresponding to the first data acquisition request according to the first data acquisition request; and sending the target data to the terminal corresponding to the terminal identifier according to the terminal identifier. The application of the embodiments of the present application can enable the terminal to acquire the latest target data and ensure the accuracy of the acquired target data. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.
[0063] Figure 1 A schematic diagram of the architecture of a smart home system provided in an embodiment of the present application;
[0064] Figure 2 A flowchart of a data synchronization method provided in an embodiment of the present application;
[0065] Figure 3 A flowchart of another data synchronization method provided in an embodiment of the present application;
[0066] Figure 4 A flowchart of another data synchronization method provided in an embodiment of the present application;
[0067] Figure 5 A flowchart of another data synchronization method provided in an embodiment of the present application;
[0068] Figure 6 A flowchart of another data synchronization method provided in an embodiment of the present application;
[0069] Figure 7 A flowchart of another data synchronization method provided in an embodiment of the present application;
[0070] Figure 8 A flowchart of another data synchronization method provided in an embodiment of the present application;
[0071] Figure 9 A schematic diagram of the functional modules of a data synchronization device provided in an embodiment of the present application;
[0072] Figure 10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0073] To make the objectives, technical solutions, and advantages of the embodiments of the present application more clear, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Generally, the components of the embodiments of the present application described and shown in the drawings herein can be arranged and designed in various different configurations.
[0074] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for protection, but merely represents selected embodiments of the present application. All other embodiments obtained by persons of ordinary skill in the art based on the embodiments in the present application without creative work are within the scope of protection of the present application.
[0075] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings.
[0076] In existing smart home systems, the data of smart home systems is mainly stored in the cloud. That is, users mainly access the cloud in the smart home system through terminals to request the synchronization of relevant query data. It can be seen that the existing access to the smart home system depends on the communication connection established between the terminal and the cloud based on the Internet. The data synchronization path is relatively single and simple. Therefore, the existing data synchronization method has the problems of poor applicability and inaccurate data synchronization.
[0077] In view of this, an embodiment of the present application provides a data synchronization method, which can improve the applicability of the data synchronization method and ensure the accuracy of the synchronized data.
[0078] Figure 1 This is a schematic diagram of the architecture of a smart home system provided in an embodiment of the present application, such as Figure 1 As shown, the smart home system may include a home server 110, a cloud 120, a terminal 130, and home appliances, wherein the home appliances may include: a printer 142, a projector 143. Of course, it should be noted that the categories of home appliances are not limited to this. According to the actual application scenario, the smart home system may include: lamps, sockets, curtains, air conditioners, window openers, projectors, water heaters, air purifiers, security equipment, smart sweeping robots and other home appliances. Figure 1It can be seen that the home server 110 is communicated with the terminal 130 and the cloud 120 in the smart home system respectively, and the home server 110 is communicated with at least one home device, wherein the terminal can be a mobile phone, a tablet computer, a computer, a wearable device, etc., which is not limited here. Of course, the present application does not limit the number of home servers in the smart home system. According to the actual application scenario, the smart home system can include multiple home servers, and each home server can be deployed in different application environments. For example, it can be deployed in different homes. Of course, each home server can also be configured to be accessible through multiple terminals in a home. Based on the above description, it can be seen that in the data synchronization method provided in the embodiment of the present application, the terminal can access the smart home system through the cloud and can also access the smart home system through the home server. That is, in the data synchronization method provided in the embodiment of the present application, the terminal can access the smart home system not only through the Internet, but also through the local area network, which can improve the applicability of the data synchronization method of the present application.
[0079] In addition, it should be noted that the above-mentioned cloud can be implemented based on a microservice cluster. Optionally, the microservice cluster can include: version service, home device service, basic configuration center, authorization service and other multiple microservices, which are used to return corresponding data to the terminal according to different types of data acquisition requests. There is no limitation here and it can be flexibly set according to the actual application scenario.
[0080] Figure 2 This is a flow chart of a data synchronization method provided in an embodiment of the present application. This method can be applied to the home server in the above-mentioned smart home system, such as Figure 2 As shown, the data synchronization method may include:
[0081] S101. Receive a first data acquisition request sent by the cloud. The first data acquisition request is a data acquisition request sent by the terminal to the cloud in response to a data acquisition operation and forwarded by the cloud when it determines that target data corresponding to the first data acquisition request is not the latest data. The first data acquisition request includes a terminal identifier.
[0082] Among them, in the smart home scenario, the terminal can be configured to access the smart home system through a preset web page or a preset home device management application. Optionally, when accessing, the terminal can be acted on by touch methods such as clicking, long pressing, re-pressing, sliding, etc. to generate a data acquisition operation. In response to the data acquisition operation, the terminal can send a first data acquisition request to the cloud in the smart home system to request to obtain target data. The first data acquisition request may include a terminal identifier; for the cloud, after receiving the first data acquisition request, if the cloud determines that the target data corresponding to the first data acquisition request stored in the cloud is not the latest data, the cloud can forward the first data acquisition request to the home server, and the home server can then receive the first data acquisition request sent remotely.
[0083] In some embodiments, the first data acquisition request may specifically be a version data acquisition request, a home device status parameter acquisition request, a smart home system basic configuration data acquisition request, an authorization information acquisition request, etc., without limitation herein. Alternatively, the terminal identifier may specifically be a terminal device serial number, a terminal name, etc., without limitation herein.
[0084] S102: According to the first data acquisition request, query and acquire target data corresponding to the first data acquisition request.
[0085] Among them, the home server in the smart home system can be understood as a home host. It can be understood that since the home server is generally in the same local area network as the home appliances to which it communicates, and various control operations on each home appliance need to be implemented by sending control instructions to each home appliance through the home server, the target data obtained by the home server according to the first data acquisition request will be the latest data.
[0086] S103: Send target data to the terminal corresponding to the terminal identifier according to the terminal identifier.
[0087] Based on the above description, after the home server queries and obtains the target data corresponding to the first data acquisition request, it can send the target data to the terminal corresponding to the terminal identifier carried in the first data acquisition request, so that the terminal can obtain the latest target data and ensure the accuracy of the acquired data.
[0088] It should be noted that the process of the home server sending the target data to the terminal corresponding to the terminal identifier can be direct or indirect, which is not limited here and can be flexibly determined according to the actual application scenario. Direct transmission means that the home server can directly send the target data to the terminal corresponding to the terminal identifier based on the terminal identifier; for indirect transmission, the home server can optionally return the acquired target data to the cloud, which will then send it to the terminal.
[0089] In summary, the embodiment of the present application provides a data synchronization method, which can be applied to a home server in a smart home system. The home server is communicatively connected to a terminal and a cloud in the smart home system respectively, and the home server is communicatively connected to at least one home device. The data synchronization method includes: receiving a first data acquisition request sent by the cloud, the first data acquisition request is a data acquisition request sent by the terminal to the cloud in response to a data acquisition operation, and forwarded by the cloud when it determines that the target data corresponding to the first data acquisition request is not the latest data, the first data acquisition request includes a terminal identifier; according to the first data acquisition request, querying and acquiring the target data corresponding to the first data acquisition request; according to the terminal identifier, sending the target data to the terminal corresponding to the terminal identifier. The application of the embodiment of the present application can enable the terminal to acquire the latest target data and ensure the accuracy of the acquired target data.
[0090] Figure 3 A flowchart of another data synchronization method provided in an embodiment of the present application. Figure 3 As shown, the above method also includes:
[0091] S201: Receive a data change request sent by a terminal.
[0092] Among them, data change requests may include: data requests for changing the status parameters of home appliances, data requests for changing the basic configuration of smart home systems, data requests for changing user permissions, etc., among which the change type may specifically be: data addition, data deletion, data modification, etc., which are not limited here.
[0093] In some embodiments, the terminal can access the smart home system through a preset web page or a preset home device management application, wherein a data change request can be generated according to the change requirements during the access process, and the generated data change request can be sent to the home server first, so that the home server can be updated in time according to the data change request sent by the terminal, thereby ensuring the timely update of home services and various home devices communicating with the home server.
[0094] S202: According to the data change request, the data to be changed corresponding to the data change request in the home server is updated.
[0095] S203: Send a data change response to the terminal, where the data change response is used to indicate whether the update is successful.
[0096] It can be understood that for the home server, after receiving the data change request sent by the terminal, the home server can update the data to be changed corresponding to the data change request, thereby realizing data synchronization between the terminal; further, after the home server is updated, it can send a data change response to the terminal, so that the terminal can know whether the home server is updated successfully according to the data change response, thereby realizing data synchronization between the terminal and the home server and improving the user's update experience.
[0097] Figure 4 A flowchart of another data synchronization method provided in an embodiment of the present application is shown. Figure 4 As shown, according to the data change request, after updating the data to be changed corresponding to the data change request, the above method further includes:
[0098] S301. Determine the data type corresponding to the data change request according to the data change request, and send a data change signal to the cloud so that the cloud marks the data type corresponding to the data change signal as a first identifier according to the data change signal.
[0099] The data change signal includes: the data type corresponding to the data change request and the server identifier of the home server.
[0100] Based on the smart home system provided by the embodiment of the present application, if the home server receives a data change request sent by the terminal, the home server can further obtain the data type corresponding to the data change request, and generate a data change signal based on the data type corresponding to the data change request and the server identifier of the home server. The generated data change signal can be sent to the cloud; for the cloud, after receiving the data change signal, the cloud can mark the data type corresponding to the data change signal in the cloud as a first identifier to indicate that the data corresponding to the first identifier is not the latest data.
[0101] Optionally, the home server's server identifier may include the home server's device serial number, serial number, or name, etc., without limitation. The data change signal may be sent to the cloud via HTTP, but the specific method of transmission is not limited thereto. Of course, this application does not specify the timing for the home server to send the data change signal; alternatively, the data change signal may be sent to the cloud asynchronously. Specifically, the signal may be sent according to a preset period, or when the home server is idle, without limitation.
[0102] S302: Receive a second data acquisition request sent by the cloud according to the data change signal.
[0103] Based on the above description, it can be seen that since the data corresponding to the first identifier in the data stored in the cloud is not the latest data, the cloud can generate a second data acquisition request based on the above data change signal and send it to the home server, so that the home server can obtain the changed data corresponding to the data change signal.
[0104] S303: Sending change data to the cloud according to the second data acquisition request, so that the cloud updates the data to be changed in the cloud according to the change data, and then marks the data type corresponding to the data change signal as a second identifier.
[0105] After receiving the second data acquisition request sent by the cloud, the home server can return the change data corresponding to the second data acquisition request to the cloud based on the second data acquisition request. After receiving the change data, the cloud can update the data to be changed in the cloud based on the change data, thereby achieving data synchronization between the cloud and the home server. The data to be changed in the cloud is the data type corresponding to the data change request in the cloud and the server identifier of the home server.
[0106] In addition, after the cloud updates the data to be changed, it is also necessary to mark the data type corresponding to the data change signal as a second identifier, so that the data corresponding to the second identifier can be represented as the latest data.
[0107] By applying the above embodiment, compared with the method of sending a large amount of change data directly to the cloud through the home server, the embodiment of the present application sends a second data acquisition request to the home server through the cloud, which can fully utilize the processing performance of the cloud; the method of sending data change signals to the cloud through the home server can greatly reduce the pressure on the home server and ensure the operating performance of the home server.
[0108] Figure 5 A flowchart of another data synchronization method provided in an embodiment of the present application. Figure 5 As shown, the above-mentioned sending of data change signals to the cloud includes:
[0109] S401: If it is determined that the data change signal sent to the cloud is not sent successfully, the data change task corresponding to the data change signal is stored in the first task queue.
[0110] S402: Read the data change signal corresponding to the data change task from the first task queue according to the first preset time interval, and resend the data change signal to the cloud.
[0111] Among them, considering that the home server may have abnormalities such as poor network signal and poor operating performance, the home server may fail to send the data change signal to the cloud. Optionally, in order to ensure the normal operation of the home server, the data change signal can be sent to the cloud in time. When it is determined that the data change signal sent to the cloud is not sent successfully, the home server can store the data change task corresponding to the unsuccessfully sent change signal in the first task queue, and poll the data change signal corresponding to each data change task from the first task queue according to the first preset time interval to resend it to the cloud.
[0112] Optionally, the first preset time interval may be 10 seconds, 30 seconds, 1 minute, etc., which is not limited here and may vary according to actual application scenarios.
[0113] Optionally, the receiving of the second data acquisition request sent by the cloud according to the data change signal includes:
[0114] A second data acquisition request corresponding to the data synchronization task acquired from the second task queue and sent by the cloud according to a second preset time interval is received.
[0115] When the cloud determines that the second data acquisition request sent to the home server according to the data change signal is not successfully sent, the cloud stores the data synchronization task corresponding to the second data acquisition request in the second task queue.
[0116] In some embodiments, the cloud may experience anomalies such as poor network signal or poor operating performance, which may result in the cloud failing to send a second data acquisition request to the home server in response to the data change signal. Optionally, in this case, the cloud can store the data synchronization task corresponding to the failed second data acquisition request in a second task queue and, at a second preset time interval, poll the second data acquisition request corresponding to each data synchronization task from the second task queue and resend it to the home server. It is understood that after receiving the second data acquisition request, the home server can send the changed data to the cloud in accordance with step S303 described above, which will not be further described here.
[0117] Optionally, the second preset time interval may be 10 seconds, 15 seconds, 30 minutes, etc., which is not limited here and may vary according to the actual application scenario. Of course, in some embodiments, the second preset time interval may be the same as or different from the first preset time interval, which is not limited here.
[0118] Optionally, if the cloud determines that the mark of the data type corresponding to the first data acquisition request is the first identifier, it is determined that the target data corresponding to the first data acquisition request is not the latest data.
[0119] Based on the above description, it can be understood that, for the cloud, each data type corresponds to an identifier, namely, a first identifier or a second identifier. Specifically, for data stored in the cloud, if the data type corresponding to the first data acquisition request is marked with the first identifier, it can be considered that the target data corresponding to the first data acquisition request is not the latest data. Otherwise, if it is marked with the second identifier, it can be considered that the target data corresponding to the first data acquisition request is the latest data.
[0120] In addition, it can also be understood that if the cloud determines that the data type corresponding to the first data acquisition request is marked as the second identifier, that is, the target data corresponding to the first data acquisition request stored in the cloud is the latest data, then the cloud can query and obtain the target data corresponding to the first data acquisition request and return it to the terminal.
[0121] Optionally, the above-mentioned change data may include full data of the data type corresponding to the data change request.
[0122] In some embodiments, considering that users may modify the data corresponding to the same home server based on multiple terminals, optionally, after receiving the second data acquisition request sent by the cloud, the home server can obtain the full data of the data type corresponding to the data change request, and send the full data of the data type corresponding to the data change request to the cloud, thereby ensuring the consistency of data synchronization between the home server and the terminal.
[0123] Figure 6 This is a flow chart of another data synchronization method provided in an embodiment of the present application. This method can be applied to the cloud in a smart home system. The cloud is connected to a home server and a terminal in the smart home system respectively. The home server is connected to at least one home device. Figure 6 As shown, the data synchronization method includes:
[0124] S501: Receive a first data acquisition request sent by a terminal in response to a data acquisition operation, where the first data acquisition request includes a terminal identifier.
[0125] S502: If it is determined that the target data corresponding to the first data acquisition request is not the latest data, forward the first data acquisition request to the home server, so that the home server acquires the target data according to the first data acquisition request and sends the target data to the terminal corresponding to the terminal identifier.
[0126] Among them, for the terminal, a data acquisition operation can be generated by acting on the terminal through touch methods such as clicking, long pressing, pressing hard, and sliding. In response to the data acquisition operation, the terminal can send a first data acquisition request including a terminal identifier to the cloud in the smart home system to request to obtain target data; after receiving the first data acquisition request, the cloud can determine whether the target data corresponding to the first data acquisition request is the latest data. If it is not the latest data, the cloud can forward the first data acquisition request to the home server so that the home server can obtain the target data corresponding to the first data acquisition request, and then send the target data to the terminal corresponding to the terminal identifier. By applying the embodiments of the present application, the terminal can obtain the latest target data during the data synchronization process, ensuring the accuracy of the acquired target data.
[0127] Optionally, the process of sending target data to the terminal corresponding to the terminal identifier can be that the home server directly sends the target data to the terminal corresponding to the terminal identifier, or the cloud can forward the target data sent by the home server to the terminal corresponding to the terminal identifier. It can be flexibly selected according to the actual application scenario and is not limited here.
[0128] Figure 7 A flowchart of another data synchronization method provided in an embodiment of the present application. Figure 7 As shown, the above method also includes:
[0129] S601: If the cloud receives data change signals sent by multiple home servers, it uses multiple threads to send a second data acquisition request to the home servers corresponding to each data change signal.
[0130] S602: Receive the change data sent by each home server according to each second data acquisition request.
[0131] Considering that in a smart home scenario, the cloud may communicate with multiple home servers, that is, the cloud may receive data change signals sent by multiple home servers. In this case, the cloud can use multiple threads to send a second data acquisition request to each home server corresponding to each data change signal. After receiving the second data acquisition request, each home server can send the change data corresponding to each second data acquisition request to the cloud. Furthermore, the cloud can receive the change data sent by each home server. For details about this part, please refer to the relevant description of the aforementioned step S303 and will not be repeated here. Based on the above description, it can be seen that the application of the embodiment of the present application can ensure the timeliness and reliability of data synchronization between the cloud and multiple home servers.
[0132] Based on the above description, optionally, for the cloud, the cloud can be configured to receive data acquisition requests with large data access volume, such as the management homepage of the smart home system, the list of home devices under the home server, and user authority information, sent by the terminal, so as to reduce the loading pressure of the home server and ensure the operating performance of the home server.
[0133] Figure 8 This is a flow chart of another data synchronization method provided in an embodiment of the present application. This method can be applied to a terminal in a smart home system. The terminal is connected to a home server and a cloud in the smart home system respectively. The home server is connected to at least one home device. Figure 8 As shown, the data synchronization method may include:
[0134] S701. In response to a data acquisition operation, send a first data acquisition request to the cloud, where the first data acquisition request includes a terminal identifier.
[0135] S702. Receive target data returned by the home server according to the first data acquisition request, wherein the cloud forwards the first data acquisition request to the home server when determining that the target data corresponding to the first data acquisition request sent by the terminal is not the latest data.
[0136] For the description of steps S701 and S702, please refer to the description of the aforementioned steps S101 and S102, or refer to the description of the aforementioned steps S501 and S502, which will not be repeated here. Based on the above description, it can be seen that the application of the embodiment of the present application can enable the terminal to obtain the latest target data during the data synchronization process, ensuring the accuracy of the obtained target data.
[0137] In addition, it should be noted that the terminal receives the target data returned by the home server according to the first data acquisition request. Specifically, the terminal may receive the target data directly returned by the home server according to the first data acquisition request, or the terminal may receive the target data returned by the home server according to the first data acquisition request forwarded by the cloud. It may be different according to the actual application scenario.
[0138] Figure 9 This is a functional module diagram of a data synchronization device provided in an embodiment of the present application. The data synchronization device can be applied to a home server in a smart home system. The home server is connected to the terminal and the cloud in the smart home system respectively. The home server is connected to at least one home appliance. The basic principle and technical effects of the device are the same as those of the corresponding method embodiment described above. For the sake of brief description, the parts not mentioned in this embodiment can be referred to the corresponding content in the method embodiment. Figure 9 As shown, the data synchronization device 200 may include:
[0139] A receiving module 210 is configured to receive a first data acquisition request sent by the cloud, wherein the first data acquisition request is sent by the terminal to the cloud in response to a data acquisition operation and forwarded by the cloud when the cloud determines that target data corresponding to the first data acquisition request is not the latest data, and the first data acquisition request includes a terminal identifier;
[0140] An acquisition module 220 is configured to query and acquire target data corresponding to the first data acquisition request according to the first data acquisition request;
[0141] The sending module 230 is configured to send the target data to the terminal corresponding to the terminal identifier according to the terminal identifier.
[0142] In an optional embodiment, the data synchronization device further includes: a change module, configured to receive a data change request sent by a terminal;
[0143] According to the data change request, updating the to-be-changed data corresponding to the data change request in the home server;
[0144] A data change response is sent to the terminal, where the data change response is used to indicate whether the update is successful.
[0145] In an optional embodiment, the change module is further configured to determine, based on the data change request, a data type corresponding to the data change request, and send a data change signal to the cloud so that the cloud marks the data type corresponding to the data change signal as a first identifier based on the data change signal, wherein the data change signal includes: the data type corresponding to the data change request and the server identifier of the home server;
[0146] receiving a second data acquisition request sent by the cloud in response to the data change signal;
[0147] Sending change data to the cloud according to the second data acquisition request, so that the cloud updates the data to be changed in the cloud according to the change data, and then marking the data type corresponding to the data change signal as a second identifier.
[0148] In an optional embodiment, the changing module is specifically configured to store the data changing task corresponding to the data changing signal in the first task queue if it is determined that the data changing signal sent to the cloud is not sent successfully;
[0149] According to a first preset time interval, a data change signal corresponding to the data change task is read from the first task queue, and the data change signal is resent to the cloud.
[0150] In an optional embodiment, the change module is specifically used to receive a second data acquisition request corresponding to the data synchronization task obtained from the second task queue and sent by the cloud according to a second preset time interval, wherein when the cloud determines that the second data acquisition request sent to the home server according to the data change signal is not successfully sent, the cloud stores the data synchronization task corresponding to the second data acquisition request in the second task queue.
[0151] In an optional implementation, if the cloud determines that the mark of the data type corresponding to the first data acquisition request is the first identifier, it is determined that the target data corresponding to the first data acquisition request is not the latest data.
[0152] In an optional implementation, the change data includes full data of the data type corresponding to the data change request.
[0153] Optionally, the present invention further provides a data synchronization device, which is applied to a cloud in a smart home system, wherein the cloud is communicatively connected to a home server and a terminal in the smart home system, respectively, and the home server is communicatively connected to at least one home appliance. The data synchronization device comprises:
[0154] A receiving module, configured to receive a first data acquisition request sent by a terminal in response to a data acquisition operation, wherein the first data acquisition request includes a terminal identifier;
[0155] a forwarding module, configured to forward the first data acquisition request to the home server if it is determined that the target data corresponding to the first data acquisition request is not the latest data, so that the home server acquires the target data according to the first data acquisition request and sends the target data to the terminal corresponding to the terminal identifier.
[0156] In an optional embodiment, the data synchronization device further includes: an update module, configured to use multiple threads to send a second data acquisition request to each home server corresponding to each data change signal if the cloud receives data change signals sent by multiple home servers;
[0157] Receive the change data sent by each home server according to each second data acquisition request.
[0158] Optionally, the present invention further provides a data synchronization device, which is applied to a terminal in a smart home system, wherein the terminal is communicatively connected to a home server and a cloud in the smart home system, respectively, and the home server is communicatively connected to at least one home appliance. The data synchronization device comprises:
[0159] a response module, configured to send a first data acquisition request to the cloud in response to the data acquisition operation, wherein the first data acquisition request includes a terminal identifier;
[0160] A receiving module is used to receive the target data returned by the home server according to the first data acquisition request, wherein the cloud forwards the first data acquisition request to the home service when it is determined that the target data corresponding to the first data acquisition request sent by the terminal is not the latest data.
[0161] The above-mentioned device is used to execute the method provided in the above-mentioned embodiment. Its implementation principle and technical effect are similar and will not be repeated here.
[0162] The above modules can be one or more integrated circuits configured to implement the above methods, such as one or more application-specific integrated circuits (ASICs), one or more microprocessors, or one or more field programmable gate arrays (FPGAs). For another example, when a module is implemented by scheduling program code through a processing element, the processing element can be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules can be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0163] Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device can be integrated into the above-mentioned data synchronization device. Figure 10 As shown, the electronic device may include: a processor 310, a storage medium 320, and a bus 330. The storage medium 320 stores machine-readable instructions executable by the processor 310. When the electronic device is running, the processor 310 and the storage medium 320 communicate via the bus 330, and the processor 310 executes the machine-readable instructions to perform the steps of the above-mentioned method embodiment. The specific implementation methods and technical effects are similar and will not be repeated here.
[0164] Optionally, the present application further provides a storage medium storing a computer program, which, when executed by a processor, executes the steps of the above method embodiment. The specific implementation and technical effects are similar and will not be described in detail here.
[0165] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0166] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0167] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0168] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) or a processor (English: processor) to perform some steps of the methods of each embodiment of the present application. The aforementioned storage medium includes: a USB flash drive, a mobile hard disk, a read-only memory (English: Read-Only Memory, abbreviated: ROM), a random access memory (English: Random Access Memory, abbreviated: RAM), a magnetic disk or an optical disk, and other media that can store program code.
[0169] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device that includes the element.
[0170] The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application. It should be noted that similar numbers and letters represent similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application.
Claims
1. A data synchronization method, characterized in that: A home server is applied to a smart home system, wherein the home server is communicatively connected to a terminal and a cloud in the smart home system, and the home server is communicatively connected to at least one home device. The data synchronization method includes: receiving a first data acquisition request sent by the cloud, where the first data acquisition request is sent by the terminal to the cloud in response to a data acquisition operation and forwarded by the cloud when it is determined that target data corresponding to the first data acquisition request is not the latest data, and the first data acquisition request includes a terminal identifier; According to the first data acquisition request, query and acquire target data corresponding to the first data acquisition request; sending the target data to a terminal corresponding to the terminal identifier according to the terminal identifier; Receiving data change requests sent by terminals; According to the data change request, updating the to-be-changed data corresponding to the data change request in the home server; According to the data change request, a data change signal is sent to the cloud so that the cloud marks the data type corresponding to the data change signal as a first identifier according to the data change signal, wherein the data change signal includes: the data type corresponding to the data change request and the server identifier of the home server; receiving a second data acquisition request sent by the cloud in response to the data change signal; Sending change data to the cloud according to the second data acquisition request, so that the cloud updates the data to be changed in the cloud according to the change data, and then marking the data type corresponding to the data change signal as a second identifier.
2. The method according to claim 1, characterized in that After updating the data to be changed corresponding to the data change request in the home server according to the data change request, the method further includes: A data change response is sent to the terminal, where the data change response is used to indicate whether the update is successful.
3. The method according to claim 1, characterized in that The sending of the data change signal to the cloud comprises: If it is determined that the data change signal sent to the cloud is not sent successfully, storing the data change task corresponding to the data change signal in the first task queue; According to a first preset time interval, a data change signal corresponding to the data change task is read from the first task queue, and the data change signal is resent to the cloud.
4. The method according to claim 1, wherein The receiving a second data acquisition request sent by the cloud according to the data change signal includes: Receive a second data acquisition request corresponding to the data synchronization task obtained from the second task queue and sent by the cloud according to a second preset time interval, wherein when the cloud determines that the second data acquisition request sent to the home server according to the data change signal is not successfully sent, the cloud stores the data synchronization task corresponding to the second data acquisition request in the second task queue.
5. The method according to claim 1, characterized in that If the cloud determines that the mark of the data type corresponding to the first data acquisition request is the first identifier, it is determined that the target data corresponding to the first data acquisition request is not the latest data.
6. The method according to claim 1, characterized in that The changed data includes the full amount of data of the data type corresponding to the data change request.
7. A data synchronization method, characterized in that: Applied to a cloud in a smart home system, the cloud is communicatively connected to a home server and a terminal in the smart home system, the home server is communicatively connected to at least one home device, and the data synchronization method includes: receiving a first data acquisition request sent by a terminal in response to a data acquisition operation, wherein the first data acquisition request includes a terminal identifier; If it is determined that the target data corresponding to the first data acquisition request is not the latest data, forwarding the first data acquisition request to the home server, so that the home server acquires the target data according to the first data acquisition request and sends the target data to the terminal corresponding to the terminal identifier; receiving a data change signal sent by the home server after the home server updates the data to be changed corresponding to the data change request, the data change signal including: a data type corresponding to the data change request and a server identifier of the home server, the data change signal being generated by the home server according to the data change request sent by the terminal; According to the data change signal, marking the data type corresponding to the data change signal as a first identifier; a second data acquisition request sent to the home server according to the data change signal; receiving the change data sent by the home server according to the second data acquisition request, updating the data to be changed in the cloud according to the change data, and marking the data type corresponding to the data change signal as a second identifier.
8. The method according to claim 7, characterized in that The method further comprises: If the cloud receives data change signals sent by multiple home servers, it uses multiple threads to send a second data acquisition request to each home server corresponding to the data change signal; Receive the change data sent by each home server according to each second data acquisition request.
9. A data synchronization method, characterized in that: A terminal is applied to a smart home system, wherein the terminal is communicatively connected to a home server and a cloud in the smart home system, and the home server is communicatively connected to at least one home device. The data synchronization method includes: In response to the data acquisition operation, sending a first data acquisition request to the cloud, where the first data acquisition request includes a terminal identifier; receiving target data returned by the home server according to the first data acquisition request, wherein the cloud forwards the first data acquisition request to the home server when determining that the target data corresponding to the first data acquisition request sent by the terminal is not the latest data; Sending a data change request to the home server so that the home server updates the data to be changed corresponding to the data change request in the home server according to the data change request; sending a data change signal to the cloud according to the data change request so that the cloud marks the data type corresponding to the data change signal as a first identifier according to the data change signal, wherein the data change signal includes: the data type corresponding to the data change request and the server identifier of the home server; receiving a second data acquisition request sent by the cloud according to the data change signal; sending change data to the cloud according to the second data acquisition request so that the cloud updates the data to be changed in the cloud according to the change data, and then marks the data type corresponding to the data change signal as a second identifier.
10. An electronic device, characterized in that: include: A processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the storage medium communicate through the bus, and the processor executes the machine-readable instructions to perform the steps of the data synchronization method as described in any one of claims 1 to 9.
11. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data synchronization method according to any one of claims 1 to 9 are executed.
Citation Information
Patent Citations
Status information update method and device of smart home equipment
CN106453657A