CN113419437A - Intelligent home data synchronization method and device based on MVVM (multifunction vehicle management model) framework and MQTT (message queuing time) protocol - Google Patents

Intelligent home data synchronization method and device based on MVVM (multifunction vehicle management model) framework and MQTT (message queuing time) protocol Download PDF

Info

Publication number
CN113419437A
CN113419437A CN202110737091.7A CN202110737091A CN113419437A CN 113419437 A CN113419437 A CN 113419437A CN 202110737091 A CN202110737091 A CN 202110737091A CN 113419437 A CN113419437 A CN 113419437A
Authority
CN
China
Prior art keywords
data
identifier
equipment
interactive
value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110737091.7A
Other languages
Chinese (zh)
Other versions
CN113419437B (en
Inventor
高崇阳
康弦
刘皓
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sichuan Hongmei Intelligent Technology Co Ltd
Original Assignee
Sichuan Hongmei Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sichuan Hongmei Intelligent Technology Co Ltd filed Critical Sichuan Hongmei Intelligent Technology Co Ltd
Priority to CN202110737091.7A priority Critical patent/CN113419437B/en
Publication of CN113419437A publication Critical patent/CN113419437A/en
Application granted granted Critical
Publication of CN113419437B publication Critical patent/CN113419437B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B15/00Systems controlled by a computer
    • G05B15/02Systems controlled by a computer electric
    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B19/00Programme-control systems
    • G05B19/02Programme-control systems electric
    • G05B19/418Total factory control, i.e. centrally controlling a plurality of machines, e.g. direct or distributed numerical control [DNC], flexible manufacturing systems [FMS], integrated manufacturing systems [IMS], computer integrated manufacturing [CIM]
    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B2219/00Program-control systems
    • G05B2219/20Pc systems
    • G05B2219/26Pc applications
    • G05B2219/2642Domotique, domestic, home control, automation, smart house
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/02Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]

Abstract

The embodiment of the specification provides an intelligent home data synchronization method and device based on an MVVM (multifunction vehicle virtual machine) framework and an MQTT (maximum transmission time) protocol, wherein the method comprises the following steps: when an interactive interface of the intelligent home client is opened, starting a poller, detecting whether a user operates on the interactive interface in real time, and setting a preset interrupt identifier to be a first value when the user operates on the interactive interface is detected; responding to each operation of a user on the interactive interface, updating data of the interactive object, and sending a corresponding control instruction to the intelligent home equipment; after feedback information returned by the intelligent household equipment after the intelligent household equipment executes the control instruction is received, data updating is carried out on the equipment object; and if the poller detects that the preset interrupt identifier is a second value, assigning the equipment object to the interactive object, updating the interactive interface according to the updated interactive object, and waiting for next polling. The invention can reduce the phenomenon of display content jumping in the interactive interface.

Description

