Granary trusted data storage method and device in weak network environment

Through differential computing, status word compression and encoding compression technologies, the granary monitoring data is locally processed and signed, which solves the problem of data proof storage and low power consumption requirements in weak network environments, and realizes trusted proof storage and energy consumption optimization of data.

CN120342579APending Publication Date: 2025-07-18HUNAN GRAIN TECHNOLOGY INNOVATION CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510692725.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-27
Publication Date
2025-07-18

AI Technical Summary

Technical Problem

In a weak network environment, granary monitoring data cannot be effectively verified, and the equipment's low power consumption needs are difficult to take into account. The existing technology cannot guarantee the integrity and credibility of data. At the same time, frequent network uploads have led to an increase in energy consumption.

Method used

Differential operation, status word compression and encoding compression technology are used to process the monitoring data locally, and upload it in batches when the network is restored to ensure data integrity and avoid tampering through blockchain key signature.

Benefits of technology

It realizes local processing and cache of data in a weak network environment, reduces data transmission time and energy consumption, ensures the authenticity and trustworthiness of data, and optimizes the data transmission efficiency after network recovery.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120342579A_ABST
    Figure CN120342579A_ABST
Patent Text Reader

Abstract

The invention discloses a granary trusted data storage method and device in a weak network environment. The method comprises the following steps: acquiring monitoring data; checking a network connection state between the Internet of Things control device and the block chain; if the network connection state is abnormal, splicing the timestamp, the remote signaling type data sequence, the telemetering type data sequence and the equipment ID of the first piece of monitoring data during the abnormal network connection state to obtain a corresponding message, compressing the timestamp through differential operation aiming at the subsequent monitoring data, performing status word compression on the remote signaling type data sequence, and sending the compressed timestamp to the remote signaling type data sequence; coding and compressing the telemetering type data sequence, then splicing compressed timestamps, telecommand type data, telemetering type data and equipment IDs to obtain messages of subsequent monitoring data, and signing all the messages by using a block chain key; and after the network connection state is normal, splicing all the signed messages, carrying out secondary signature, and sending the signed messages to the block chain for evidence storage. According to the invention, the problem of data storage in a weak network environment is effectively solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of the Internet of Things, and specifically relates to a method and device for storing reliable data in a granary under a weak network environment. Background Art

[0002] Monitoring information of a granary, such as temperature, humidity, and the quantity of grain, requires reliable data to ensure that the actual situation is truly reflected and to avoid management mistakes caused by data tampering. Through blockchain + Internet of Things technology, the reliability of the data source can be achieved, enhancing the authenticity of the data. However, due to the environmental characteristics inside the granary (weak network coverage and low power consumption requirements for devices), traditional Internet of Things technologies face challenges.

[0003] The Internet of Things acquisition technology based on blockchain usually stores data through the methods of acquisition, preprocessing, signature, and sending. However, in the scenario of storing grain in containers, since the containers need to be moved, network instability may occur, resulting in failed blockchain uploads. At this time, if the message is discarded, the data loss of the container cannot be guaranteed, and if it is temporarily cached and uploaded after the network resumes, it will greatly consume network bandwidth; in addition, in order to reduce the overall cost, the containers are powered by batteries with limited battery capacity, so it is necessary to minimize the power consumption of the devices to extend the usage time. However, in a weak network situation, if network sending operations are repeatedly performed (for example, when a sending failure is detected, a retry mechanism is used to upload every 5 seconds), unnecessary power consumption will increase.

[0004] In summary, there is currently no good method to ensure the integrity of reliable data considering the network disconnection caused by a weak network environment and the need to minimize the power consumption of devices. Summary of the Invention

[0005] The technical problem to be solved by the present invention: In view of the above problems of the prior art, a method and device for storing reliable data in a granary under a weak network environment are provided, which can effectively avoid the risk of data tampering, solve the problem of ineffective data storage in a weak network environment, and meet the low power consumption requirements of the devices.

[0006] To solve the above technical problems, the technical solution adopted by the present invention is as follows:

[0007] A method for storing reliable data in a granary under a weak network environment, the method is applied to an Internet of Things control device of a granary, and the method includes the following steps:

[0008] Obtain monitoring data, where the monitoring data includes the telemetry data sequence and the telemetry data sequence of all sensors in the granary corresponding to the Internet of Things control device;

[0009] Check the network connection status with the blockchain;

[0010] If the network connection status is abnormal, splice the timestamp, telecontrol data sequence, and telemetry data sequence of the first piece of monitoring data during the abnormal network connection status with the device ID of the Internet of Things control device to obtain the corresponding message. For the subsequent monitoring data during the abnormal network connection status, compress the timestamp through differential operation, compress the telecontrol data sequence by status word, and compress the telemetry data sequence by encoding. Then, splice the compressed timestamp, telecontrol data, and telemetry data with the device ID of the Internet of Things control device to obtain the message corresponding to the subsequent monitoring data, and sign all messages using the blockchain key;

[0011] Wait for the network connection status to be normal, splice all the signed messages during the abnormal network connection status and perform secondary signing to obtain a signed data packet, and send the data packet to the blockchain for evidence storage.

[0012] Further, when compressing the timestamp through differential operation, the following steps are included:

[0013] Take the timestamp of the first piece of monitoring data during the abnormal network connection status as the reference timestamp;

[0014] Perform a first-order differential operation on the timestamp of the current monitoring data and the reference timestamp to obtain the first-order differential operation result of the timestamp of the current monitoring data;

[0015] If the current monitoring data is the second piece of monitoring data during the abnormal network connection status, add a timestamp mark to the first-order differential operation result of the timestamp of the current monitoring data to obtain the compressed timestamp of the current monitoring data;

[0016] If the current monitoring data is not the second piece of monitoring data during the abnormal network connection status, perform a second-order differential operation on the first-order differential operation result of the timestamp of the current monitoring data and the previous piece of monitoring data to obtain the second-order differential operation result of the timestamp of the current monitoring data, and add a timestamp mark T to the head of the second-order differential operation result of the timestamp of the current monitoring data to obtain the compressed timestamp of the current monitoring data.

[0017] Further, after sending the data packet to the blockchain for evidence storage, it includes the step of decompressing the compressed timestamp by the smart contract of the blockchain, including:

[0018] Obtain the reference timestamp at the position of the timestamp in the message corresponding to the first piece of monitoring data. For each message after the message corresponding to the first piece of monitoring data, obtain the compressed timestamp of each message in turn according to the timestamp mark T;

[0019] If the current message is the message corresponding to the second piece of monitoring data after the first piece of monitoring data, add the value of the timestamp after compression of the current message to the value of the reference timestamp to obtain the timestamp of the current message;

[0020] If the current message is other messages, add the value of the timestamp after compression of the current message to the values of the timestamps after compression of all the messages before the current message, and then add the calculation result to the value of the reference timestamp to obtain the timestamp of the current message.

[0021] Further, when performing status word compression on the telecontrol data sequence, the following steps are included:

