Wi-Fi module and related data transmission method, device, equipment and medium
By caching data in the Wi-Fi module and uploading it upon reconnection, the problem of data loss caused by Wi-Fi module network outages is solved, achieving data integrity and timeliness.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GREE ELECTRIC APPLIANCE INC OF ZHUHAI
- Filing Date
- 2025-12-16
- Publication Date
- 2026-05-01
AI Technical Summary
In complex network environments, when a Wi-Fi module loses network access, abnormal data on the device cannot be reported in a timely manner, resulting in data loss.
After the Wi-Fi module loses connection with the server, the data type is determined and the target data is stored in the cache module. When reconnecting, the target data in the cache module is uploaded to the server.
This prevented the loss of abnormal data and ensured data integrity and timely uploading.
Smart Images

Figure CN121968371A_ABST
Abstract
Description
Wi-Fi modules and related data transmission methods, devices, equipment and media Technical Field
[0001] This application belongs to the technical field of data transmission, specifically relating to a Wi-Fi module and related data transmission methods, apparatus, devices and media. Background Technology
[0002] With the increasing prevalence of network applications in commercial air conditioning, the demand from the device side for real-time data upload and feedback from the server side is growing.
[0003] Abnormal data (such as fault codes, sudden changes in energy consumption, over-temperature alarms, etc.) are key evidence in operation and maintenance and service. However, in complex network environments, Wi-Fi modules often face the problem of network outages. When a Wi-Fi module is out of the network, it may cause the device to lose abnormal data because it cannot report abnormal data in a timely manner. Summary of the Invention
[0004] In view of the above problems, a Wi-Fi module and related data transmission methods, apparatus, devices, and media are proposed to overcome or at least partially solve the above problems, including: a data transmission method based on a Wi-Fi module, wherein the Wi-Fi module includes a cache module, the Wi-Fi module is used to receive data reported by a device and upload the data reported by the device to a server; the method includes: after the Wi-Fi module loses connection with the server, determining the data type of the data received from the device; storing the target data of the target data type in the cache module; and when the Wi-Fi module reconnects with the server, uploading the target data in the cache module to the server.
[0005] In some embodiments, the caching module includes a caching region, the caching region having a ring structure, the ring structure including a start region and an end region; storing the target data of the target data type into the caching module includes: storing the target data into the caching module in order from the start region to the end region; and writing the new target data into the start region after performing a write operation on the end region.
[0006] In some embodiments, writing new target data to the start area after writing to the end area includes: determining a first priority of the data stored in the start area and a second priority of the new target data; when the first priority is greater than the second priority, writing new target data to the next area of the start area in the order from the start area to the end area; when the first priority is less than the second priority, writing new target data to the start area.
[0007] In some embodiments, the caching module establishes a data index table, and the method further includes: determining the write address of the target data and determining the target index of the target data; and writing the target index and the write address into the data index table.
[0008] In some embodiments, uploading the target data in the cache module to the server includes: determining the priority of each piece of data in the cache module and the storage time of each piece of data; and uploading the target data in the cache module to the server according to the priority and the storage time.
[0009] In some embodiments, the method further includes: in a weak network scenario, generating an abnormal data digest based on at least one data to be reported; and uploading the abnormal data digest to the server.
[0010] In some embodiments, uploading the target data in the cache module to the server includes: determining the network status of the Wi-Fi module and the server, and determining the re-reporting time interval of the target data according to the network status; and sequentially uploading the target data in the cache module to the server according to the re-reporting time interval.
[0011] In some embodiments, the cache module stores a record header of the target data; the method further includes: when the cache module is abnormal, determining a valid record header from multiple record headers; initializing the index structure of the cache module according to the valid record header and retaining the target data corresponding to the valid record header.
[0012] This application also provides a Wi-Fi module, including a cache module; the Wi-Fi module is used to implement the data transmission method based on the Wi-Fi module as described above.
[0013] This application embodiment also provides a data transmission device based on a Wi-Fi module. The Wi-Fi module includes a cache module, which is used to receive data reported by a device and upload the data reported by the device to a server. The device includes: a determination module, used to determine the data type of the data received from the device after the Wi-Fi module loses connection with the server; a storage module, used to store the target data of the target data type in the cache module; and a re-reporting module, used to upload the target data in the cache module to the server when the Wi-Fi module reconnects with the server.
[0014] In some embodiments, the caching module includes a caching region, which is a ring structure, including a start region and an end region; the storage module is configured to store the target data in the caching module in order from the start region to the end region; and after a write operation is performed on the end region, new target data is written to the start region.
[0015] In some embodiments, the storage module is configured to determine a first priority of the data stored in the start region and a second priority of the new target data; when the first priority is greater than the second priority, the new target data is written in the next region of the start region in the order from the start region to the end region; when the first priority is less than the second priority, the new target data is written to the start region.
[0016] In some embodiments, the caching module establishes a data index table, and the storage module is further configured to determine the write address of the target data and determine the target index of the target data; and write the target index and the write address into the data index table.
[0017] In some embodiments, the supplementary reporting module is used to determine the priority of each piece of data in the cache module and the storage time of each piece of data; and upload the target data in the cache module to the server according to the priority and the storage time.
[0018] In some embodiments, the supplementary reporting module is further configured to generate an abnormal data digest based on at least one data to be reported in a weak network scenario; and upload the abnormal data digest to the server.
[0019] In some embodiments, the supplementary reporting module is configured to determine the network status of the Wi-Fi module and the server, and determine the supplementary reporting time interval of the target data according to the network status; and sequentially upload the target data in the cache module to the server according to the supplementary reporting time interval.
[0020] In some embodiments, the caching module stores a record header of the target data; the storage module is further configured to determine a valid record header from multiple record headers when the caching module is abnormal; initialize the index structure of the caching module according to the valid record header and retain the target data corresponding to the valid record header.
[0021] This application also provides an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the above-described data transmission method based on a Wi-Fi module.
[0022] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the above-described data transmission method based on a Wi-Fi module.
[0023] The embodiments of this application have the following advantages: In these embodiments, after the Wi-Fi module loses connection with the server, the data type of the data received from the device is determined; the target data of the target data type is stored in the cache module; and when the Wi-Fi module reconnects with the server, the target data in the cache module is uploaded to the server. Through these embodiments, the target data sent from the device to the server in a network outage scenario can be temporarily cached based on the Wi-Fi module, and then uploaded to the server after reconnection. Because the target data is cached in the Wi-Fi module, problems such as loss of target data due to abnormal data can be avoided. Attached Figure Description
[0024] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which: FIG1 is a flowchart of the steps of a data transmission method based on a Wi-Fi module according to an embodiment of this application; FIG2 is a flowchart of the steps of another data transmission method based on a Wi-Fi module according to an embodiment of this application; FIG3 is a flowchart of the steps of yet another data transmission method based on a Wi-Fi module according to an embodiment of this application; FIG4 is a flowchart of a method for supplementing abnormal data based on a Wi-Fi module according to an embodiment of this application; FIG5 is a schematic diagram of the structure of a data transmission device based on a Wi-Fi module according to an embodiment of this application. Detailed Implementation
[0025] To make the above-mentioned objectives, features, and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0026] In related technologies, server-side compensation mechanisms or timed retries can be used to avoid the loss of abnormal data; however, for the device side, the problem of abnormal data loss may still exist during reconnection; and compensation mechanisms may also have the problem of some abnormal data not being compensated. To address this, this application proposes a data transmission method based on a Wi-Fi module. This method can temporarily cache abnormal data sent from the device to the server during network outages using the Wi-Fi module, and then upload the abnormal data to the server after reconnection. Because the abnormal data is cached in the Wi-Fi module, the problem of abnormal data loss can be avoided.
[0027] Referring to FIG1, a flowchart of a data transmission method based on a Wi-Fi module according to an embodiment of the present application is shown, which may include the following steps: Step 101: After the Wi-Fi module is disconnected from the server, determine the data type of the data received from the device.
[0028] In some embodiments, a Wi-Fi module may refer to an embedded hardware device that integrates Wi-Fi wireless communication functionality; it may be connected to a device and a server respectively; wherein the device may refer to a device in a smart home system that needs to report target data to the server, such as a smart air conditioner.
[0029] In this embodiment, the Wi-Fi module is used to receive data reported by the device and upload the data reported by the device to the server. The data reported by the device may include abnormal data, such as fault codes and sensor abnormal data, or normal status data, such as device status data and periodic heartbeat information. This embodiment does not limit the data in this respect.
[0030] The Wi-Fi module mentioned in this application embodiment is equipped with a caching module, which can be used to cache the data that the device is about to upload to the server when the Wi-Fi module is disconnected from the server, thereby avoiding the loss of important data such as abnormal data.
[0031] In some embodiments, the Wi-Fi module can have a built-in network status monitoring mechanism that uses MQTT (Message Queuing Telemetry Transport) heartbeat packets, TCPACK (Transmission Control Protocol Acknowledgment) confirmations, and Ping probes to comprehensively determine network connectivity.
[0032] When the Wi-Fi module detects that the network connection with the server is normal, it can push the data reported by the device to the server via MQTT / TCP.
[0033] When the Wi-Fi module detects a disconnection from the server (i.e., the network connection is broken), it can cache the data currently received and reported by the device. Specifically, due to the limited storage space of the Wi-Fi module, in order to preserve important data such as abnormal data within the limited space, after detecting a disconnection from the server, if the Wi-Fi module receives data reported by the device, it can first determine the data type. The data type can include abnormal data, normal status data, etc. This application embodiment does not limit the classification of data, and it can be set according to the actual situation.
[0034] Step 102: Store the target data of type target data into the cache module.
[0035] After determining the data type of the currently received data, if the data type is the target data type, then the data can be used as the target data and stored in the cache module, to be reported to the server after the Wi-Fi module reconnects with the server. The target data type can be set according to the actual situation; for example, the target data type can be an exception data type, an alarm data type, or other important data type.
[0036] Conversely, if the data type is not the target data type, then the data does not need to be cached; or, when there is spare storage space, these data can be stored in the cache space, and this application embodiment does not limit this.
[0037] In some embodiments, after the Wi-Fi module is powered on, a lightweight storage engine can be initialized first, and a dedicated cache area can be allocated in the cache module (e.g., Flash or RAM (Random Access Memory)) for storing target data.
[0038] In some embodiments, the cache area can be logically divided into two independent data pools: a high-priority pool and a low-priority pool. The high-priority pool is used to store anomaly and alarm information (such as fault codes, sensor anomalies, etc.), while the low-priority pool is used to store normal status data or periodic heartbeat information.
[0039] Step 103: When the Wi-Fi module reconnects with the server, upload the target data in the cache module to the server.
[0040] In some embodiments, when the Wi-Fi module detects that the network has been restored to availability, it can immediately initiate the data re-reporting process; specifically, when the Wi-Fi module detects a reconnection with the server, it can read the target data from the cache module and upload the target data to the server.
[0041] After the server confirms that the target data has been received, the Wi-Fi module can automatically delete the corresponding data from the cache to avoid duplicate reporting.
[0042] In this embodiment, after the Wi-Fi module loses connection with the server, the data type of the data received from the device is determined; the target data of the target data type is stored in the cache module; when the Wi-Fi module reconnects with the server, the target data in the cache module is uploaded to the server. Through this embodiment, target data sent from the device to the server in a network outage scenario can be temporarily cached using the Wi-Fi module, and then uploaded to the server after reconnection. Because the target data is cached in the Wi-Fi module, problems such as loss of target data due to abnormal data can be avoided.
[0043] Referring to FIG2, a flowchart of another data transmission method based on a Wi-Fi module according to an embodiment of the present application is shown, which may include the following steps: Step 201: After the Wi-Fi module is disconnected from the server, determine the data type of the data received from the device.
[0044] In some embodiments, the Wi-Fi module can be used to receive data reported by the device and upload the data reported by the device to the server. The data reported by the device may include abnormal data, such as fault codes and sensor abnormal data, or normal status data, such as device status data and periodic heartbeat information.
[0045] Wi-Fi modules can have a built-in network status monitoring mechanism that uses MQTT heartbeat packets, TCP ACK confirmations, and Ping probes to comprehensively determine network connectivity.
[0046] When the Wi-Fi module detects that the network connection with the server is normal, it can push the data reported by the device to the server via MQTT / TCP.
[0047] When the Wi-Fi module detects a disconnection from the server, i.e., the network connection is broken, it can cache the data currently received and reported by the device.
[0048] Specifically, due to the limited storage space of Wi-Fi modules, in order to save important data such as abnormal data within the limited space, the Wi-Fi module can first determine the data type if it receives data reported by the device after detecting a disconnection from the server.
[0049] Step 202: The cache module includes a cache area, which is a ring structure. The ring structure includes a start area and an end area. The target data is stored in the cache module in the order from the start area to the end area.
[0050] In some embodiments, a "sequential write" and "circular overwrite" mode can be used to avoid storage degradation caused by frequent erases and writes. Specifically, the cache module can include a cache region, which can be a circular structure, i.e., the cache region includes a start region and an end region, which are concatenated together. When data is written, it is first written to the start region, and then written sequentially until the end region is reached. When the end region is also full, data can be written again from the start region.
[0051] In this embodiment of the application, after the Wi-Fi module receives data reported by the device after the network is disconnected, if it determines that the data data type is the target data type, it can store the target data in the cache module in the order from the start area to the end area.
[0052] Step 203: After writing to the end region, write the new target data to the start region.
[0053] In some embodiments, the storage area of the Wi-Fi module's cache module is limited; and the new target data is more representative of the current situation on the device than the old target data; based on this, the new target data can be written to the start area after the end area is written.
[0054] In this embodiment, the Wi-Fi module automatically switches to offline caching mode when it detects a continuous heartbeat timeout or a TCP connection disconnection. In this mode, high-priority data is written to the local cache storage area, recording the storage time, data type, and CRC (Cyclic Redundancy Check) checksum to prevent subsequent data tampering or out-of-order processing.
[0055] Low-priority data, such as ordinary status data, is preferentially stored based on the remaining space in the current cache module. If space is insufficient, writing is delayed. In this embodiment, low-priority data can be first placed in a temporary queue inside RAM. When the RAM queue is nearly full, low-priority data is then pruned according to priority. Low-priority "non-critical data" is discarded, while abnormal data is not. This mechanism allows for a smooth transition when the network is unstable, avoiding the risk of data blockage or module restart.
[0056] In some embodiments of this application, step 203 can be implemented by the following sub-steps: Sub-step 11, determining the first priority of the data stored in the starting region and the second priority of the new target data.
[0057] In some embodiments, "circular overwrite" can be controlled based on priority to avoid overwriting high-priority data. Specifically, when a write operation is performed on the end region and a write operation needs to be performed again from the start region, the priority of the data currently stored in the start region can be determined first, i.e., the first priority.
[0058] Additionally, the priority of the target data for which a write operation is currently required can be determined, i.e., the second priority.
[0059] Data priority can be determined based on its specific type. For example, abnormal data can be further categorized into different specific abnormality types, and different priorities can be set for each type. When determining data priority, the specific abnormality type of the data can be identified first, and then the priority of that data can be determined.
[0060] For example, a device (e.g., the main control board of an air conditioner) can periodically report data to the Wi-Fi module via a UART (Universal Asynchronous Receiver / Transmitter) interface, such as "line status and control feedback".
[0061] The Wi-Fi module has an internal data parsing module that performs content recognition and formatted parsing on the received data. Based on the data content, the Wi-Fi module automatically tags the data with different data types (such as "ALARM", "STATUS", "CONTROL") and assigns it to queues of different priorities according to the tags.
[0062] Sub-step 12: When the first priority is greater than the second priority, write the new target data in the next region after the start region in the order from the start region to the end region.
[0063] After determining the first and second priorities, their relative importance can be compared. For example, if the first priority is greater than the second priority, it means that the data stored in the starting area has a higher priority than the new target data; the new target data cannot overwrite the data in the starting area. In this case, the new target data can be written to the area following the starting area, in the order from the starting area to the ending area.
[0064] In some embodiments, when writing new target data to the area following the starting area, priority can still be determined; if the priority of the new target data is higher than the priority of the data in that area, then writing can proceed. Otherwise, the priority of the next area and the new target data is determined.
[0065] Sub-step 13: When the first priority is less than the second priority, write the new target data into the starting area.
[0066] Conversely, if the first priority of the data in the starting region is lower than the second priority of the new target data, the new target data can be written into the starting region to overwrite the data in the starting region.
[0067] Step 204: When the Wi-Fi module reconnects with the server, determine the priority of each piece of data in the cache module and the storage time of each piece of data.
[0068] In some embodiments, when the Wi-Fi module detects that the network has been restored to availability, it can immediately initiate the data re-reporting process; specifically, when the Wi-Fi module detects a reconnection with the server, it can read the target data from the cache module and upload the target data to the server.
[0069] For example, when the Wi-Fi module detects a reconnection to the server, it can first determine the priority of each piece of data cached in the caching module, as well as the storage time of each piece of data in the caching module.
[0070] Step 205: Upload the target data in the cache module to the server according to priority and storage time.
[0071] After determining the priority and storage time, the target data in the cache module can be uploaded to the server sequentially according to the priority and storage time. In this embodiment, the dual-dimensional scheduling based on time and priority can ensure that the upload of critical data is not crowded out by low-priority data, ensure that critical alarm data is not lost or delayed, and improve the accuracy of operation and maintenance diagnosis.
[0072] After the server confirms that the target data has been received, the Wi-Fi module can automatically delete the corresponding data from the cache to avoid duplicate reporting.
[0073] In some embodiments, low-priority data will be reported sequentially after high-priority data has been sent and bandwidth is available. The entire reporting process supports a resume mechanism, allowing retransmission to resume after a network outage.
[0074] In some embodiments, this application can send a record locally (status: pending confirmation) when supplementary data is generated. If an ACK is not received (network disconnection), the Wi-Fi module will not delete the record.
[0075] After network recovery, the shadow table is used to determine which data was not successfully confirmed, and then resends it. If the server receives duplicate data, it automatically deduplicates it using a timestamp and a unique ID. This ensures data continuity and integrity.
[0076] In some embodiments of this application, the caching module establishes a data index table, and the above method may further include the following steps: determining the write address of the target data and determining the target index of the target data; writing the target index and the write address into the data index table.
[0077] In some embodiments, a data index table may be established in the caching module, which can provide a basis for subsequent data supplementation.
[0078] In this embodiment of the application, after the target data is written to the cache module, its write address can be determined; then, the corresponding target index can be determined based on the target data.
[0079] For example, the target index may include data type, storage time, checksum, data length, etc., but this application embodiment does not limit this.
[0080] After obtaining the target index and write address, the target index and write address can be written into the data index table so that in subsequent supplementary reporting, the data can be verified based on the checksum, data length, etc., and the data can be retrieved and reported based on the data index table.
[0081] In some embodiments of this application, the above method may further include the following steps: in a weak network scenario, generating an abnormal data digest based on at least one data to be reported; and uploading the abnormal data digest to the server.
[0082] In some embodiments, in weak network scenarios, due to poor network connection between the Wi-Fi module and the server, in order to reduce the amount of data to be reported, an abnormal data summary can be generated based on at least one data to be reported.
[0083] Among them, weak network scenarios can refer to network environments where the Wi-Fi module and the server are in a state of low network bandwidth, high latency, large jitter, high packet loss rate, or unstable connection, resulting in a poor service experience.
[0084] The data to be reported can refer to the data that the device will report to the server; specifically, it can refer to the data that the device reports to the Wi-Fi module when the Wi-Fi module and the server are in a weak network scenario.
[0085] After receiving at least one piece of data to be reported, the Wi-Fi module can use the "summary data" mode to report only the summary of abnormal data to the server.
[0086] Anomaly data summaries can be generated by compressing and statistically analyzing at least one piece of data to be reported, retaining only key information and thus reducing bandwidth pressure. For example: record the first and last times; count the number of occurrences; extract the maximum / minimum values of relevant parameters; and finally form a simplified record, such as: over-temperature alarm: first time 10:03, last time 10:25, a total of 7 times, highest temperature 68℃.
[0087] In some embodiments of this application, the cache module stores the record header of the target data; the above method may also include the following steps: when the cache module is abnormal, determine the valid record header from multiple record headers; initialize the index structure of the cache module according to the valid record header and retain the target data corresponding to the valid record header.
[0088] In some embodiments, the caching module may store a record header of the target data; for example, the record header may include minimal metadata such as data type, storage time, checksum, and data length, to avoid additional indexes and redundant fields.
[0089] During each read / write operation, the Wi-Fi module calculates and compares the checksum to ensure that the data is not tampered with or damaged during the network outage.
[0090] If a data structure anomaly or storage access failure is detected, the Wi-Fi module will automatically trigger a self-repair mechanism to reinitialize the index structure and retain valid data. Specifically, when an anomaly is detected in the cache module due to a data structure anomaly or storage access failure, multiple record headers can be queried, and the validity of the record header can be determined based on data length, checksum, etc., without relying on the original data index table.
[0091] After determining the valid record headers, the index structure of the cache module can be initialized based on these valid record headers, and the target data corresponding to the valid record headers can be retained. Data corresponding to invalid record headers can be set to "free". When write operations are required on the regions corresponding to these data based on cyclic overwrite, the data in these regions can be directly determined to have lower priority than the new target data and thus be overwritten.
[0092] Specifically, the cache module can be scanned first to find valid record headers. Then, the read pointer, write pointer, and priority partition boundaries can be reconstructed based on the valid record headers. Finally, data that cannot be parsed is automatically skipped and uniformly marked as "free area," ensuring the long-term reliable operation of the cache.
[0093] When scanning the cache module, the record header, length field, and CRC of each record are checked in sequence to determine whether it is valid: First, the pointer is read: pointing to the position of the earliest valid record scanned.
[0094] Then write the pointer: pointing to the empty space after the last valid record.
[0095] Finally, the priority partition boundaries are determined by re-establishing the start and end addresses of the high-priority and low-priority partitions based on the position of the "priority field" in the records. All pointers and boundaries are dynamically recovered based on the scan results, without relying on the original index table.
[0096] "Skip" means marking unresolved areas as "free," allowing subsequent write pointers to directly overwrite them; the content on the Flash memory will not be actively erased (reducing the number of write cycles). Therefore, "Skip" is logically considered as deletion, but physically waits to be overwritten.
[0097] In some embodiments, to enhance flexibility, the server can dynamically adjust the caching strategy of the Wi-Fi module via control commands. For example, it can modify the maximum cache capacity, the priority level of abnormal data, and the re-reporting interval.
[0098] After receiving instructions from the server, the Wi-Fi module can perform hot parameter updates without restarting and automatically save the new configuration. This design allows the system to adaptively optimize according to different field environments, such as increasing the buffer time in areas with unstable signals; specifically, in environments with weak networks or frequent disconnections, high-frequency retransmissions can lead to frequent retransmissions and a decrease in success rate.
[0099] Increasing cache time extends the waiting time after data is saved locally, thereby reducing the amount of low-priority data written.
[0100] Extending the reporting interval makes data transmission more reliable and successful. Limiting the storage ratio of low-priority data in high-traffic scenarios ensures the timeliness and completeness of critical alarm information.
[0101] In this embodiment, after the Wi-Fi module loses connection with the server, the data type of the data received from the device is determined. The caching module includes a caching area with a ring structure, comprising a start area and an end area. Target data is stored in the caching module in order from the start area to the end area. After writing to the end area, new target data is written to the start area. When the Wi-Fi module reconnects with the server, the priority and storage time of each piece of data in the caching module are determined. Target data in the caching module is uploaded to the server according to priority and storage time. Through this embodiment, target data sent from the device to the server in a network outage scenario can be temporarily cached using the Wi-Fi module, and then uploaded to the server after reconnection. Since the target data is cached in the Wi-Fi module, problems such as loss of target data due to abnormal data can be avoided.
[0102] Referring to FIG3, a flowchart of another data transmission method based on a Wi-Fi module according to an embodiment of the present application is shown, which may include the following steps: Step 301: After the Wi-Fi module is disconnected from the server, determine the data type of the data received from the device.
[0103] In some embodiments, the Wi-Fi module can be used to receive data reported by the device and upload the data reported by the device to the server. The data reported by the device may include abnormal data, such as fault codes and sensor abnormal data, or normal status data, such as device status data and periodic heartbeat information.
[0104] Wi-Fi modules can have a built-in network status monitoring mechanism that uses MQTT heartbeat packets, TCP ACK confirmations, and Ping probes to comprehensively determine network connectivity.
[0105] When the Wi-Fi module detects that the network connection with the server is normal, it can push the data reported by the device to the server via MQTT / TCP.
[0106] When the Wi-Fi module detects a disconnection from the server, i.e., the network connection is broken, it can cache the data currently received and reported by the device.
[0107] Specifically, due to the limited storage space of Wi-Fi modules, in order to save important data such as abnormal data within the limited space, the Wi-Fi module can first determine the data type if it receives data reported by the device after detecting a disconnection from the server.
[0108] Step 302: Store the target data in the cache module in order from the start region to the end region.
[0109] In some embodiments, a "sequential write" and "circular overwrite" pattern can be used to avoid frequent erasure and rewriting of the cache module. Specifically, the cache module can include a cache region, which can be a circular structure, i.e., the cache region includes a start region and an end region, which are concatenated together. When data is written, it is first written to the start region, and then written sequentially until the end region is reached. When the end region is also full, data can be written again from the start region.
[0110] In this embodiment of the application, after the Wi-Fi module receives data reported by the device after the network is disconnected, if it determines that the data data type is the target data type, it can store the target data in the cache module in the order from the start area to the end area.
[0111] Step 303: Determine the first priority of the data stored in the starting area and the second priority of the new target data.
[0112] In some embodiments, "circular overwrite" can be controlled based on priority to avoid overwriting high-priority data. Specifically, when a write operation is performed on the end region and a write operation needs to be performed again from the start region, the priority of the data currently stored in the start region can be determined first, i.e., the first priority.
[0113] Additionally, the priority of the target data for which a write operation is currently required can be determined, i.e., the second priority.
[0114] Step 304: When the first priority is greater than the second priority, write the new target data in the next area after the start area in the order from the start area to the end area.
[0115] After determining the first and second priorities, their relative importance can be compared. For example, if the first priority is greater than the second priority, it means that the data stored in the starting area has a higher priority than the new target data; the new target data cannot overwrite the data in the starting area. In this case, the new target data can be written to the area following the starting area, in the order from the starting area to the ending area.
[0116] In some embodiments, when writing new target data to the area following the starting area, priority can still be determined; if the priority of the new target data is higher than the priority of the data in that area, then writing can proceed. Otherwise, the priority of the next area and the new target data is determined.
[0117] Step 305: When the first priority is lower than the second priority, write the new target data into the starting area.
[0118] Conversely, if the first priority of the data in the starting region is lower than the second priority of the new target data, the new target data can be written into the starting region to overwrite the data in the starting region.
[0119] Step 306: When the Wi-Fi module reconnects with the server, determine the network status of the Wi-Fi module and the server, and determine the time interval for re-reporting the target data based on the network status.
[0120] In some embodiments, when the Wi-Fi module detects that the network has been restored to availability, it can immediately initiate the data re-reporting process; specifically, when the Wi-Fi module detects a reconnection with the server, it can read the target data from the cache module and upload the target data to the server.
[0121] For example, when a Wi-Fi module detects a reconnection with the server, it can first determine the network status between the Wi-Fi module and the server. This network status can be represented by a numerical value. The larger the value, the better the network connection between the Wi-Fi module and the server; conversely, the smaller the value, the worse the network connection between the Wi-Fi module and the server.
[0122] After determining the network status, the reporting interval for target data can be set according to that network status. This reporting interval refers to the interval between the reporting times of two target data points, and it can be determined based on the network status. The worse the network status, the longer the reporting interval; the better the network status, the shorter the reporting interval. This avoids saturating bandwidth during reporting and affecting real-time online data. It also prevents excessive server load when a large number of devices simultaneously restore the network. This setting can be configured by the server to adapt to different network environments.
[0123] Step 307: According to the supplementary reporting time interval, upload the target data in the cache module to the server in sequence.
[0124] After determining the reporting interval, the target data in the cache module can be uploaded to the server sequentially according to this interval. For example, when uploading the target data in the cache module to the server sequentially according to the reporting interval, the priority and storage time of the target data can also be considered to determine which target data to report first and which to report later.
[0125] In some embodiments, to prevent excessive storage usage by the caching module from causing operational abnormalities, a cache monitoring threshold can be set. When storage usage reaches the limit, a data pruning strategy is automatically executed: prioritizing the retention of high-priority data and cleaning up some low-priority or expired data.
[0126] In this embodiment, after the Wi-Fi module loses connection with the server, the data type of the data received from the device is determined; the target data is stored in the cache module in order from the start area to the end area; a first priority of the data stored in the start area and a second priority of the new target data are determined; when the first priority is greater than the second priority, the new target data is written in the next area after the start area in order from the start area to the end area; when the first priority is less than the second priority, the new target data is written to the start area; when the Wi-Fi module reconnects with the server, the network status of the Wi-Fi module and the server is determined, and the re-reporting interval of the target data is determined according to the network status; the target data in the cache module is uploaded to the server sequentially according to the re-reporting interval. Through this embodiment, target data sent from the device to the server in a network outage scenario can be temporarily cached based on the Wi-Fi module, and the target data can be uploaded to the server after reconnection. Since the target data is cached in the Wi-Fi module, problems such as loss of target data due to abnormal data can be avoided.
[0127] Taking abnormal data as an example, referring to Figure 4, a flowchart of an abnormal data reporting method based on a Wi-Fi module according to an embodiment of this application is shown: First, the Wi-Fi module can collect data to obtain the air conditioner's operating data, abnormal data, etc.
[0128] Then, the Wi-Fi module can determine whether the network connection with the server is available; if it is available, the data is uploaded to the server normally; otherwise, if the network connection is unavailable, the data can be written to the Wi-Fi module's cache module. During the writing process, abnormal data is prioritized.
[0129] Next, the Wi-Fi module can wait for the network connection with the server to be restored. If the network connection is restored, it can prioritize reporting the abnormal data to the server, followed by reporting the lower-priority data. If the network connection is not restored, it continues to wait for the network connection with the server to be restored.
[0130] After the data is resubmitted to the server, the Wi-Fi module can clear its cache and confirm the ACK. The Wi-Fi module can also adjust data priority and the capacity of the cache module for storing abnormal data based on policies issued by the cloud.
[0131] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of this application are not limited to the described order of actions, because according to the embodiments of this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of this application.
[0132] Referring to Figure 5, a schematic diagram of a data transmission device based on a Wi-Fi module according to an embodiment of this application is shown. The Wi-Fi module includes a cache module, which is used to receive data reported by the device and upload the data reported by the device to the server. The device may include the following modules: a determination module 501, used to determine the data type of the data received from the device after the Wi-Fi module loses connection with the server; a storage module 502, used to store the target data of the target data type in the cache module; and a re-reporting module 503, used to upload the target data in the cache module to the server when the Wi-Fi module reconnects with the server.
[0133] In some embodiments, the cache module includes a cache region, which is a ring structure, and the ring structure includes a start region and an end region; the storage module 502 is used to store target data into the cache module in order from the start region to the end region; after performing a write operation on the end region, new target data is written to the start region.
[0134] In some embodiments, the storage module 502 is configured to determine a first priority of the data stored in the start region and a second priority of the new target data; when the first priority is greater than the second priority, the new target data is written in the next region after the start region in the order from the start region to the end region; when the first priority is less than the second priority, the new target data is written to the start region.
[0135] In some embodiments, the caching module establishes a data index table, and the storage module 502 is further configured to determine the write address of the target data and determine the target index of the target data; and write the target index and the write address into the data index table.
[0136] In some embodiments, the reporting module 503 is used to determine the priority of each piece of data in the cache module and the storage time of each piece of data; and upload the target data in the cache module to the server according to the priority and storage time.
[0137] In some embodiments, the supplementary reporting module 503 is further configured to generate an abnormal data summary based on at least one data to be reported in a weak network scenario; and upload the abnormal data summary to the server.
[0138] In some embodiments, the supplementary reporting module 503 is used to determine the network status of the Wi-Fi module and the server, and determine the supplementary reporting time interval of the target data according to the network status; and upload the target data in the cache module to the server in sequence according to the supplementary reporting time interval.
[0139] In some embodiments, the cache module stores a record header of the target data; the storage module 502 is further configured to determine a valid record header from multiple record headers when an exception occurs in the cache module; and initialize the index structure of the cache module based on the valid record header and retain the target data corresponding to the valid record header.
[0140] In this embodiment, after the Wi-Fi module loses connection with the server, the data type of the data received from the device is determined; the target data of the target data type is stored in the cache module; when the Wi-Fi module reconnects with the server, the target data in the cache module is uploaded to the server. Through this embodiment, target data sent from the device to the server in a network outage scenario can be temporarily cached using the Wi-Fi module, and then uploaded to the server after reconnection. Because the target data is cached in the Wi-Fi module, problems such as loss of target data due to abnormal data can be avoided.
[0141] This application also provides a Wi-Fi module, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the above-described data transmission method based on the Wi-Fi module.
[0142] This application also provides an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the above-described data transmission method based on a Wi-Fi module.
[0143] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the above-described data transmission method based on a Wi-Fi module.
[0144] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0145] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0146] Those skilled in the art will understand that embodiments of this application can be provided as methods, apparatus, or computer program products. Therefore, embodiments of this application can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of this application can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0147] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, create means for implementing the functions specified in one or more blocks of the flowchart illustrations and / or one or more blocks of the block diagrams.
[0148] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means that implement the functions specified in one or more flowcharts and / or one or more block diagrams.
[0149] These computer program instructions may also be loaded onto a computer or other programmable data processing terminal equipment to cause a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, such that the instructions, which execute on the computer or other programmable terminal equipment, provide steps for implementing the functions specified in one or more flowcharts and / or one or more block diagrams.
[0150] Although preferred embodiments of the present application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present application.
[0151] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0152] The foregoing has provided a detailed description of a Wi-Fi module and related data transmission methods, apparatus, devices, and media. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A data transmission method based on a Wi-Fi module, characterized in that, The Wi-Fi module includes a caching module, which is used to receive data reported by the device and upload the data reported by the device to the server. The method includes: after the Wi-Fi module loses connection with the server, determining the data type of the data received from the device; storing the target data of the target data type in the caching module; and uploading the target data in the caching module to the server when the Wi-Fi module reconnects with the server.
2. The method according to claim 1, characterized in that, The caching module includes a caching area, which has a ring structure, including a start area and an end area. The step of storing the target data (of type target data type) into the caching module includes: storing the target data into the caching module in order from the start area to the end area; and writing the new target data to the start area after performing a write operation on the end area.
3. The method according to claim 2, characterized in that, The step of writing new target data to the start area after writing to the end area includes: determining a first priority of the data stored in the start area and a second priority of the new target data; when the first priority is greater than the second priority, writing new target data to the next area of the start area in the order from the start area to the end area; when the first priority is less than the second priority, writing new target data to the start area.
4. The method according to claim 1, characterized in that, The caching module establishes a data index table, and the method further includes: determining the write address of the target data and determining the target index of the target data; and writing the target index and the write address into the data index table.
5. The method according to claim 1, characterized in that, Uploading the target data in the cache module to the server includes: determining the priority of each piece of data in the cache module and the storage time of each piece of data; and uploading the target data in the cache module to the server according to the priority and the storage time.
6. The method according to claim 1, characterized in that, The method further includes: in a weak network scenario, generating an abnormal data digest based on at least one data to be reported; and uploading the abnormal data digest to the server.
7. The method according to claim 1, characterized in that, Uploading the target data in the cache module to the server includes: determining the network status of the Wi-Fi module and the server, and determining the re-reporting time interval of the target data according to the network status; and sequentially uploading the target data in the cache module to the server according to the re-reporting time interval.
8. The method according to claim 1, characterized in that, The cache module stores the record header of the target data; the method further includes: when the cache module is abnormal, determining a valid record header from multiple record headers; initializing the index structure of the cache module according to the valid record header and retaining the target data corresponding to the valid record header.
9. A Wi-Fi module, characterized in that, It includes a caching module; the Wi-Fi module is used to implement the data transmission method based on the Wi-Fi module as described in any one of claims 1-8.
10. A data transmission device based on a Wi-Fi module, characterized in that, The Wi-Fi module includes a cache module, which is used to receive data reported by the device and upload the data reported by the device to the server. The device includes: a determination module, used to determine the data type of the data received from the device after the Wi-Fi module loses connection with the server; a storage module, used to store the target data of the target data type in the cache module; and a re-reporting module, used to upload the target data in the cache module to the server when the Wi-Fi module reconnects with the server.
11. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the data transmission method based on a Wi-Fi module as described in any one of claims 1 to 8.
12. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the data transmission method based on a Wi-Fi module as described in any one of claims 1 to 8.