Intelligent home data synchronization method and device based on MVVM (multifunction vehicle management model) framework and MQTT (message queuing time) protocol
Technical Field
One or more embodiments of the present disclosure relate to the technical field of internet of things, and in particular, to a method and an apparatus for synchronizing data of smart homes based on an MVVM framework and an MQTT protocol.
Background
In an intelligent home system, an appliance control system, a light control system, a home security system, a video entertainment control system and the like all use an MQTT (Message Queuing Telemetry Transport) protocol to perform data transmission and communication. In the application layer of the mobile phone, an application software is developed to control the smart home system by using an MVVM (fully called Model-View Model, i.e. data Model-View Model) architecture. The MVVM is a software architecture mode, and the view data and the UI (all called User Interface, namely User interaction Interface) are bound through a ViewModel in the MVVM, so that the drive of the view data to the UI is realized. The MQTT is a "lightweight" communication protocol based on a publish/subscribe (i.e., publish/subscribe) mode, and in some application software using the MVVM as an application development framework, a phenomenon that a user frequently operates a UI interface of a mobile phone end to cause data hopping of the UI interface occurs.
For example, a user sets the cabin temperature of a refrigerator to be-5 ℃ by using a mobile phone App, the display temperature of a mobile phone UI is-5 ℃, and a mobile phone end sends a related first control instruction to intelligent household equipment through an MQTT protocol; at the moment, the user continues to set the refrigerator temperature to be 0 ℃, the mobile phone UI interface also shows that the temperature is 0 ℃, the second control instruction is sent to the intelligent household equipment again, the refrigerator equipment responds to the first control instruction and returns data to the mobile phone end, the current refrigerator is informed that the setting at minus 5 ℃ is successful, the mobile phone UI can be immediately modified through the ViewModel layer by the data at minus 5 ℃, and the mobile phone interface is changed from the currently displayed 0 ℃ to minus 5 ℃. After a time interval, the refrigerator equipment end responds to the second control instruction and returns data to the mobile phone end to inform that the current refrigerator is successfully set at 0 ℃ to cause the UI of the mobile phone end to jump from-5 ℃ to 0 ℃, so that the data jump caused by the delayed feedback of the equipment end greatly influences the use experience of a user.
Disclosure of Invention
One or more embodiments of the present specification describe an intelligent home data synchronization method and apparatus based on an MVVM framework and an MQTT protocol, which can reduce a phenomenon of display content jumping in an interactive interface.
The application provides an intelligent home data synchronization method based on an MVVM (multifunction vehicle virtual machine) frame and an MQTT (multiple quantum dots) protocol, the method is executed by an intelligent home client developed based on the MVVM frame, data transmission is carried out between the intelligent home client and intelligent home equipment through the MQTT protocol, and the method comprises the following steps:
when an interactive interface of an intelligent home client is opened, starting a poller, detecting whether a user operates on the interactive interface in real time, and setting a preset interrupt identifier as a first value when the user operates on the interactive interface is detected, wherein the initial value of the preset interrupt identifier is a second value; the polling device is used for detecting the preset interrupt identifier once every preset time length;
responding to each operation of a user on the interactive interface, updating data of a preset created interactive object according to the state of the interactive page after the operation, and sending a corresponding control instruction to the intelligent home equipment; the interactive object is used for representing the current state of the interactive page;
after feedback information returned by the intelligent household equipment after the control instruction is executed is received, updating data of a pre-established equipment object according to the feedback information; the equipment object is used for representing the current state of the intelligent household equipment;
in each polling, if the poller detects that the preset interrupt identifier is the first value, setting the preset interrupt identifier as a second value, and waiting for next polling; and if the poller detects that the preset interrupt identifier is the second value, assigning the equipment object to the interactive object, updating the interactive interface according to the updated interactive object, and waiting for next polling.
The application provides an intelligent house data synchronizer based on MVVM frame and MQTT agreement, the device is located based on the intelligent house client of MVVM frame development, just carry out data transmission through the MQTT agreement between intelligent house client and the intelligent house equipment, the device includes:
the polling detection module is used for starting a poller when an interactive interface of the intelligent home client is opened, detecting whether a user operates on the interactive interface in real time, and setting a preset interrupt identifier as a first value when the user operates on the interactive interface is detected, wherein the initial value of the preset interrupt identifier is a second value; the polling device is used for detecting the preset interrupt identifier once every preset time length;
the first updating module is used for responding to each operation of a user on the interactive interface, updating data of a preset and established interactive object according to the state of the interactive page after the operation, and sending a corresponding control instruction to the intelligent home equipment; the interactive object is used for representing the current state of the interactive page;
the second updating module is used for updating data of a pre-established equipment object according to feedback information after the feedback information returned by the intelligent household equipment after the intelligent household equipment executes the control instruction is received; the equipment object is used for representing the current state of the intelligent household equipment;
a third updating module, configured to, in each polling, set the preset interrupt identifier to a second value if the poller detects that the preset interrupt identifier is the first value, and wait for next polling; and if the poller detects that the preset interrupt identifier is the second value, assigning the equipment object to the interactive object, updating the interactive interface according to the updated interactive object, and waiting for next polling.
The intelligent home data synchronization method and device based on the MVVM frame and the MQTT protocol respectively store the equipment state and the interactive interface state, set a preset interrupt identifier to represent whether a user operates on the interactive interface or not, and set a polling device, wherein the polling device detects the preset interrupt identifier once every preset time. And when the preset interrupt identifier is a first value, the operation of the user on the interactive interface is indicated, and at the moment, the preset interrupt identifier is only modified into a second value to wait for next polling. And only when the preset interrupt identifier is a second value, the interactive object is updated according to the equipment object, and then the interactive interface is updated. It can be seen that the interactive interface is not updated after the device state returned by the smart home device is received, but the interactive interface is updated after the user does not operate on the interactive interface. And the interactive interface is not updated as soon as the user does not operate on the interactive interface, but is updated after the detection time of the poller is reached. That is, the mode that the polling device detects the preset interrupt identifier is adopted, and even if the user does not operate on the interactive interface, the user interface can be updated only when the detection time of the polling device is reached. By the method, the updating of the interactive interface is delayed as far as possible, and the interactive interface is updated as far as possible according to the equipment state corresponding to the last operation of the user on the interactive interface, so that the problem of interface data jumping caused by delayed return of the intelligent household equipment to the equipment state is reduced as far as possible, and the use experience of the user is improved.
Drawings
In order to more clearly illustrate the embodiments of the present specification or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present specification, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a schematic flowchart of a smart home data synchronization method based on an MVVM framework and an MQTT protocol in an embodiment of the present disclosure;
fig. 2 is a schematic structural diagram of an intelligent home data synchronization device based on an MVVM framework and an MQTT protocol in an embodiment of the present specification.
Detailed Description
The scheme provided by the specification is described below with reference to the accompanying drawings.
The embodiment of the application provides an intelligent home data synchronization method based on an MVVM (multifunction vehicle virtual machine) frame and an MQTT (maximum transmission part) protocol, the method is executed by an intelligent home client developed based on the MVVM frame, and data transmission is carried out between the intelligent home client and intelligent home equipment through the MQTT protocol.
As shown in fig. 1, the method includes:
s110, when an interactive interface of the smart home client is opened, starting a poller, detecting whether a user operates on the interactive interface in real time, and setting a preset interrupt identifier as a first value when detecting that the user operates on the interactive interface, wherein the initial value of the preset interrupt identifier is a second value; the polling device is used for detecting the preset interrupt identifier once every preset time length;
that is to say, when the interactive interface is opened, the polling device is started, and meanwhile, whether the user operates on the interactive interface is detected in real time, and the preset interrupt identifier is set according to the detection result.
The initial value of the interrupt identifier is a second value, the interrupt identifier is updated to a first value when the fact that the user operates the interactive interface is detected, and the interrupt identifier is kept unchanged when the user does not operate the interactive interface. It can be seen that the preset interrupt flag transitions between a first value and a second value, and thus the preset interrupt flag may be, but is not limited to, of boolean type. For example, the first value is true and the second value is false.
When the interactive interface of the intelligent home client is started, the poller is started, and the poller is used for detecting the preset interrupt identifier according to the preset duration. For example, the preset duration is 4s, and the poller performs detection every 4s, specifically detecting whether the preset interrupt identifier is the first value or the second value at present.
S120, responding to each operation of a user on the interactive interface, updating data of a preset and established interactive object according to the state of the interactive page after the operation, and sending a corresponding control instruction to the intelligent home equipment; the interactive object is used for representing the current state of the interactive page;
an interactive object is provided for identifying the current state of the interactive page. Every time the user operates the interactive interface once, the display content of the interactive interface is modified once, and the interactive object needs to be updated once, for example, the temperature of the refrigerator is displayed on the interactive interface at 0 ℃, the temperature of the refrigerator is changed on the interactive interface by the user to be-1 ℃, and the temperature of the refrigerator is updated to be-1 ℃; the user changes the refrigerator temperature to-2 ℃ on the interactive interface, and the interactive object is updated to the refrigerator temperature to-2 ℃; and then the user changes the refrigerator temperature to-3 ℃, the interactive object is updated to the refrigerator temperature of-3 ℃, and the interactive object is updated along with the operation of the user on the interactive interface.
Certainly, the client sends a control instruction once every time the user performs an operation on the interactive interface, in the above example, the user changes the temperature of the refrigerator to-1 ℃ on the interactive interface, and the client sends the control instruction set to-1 ℃ to the refrigerator; the user changes the temperature of the refrigerator to-2 ℃ on the interactive interface, and the client sends a control instruction set to-2 ℃ like the refrigerator; and then the user changes the temperature of the refrigerator to-3 ℃, and the client sends a control instruction set to-3 ℃ to the refrigerator.
It will be appreciated that the client will set the interrupt flag to a first value when the user is operating on the interactive interface.
S130, after feedback information returned after the intelligent household equipment executes the control instruction is received, updating data of a pre-established equipment object according to the feedback information; the equipment object is used for representing the current state of the intelligent household equipment;
it can be understood that, when the smart home device receives a control instruction, corresponding operation is performed according to the control instruction, for example, when a control instruction for changing the temperature of the refrigerator to-3 ℃ is received, the smart refrigerator adjusts the temperature, and returns feedback information for successfully changing the temperature of the refrigerator to-3 ℃ to the client after the adjustment is successful, and the state of the refrigerator at this time is embodied in the feedback information: the refrigerator temperature was-3 ℃. And after the feedback information is received, updating the equipment object.
It can be understood that, each time the smart home device receives a control instruction, the smart home device executes the control instruction, and returns feedback information to the client after executing the control instruction, and the client updates the device object each time the client receives the feedback information, so that the device object represents the current state of the smart home device.
S140, in each polling, if the poller detects that the preset interrupt identifier is the first value, setting the preset interrupt identifier as a second value, and waiting for next polling; and if the poller detects that the preset interrupt identifier is the second value, assigning the equipment object to the interactive object, updating the interactive interface according to the updated interactive object, and waiting for next polling.
It can be understood that in one polling, there are two cases when the poller detects the preset interrupt identifier: one is to preset the interrupt flag to a first value, and one is to preset the interrupt flag to a second value.
And when the preset interrupt identifier is a first value, indicating that the user still operates on the interactive interface, and not updating the interactive interface according to the state of the equipment. And, updating the preset interrupt flag to a second value. According to the method and the device, the client can detect whether the user operates on the interactive interface in real time, when the fact that the user still operates on the interactive interface is detected, the client can set the preset interrupt identifier to be a first value, and if the fact that the user does not operate on the interactive interface is not detected, the client cannot update the preset interrupt identifier, namely the preset interrupt identifier keeps a second value unchanged. Thus, when the polling is finished, waiting for next polling, namely waiting for the preset duration to detect whether the preset interrupt identifier is the first value or the second value.
When the user frequently operates, the client updates the interactive object along with the operation of the user, sends a control instruction to the intelligent home equipment, and does not perform data synchronization between the equipment object and the interactive object at the moment. And after receiving the equipment state and waiting for the detection time of the poller, the client detects whether the preset interrupt identifier is a first value or a second value, and synchronizes the equipment object to the interactive object if the preset interrupt identifier is the second value, so as to update the interactive interface.
In a specific implementation, if the poller detects that the preset interrupt flag is the second value, before assigning the device object to the interactive object, the method may further include: judging whether the equipment object is consistent with the interactive object; and if not, executing the step of assigning the equipment object to the interactive object.
That is, if the device object and the interactive object are consistent, it is not necessary to update the interactive object, and when the device object and the interactive object are not consistent, the interactive object is updated according to the device object, and then the interactive interface is updated.
It can be understood that since the state data of the interactive interface and the device state are stored separately, rather than using one copy of data, the client is prevented from directly modifying the interactive interface as soon as the device state is received.
When the preset interrupt identifier is a second value, it indicates that the user does not currently operate on the interactive interface, and at this time, the interactive interface may be updated according to the state of the device. The specific updating process is as follows: and assigning the equipment object to the interactive object, namely updating the interactive object according to the equipment object to ensure that the interactive object is consistent with the equipment object. And then triggering the updating of the interactive interface, namely updating the interactive interface according to the updated interactive object. It can be seen that, here, the interactive interface is not updated after the device state returned by the smart home device is received, but the interactive interface is updated after the user does not operate on the interactive interface. And the interactive interface is not updated as soon as the user does not operate on the interactive interface, but is updated after the detection time of the poller is reached. That is, the mode that the polling device detects the preset interrupt identifier is adopted, and even if the user does not operate on the interactive interface, the user interface can be updated only when the detection time of the polling device is reached. By the method, the updating of the interactive interface is delayed as far as possible, and the interactive interface is updated as far as possible according to the equipment state corresponding to the last operation of the user on the interactive interface, so that the problem of interface data jumping caused by delayed return of the intelligent household equipment to the equipment state is reduced as far as possible.
In the invention, the client is developed based on an MVVM (multifunction vehicle virtual machine) architecture, and the client and the intelligent household equipment are communicated through an MQTT (message queuing time) protocol. The invention mainly aims at solving the problem of data synchronization caused by inconsistency between the content displayed on an interactive interface and the equipment state returned by the equipment in the communication process. In the invention, the equipment object for storing the equipment state and the interactive object for storing the interactive interface state are separated, and the data jumping problem on the interactive interface of the client is solved by delaying one end of time and then synchronizing, thereby improving the use experience of the user.
In specific implementation, the client and the smart home device may have a problem of an analysis error due to a large data volume, and in order to avoid the analysis error as much as possible, the client may process the received data by using the following steps:
s10, when a data sub-package sent by the intelligent household equipment is received, the data sub-package is placed into a buffer queue; the intelligent home equipment generates feedback information, the total length of the feedback information and a corresponding data type into a data long packet, wherein the data long packet comprises a length field, a type field and a data field, the length field is used for storing the total length of the feedback information, the type field is used for storing the data type, and the data field is used for storing the feedback information; dividing the long data packet into a plurality of data sub-packets according to a preset length, adding an equipment identification field and an instruction identification field in each data sub-packet, and sending the equipment identification field and the instruction identification field to the intelligent home client one by one; the instruction identification field is used for storing an instruction identification corresponding to the corresponding control instruction;
here, a device identification field is added to each data sub-packet to identify which device the data sub-packet originates from, because there are multiple smart home devices in the smart home environment, such as a refrigerator, a television, a sweeping robot, etc. In order to distinguish different home intelligent settings, a corresponding device identifier is set for each intelligent home device. Therefore, when the client receives a data sub-packet, the client knows from which smart home device the data sub-packet comes from.
Here, an instruction identification field is further added in each data sub-packet to identify which control instruction the data sub-packet is for, because a user may frequently operate on the interactive interface, multiple operations may generate multiple control instructions, and in order to distinguish the multiple control instructions, an instruction identification field is set in each data sub-packet.
The source of the data sub-packet and the control instruction for which can be distinguished by the instruction identification field and the equipment identification field, can not cause confusion.
The length field is used to identify the total length of the feedback information, and may occupy one byte. The type field is used to identify the type of the feedback information, which may be various types, such as text, picture, video, etc., but in this application, the feedback information is text, and if other types are received, it indicates that the feedback information is wrong. The type field may occupy one byte. The data field is used to store feedback information, e.g., information that the refrigerator was successfully set to-5 degrees celsius. The data field may need to occupy multiple bytes. Some feedback information has a large information amount and occupies a large number of bytes, so that one data sub-packet cannot be stored, and a plurality of data sub-packets are required to be stored. For example, two data sub-packets are divided, one data sub-packet may include a length field, a type field, and a portion of a data field, and the other data sub-packet may include the remaining portion of another number field. For another example, the division into three data subsets includes: the first data sub-packet comprises a length field and a part of a data field; the second data sub-packet includes the remaining portion of the data field; the third data sub-packet includes a type field. All the data sub-packets form the data long packet.
S20, taking out a data sub-packet from the buffer queue, judging whether the device identifier in the device identifier field corresponding to the data sub-packet is the device identifier in the pre-constructed configuration set, if so, judging whether the instruction identifier in the instruction identifier field is the identifier corresponding to the control instruction sent by the client; if yes, go to S30;
a configuration set is maintained at a client, and a plurality of equipment identifications, such as a refrigerator identification of a certain family, a sweeping robot identification, a television identification, a sound identification and other identifications of a plurality of intelligent household equipment, are set in the configuration set. And only if the equipment identification in the equipment identification field in the data sub-package belongs to the equipment identification in the configuration set, the subsequent judgment step is carried out. In the subsequent judging step, judging whether the instruction identifier in the instruction identifier field is an identifier corresponding to the control instruction sent by the client, if so, entering the subsequent step, otherwise, exiting the data analyzing process.
S30, analyzing the data sub-package to obtain the content in each field contained in the data sub-package; the content in each field in the data sub-packet can be obtained by analyzing the data sub-packet, so as to execute the subsequent steps.
S40, determining whether a data type field is analyzed according to the data sub-package of the same device identifier and instruction identifier which are analyzed currently; if the data type field is analyzed, judging whether the data type in the data type field is a preset data type; if yes, determining whether the length field is analyzed according to the data sub-package of the same equipment identifier and instruction identifier which are analyzed currently; if the length field is analyzed, judging whether the sum of the lengths of the data streams in the analyzed data field in the data sub-packets with the same equipment identifier reaches the total length of the feedback information in the length field;
here, whether the type field is analyzed is judged, and whether the data type in the type field is a preset data type is judged, where the preset data type may be a text type. And if the data type field is determined not to be analyzed according to the data sub-packet of the same equipment identifier and the same instruction identifier which are analyzed currently, taking out the next data sub-packet of the same equipment identifier and the same instruction identifier from the cache queue, and returning to the step S30.
Of course, if the data type in the data type field of the data sub-packet is not the preset data type, the parsing of the data sub-packet ending the current device identifier and the instruction identifier is performed.
In the step, whether a length field is analyzed or not is further judged, whether the total length of the data field in each analyzed data sub-packet reaches the total length in the length field or not is judged, and if the total length reaches the total length in the length field, it is indicated that the feedback information of the intelligent home equipment aiming at the control instruction is received completely.
Of course, in S40, if it is determined that the length field has not been parsed from the data subpacket identified by the same device identifier and instruction identifier that have been currently parsed, the next data subpacket identified by the same device identifier and instruction identifier may be fetched from the buffer queue and returned to S30.
S50, if the sum of the lengths reaches the total length of the feedback information, the receiving is completed, and data updating is carried out on the pre-established equipment object according to the received feedback information;
it can be understood that after the sum of the lengths reaches the total length in the length field, the device object can be updated by using the feedback information after the reception is completed.
And S60, if the sum of the lengths is less than the total length of the feedback information, taking out the next data sub-packet with the same equipment identifier and instruction identifier from the buffer queue, and returning to S30.
Of course, if the sum of the lengths is smaller than the total length in the length field, which indicates that the receiving is not completed, the data sub-packet with the next device identifier and the next instruction identifier that are the same is continuously extracted from the buffer queue, and the analysis is continuously performed.
Through the steps of S10-S60, the device identification and the instruction identification are uniquely determined for the data sub-package, and the analysis error is avoided. Meanwhile, the length field and the type field are arranged in the data sub-packets, the data types in the data sub-packets are limited according to the type field, whether the analysis of the data sub-packets is completed or not is judged through the length field, the data sub-packets can be accurately analyzed under the condition that the data volume of the feedback information is large, and the problem of analysis errors caused by the large data volume is reduced.
In a second aspect, the present invention further provides an intelligent home data synchronization device based on an MVVM frame and an MQTT protocol, where the device is located on an intelligent home client developed based on the MVVM frame, and data transmission is performed between the intelligent home client and an intelligent home device through the MQTT protocol, as shown in the figure, the device 100 includes:
the polling detection module 110 is configured to start a poller when an interactive interface of the smart home client is opened, detect whether a user operates on the interactive interface in real time, and set a preset interrupt identifier to a first value when it is detected that the user operates on the interactive interface, where an initial value of the preset interrupt identifier is a second value; the polling device is used for detecting the preset interrupt identifier once every preset time length;
the first updating module 120 is configured to, in response to each operation of a user on the interactive interface, perform data updating on a preset created interactive object according to the state of the interactive page after the operation, and send a corresponding control instruction to the smart home device; the interactive object is used for representing the current state of the interactive page;
the second updating module 130 is configured to, after receiving feedback information returned by the smart home device after executing the control instruction, perform data updating on a pre-created device object according to the feedback information; the equipment object is used for representing the current state of the intelligent household equipment;
a third updating module 140, configured to, in each polling, if the poller detects that the preset interrupt flag is the first value, set the preset interrupt flag to a second value, and wait for next polling; and if the poller detects that the preset interrupt identifier is the second value, assigning the equipment object to the interactive object, updating the interactive interface according to the updated interactive object, and waiting for next polling.
In specific implementation, if the polling detection module detects that the preset interrupt identifier is the second value through the poller, the third update module determines whether the device object and the interactive object are consistent before assigning the device object to the interactive object; and if not, executing the step of assigning the equipment object to the interactive object.
In specific implementation, the preset interrupt flag is a boolean type, the first value is true, and the second value is false.
It is understood that the apparatus provided in the second aspect corresponds to the method provided in the first aspect, and the explanation, the example, the beneficial effects, the detailed description, and the like of the related contents in the second aspect may refer to the corresponding parts in the first aspect, and are not repeated herein.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the apparatus embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
Those skilled in the art will recognize that, in one or more of the examples described above, the functions described in this disclosure may be implemented in hardware, software, hardware, or any combination thereof. When implemented in software, the functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium.
The above-mentioned embodiments, objects, technical solutions and advantages of the present invention are further described in detail, it should be understood that the above-mentioned embodiments are only exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made on the basis of the technical solutions of the present invention should be included in the scope of the present invention.