[0022] Compare each piece of telecontrol data in the current monitoring data with each piece of telecontrol data in the previous detection data;

[0023] If the current status value of the telecontrol data is the same as the previous status value, update the status retention value of the telecontrol data;

[0024] If the current status value of the telecontrol data is different from the previous status value, splice the serial number, status retention value and current status value of the telecontrol data, and add the telecontrol data marker K at the head of the splicing result to obtain the compressed telecontrol data, and then reset the status retention value of the telecontrol data.

[0025] Further, after sending the data packet to the blockchain for evidence storage, it includes the step of decompressing the compressed telecontrol data by the smart contract of the blockchain, including:

[0026] Obtain the telecontrol data sequence at the position of the telecontrol data sequence in the message corresponding to the first piece of monitoring data. For each message after the message corresponding to the first piece of monitoring data, check the telecontrol data marker K;

[0027] If the telecontrol data marker K does not exist in the current message, use the telecontrol data sequence of the previous message as the telecontrol data sequence of the current message;

[0028] If the telecontrol data marker K exists in the current message, obtain the compressed telecontrol data after the telecontrol data marker K, select the corresponding message before the current message according to the status retention value, obtain the telecontrol data sequence of the selected message, and adjust the telecontrol data at the corresponding position in the telecontrol data sequence of the selected message according to the serial number and current status value of the telecontrol data to obtain the telecontrol data sequence of the current message.

[0029] Further, when performing encoding and compression on the telemetry data sequence in the current monitoring data, the following steps are included:

[0030] Sequentially select the data query index library of the basic unit from the telemetry data sequence;

[0031] If there is no query result for the currently selected data in the index library, add the currently selected data to the index library and update the total amount of the index. If the compression result of the previous selected data is the data of the basic unit or the data of the basic unit with the first marker Y added at the head, use the currently selected data as the compression result of the currently selected data; otherwise, add the first marker Y to the head of the currently selected data as the compression result of the currently selected data.

[0032] If there is a query result for the currently selected data in the index library, obtain the corresponding index number. If the compression result of the previous selected data is the index number or the index number with the second marker G added at the head, use the corresponding index number as the compression result of the currently selected data; otherwise, add the second marker G to the head of the corresponding index number as the compression result of the currently selected data.

[0033] Concatenate all the compression results and add the telemetry data marker L and the total amount of the index at the head.

[0034] Further, the index library includes a main index library and multiple backup index libraries. When adding the currently selected data to the index library and updating the total amount of the index, it includes:

[0035] Judge whether the main index library or the current backup index library is full. If the main index library or the current index library is full, enable the next backup index library and add the currently selected data to the next backup index library.

[0036] If the number of indexes in the main index library is less than the first value, update the total amount of the index after encoding the index number of the currently selected data as a single-digit number.

[0037] If the number of indexes in the main index library is greater than the first value and all backup index libraries are empty, update the total amount of the index after encoding the index number of the currently selected data as a two-digit number.

[0038] If a backup index library is enabled and the number of enabled backup index libraries is less than the second value, update the total amount of the index after encoding the index number of the currently selected data as a three-digit number, and the first digit of the encoding result is the index library number.

[0039] If a backup index library is enabled and the number of enabled backup index libraries is greater than the second value, update the total amount of the index after encoding the index number of the currently selected data as a four-digit number, and the first two digits of the encoding result are the index library number.

[0040] When encoding and compressing the telemetry data sequence in the current monitoring data, the following steps are also included:

[0041] If the number of indexes in the main index library is greater than the first value and the backup index libraries are all empty, modify the compression result and all single-digit encoded index numbers in the main index library to double-digit encoding;

[0042] If the backup index libraries are enabled and the number of enabled backup index libraries is less than the second value, add the corresponding index library number to the compression result of all basic unit data, and modify the compression result and all double-digit encoded index numbers in the main index library to three-digit encoding;

[0043] If the backup index libraries are enabled and the number of enabled backup index libraries is greater than the second value, add the corresponding index library number to the compression result of all basic unit data, and modify the compression result and all three-digit encoded index numbers in the main index library and the enabled backup index libraries to four digits.

[0044] Further, after sending the data packet to the blockchain for deposit, it includes the step of decompressing the compressed telemetry data by the smart contract of the blockchain, including:

[0045] Obtain the telemetry data sequence at the position of the telemetry data sequence in the message corresponding to the first piece of monitoring data. For each message after the message corresponding to the first piece of monitoring data, check the telemetry data flag L, the first flag Y, and the second flag G, and establish the corresponding index library according to the total amount of indexes;

[0046] For all data in the interval of the current message where the starting position is the first flag Y and the ending position is the second flag G, determine the length of the data after adding the index library number according to the total amount of indexes, sequentially select the data of the corresponding length, and add the basic unit part of the selected data to the corresponding index library according to the index library number part of the selected data, and use the basic unit part in the selected data as the decompressed telemetry data;

[0047] For all data in the interval of the current message where the starting position is the second flag G and the ending position is the first flag Y, determine the encoding length according to the total amount of indexes, sequentially select the data of the corresponding encoding length, query the corresponding index library according to the index library number of the data, and use the corresponding query result as the decompressed telemetry data.

[0048] Further, when splicing all signed messages during the abnormal network connection state and performing secondary signature to obtain the signed data packet, specifically, when the IoT control device is not in the sleep state, regularly obtain all signed messages within each specified-size time period during the abnormal network connection state, obtain all signed messages within at least one time period each time, splice all the signed messages obtained each time respectively, and perform secondary signature to obtain the corresponding signed data packet.

[0049] The present invention also provides an Internet of Things control device, including:

[0050] A data acquisition module, configured to obtain monitoring data, where the monitoring data includes the telemetry data sequence and the telemetering data sequence of all sensors in the grain bin corresponding to the Internet of Things control device;

[0051] A data processing module, configured to check the network connection status between the Internet of Things control device and the blockchain. If the network connection status is abnormal, splice the timestamp, the telemetry data sequence, the telemetering data sequence of the first monitoring data during the abnormal network connection status and the device ID of the Internet of Things control device to obtain a corresponding message. For the subsequent monitoring data during the abnormal network connection status, compress the timestamp through differential operation, compress the telemetry data sequence by status word, compress the telemetering data sequence by encoding, and then splice the compressed timestamp, telemetry data, and telemetering data with the device ID of the Internet of Things control device to obtain the message corresponding to the subsequent monitoring data, and sign all messages using the blockchain key;

[0052] A data uploading module, configured to wait for the network connection status to be normal, splice all the signed messages during the abnormal network connection status and perform a secondary signature to obtain a signed data packet, and send the data packet to the blockchain for evidence storage.

[0053] Compared with the prior art, the advantages of the present invention are as follows:

[0054] When the network connection status is abnormal, the present invention compresses the timestamp of the monitoring data through differential operation, compresses the telemetry data sequence of the monitoring data by status word, and compresses the telemetering data sequence of the monitoring data by encoding. Through an effective local data compression mechanism, local processing and caching of data in a weak network environment are realized, avoiding data loss.

