A method for obtaining real-time state of a device, a storage medium and an electronic device
By employing serial communication protocols and master-slave control in the Internet of Things (IoT), real-time status data is transmitted directly between front-end devices and hardware devices, solving the problem of data transmission dependence on networks, achieving efficient, low-latency, and accurate data transmission, and reducing costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- FUJIAN STAR NET EVIDEO INFORMATION SYST CO LTD
- Filing Date
- 2024-12-26
- Publication Date
- 2026-07-03
AI Technical Summary
In IoT scenarios, data transmission between hardware devices and front-end devices relies on network connectivity, which is easily affected by network stability, bandwidth limitations, and device processing capabilities, leading to incomplete data or transmission failures. Furthermore, the encapsulation and processing by cloud servers increases latency and resource consumption, thus increasing the cost burden.
The front-end device communicates directly with the hardware device using a serial communication protocol (such as BACnet or Modbus), encapsulates and transmits real-time status data, and uses master-slave control to ensure the stability and accuracy of data transmission. The front-end device obtains the real-time status data by parsing the communication protocol.
It enables real-time data transmission without cloud servers, reducing latency and storage consumption, improving communication efficiency and data accuracy, and lowering costs.
Smart Images

Figure CN122340171A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Internet of Things (IoT) data monitoring technology, specifically to a method, storage medium, and electronic device for acquiring the real-time status of a device. Background Technology
[0002] Currently, data transmission between hardware devices and front-end devices (such as Android terminals), especially in Internet of Things (IoT) scenarios, mainly involves the hardware device first uploading data to a cloud server via wired or wireless means (such as Wi-Fi, Bluetooth, LoRa, NB-IoT, etc.). The cloud server, acting as a data transmission relay, needs to encapsulate the received raw data (such as encapsulating the data into a JSON data format string). The encapsulated data is then sent to the front-end device through the cloud server. After receiving the data, the front-end device needs to parse it for display on the user interface or for further processing. In this process, data uploading and downloading rely on network connectivity. Affected by network stability, bandwidth limitations, and the device's own processing capabilities, data incompleteness or transmission failure may occur due to network latency or packet loss, and there are also data security risks. The cloud server's encapsulation of the received raw data increases data transmission latency and may introduce additional errors and uncertainties. Encapsulated data occupies more memory and storage space than the original data, which is a significant issue for resource-constrained embedded devices and mobile front-end devices. Renting and maintaining cloud servers incurs high costs, further burdening small and medium-sized enterprises and individual developers with their R&D workload. Summary of the Invention
[0003] In view of the above problems, this application provides a method for obtaining the real-time status of a device to solve the above problems.
[0004] To achieve the above objectives, the inventors provide a method for obtaining the real-time status of a device, which includes a front-end device and a hardware device, wherein the front-end device is connected to the hardware device via a communication protocol.
[0005] Specifically, the following steps are included:
[0006] The hardware device encapsulates the current real-time status data into communication data frames according to the communication protocol and stores them;
[0007] The front-end device obtains communication data frames based on the current master-slave control.
[0008] The front-end device parses the communication data frames using the communication protocol parsing method to obtain real-time status data of the hardware device.
[0009] Furthermore, the communication protocol is a serial communication protocol, including the BACnet protocol or the Modbus protocol.
[0010] Furthermore, in the step of communicating according to the current master-slave control, and the front-end device obtaining the communication data frame, the hardware device is the master device and the front-end device is the slave device; according to the current master-slave control, the hardware device actively pushes the communication data frame to the front-end device;
[0011] Alternatively, the front-end device may be the master device, and the hardware device may be the slave device; according to the current master-slave control, the front-end device may actively obtain data from the hardware device.
[0012] Furthermore, in the step of communicating according to the current master-slave control and the front-end device obtaining the communication data frame, the method further includes data verification of the communication data frame.
[0013] Furthermore, the received communication data frames are checked and matched against the data frame header and CRC. If they are incorrect, the first byte of data is discarded and new bytes are added to the end for rematching and supplementation.
[0014] Alternatively, the received communication data frame can be continuously verified with ACK to obtain data with a defined ID number; if the data passes the ACK verification, the data is correct; otherwise, the data obtained is incorrect and the data is obtained again.
[0015] Furthermore, the front-end device establishes a communication parsing function corresponding to the communication protocol and provides a communication parsing function interface; the front-end device calls the communication parsing function interface to parse the communication data frame and obtain real-time status data.
[0016] Furthermore, the step of the front-end device calling the communication parsing function interface to parse the communication data frame and obtain real-time status data includes the following steps:
[0017] The front-end device starts a sub-thread, which processes the received communication data frames through the communication parsing function interface.
[0018] Furthermore, after the front-end device parses the communication data frame using the communication protocol parsing method to obtain real-time status data, the process also includes the front-end device rendering and displaying the real-time status data in real time.
[0019] A storage medium storing a computer program that, when executed by a processor, implements the method for obtaining the real-time status of a device.
[0020] An electronic device includes a memory and a processor, wherein the memory stores a computer program, and the computer program, when executed by the processor, implements the method for obtaining the real-time status of the device.
[0021] Unlike existing technologies, the above technical solution establishes a communication connection between the front-end device and the hardware device through a communication protocol, eliminating the need for transmission through a cloud server, reducing transmission latency, and significantly improving data transmission speed to achieve true real-time data transmission. The real-time status data of the hardware device is encapsulated using the communication protocol, without being converted to a string during encapsulation, avoiding unnecessary encoding or conversion steps and reducing memory consumption during storage. Communication is achieved through master-slave control, with a clear master-slave relationship, improving communication efficiency, avoiding communication conflicts and data loss, and enhancing communication stability and reliability. The front-end device parses the communication data frames using the communication protocol to reconstruct the real-time status data, ensuring data accuracy and integrity.
[0022] The above description of the invention is merely an overview of the technical solution of this application. In order to enable those skilled in the art to better understand the technical solution of this application and to implement it based on the description and drawings, and to make the above-mentioned objectives and other objectives, features and advantages of this application easier to understand, the following description is provided in conjunction with the specific embodiments and drawings of this application. Attached Figure Description
[0023] The accompanying drawings are only used to illustrate the principles, implementation methods, applications, features, and effects of specific embodiments of the present invention and other related contents, and should not be considered as limitations on this application.
[0024] In the accompanying drawings of the instruction manual:
[0025] Figure 1 This is a schematic diagram of the method for obtaining the real-time status of a device as described in a specific implementation. Detailed Implementation
[0026] To illustrate the possible application scenarios, technical principles, implementable specific solutions, and achievable objectives and effects of this application in detail, the following description, in conjunction with the listed specific embodiments and accompanying drawings, provides a detailed explanation. The embodiments described herein are merely illustrative of the technical solutions of this application and are therefore intended to limit the scope of protection of this application.
[0027] In this document, the term "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The term "embodiment" appearing in various places throughout the specification does not necessarily refer to the same embodiment, nor does it specifically limit its independence or connection with other embodiments. In principle, in this application, as long as there are no technical contradictions or conflicts, the technical features mentioned in each embodiment can be combined in any way to form corresponding implementable technical solutions.
[0028] Unless otherwise defined, the technical terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the use of related terms herein is merely for the purpose of describing particular embodiments and is not intended to limit this application.
[0029] In the description of this application, the term "and / or" is used to describe the logical relationship between objects, indicating that three relationships can exist. For example, A and / or B means: A exists, B exists, and A and B exist simultaneously. Additionally, the character " / " in this document generally indicates that the preceding and following objects have an "or" logical relationship.
[0030] In this application, terms such as “first” and “second” are used only to distinguish one entity or operation from another, and do not necessarily require or imply any actual quantity, hierarchy or order relationship between these entities or operations.
[0031] Without further limitations, the use of terms such as “comprising,” “including,” “having,” or other similar open-ended expressions in this application is intended to cover non-exclusive inclusion, which does not exclude the presence of additional elements in a process, method, or product that includes the stated elements, such that a process, method, or product that includes a list of elements may include not only those defined elements but also other elements not expressly listed, or elements inherent to such a process, method, or product.
[0032] Similar to the understanding in the Examination Guidelines, in this application, expressions such as "greater than," "less than," and "exceeding" are understood to exclude the stated number; expressions such as "above," "below," and "within" are understood to include the stated number. Furthermore, in the description of the embodiments in this application, "multiple" means two or more (including two), and similar expressions related to "multiple" are also understood in this way, such as "multiple groups" and "multiple times," unless otherwise explicitly specified.
[0033] In the description of the embodiments of this application, the space-related expressions used, such as "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "vertical," "top," "bottom," "inner," "outer," "clockwise," "counterclockwise," "axial," "radial," and "circumferential," indicate the orientation or positional relationship based on the orientation or positional relationship shown in the specific embodiments or drawings. They are only for the purpose of describing the specific embodiments of this application or for the reader's understanding, and do not indicate or imply that the device or component referred to must have a specific position, a specific orientation, or be constructed or operated in a specific orientation. Therefore, they should not be construed as limitations on the embodiments of this application.
[0034] See Figure 1 As shown, a method for obtaining the real-time status of a device includes a front-end device and a hardware device. The front-end device and the hardware device are connected via a communication protocol, eliminating the need for transmission through a cloud server, reducing transmission latency, and significantly improving data transmission speed, thus achieving true real-time data transmission. The real-time status data of the hardware device is encapsulated using the communication protocol. The real-time status data is not converted to a string during the encapsulation process, avoiding unnecessary encoding or conversion steps and reducing memory consumption during storage. Communication is conducted through master-slave control, with a clear master-slave relationship, improving communication efficiency, avoiding communication conflicts and data loss, and enhancing communication stability and reliability. The front-end device parses the communication data frames using the communication protocol parsing method to reconstruct the real-time status data, ensuring the accuracy and integrity of the data.
[0035] The following combination Figure 1 As shown, an embodiment of a method for obtaining the real-time status of a device is provided, which includes a front-end device and a hardware device, wherein the front-end device is connected to the hardware device through a communication protocol.
[0036] Specifically, the following steps are included:
[0037] S1. The hardware device encapsulates the current real-time status data into communication data frames according to the communication protocol and stores them.
[0038] S2. Communication is performed according to the current master-slave control, and the front-end device obtains communication data frames;
[0039] S3. The front-end device parses the communication data frame through the communication protocol parsing method to obtain the real-time status data of the hardware device.
[0040] The aforementioned front-end devices are responsible for interacting with the user, and can be smartphones, tablets, computers, smart wearable devices, etc. The aforementioned hardware devices are responsible for collecting real-time status data of the environment or a specific object and transmitting this data to the front-end devices; these can be sensors (such as temperature sensors, humidity sensors, pressure sensors, etc.), RFID tags, electronic components (such as Hall effect sensors, current transformers, multimeters, oscilloscopes, etc.), etc.
[0041] The aforementioned front-end device communicates with the hardware device via a communication protocol. This front-end device can communicate with the hardware device via a serial communication protocol, specifically a physical wired serial port connection or a wireless serial port connection. The physical serial port can be a physical serial port conforming to RS-485 or other communication standards. When connecting the physical serial port, it is essential to follow the standard wiring according to the physical layer protocol. Taking an RS-485 physical serial port as an example, connect port A to port A and port B to port B. The front-end device and the hardware device use a communication protocol to achieve data interaction. This communication protocol enables data interaction between the front-end device and the hardware device without requiring transmission through a cloud server, reducing transmission latency and significantly improving data transmission speed, thus achieving true real-time data transmission. The aforementioned serial communication protocol can be BACnet, Modbus, etc.
[0042] The aforementioned real-time status data is typically stored in binary form on hardware devices. This binary data directly reflects various status parameters of the environment or a specific object acquired by the hardware device. The hardware device encapsulates the current real-time status data into communication data frames according to a communication protocol and stores them. The real-time status data is encapsulated using a communication protocol, and it is not converted into a string during the encapsulation process, avoiding unnecessary encoding or conversion steps and reducing memory consumption during storage, thereby improving memory utilization efficiency. Special attention must be paid to the uniqueness of the communication address and the correctness of the protocol format to ensure effective communication and interoperability between the front-end device and the hardware device.
[0043] In some embodiments, the front-end device and the hardware device use the Modbus protocol for data interaction, and the communication data is in serial data frames. The communication data frame structure includes an address field, a function code field, a data field, and a checksum field. The address field identifies the address of the front-end device, the function code field specifies the type of operation to be performed (e.g., read, write), the data field contains real-time status data, and the checksum field is used for error detection. It should be noted that the Modbus protocol communication address can be the same as that of the front-end device. In some embodiments, the front-end device and the hardware device use the BACnet protocol for data interaction, and the communication data is also in serial data frames. The communication data frame structure includes a BVLC (BACnet Virtual Link Control) header, NPDU (Network Protocol Data Unit), and APDU (Application Protocol Data Unit) layers. Because the BACnet protocol requires real-time status data to be filled in the correct ID bit, the communication address of each device has a specific meaning and cannot be duplicated.
[0044] The above-described communication is based on the current master-slave control. The front-end device obtains communication data frames and communicates through master-slave control. This clearly defines the master-slave relationship, improves communication efficiency, avoids communication conflicts and data loss, and enhances communication stability and reliability. Specifically, based on the current master-slave control, the front-end device selects the current communication mode and begins data communication with the hardware device. The master device is the hardware device, and the front-end device is the slave device, or vice versa. When the hardware device is the master device and the front-end device is the slave device, the hardware device actively pushes communication data frames to the front-end device according to the current master-slave control. When the front-end device is the master device and the hardware device is the slave device, the front-end device actively obtains data from the hardware device according to the current master-slave control.
[0045] Of course, in the step of obtaining communication data frames by the front-end device according to the current master-slave control, when the communication data frame is a serial port data frame, it may also include data verification of the communication data frame. When data is stacked, there may be situations where it is not a complete and correct set of communication data frames. Data verification can detect errors that may occur during data transmission, such as bit flips, data loss, or duplication. Through the verification mechanism, the front-end device can verify whether the received communication data frame is consistent with the data sent by the hardware device, thereby ensuring the accuracy of the data and being able to detect and correct these errors in a timely manner, thereby enhancing the reliability of communication. When an error is detected, the front-end device re-acquires the communication data frame or takes other error recovery measures to ensure smooth communication. For example, when communicating using the Modbus protocol, the received communication data frame is checked and matched with the data frame header and CRC. If it is incorrect, the first byte of data is discarded, and new bytes of data are added to the end for re-matching and supplementation. When communicating using the BACnet protocol, the received communication data frame is continuously checked with ACK to obtain data with a defined ID number. If the data passes the ACK verification, the data is correct; otherwise, the data acquisition is incorrect, and the data is re-acquired.
[0046] The front-end device parses communication data frames using a communication protocol parsing method to reconstruct real-time status data, ensuring the accuracy and integrity of the data. Specifically, the front-end device establishes a communication parsing function corresponding to the communication protocol and provides an interface for this function, namely the communication parsing function interface. In actual operation, the front-end device calls this communication parsing function interface to perform detailed and accurate parsing of the received communication data frames. Through this process, the front-end device can successfully extract the required real-time status data from the communication data frames. This includes the following steps:
[0047] After the front-end device starts up, it first performs initialization operations, including configuring the parameters of the communication protocol and preparing a buffer for storing the received communication data frames.
[0048] To avoid blocking the main thread (which is typically used by the front-end device to handle the user interface or other critical tasks) when parsing communication data frames, the front-end device starts one or more sub-threads to handle the reception and parsing of serial communication data.
[0049] In a certain sub-thread, the front-end device receives communication data frames from the hardware device through the communication interface; once a complete communication data frame is received, the sub-thread calls the predefined communication parsing function interface to parse and process the communication data frame and obtain the real-time status data of the hardware device.
[0050] The front-end device can further process the extracted real-time status data of the hardware devices, such as storing it in a database, displaying it on the user interface, or triggering alarms. Taking display on the user interface as an example, the front-end device renders the real-time status data and displays it in real time. The aforementioned rendering refers to converting the real-time status data into a visual representation of the real-time status data seen on the front-end device, which can be various elements such as text, images, charts, videos, or any visual element that the user can interact with.
[0051] This application also provides a storage medium storing a computer program that, when executed by a processor, implements the above-described method for obtaining the real-time status of a device.
[0052] The computer program involved in the embodiments can be stored in a storage medium, including but not limited to disks, magnetic tapes, magnetic cards, floppy disks, flash memory, optical disks, optical cards, read-only memory (ROM), random access memory (RAM), erasable programmable ROM (EPROM), and electrically erasable programmable ROM (EEPROM), etc. It also includes other biological, physical, or chemical structures capable of performing similar or equivalent functions to the storage media listed above, such as DNA, RNA, proteins, and other units with information storage capabilities. In specific embodiments, the storage medium can be one of the above-mentioned media types or a combination of the above media types. In different embodiments, the computer program involved in the embodiments can be centrally stored in a single medium or distributed across multiple media. The memory containing the storage medium can be non-volatile memory or random access memory. These storage media can be built into the device or connected to the device involved in the embodiments as an external device or part of an external device. In some embodiments, the memory with storage medium is deployed locally; in other embodiments, the memory may be deployed remotely from the processor, such as a network-attached memory accessed via RF circuitry or an external port and a communication network, wherein the communication network may be the Internet, one or more intranets, a local area network (LAN), a wide area network (WLAN), a storage area network (SAN), or a suitable combination thereof, as long as it enables computer devices to access the memory. Furthermore, the computer program involved in the embodiments may be stored in plaintext / ciphertext form, or it may be designed as training data, integrated and recombined through model training and implicitly stored in the parameter states of a deep neural network or other machine learning model.
[0053] This application also provides an electronic device including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, it implements the method for obtaining the real-time status of the device.
[0054] The processor described in the embodiments of this application can be implemented by hardware, firmware, software, or a combination thereof. It can be a circuit, one or more of an application-specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field-programmable gate array (FPGA), a central processing unit (CPU), a controller, a microcontroller, or a microprocessor. It also includes other physical, biological, or chemical structures that can implement the same or equivalent functions as the processors listed above, such as biological neurons, quantum computing units, DNA computing units, etc., so that the processor can execute some or all of the steps in the computer program or method involved in the various embodiments of this application, or any combination of the steps mentioned therein.
[0055] Finally, it should be noted that although the above embodiments have been described in the text and drawings of this application, this should not limit the scope of patent protection of this application. Any technical solutions that are based on the essential concept of this application and utilize the content described in the text and drawings of this application, resulting in equivalent structural or procedural substitutions or modifications, as well as the direct or indirect application of the technical solutions of the above embodiments to other related technical fields, are all included within the scope of patent protection of this application.
Claims
1. A method for obtaining real-time status of a device, characterized in that, It includes a front-end device and a hardware device, wherein the front-end device communicates with the hardware device via a communication protocol; Specifically, the following steps are included: The hardware device encapsulates the current real-time status data into communication data frames according to the communication protocol and stores them; The front-end device obtains communication data frames based on the current master-slave control. The front-end device parses the communication data frames using the communication protocol parsing method to obtain real-time status data of the hardware device.
2. The method of claim 1, wherein, The communication protocol is a serial communication protocol, including BACnet protocol or Modbus protocol.
3. The method of obtaining real-time status of a device according to claim 1 or 2, wherein, In the step of communicating according to the current master-slave control, and the front-end device obtaining the communication data frame, the hardware device is the master device and the front-end device is the slave device; according to the current master-slave control, the hardware device actively pushes the communication data frame to the front-end device. Alternatively, the front-end device may be the master device, and the hardware device may be the slave device; according to the current master-slave control, the front-end device may actively obtain data from the hardware device.
4. The method of claim 1, wherein, The step of communicating according to the current master-slave control and the front-end device obtaining the communication data frame further includes data verification of the communication data frame.
5. The method of claim 1, wherein, The specific steps for performing data verification on communication data frames include: The received communication data frames are checked and matched against the data frame header and CRC. If they are incorrect, the first byte of data is discarded and new bytes are added to the end for rematching and supplementation. Alternatively, the received communication data frame can be continuously verified with ACK to obtain data with a defined ID number; if the data passes the ACK verification, the data is correct; otherwise, the data obtained is incorrect and the data is obtained again.
6. The method of claim 1, wherein, The front-end device establishes a communication parsing function corresponding to the communication protocol and provides a communication parsing function interface; the front-end device calls the communication parsing function interface to parse the communication data frame and obtain real-time status data.
7. The method of claim 6, wherein, The step of the front-end device calling the communication parsing function interface to parse the communication data frame and obtain real-time status data includes the following steps: The front-end device starts a sub-thread, which processes the received communication data frames through the communication parsing function interface.
8. The method of claim 1, wherein, After the front-end device parses the communication data frame using the communication protocol to obtain real-time status data, the next step is for the front-end device to render and display the real-time status data in real time.
9. A storage medium storing a computer program that, when executed by a processor, implements the method for obtaining the real-time status of a device as described in any one of claims 1-8.
10. An electronic device, characterized by It includes a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, it implements the method for obtaining the real-time status of a device as described in any one of claims 1-8.