Claims (10)

1. An intelligent household data synchronization method based on an MVVM (multifunction vehicle virtual machine) frame and an MQTT (multiple quantum dots technology) protocol is characterized in that the method is executed by an intelligent household client developed based on the MVVM frame, and data transmission is carried out between the intelligent household client and an intelligent household device through the MQTT protocol, and the method comprises the following steps:
when an interactive interface of an intelligent home client is opened, starting a poller, detecting whether a user operates on the interactive interface in real time, and setting a preset interrupt identifier as a first value when the user operates on the interactive interface is detected, wherein the initial value of the preset interrupt identifier is a second value; the polling device is used for detecting the preset interrupt identifier once every preset time length;
responding to each operation of a user on the interactive interface, updating data of a preset created interactive object according to the state of the interactive page after the operation, and sending a corresponding control instruction to the intelligent home equipment; the interactive object is used for representing the current state of the interactive page;
after feedback information returned by the intelligent household equipment after the control instruction is executed is received, updating data of a pre-established equipment object according to the feedback information; the equipment object is used for representing the current state of the intelligent household equipment;
in each polling, if the poller detects that the preset interrupt identifier is the first value, setting the preset interrupt identifier as a second value, and waiting for next polling; and if the poller detects that the preset interrupt identifier is the second value, assigning the equipment object to the interactive object, updating the interactive interface according to the updated interactive object, and waiting for next polling.
2. The method of claim 1, wherein if the poller detects that the predetermined interrupt flag is the second value, the method further comprises, prior to assigning the device object to the interactive object: judging whether the equipment object is consistent with the interactive object; and if not, executing the step of assigning the equipment object to the interactive object.
3. The method of claim 1, wherein the predetermined interrupt flag is a boolean type, wherein the first value is true, and wherein the second value is false.
4. The method according to claim 1, wherein after receiving feedback information returned by the smart home device after executing the control instruction, performing data update on a pre-created device object according to the feedback information includes:
s10, when a data sub-package sent by the intelligent household equipment is received, the data sub-package is placed into a buffer queue; the intelligent home equipment generates feedback information, the total length of the feedback information and a corresponding data type into a data long packet, wherein the data long packet comprises a length field, a type field and a data field, the length field is used for storing the total length of the feedback information, the type field is used for storing the data type, and the data field is used for storing the feedback information; dividing the long data packet into a plurality of data sub-packets according to a preset length, adding an equipment identification field and an instruction identification field in each data sub-packet, and sending the equipment identification field and the instruction identification field to the intelligent home client one by one; the instruction identification field is used for storing an instruction identification corresponding to the corresponding control instruction;
s20, taking out a data sub-packet from the buffer queue, judging whether the device identifier in the device identifier field corresponding to the data sub-packet is the device identifier in the pre-constructed configuration set, if so, judging whether the instruction identifier in the instruction identifier field is the identifier corresponding to the control instruction sent by the client; if yes, go to S30;
s30, analyzing the data sub-package to obtain the content in each field contained in the data sub-package;
s40, determining whether a data type field is analyzed according to the data sub-package of the same device identifier and instruction identifier which are analyzed currently; if the data type field is analyzed, judging whether the data type in the data type field is a preset data type; if yes, determining whether the length field is analyzed according to the data sub-package of the same equipment identifier and instruction identifier which are analyzed currently; if the length field is analyzed, judging whether the sum of the lengths of the data streams in the analyzed data field in the data sub-packets with the same equipment identifier reaches the total length of the feedback information in the length field;
s50, if the sum of the lengths reaches the total length of the feedback information, the receiving is completed, and data updating is carried out on the pre-established equipment object according to the received feedback information;
and S60, if the sum of the lengths is less than the total length of the feedback information, taking out the next data sub-packet with the same equipment identifier and instruction identifier from the buffer queue, and returning to S30.
5. The method according to claim 4, wherein S40 further comprises:
and if the length field is determined not to be analyzed according to the data sub-packet with the same equipment identifier and the same instruction identifier which are analyzed currently, taking out the next data sub-packet with the same equipment identifier and the same instruction identifier from the cache queue, and returning to the step S30.
6. The method according to claim 4, wherein S40 further comprises:
and if the data type in the data type field of the data sub-packet is not the preset data type, the analysis of the data sub-packet of the current equipment identifier and the instruction identifier is finished.
7. The method according to claim 4, wherein S40 further comprises: and if the data type field is determined not to be analyzed according to the data sub-packet of the same equipment identifier and the same instruction identifier which are analyzed currently, taking out the next data sub-packet of the same equipment identifier and the same instruction identifier from the cache queue, and returning to the step S30.
8. The utility model provides an intelligent house data synchronizer based on MVVM frame and MQTT agreement, its characterized in that, the device is located on the intelligent house client based on MVVM frame development, just carry out data transmission through the MQTT agreement between intelligent house client and the intelligent house equipment, the device includes:
the polling detection module is used for starting a poller when an interactive interface of the intelligent home client is opened, detecting whether a user operates on the interactive interface in real time, and setting a preset interrupt identifier as a first value when the user operates on the interactive interface is detected, wherein the initial value of the preset interrupt identifier is a second value; the polling device is used for detecting the preset interrupt identifier once every preset time length;
the first updating module is used for responding to each operation of a user on the interactive interface, updating data of a preset and established interactive object according to the state of the interactive page after the operation, and sending a corresponding control instruction to the intelligent home equipment; the interactive object is used for representing the current state of the interactive page;
the second updating module is used for updating data of a pre-established equipment object according to feedback information after the feedback information returned by the intelligent household equipment after the intelligent household equipment executes the control instruction is received; the equipment object is used for representing the current state of the intelligent household equipment;
a third updating module, configured to, in each polling, set the preset interrupt identifier to a second value if the poller detects that the preset interrupt identifier is the first value, and wait for next polling; and if the poller detects that the preset interrupt identifier is the second value, assigning the equipment object to the interactive object, updating the interactive interface according to the updated interactive object, and waiting for next polling.
9. The apparatus according to claim 8, wherein if the polling detection module detects that the preset interrupt flag is the second value through the poller, the third update module determines whether the device object and the interactive object are consistent before assigning the device object to the interactive object; and if not, executing the step of assigning the equipment object to the interactive object.
10. The apparatus of claim 8, wherein the preset interrupt flag is a boolean type, wherein the first value is true, and wherein the second value is false.
CN202110737091.7A 2021-06-30 2021-06-30 Intelligent home data synchronization method and device based on MVVM (multifunction vehicle management model) framework and MQTT (message queuing time) protocol Active CN113419437B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110737091.7A CN113419437B (en) 2021-06-30 2021-06-30 Intelligent home data synchronization method and device based on MVVM (multifunction vehicle management model) framework and MQTT (message queuing time) protocol

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110737091.7A CN113419437B (en) 2021-06-30 2021-06-30 Intelligent home data synchronization method and device based on MVVM (multifunction vehicle management model) framework and MQTT (message queuing time) protocol