[0055] The present invention signs all messages using the blockchain key, performs signature verification on the data from the source, and avoids the risk of data tampering.

[0056] After waiting for the network connection status to be normal, the present invention splices all the signed messages, performs a secondary signature, and then sends them to the blockchain for evidence storage, realizing the packaging and uploading of batch data. At this time, the content of the message is the compressed content, reducing the data transmission time, and only uploading after the network is restored, which can effectively reduce the upload times and energy consumption compared with the retry mechanism, meeting the requirements of low-power devices. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] Figure 1 It is a flowchart of an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0058] The present invention will be further described below in conjunction with the accompanying drawings of the specification and specific preferred embodiments, but the protection scope of the present invention is not limited thereby.

[0059] Embodiment 1

[0060] For the environmental monitoring in the granary, the main problems to be solved are as follows:

[0061] (1) Data processing limitations in a weak network environment: When there is no network or the network is unstable, data is easily lost.

[0062] (2) Low data processing efficiency after network recovery: When the network recovers, traditional solutions need to upload data item by item, resulting in high upload latency and increased energy consumption.

[0063] (3) Special requirements for low-power devices: The device is in a dormant state most of the time, and frequent network attempts when there is no network or the network is unstable and a large number of upload times when uploading data item by item will lead to excessive energy consumption and shorten the device life.

[0064] (4) Insufficient batch data processing ability: Existing solutions lack an optimized processing mechanism for batch data and cannot quickly complete data upload after network recovery.

[0065] To solve the above problems, this embodiment proposes a method for storing reliable data in a granary in a weak network environment. In the case of poor network, the monitoring data is compressed and saved locally, and preliminary processing of the data is completed locally and signed, verifying the signature of the data from the source to avoid the risk of data tampering. Wait until the network recovers, then pack and upload the compressed data saved locally to the chain. While ensuring the authenticity of the data, it reduces the time for data transmission and processing, realizing effective data storage. This method is applied to the Internet of Things control device of the granary.

[0066] As Figure 1 shown, the method of this embodiment includes the following steps:

[0067] S101) Obtain monitoring data. In this embodiment, the monitoring data includes the sequence of tele-signal data (0 or 1) and the sequence of telemetry data (an analog quantity, an integer, for example, an integer between 0 and 65535) of all sensors in the granary corresponding to the Internet of Things control device. All monitoring data is with a second-level timestamp. The monitoring data obtained in step S101 can be real-time obtained monitoring data or all monitoring data within each period obtained regularly according to a specified period;

[0068] S102) Check the network connection status with the blockchain. If the network connection status is normal, execute step S103; if the network connection status is abnormal, execute step S104;

[0069] In this embodiment, there are various ways to check whether the network connection status with the blockchain is normal, including but not limited to:

[0070] Collect the network latency, jitter or packet loss rate between the IoT control device and the blockchain in real time or at regular intervals, and calculate the average value. If one or more of the average values of the network latency, jitter or packet loss rate are greater than the corresponding threshold, the network connection status is abnormal. If the average values of the network latency, jitter or packet loss rate are all less than the corresponding threshold, the network connection status is normal;

[0071] Collect the network bandwidth rate between the IoT control device and the blockchain in real time or at regular intervals. If the average value of the network bandwidth rate is less than the threshold, the network connection status is abnormal, otherwise the network connection status is normal;

[0072] Send a request to the address of the blockchain at regular intervals. If a response is received within the specified time, the network connection status is normal. If the response times out, the network connection status is abnormal;

[0073] S103) If the network connection status is normal, splice the timestamp, the telecontrol data sequence, the telemetry data sequence of each piece of monitoring data during the period when the network connection status is normal with the device ID of the IoT control device to obtain the corresponding message. Use the blockchain key to sign each message, and then pack and perform secondary signature on each signed message during the period when the network connection status is normal and send it to the blockchain for evidence storage.

[0074] A complete blockchain evidence storage message can be mainly divided into three parts: second-level timestamp, message body, and data signature. In the case of normal network, the evidence storage process is as follows:

[0075] (1) Read data from the sensor. The data includes telecontrol type (0 or 1) and telemetry type (an analog quantity, an integer, for example, an integer between 0 and 65535)

[0076] (2) Assemble the data according to the assembly rules. (For example, if the current status of 16 fans is off (0), 8 temperature values are 255, 255, 255, 254, 254, 253, 254, 255, and 8 humidity values are 604, 603, 604, 603, 604, 603, 604, 603, then the assembled value is [00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00ff 00ff00ff00fe 00fe 00fd 00fe 00ff 02 5e 02 5b 02 5e 02 5b 02 5e 02 5b 02 5e 025b])

[0077] (3) Concatenate the device ID number and the timestamp. For example, the second-level timestamp for 2025-04-23 08:00:04 is 1745366404, and the device ID number is 125. Then the assembled value is 【00 7d 68 08 2D 84 00 00 00 00 00 00 0000 00 00 00 00 00 0000 00 00ff 00ff 00ff 00fe 00fe 00fd 00fe 00ff 02 5e 02 5b02 5e 02 5b 02 5e 02 5b 02 5e 02 5b】

[0078] (4) Use the built-in blockchain key of the Internet of Things device to sign the above message, and take the last 8 bytes to get the message 【00 7d 68 08 2D 84 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000ff 00ff 00ff 00fe00fe 00fd 00fe 00ff 02 5e 02 5b 02 5e 02 5b 02 5e 02 5b 025e 02 5b bb 1a 88fe ad 34c9 14】

[0079] (5) Perform a packaging operation on the message. Specifically, store the above message in the extra field of the blockchain transaction to encapsulate it into the following transaction form:

[0080] {"jsonrpc":"2.0","namespace":"global","method":"tx_sendTransaction","params":[{

[0081] "signature":0x00acc3e13d8124fe799d55d7d2af06223148dc7bbc723718bb1a88fead34c914",

[0082] "from":"0x856E2B9A5FA82FD1B031D1FF6863864DBAC7995D",

[0083] "to":"0x794BF01AB3D37DF2D1EA1AA4E6F4A0E988F4DEA5",

[0084] "type":"EVM",

[0085] "nonce":8916188877127249,

[0086] "simulate": false,

[0087] "timestamp": 1745366404839922607,

[0088] "extra": "00 7d 68 08 2D 84 00 00 00 00 00 00 00 00 00 00 00 00 00 0000 00 00ff 00ff 00ff00fe 00fe 00fd 00fe 00ff 02 5e 02 5b 02 5e 02 5b 02 5e 025b bb 1a 88fe ad 34c9 14"}],"id": 1}

[0089] (6) Perform a secondary signature on the transaction and send the signed transaction to the blockchain. Specifically, use the private key of the sender (i.e., the IoT control device) to sign the transaction to ensure the integrity of the transaction and the authentication of the sender's identity.

[0090] S104) Concatenate the timestamp, the sequence of telecontrol data, and the sequence of telemetry data of the first piece of monitoring data during the abnormal network connection state with the device ID of the IoT control device to obtain the corresponding message. For the subsequent monitoring data during the abnormal network connection state, compress the timestamp through differential operation, compress the sequence of telecontrol data by status word, and compress the sequence of telemetry data by encoding. Then, concatenate the compressed timestamp, telecontrol data, and telemetry data with the device ID of the IoT control device to obtain the message corresponding to the subsequent monitoring data. Sign all the messages with the blockchain key, wait for the network connection state to return to normal, concatenate all the signed messages during the abnormal network connection state and perform a secondary signature to obtain the signed data packet, and send the data packet to the blockchain for evidence storage.

[0091] In view of the fact that data cannot be effectively uploaded to the blockchain in a weak network environment, in order to ensure that data is not lost, it is necessary to perform local caching on the data. When the network is restored, multiple pieces of data need to be stored on the chain simultaneously. At this time, if all the data is simply concatenated without compression, the network bandwidth requirements and the latency time are positively correlated. Therefore, it is necessary to compress the data from the source. In this embodiment, the first piece of monitoring data during the recognized abnormal network connection state is used as the benchmark, and the process of generating the message is basically the same as the processing process of the monitoring data when the network connection state is normal. For the subsequent monitoring data, perform data compression according to the following process:

[0092] (1) Compress the timestamp through differential operation. Specifically, use the second-order difference algorithm for processing and start with T, including the following steps:

[0093] Take the timestamp of the first piece of monitoring data during the abnormal network connection state as the reference timestamp;

[0094] Perform a first-order difference operation on the timestamp of the current monitoring data and the reference timestamp to obtain the result of the first-order difference operation of the timestamp of the current monitoring data;

[0095] If the current monitoring data is the second piece of monitoring data during the abnormal network connection state, add a timestamp marker to the result of the first-order difference operation of the timestamp of the current monitoring data to obtain the compressed timestamp of the current monitoring data;

[0096] If the current monitoring data is not the second piece of monitoring data during the abnormal network connection state, perform a second-order difference operation on the result of the first-order difference operation of the timestamps of the current monitoring data and the previous piece of detection data to obtain the result of the second-order difference operation of the timestamp of the current monitoring data, and add a timestamp marker T to the head of the result of the second-order difference operation of the timestamp of the current monitoring data to obtain the compressed timestamp of the current monitoring data.

[0097] For example, if the reference timestamp is 1745366404 (2025-04-23 08:00:04) and the current time is 1745366405 (2025-04-23 08:00:05), the result of the first-order difference operation is 1. On this basis, perform a second-order difference operation. For example, if the current time of the third piece of monitoring data is 1745366407 (2025-04-23 08:00:07), the result of its first-order difference operation is 3, and the result of the second-order difference operation is 2. Therefore, its timestamp value is compressed to T02. For the second piece of monitoring data, its timestamp is T01.

[0098] (2) Perform different compressions according to data classification. If it is telecontrol signal data (0 or 1), perform status word compression; if it is telemetry data (analog quantity), perform variable-length coding compression. Specifically:

[0099] Telecontrol signal data only uses 0 or 1 to identify the working state or fault state, and has the characteristic of continuity (that is, it remains 0 or 1 within a period of time). Therefore, the data points with the same status word that appear continuously can be merged into one time period, and only three indicators, namely start time, time interval, and value, are used to represent it, and it starts with K. Reduce duplicate storage and transmission of data. When performing status word compression on the telecontrol signal data sequence, the following steps are included:

[0100] Compare each piece of telecontrol signal data of the current monitoring data with each piece of telecontrol signal data of the previous piece of detection data;

[0101] If the current status value of the telemetry data is the same as the previous status value, update the status hold value of the telemetry data, specifically, increment the status hold value by one;

[0102] If the current status value of the telemetry data is different from the previous status value, concatenate the serial number of the telemetry data, the status hold value, and the current status value, and add the telemetry data marker K at the head of the concatenation result to obtain the compressed telemetry data, then reset the status hold value of the telemetry data, specifically, reset the status hold value to 1.

[0103] For example, at the previous time 1745366404 (2025-04-23 08:00:04), the statuses of 16 fans were all off (0). At the current time 1745366405 (2025-04-23 08:00:05), it is received that the statuses of the first 15 fans are off (0), and the status of the 16th fan is on (1). Then the data can be compressed to 10 01 01, where 10 is a hexadecimal number representing the 16th fan, the first 01 is the status hold value, and the second 01 is the current status value, indicating that after 1 consecutive status hold, the status changes to 1.

[0104] In the granary scenario, it is necessary to use the same type of sensors to monitor the grain storage environment at multiple detection points, and at the same time use the AD sampling method for analog-to-digital conversion. Therefore, the data will fluctuate up and down in a short period of time, so it is not suitable for the data compression algorithm of telemetry data (because the data between the previous and the current time has volatility); however, due to the principle of arranging the same type of data adjacent to each other in data grouping, there are cases where adjacent data are similar. Therefore, based on this feature, the telemetry data can be encoded and compressed, and it starts with L. When encoding and compressing the telemetry data sequence in the current monitoring data, the following steps are included:

[0105] Select the data query index library of the basic unit from the telemetry data sequence in turn. Since the data in the telemetry data sequence is an integer, the range is 0x0000 - 0xffff, that is, 2 bytes. At the same time, in this embodiment, 2 bytes are used as the basic unit;

[0106] If there is no query result for the currently selected data in the index library, add the currently selected data to the index library. If the compression result of the previous selected data is the data of the basic unit or the data of the basic unit with the first marker Y added at the head, then use the currently selected data as the compression result of the currently selected data; otherwise, add the first marker Y at the head of the currently selected data as the compression result of the currently selected data;

[0107] If there is a query result for the currently selected data in the index library, obtain the index number. If the compressed result of the previous selected data is the index number or the index number with the second marker G added to the head, then use the index number as the compressed result of the currently selected data; otherwise, add the second marker G to the head of the index number as the compressed result of the currently selected data.

[0108] Concatenate all the compressed results and add the telemetry data marker L and the total amount of the index to the head.

[0109] Take the telemetry data sequence [00ff 00ff00ff 00fe 00fe 00fd 00fe 00ff 02 5e 02 5b 02 5e 02 5b 02 5e 02 5b 02 5e 025b] with the current time being 1745366405 (2025-04-23 08:00:05) as an example:

[0110] First, check 00ff. Since it is not in the index library, add 00ff to the index library, and the index number is 1. At this time, the encoded result returned is Y00ff;

[0111] Secondly, check 00ff. It is found that the value is included in the index library, so directly return the index number 1. At this time, the encoded result returned is Y00ffG1;

[0112] And so on. When checking 00fe, it is found that it is not in the index library, so add 00fe to the index library, and the index number is 2. At this time, the encoded result returned is Y00ffG11Y00fe;