Publications (2)

Publication Number Publication Date
CN113419437A true CN113419437A (en) 2021-09-21
CN113419437B CN113419437B (en) 2022-04-19

Family

ID=77717282

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110737091.7A Active CN113419437B (en) 2021-06-30 2021-06-30 Intelligent home data synchronization method and device based on MVVM (multifunction vehicle management model) framework and MQTT (message queuing time) protocol

Country Status (1)

Country Link
CN (1) CN113419437B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115174672A (en) * 2022-06-28 2022-10-11 海信集团控股股份有限公司 Terminal, display device and data transmission method

Citations (22)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090248934A1 (en) * 2008-03-26 2009-10-01 International Business Machines Corporation Interrupt dispatching method in multi-core environment and multi-core processor
CN101699417A (en) * 2009-10-16 2010-04-28 华亚微电子(上海)有限公司 Interrupt method
US20100333102A1 (en) * 1999-09-30 2010-12-30 Sivaram Balasubramanian Distributed Real-Time Operating System
EP2442227A1 (en) * 2006-02-24 2012-04-18 Qualcomm Incorporated Two-level interrupt service routine
US20120276839A1 (en) * 2007-10-03 2012-11-01 Cisco Technology, Inc. System and Method for Reliably Communicating Information Without Explicit Acknowledgements
CN202795017U (en) * 2012-09-19 2013-03-13 山东神戎电子股份有限公司 Serial communication distribution device based on FPGA (field programmable gate array)
CN202956652U (en) * 2012-12-12 2013-05-29 郑州科技学院 Programmable wireless multi-channel household power intelligent control system
CN104636287A (en) * 2013-11-07 2015-05-20 上海斐讯数据通信技术有限公司 Data acquisition device and mobile terminal
CN104765870A (en) * 2015-04-26 2015-07-08 成都创行信息科技有限公司 Delay scheduling method related to network data
CN104950823A (en) * 2014-03-26 2015-09-30 广州合立正通信息科技有限公司 Method for realizing scene control of a plurality of sets of wireless controlled equipment
CN106094534A (en) * 2016-05-23 2016-11-09 深圳市汉科电子股份有限公司 The intelligent domestic system that a kind of wearable device intelligent watch controls
CN106131947A (en) * 2016-09-14 2016-11-16 潘进 A kind of method that between Wireless Communication Equipment, clock synchronizes
CN108199867A (en) * 2017-12-20 2018-06-22 北京城市系统工程研究中心 A kind of network-building method and data transmission method of wired sensor network
CN108924042A (en) * 2018-06-14 2018-11-30 芜湖康爱而电气有限公司 The things-internet gateway and implementation method of transparent transmission between a kind of multi-protocols
CN108958203A (en) * 2018-07-27 2018-12-07 上海与德科技有限公司 Applied to the control method of central control system, central control system and vehicle
CN109299117A (en) * 2017-07-25 2019-02-01 北京国双科技有限公司 The treating method and apparatus of request of data, storage medium, processor
CN109474692A (en) * 2018-12-03 2019-03-15 四川虹美智能科技有限公司 A kind of intelligent household appliance remote control method, apparatus and system
CN111045738A (en) * 2019-11-29 2020-04-21 RealMe重庆移动通信有限公司 Electronic device control method and device, electronic device and storage medium
US20200201808A1 (en) * 2018-12-21 2020-06-25 Qualcomm Incorporated Time-division multiplexing (tdm) data transfer on serial interfaces
CN111709255A (en) * 2020-05-22 2020-09-25 中电长城(长沙)信息技术有限公司 CEN/XFS-based concurrent calling method for card reading composite module
CN111727649A (en) * 2018-02-13 2020-09-29 三星电子株式会社 Method and apparatus for transmitting or receiving data and control information in wireless communication system
CN112947328A (en) * 2021-01-28 2021-06-11 卓然(靖江)设备制造有限公司 Automatic control system for industrial furnace group