[0113] And so on until the compression is completed. At this time, the encoded result returned is Y00ffG11Y00feG2Y00fdG21Y025e025bG45454545.

[0114] Therefore, the compressed telemetry data is: L5 Y00ffG11Y00feG2Y00fdG21Y025e025bG45454545.

[0115] For the monitoring data with the timestamp of 1745366405 (2025-04-23 08:00:05), after compressing the data and then concatenating the device ID number and the timestamp, the corresponding message is:

[0116] 00 7d T01 K10 01 01L Y00ffG11Y00feG2Y00fdG21Y025e025bG45454545, a total of 56 characters, while the message after splicing the monitoring data with a timestamp of 1745366404 (2025-04-23 08:00:04) under the example of step S103: 00 7d 68 08 2D 84 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000ff 00ff 00ff 00fe 00fe 00fd 00fe 00ff 02 5e 02 5b 02 5e 02 5b 02 5e 02 5b02 5e 02 5b, a total of 108 characters. It can be seen that a better compression effect is achieved in comparison.

[0117] In step S104 of this embodiment, when using the blockchain key to sign all messages, the built-in blockchain key of the Internet of Things device is also used to sign the message, and the last 8 bytes are added to the sequence of the message. For example, after signing the above message, the message [00 7d T01 K10 01 01LY00ffG11Y00feG2Y00fdG21Y025e025bG45454545bb 1a 88fe ad 34c9 14] is obtained.

[0118] In step S104 of this embodiment, when splicing all the signed messages during the abnormal network connection state and performing a secondary signature to obtain a signed data packet, specifically, when the Internet of Things control device is not in the low-power sleep state and the network connection state is normal, the signed messages in each specified-size time period during the abnormal network connection state saved locally are obtained regularly. Each time, all the signed messages in one or more time periods are obtained, and then all the signed messages corresponding to that time period are spliced and a secondary signature is performed to obtain the corresponding signed data packet for each time. By regularly and batch-wise uploading the signed messages during the abnormal network connection state saved locally to the blockchain for evidence storage, the energy consumption is effectively reduced compared to uploading data item by item, and at the same time, it can also avoid occupying too much network resources and affecting the uploading of the messages of the monitoring data obtained during the normal network connection state to the blockchain for evidence storage.

[0119] In step S104 of this embodiment, the following improvements are also considered for the index library: Since the index library uses index numbers for direct indexing and the index range is from 0 to 65536, when the number of indexed contents exceeds 10,000, the number of digits of the index number will be greater than the indexed content. To solve this problem, the index library is designed with 1 main index library and 255 backup index libraries, and each index library can store up to 256 indexes at most. Only when the main index library or the previous backup index library is full, the next backup index library will be enabled. It should be noted that when only the main index library is enabled and the number of indexes is less than 16, the index uses single-digit encoding and the index library number can be omitted, that is, from 0 to f; when only the main index library is enabled and the number of indexes is greater than 16, the index uses two-digit encoding and the index library number can be omitted, that is, from 00 to ff; when the backup index library is enabled and the number of enabled backup index libraries is less than 16, three-digit encoding is used and the index library number needs to be carried, that is, from 000 to fff, where the first digit represents the index library number and the last two digits represent the index value; when the backup index library is enabled and the number of enabled backup index libraries is greater than 16, four-digit encoding is used, that is, from 0000 to ffff, where the first two digits represent the index library number and the last two digits represent the index value. This ensures that the number of digits of the index number is greater than the indexed content. It should be noted that during the dynamic encoding process, since the number of indexes cannot be known in advance, when reaching the above critical point, the idea of trading time for space is adopted, and all the previously encoded contents need to be updated to ensure the correctness of the indexed content; while in the decoding process, since the total number of indexes has been determined after the marker L, the encoding digits of the index can be directly calculated to ensure the correctness of the decoding.

[0120] When adding the currently selected data to the index library and updating the total amount of indexes, it includes:

[0121] Judge whether the main index library or the current backup index library is full. If the main index library or the current index library is full, enable the next backup index library and add the currently selected data to the next backup index library;

[0122] If the number of indexes in the main index library is less than the first value, encode the index number of the currently selected data with single digits and then update the total amount of indexes;

[0123] If the number of indexes in the main index library is greater than the first value and all backup index libraries are empty, encode the index number of the currently selected data with two digits and then update the total amount of indexes;

[0124] If the backup index library is enabled and the number of enabled backup index libraries is less than the second value, encode the index number of the currently selected data with three digits and then update the total amount of indexes. The first digit of the encoding result is the index library number;

[0125] If the backup index library is enabled and the number of enabled backup index libraries is greater than the second value, the total amount of the index is updated after four-digit encoding of the index number of the currently selected data, and the first two digits of the encoding result are the index library number;

[0126] Correspondingly, in step S104, when encoding and compressing the telemetry data sequence in the current monitoring data, the following steps are further included:

[0127] If the number of indexes in the main index library is greater than the first value and the backup index libraries are all empty, the compression result and all single-digit encoded index numbers in the main index library are modified to double-digit encoding;

[0128] If the backup index library is enabled and the number of enabled backup index libraries is less than the second value, the corresponding index library number is added to the compression results of the data of all basic units, and the compression result and all double-digit encoded index numbers in the main index library are modified to three-digit encoding;

[0129] If the backup index library is enabled and the number of enabled backup index libraries is greater than the second value, the corresponding index library number is added to the compression results of the data of all basic units, and the compression result and all three-digit encoded index numbers in the main index library and the enabled backup index libraries are modified to four digits.

[0130] For example, when there are already 15 indexes in the main index and the original encoded content is G1122, when the 16th index is added, the index is changed to two-digit encoding. Therefore, the original encoded content is changed to G01010202; when decoding, since the total number of indexes is known to be 16, it can be known that two-digit encoding is used and the index library number can be omitted. Therefore, decoding is directly performed according to the two-digit encoding in the main library, that is, the first index, the first index, the second index, and the second index in the main library are obtained respectively.

[0131] In this embodiment, for step S103, when the signed messages during each normal network connection state are respectively packed, secondarily signed, and then sent to the blockchain for evidence storage, specifically, the signed transaction is sent to the blockchain smart contract. After the smart contract verifies the signature of the content to be uploaded, since the messages signed during the normal network connection state are not compressed, the smart contract directly calls the built-in evidence storage method of the contract to perform data evidence storage.

[0132] For step S104, when sending the signed data packet to the blockchain for evidence storage, specifically, the signed transaction is sent to the blockchain smart contract. After the smart contract verifies the signature of the content uploaded to the chain, since the data packet is obtained by splicing the messages signed during the abnormal network connection state, and the content of the messages other than the message corresponding to the first monitoring data has been compressed, the smart contract decompresses the content of each message and then calls the built-in evidence storage method in the contract to perform data evidence storage.

[0133] In this embodiment, when splicing all the signed messages during the abnormal network connection state, specifically, the messages are spliced in ascending order of the second-level timestamps corresponding to all the signed messages during the abnormal network connection state, so that during the decompression process, based on the relevant information of the message corresponding to the first monitoring data, an accurate decompression result can be obtained. Specifically, in this embodiment, after sending the data packet to the blockchain for evidence storage, the smart contract of the blockchain decompresses the content of each message, including:

[0134] (1) Decompress the compressed timestamp, and the steps are as follows:

[0135] Obtain the reference timestamp at the position of the timestamp in the message corresponding to the first monitoring data. For each message after the message corresponding to the first monitoring data, respectively obtain the compressed timestamp of each message according to the timestamp marker T in turn;

[0136] If the current message is the message corresponding to the second monitoring data after the first monitoring data, add the value of the compressed timestamp of the current message to the value of the reference timestamp to obtain the timestamp of the current message;

[0137] If the current message is other messages, add the value of the compressed timestamp of the current message to the values of the compressed timestamps of all the messages before the current message, and then add the calculation result to the value of the reference timestamp to obtain the timestamp of the current message.

[0138] (2) Decompress the compressed telecontrol data, and the steps are as follows:

[0139] Obtain the telecontrol data sequence at the position of the telecontrol data sequence in the message corresponding to the first monitoring data. For each message after the message corresponding to the first monitoring data, check the telecontrol data marker K;

[0140] If the telecontrol data marker K does not exist in the current message, use the telecontrol data sequence of the previous message as the telecontrol data sequence of the current message;

[0141] If the remote signaling data flag K exists in the current message, obtain the compressed remote signaling data after the remote signaling data flag K, select the corresponding message before the current message according to the status retention value, obtain the remote signaling data sequence of the selected message, and adjust the remote signaling data at the corresponding position in the remote signaling data sequence of the selected message according to the serial number of the remote signaling data and the current status value to obtain the remote signaling data sequence of the current message.

[0142] For example, if the current message is the third message and the compressed remote signaling data after the remote signaling data flag K is 1001 01, then select the second message according to the status retention value 01, obtain the remote signaling data sequence of the second message, and then adjust the status value of the 16th fan in the remote signaling data sequence of the second message to 01 according to the serial number 10 of the remote signaling data and the current status value 01 to obtain the remote signaling data sequence of the current message.

[0143] (3) Decompress the compressed remote measurement data, and the steps are as follows:

[0144] Obtain the remote measurement data sequence at the position of the remote measurement data sequence in the message corresponding to the first piece of monitoring data. For each message after the message corresponding to the first piece of monitoring data, check the remote measurement data flag L;

[0145] If the remote measurement data flag L of the current message exists, obtain the compressed remote measurement data after the remote measurement data flag L, check the first flag Y and the second flag G, and establish a corresponding index library according to the total amount of indexes;

[0146] For all the data in the interval of the current message where the starting position is the first flag Y and the ending position is the second flag G, determine the length of the data after adding the index library number according to the total amount of indexes, sequentially select the data of the corresponding length, add the basic unit part of the selected data to the corresponding index library according to the index library number part of the selected data, and use the selected data as the decompressed remote measurement data;

[0147] For all the data in the interval of the current message where the starting position is the second flag G and the ending position is the first flag Y, determine the coding length according to the total amount of indexes, sequentially select the data of the corresponding coding length, query the corresponding index library for the index of the front one or two bits of the data according to the index library number of the front part of the data, and use the corresponding query result as the decompressed remote measurement data.

[0148] Embodiment 2

[0149] Due to the special requirements of low-power devices, frequent data uploads will consume a large amount of power. The IoT control device needs to adopt an operating mode that alternates between a sleep state and a working state, and is in the sleep state for most of the time. Therefore, this embodiment proposes a method for storing trusted data in a granary under a weak network environment, which is basically the same as Embodiment 1. The difference is that before step S102 of this embodiment, it further includes: checking the state of the IoT control device. If it is in the working state, jump to execute step S102; if it is in the sleep state, jump to execute step S105;

[0150] Correspondingly, step S105 of this embodiment includes the following steps:

[0151] If it is in the sleep state, during the sleep state, splice the timestamp of the first monitoring data, the telecontrol data sequence, the telemetry data sequence with the device ID of the IoT control device to obtain the corresponding message. For subsequent monitoring data, compress the timestamp through the same differential operation as in Embodiment 1, compress the telecontrol data sequence with the same status word compression as in Embodiment 1, and compress the telemetry data sequence with the same coding compression as in Embodiment 1. Then splice the compressed timestamp, telecontrol data, and telemetry data with the device ID of the IoT control device to obtain the message corresponding to the subsequent monitoring data, and sign all messages using the blockchain key;

[0152] Wait until it is in the working state and the network connection status is normal, splice the messages signed during the sleep state and perform a secondary signature to obtain a signed data packet, and send the data packet to the blockchain for evidence storage.

[0153] This embodiment takes into account the actual situation and adds a working mechanism for local compression and signature of monitoring data in the sleep state, which more effectively solves the problem that data cannot be effectively stored under the device sleep mechanism and weak network environment.

[0154] Embodiment 3

[0155] This embodiment proposes a method for storing trusted data in a granary under a weak network environment, which is basically the same as Embodiment 1. The difference is that step S103 of this embodiment is as follows:

[0156] If the network connection status is normal, during the period when the network connection status is normal, at a specified size period, the timestamp of the first piece of monitoring data, the telecontrol data sequence, the telemetry data sequence in each period are concatenated with the device ID of the Internet of Things control device to obtain the corresponding message. For the subsequent monitoring data in each period, the timestamp is compressed through the same differential operation as in Embodiment 1, the telecontrol data sequence is compressed with the same status word as in Embodiment 1, the telemetry data sequence is compressed with the same encoding as in Embodiment 1. Then, the compressed timestamp, telecontrol data, telemetry data are concatenated with the device ID of the Internet of Things control device to obtain the message corresponding to the subsequent monitoring data, and all messages are signed using the blockchain key;

[0157] At the start moment of each period, all the signed messages of the previous period are concatenated, and after secondary signing, they are sent to the blockchain for deposit.

[0158] In this embodiment, in the case of normal network connection status, by adopting the method of timing data uploading to the blockchain, it can avoid frequent data uploading. At the same time, the data uploaded to the blockchain has also undergone local compression processing, which can effectively reduce power consumption compared with the method of uploading uncompressed messages one by one.

[0159] Embodiment 4

[0160] This embodiment provides an Internet of Things control device, including:

[0161] A data acquisition module, configured to acquire monitoring data, where the monitoring data includes the telecontrol data sequence and the telemetry data sequence of all sensors in the grain bin corresponding to the Internet of Things control device;