Patent Citations (22)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100333102A1 (en) * 1999-09-30 2010-12-30 Sivaram Balasubramanian Distributed Real-Time Operating System
EP2442227A1 (en) * 2006-02-24 2012-04-18 Qualcomm Incorporated Two-level interrupt service routine
US20120276839A1 (en) * 2007-10-03 2012-11-01 Cisco Technology, Inc. System and Method for Reliably Communicating Information Without Explicit Acknowledgements
US20090248934A1 (en) * 2008-03-26 2009-10-01 International Business Machines Corporation Interrupt dispatching method in multi-core environment and multi-core processor
CN101699417A (en) * 2009-10-16 2010-04-28 华亚微电子(上海)有限公司 Interrupt method
CN202795017U (en) * 2012-09-19 2013-03-13 山东神戎电子股份有限公司 Serial communication distribution device based on FPGA (field programmable gate array)
CN202956652U (en) * 2012-12-12 2013-05-29 郑州科技学院 Programmable wireless multi-channel household power intelligent control system
CN104636287A (en) * 2013-11-07 2015-05-20 上海斐讯数据通信技术有限公司 Data acquisition device and mobile terminal
CN104950823A (en) * 2014-03-26 2015-09-30 广州合立正通信息科技有限公司 Method for realizing scene control of a plurality of sets of wireless controlled equipment
CN104765870A (en) * 2015-04-26 2015-07-08 成都创行信息科技有限公司 Delay scheduling method related to network data
CN106094534A (en) * 2016-05-23 2016-11-09 深圳市汉科电子股份有限公司 The intelligent domestic system that a kind of wearable device intelligent watch controls
CN106131947A (en) * 2016-09-14 2016-11-16 潘进 A kind of method that between Wireless Communication Equipment, clock synchronizes
CN109299117A (en) * 2017-07-25 2019-02-01 北京国双科技有限公司 The treating method and apparatus of request of data, storage medium, processor
CN108199867A (en) * 2017-12-20 2018-06-22 北京城市系统工程研究中心 A kind of network-building method and data transmission method of wired sensor network
CN111727649A (en) * 2018-02-13 2020-09-29 三星电子株式会社 Method and apparatus for transmitting or receiving data and control information in wireless communication system
CN108924042A (en) * 2018-06-14 2018-11-30 芜湖康爱而电气有限公司 The things-internet gateway and implementation method of transparent transmission between a kind of multi-protocols
CN108958203A (en) * 2018-07-27 2018-12-07 上海与德科技有限公司 Applied to the control method of central control system, central control system and vehicle
CN109474692A (en) * 2018-12-03 2019-03-15 四川虹美智能科技有限公司 A kind of intelligent household appliance remote control method, apparatus and system
US20200201808A1 (en) * 2018-12-21 2020-06-25 Qualcomm Incorporated Time-division multiplexing (tdm) data transfer on serial interfaces
CN111045738A (en) * 2019-11-29 2020-04-21 RealMe重庆移动通信有限公司 Electronic device control method and device, electronic device and storage medium
CN111709255A (en) * 2020-05-22 2020-09-25 中电长城(长沙)信息技术有限公司 CEN/XFS-based concurrent calling method for card reading composite module
CN112947328A (en) * 2021-01-28 2021-06-11 卓然(靖江)设备制造有限公司 Automatic control system for industrial furnace group

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
MARTIN LÉVESQUE等: "A Survey of Clock Synchronization Over Packet-Switched Networks", 《IEEE COMMUNICATIONS SURVEYS & TUTORIALS》 *
S. NARASIMHA SWAMY等: "An Empirical Study on System Level Aspects of Internet of Things", 《IEEE ACCESS》 *
司宇星: "智能家居的设备控制系统设计与实现", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *
郭君成: "基于AMBA总线的CAN控制器的设计与验证", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115174672A (en) * 2022-06-28 2022-10-11 海信集团控股股份有限公司 Terminal, display device and data transmission method
CN115174672B (en) * 2022-06-28 2024-03-08 海信集团控股股份有限公司 Terminal, display device and data transmission method