[0162] A data processing module, configured to check the network connection status between the Internet of Things control device and the blockchain. If the network connection status is abnormal, the timestamp of the first piece of monitoring data, the telecontrol data sequence, the telemetry data sequence during the period when the network connection status is abnormal are concatenated with the device ID of the Internet of Things control device to obtain the corresponding message. For the subsequent monitoring data during the period when the network connection status is abnormal, the timestamp is compressed through the same differential operation as in Embodiment 1, the telecontrol data sequence is compressed with the same status word as in Embodiment 1, the telemetry data sequence is compressed with the same encoding as in Embodiment 1. Then, the compressed timestamp, telecontrol data, telemetry data are concatenated with the device ID of the Internet of Things control device to obtain the message corresponding to the subsequent monitoring data, and all messages are signed and saved using the blockchain key;

[0163] If the network connection status is normal, then the timestamp of each piece of monitoring data, the telecontrol data sequence, the telemetry data sequence during the period when the network connection status is normal are concatenated with the device ID of the Internet of Things control device to obtain the corresponding message, and each message is signed using the blockchain key;

[0164] The data uploading module is used to splice all the signed messages during the period when the network connection status is abnormal after waiting for the network connection status to be normal, perform secondary signature to obtain a signed data packet, send the data packet to the blockchain for evidence storage, and is also used to pack and perform secondary signature on each signed message during the period when the network connection status is normal, and then send it to the blockchain for evidence storage.

[0165] In this embodiment, the data uploading module is decoupled from the data processing module. When the data uploading module works, the data processing module pauses working, and the data acquisition module continues to work. At this time, the data acquired by the data acquisition module is temporarily stored in the buffer, and waits to be compressed and processed after the data processing module resumes working. Because the time consumed for compression processing is much lower than the acquisition time of data acquisition, therefore, it can ensure that the data is processed completely.

[0166] In a weak network environment. The working process of the IoT control device in this embodiment when the network connection status is abnormal is as follows:

[0167] (1) After the data acquisition module collects the environment (temperature, humidity, nitrogen, pressure, etc.) in the granary, it sends it to the data processing module.

[0168] (2) The data processing module compresses and packages according to the message of the acquisition module and the acquisition time, and signs it using the blockchain key with one key for one device built in the IoT control device.

[0169] (3) The data uploading module is decoupled from the data processing module. After waiting for the network connection status to be normal, it first detects whether it is in the low-power sleep mode. If so, it does not work. Otherwise, it regularly obtains the data to be uploaded from the data processing module, performs secondary signature, and sends it to the blockchain smart contract. If the sending is successful, it clears the data processing module and performs the next processing; when the sending fails, it waits for the next retry.

[0170] (4) After the smart contract verifies and decrypts the uploaded content, it then calls the evidence storage method built in the contract to perform data evidence storage.

[0171] The IoT control device in this embodiment realizes a transmission mechanism that decouples data acquisition and processing and data uploading through the above process. That is, when the data acquisition module receives the acquired data, it first sends the data to the data processing module, and performs data encoding and primary signature according to step S104 in Embodiment 1. At the same time, the data uploading module regularly obtains data from the data processing module for uploading.

[0172] In summary, in view of the problem that the existing solutions lack optimized designs for weak network environments and low power consumption requirements and are difficult to meet the specific requirements of environmental monitoring in granaries, the present invention proposes a method for storing reliable data in granaries in a weak network environment and an Internet of Things control device for implementing this method, effectively solving the problem that data cannot be effectively certified in the device sleep mechanism and weak network environments.

[0173] It has the following advantages:

[0174] (1) Through the secondary signature and compression mechanism, it is possible to complete the local processing and caching of data in a weak network environment, avoid data loss, and reduce the time for data transmission and processing while ensuring the authenticity of the data.

[0175] (2) The local signature mechanism can complete the preliminary processing of data in a network-free environment and perform signature verification on the data from the source, avoiding the risk of data tampering.

[0176] (3) Batch data packaging and uploading: Optimize the efficiency of data transmission after network recovery, reduce the number of uploads and energy consumption. At the same time, the decoding and certification of smart contracts achieve the automated processing and reliable certification of data.

[0177] The above is only the preferred implementation mode of the present invention. The protection scope of the present invention is not limited to the above embodiments. All technical solutions falling within the idea of the present invention belong to the protection scope of the present invention. It should be noted that for those of ordinary skill in the art, several improvements and refinements made without departing from the principle of the present invention should also be regarded as within the protection scope of the present invention.

Claims

1. A method for storing trusted data in a granary under a weak network environment, characterized in that, The method is applied to the Internet of Things control device of a granary, and the method includes the following steps: Obtain monitoring data, where the monitoring data includes the telemetry data sequence and the telemetry data sequence of all sensors in the granary corresponding to the Internet of Things control device; Check the network connection status with the blockchain; If the network connection status is abnormal, splice the timestamp, the telemetry data sequence, the telemetry data sequence of the first monitoring data during the abnormal network connection status with the device ID of the Internet of Things control device to obtain the corresponding message. For the subsequent monitoring data during the abnormal network connection status, compress the timestamp through differential operation, compress the telemetry data sequence by status word, and compress the telemetry data sequence by encoding. Then splice the compressed timestamp, telemetry data, and telemetry data with the device ID of the Internet of Things control device to obtain the message corresponding to the subsequent monitoring data, and sign all messages with the blockchain key; Wait for the network connection status to be normal, splice all the signed messages during the abnormal network connection status and perform a secondary signature to obtain a signed data packet, and send the data packet to the blockchain for evidence storage.

2. The method for storing reliable data of a granary in a weak network environment according to claim 1, wherein, When compressing the timestamp through differential operation, it includes the following steps: Take the timestamp of the first monitoring data during the abnormal network connection status as the reference timestamp; Perform a first-order differential operation on the timestamp of the current monitoring data and the reference timestamp to obtain the first-order differential operation result of the timestamp of the current monitoring data; If the current monitoring data is the second monitoring data during the abnormal network connection status, add a timestamp mark to the first-order differential operation result of the timestamp of the current monitoring data to obtain the compressed timestamp of the current monitoring data; If the current monitoring data is not the second monitoring data during the abnormal network connection status, perform a second-order differential operation on the first-order differential operation result of the timestamp of the current monitoring data and the first-order differential operation result of the timestamp of the previous monitoring data to obtain the second-order differential operation result of the timestamp of the current monitoring data, and add a timestamp mark T to the head of the second-order differential operation result of the timestamp of the current monitoring data to obtain the compressed timestamp of the current monitoring data.

3. The method for storing trustworthy data of a granary in a weak network environment according to claim 2, characterized in that, After sending the data packet to the blockchain for evidence storage, it includes the step of decompressing the compressed timestamp by the smart contract of the blockchain, including: Obtain the reference timestamp at the position of the timestamp in the message corresponding to the first monitoring data. For each message after the message corresponding to the first monitoring data, respectively obtain the compressed timestamp of each message in turn according to the timestamp mark T; If the current message is the message corresponding to the second monitoring data after the first monitoring data, add the value of the compressed timestamp of the current message to the value of the reference timestamp to obtain the timestamp of the current message; If the current message is other messages, add the value of the compressed timestamp of the current message to the values of the compressed timestamps of all messages before the current message, and then add the calculation result to the value of the reference timestamp to obtain the timestamp of the current message.

4. The method for storing reliable data of a granary in a weak network environment according to claim 1, characterized in that, When compressing the telemetry data sequence by status word, it includes the following steps: Compare each telemetry data of the current monitoring data with each telemetry data of the previous monitoring data; If the current status value of the telemetry data is the same as the previous status value, update the status retention value of the telemetry data; If the current status value of the telemetry data is different from the previous status value, concatenate the serial number, status retention value, and current status value of the telemetry data, and add the telemetry data marker K at the head of the concatenated result to obtain the compressed telemetry data, then reset the status retention value of the telemetry data.

5. The method for storing trustworthy data of a granary in a weak network environment according to claim 4, wherein After sending the data packet to the blockchain for evidence storage, it includes the step of decompressing the compressed telemetry data by the smart contract of the blockchain, including: Obtain the telemetry data sequence at the position of the telemetry data sequence in the message corresponding to the first monitoring data. For each message after the message corresponding to the first monitoring data, check the telemetry data marker K; If the telemetry data marker K does not exist in the current message, use the telemetry data sequence of the previous message as the telemetry data sequence of the current message; If the telemetry data marker K exists in the current message, obtain the compressed telemetry data after the telemetry data marker K, select the corresponding message before the current message according to the status retention value, obtain the telemetry data sequence of the selected message, and adjust the telemetry data at the corresponding position in the telemetry data sequence of the selected message according to the serial number and current status value of the telemetry data to obtain the telemetry data sequence of the current message.

6. The method for storing reliable data of a granary in a weak network environment according to claim 1, wherein, When encoding and compressing the telemetry data sequence in the current monitoring data, it includes the following steps: Sequentially select the data query index library of the basic unit from the telemetry data sequence; If there is no query result for the currently selected data in the index library, add the currently selected data to the index library and update the total amount of the index. If the compression result of the previous selected data is the data of the basic unit or the data of the basic unit with the first marker Y added at the head, use the currently selected data as the compression result of the currently selected data, otherwise add the first marker Y at the head of the currently selected data as the compression result of the currently selected data; If there is a query result for the currently selected data in the index library, obtain the corresponding index number. If the compression result of the previous selected data is the index number or the index number with the second marker G added at the head, use the corresponding index number as the compression result of the currently selected data, otherwise add the second marker G at the head of the corresponding index number as the compression result of the currently selected data; Concatenate all the compression results and add the telemetry data marker L and the total amount of the index at the head.

7. The method for storing trustworthy data of a granary in a weak network environment according to claim 6, characterized in that, The index library includes a main index library and multiple backup index libraries. When adding the currently selected data to the index library and updating the total amount of the index, it includes: Judge whether the main index library or the current backup index library is full. If the main index library or the current index library is full, enable the next backup index library and add the currently selected data to the next backup index library; If the number of indexes in the main index library is less than the first value, encode the index number of the currently selected data by a single digit and update the total amount of the index; If the number of indexes in the main index library is greater than the first value and all the backup index libraries are empty, encode the index number of the currently selected data by a double digit and update the total amount of the index; If the backup index library is enabled and the number of enabled backup index libraries is less than the second value, the total amount of indexes is updated after three-digit encoding of the index numbers of the currently selected data, and the first digit of the encoding result is the index library number; If the backup index library is enabled and the number of enabled backup index libraries is greater than the second value, the total amount of indexes is updated after four-digit encoding of the index numbers of the currently selected data, and the first two digits of the encoding result are the index library numbers; When encoding and compressing the telemetry data sequence in the current monitoring data, the following steps are further included: If the number of indexes in the main index library is greater than the first value and the backup index libraries are all empty, the compression result and all single-digit encoded index numbers in the main index library are modified to double-digit encoding; If the backup index library is enabled and the number of enabled backup index libraries is less than the second value, the corresponding index library number is added to the compression results of all base unit data, and the compression result and all double-digit encoded index numbers in the main index library are modified to three-digit encoding; If the backup index library is enabled and the number of enabled backup index libraries is greater than the second value, the corresponding index library number is added to the compression results of all base unit data, and the compression result and all three-digit encoded index numbers in the main index library and the enabled backup index libraries are modified to four-digit encoding.

8. The method for storing reliable data of a granary in a weak network environment according to claim 7, characterized in that, After sending the data packet to the blockchain for evidence storage, it includes the step of decompressing the compressed telemetry data by the smart contract of the blockchain, including: Obtain the telemetry data sequence at the position of the telemetry data sequence in the message corresponding to the first piece of monitoring data. For each message after the message corresponding to the first piece of monitoring data, check the telemetry data flag L, the first flag Y, and the second flag G, and establish the corresponding index library according to the total amount of indexes; For all data in the interval of the current message whose start position is the first flag Y and end position is the second flag G, determine the length of the data after adding the index library number according to the total amount of indexes, sequentially select the data of the corresponding length, and add the base unit part of the selected data to the corresponding index library according to the index library number part of the selected data, and use the base unit part in the selected data as the decompressed telemetry data; For all data in the interval of the current message whose start position is the second flag G and end position is the first flag Y, determine the encoding length according to the total amount of indexes, sequentially select the data of the corresponding encoding length, query the corresponding index library according to the index library number of the data, and use the corresponding query result as the decompressed telemetry data.

9. The method for storing reliable data of a granary in a weak network environment according to claim 1, wherein When splicing all signed messages during abnormal network connection status and performing secondary signature to obtain a signed data packet, specifically, when the IoT control device is not in the sleep state, regularly obtain all signed messages within each specified-size time period during abnormal network connection status. Each time, obtain all signed messages within at least one time period, splice all the signed messages obtained each time respectively, and perform secondary signature to obtain the corresponding signed data packet.

10. An Internet of Things control device, characterized in that, Including: A data acquisition module, which is used to obtain monitoring data, and the monitoring data includes the teleinformation data sequence and the telemetry data sequence of all sensors in the grain bin corresponding to the Internet of Things control device; A data processing module, which is used to check the network connection status between the Internet of Things control device and the blockchain. If the network connection status is abnormal, it will splice the timestamp, the teleinformation data sequence, the telemetry data sequence of the first monitoring data during the abnormal network connection status with the device ID of the Internet of Things control device to obtain the corresponding message. For the subsequent monitoring data during the abnormal network connection status, the timestamp is compressed through differential operation, the teleinformation data sequence is compressed by status word, the telemetry data sequence is compressed by encoding, and then the compressed timestamp, teleinformation data, and telemetry data are spliced with the device ID of the Internet of Things control device to obtain the message corresponding to the subsequent monitoring data, and all messages are signed using the blockchain key; A data uploading module, which is used to wait for the network connection status to be normal, splice all the signed messages during the abnormal network connection status and perform secondary signature to obtain a signed data packet, and send the data packet to the blockchain for evidence storage.