Also Published As

Publication number Publication date
CN113419437B (en) 2022-04-19

Similar Documents

Publication Publication Date Title
US20120079419A1 (en) Gui processing apparatus, gui processing method and gui processing program
CN110830460B (en) Connection establishing method and device, electronic equipment and storage medium
CN112787945B (en) Data transmission method, data transmission device, computer readable medium and electronic equipment
CN111200622B (en) Resource transmission method and device and storage medium
CN110753129A (en) Message transmission method, system, device, equipment and computer readable storage medium
CN113419437B (en) Intelligent home data synchronization method and device based on MVVM (multifunction vehicle management model) framework and MQTT (message queuing time) protocol
CN103533435A (en) Set-top box with two systems and double-system communication method
US20180115474A1 (en) Flow entry aging method, switch, and controller
US11909840B2 (en) Resource subscription method, device, and storage medium
US20090031011A1 (en) Device management system and method for setting configuration-valve therein
CN110875887A (en) MQTT protocol-based communication interaction method and communication interaction system
CN114584833A (en) Audio and video processing method and device and storage medium
CN115004673A (en) Message pushing method and device, electronic equipment and computer readable medium
WO2017143743A1 (en) Heterogeneous protocol communication method and controller
CN109600423B (en) Data synchronization method and device, electronic equipment and storage medium
CN112583822B (en) Communication apparatus and communication method
KR20090094948A (en) Apparatus and method for controling automatic repeat request reset in wireless broadbandinternet system
CN112261142A (en) Data retransmission method and device for RDMA (remote direct memory Access) network and FPGA (field programmable Gate array)
CN114430307A (en) Data decoding method, data encoding method, data decoding device and terminal equipment
CN102684865B (en) Method, system and device for data synchronization
CN107070872B (en) A kind of data processing method and device for client
CN107171915B (en) Communication protocol changing method and device
CN111479142B (en) Program content updating method and system based on information release
CN109086107B (en) Bullet screen message distribution method, device, equipment and storage medium
KR101831686B1 (en) Method and apparatus for determinig object change in home network

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant