Disclosure of Invention
The invention aims to solve the technical problem of providing an agricultural environment data acquisition system and method based on Beidou short messages aiming at the defects in the prior art.
The technical scheme adopted by the invention for solving the technical problems is as follows:
the invention provides an agricultural environment data acquisition system based on Beidou short messages, which comprises a sending end and a receiving end, wherein the sending end comprises a receiving end, and the receiving end comprises a receiving end and a transmitting end, wherein the receiving end comprises a receiving end body, a receiving end body and a transmitting end body, and the receiving end body comprises a receiving end:
the transmitting end includes: the Beidou short message all-in-one machine comprises a control terminal, a Beidou short message all-in-one machine at a sending end and various environment sensors;
the multiple environment sensors are connected with the control terminal and used for acquiring multiple agricultural environment data and transmitting the acquired agricultural environment data to the control terminal through multiple communication protocols;
the control terminal is used for carrying out format conversion processing and local storage on the agricultural environment data, transmitting the agricultural environment data to be transmitted to the Beidou short message all-in-one machine and controlling the Beidou short message all-in-one machine to carry out data transmission;
the Beidou short message all-in-one machine of the sending end is connected with the control terminal and used for carrying out Beidou positioning and time service, taking out agricultural environment data to be sent from local storage, and coding the agricultural environment data into short message data for transmission according to a reliable communication protocol of the Beidou short message of the sending end; the reliable communication protocol of the Beidou short message at the sending end comprises the following steps: the sending end carries out environment data coding and flag bit coding; the sending frequency is dynamically adjusted according to different environments through a request confirmation mechanism based on probability judgment;
the receiving end includes: the Beidou short message all-in-one machine, the data processor and the cloud database at the receiving end;
the Beidou short message all-in-one machine of the receiving end is used for receiving the short message data according to the reliable communication protocol of the Beidou short message of the receiving end; the reliable communication protocol of the Beidou short message at the receiving end comprises the following steps: the environment data receiving end codes; dynamically adjusting response frequency according to the number of the sending ends through a dynamic accumulation confirmation mechanism;
the data processor is connected with the Beidou short message all-in-one machine and used for performing anti-coding extraction on the received Beidou short message data to obtain agricultural environment data;
the cloud database is connected with the data processor and used for carrying out cloud storage on the agricultural environment data and realizing remote checking of the user anytime and anywhere.
Further, the sending end of the system of the present invention further includes: a solar panel and an energy storage device;
the solar cell panel is connected with the control terminal through the energy storage device and used for converting light energy into electric energy and storing the electric energy in the energy storage device as an electric energy source of the sending end.
Further, in the beidou short message all-in-one machine at the transmitting end of the present invention, the mode of encoding the environmental data specifically is as follows:
the sequence of the multiple agricultural environment data is fixed, and the length occupied by each item of data is fixed, so that a receiving end can analyze and extract the data according to the coding sequence without distinguishing each data piece by using a separator; the specific transmission rule is as follows:
(1) the length of each agricultural environment data distribution is as follows: temperature, 2 bytes; humidity, 2 bytes; illumination, 3 bytes; pressure, 3 bytes; soil moisture, 2 bytes; soil pH, 2 bytes; wind speed, 2 bytes; wind direction, 2 bytes; rainfall, 2 bytes; PM2.5, 3 bytes; oxygen content, 3 bytes; CO 22Content, 3 bytes;
(2) the Beidou short message is communicated in a code transmission mode, and agricultural environment data are converted into hexadecimal ASCII code data;
(3) only transmitting numerical values and not transmitting units for each agricultural environment data;
(4) for data items with decimal numbers, the data items are divided into an integer part and a decimal part, decimal points are not transmitted, two decimal parts are uniformly reserved in the decimal part, and the decimal part is multiplied by 100 to form an integer to be transmitted.
Further, in the beidou short message all-in-one machine at the transmitting end of the present invention, the flag bit coding mode is specifically as follows:
the transmitting end flag bit coding comprises the following steps: data type, 1 byte; timestamp, 5 bytes; data identification, 1 byte; request acknowledgment, 1 byte; acknowledge reply, 1 byte; retransmit count, 1 byte; 2 bytes of the check code are replied; check bit, 2 bytes.
Further, in the beidou short message all-in-one machine of the receiving end of the present invention, the mode of encoding the environment data receiving end specifically is as follows:
data type, 1 byte; a loss number which is represented by indefinite bytes and indicates the sequence number of the data lost since the last confirmation, whether the data is lost is confirmed by the time stamp of the data, the first byte represents the number of the lost data, and each byte represents the sequence number of the lost data; request acknowledgment, 1 byte; retransmit count, 1 byte; the time length of waiting for confirmation, 1 byte, represents the maximum time length of the equipment waiting for confirmation reply; device mode, 1 byte; request acknowledge, 1 byte.
Further, the specific method of the request acknowledgement mechanism based on probability judgment adopted by the sending end of the present invention is as follows:
setting the success rate of communication of the Beidou integrated short message communication machine as p, and dividing a sending end into two modes according to whether agricultural environment data is stored locally or not, wherein the first mode is that data which are stored accumulatively are not stored locally, and the second mode is that a plurality of data are stored locally; wherein:
when the data stored in the local area is not accumulated, namely all the data are sent out, the communication times are sufficient, and the data can be sent out immediately as long as the data exist; the time interval of data sampling is t minutes, and in consideration of communication delay and time required by equipment processing, t-1 communication can be carried out in the t minutes, wherein 1 time is used for transmitting newly generated data, t-2 times is used for transmitting lost data, and t > is 5, then:
n*(1-p)>=t-2
wherein n is the interval times of sending the confirmation application to the receiving end, namely, the sending end requests the receiving end for one confirmation after sending n times of data; since n is an integer, we obtain:
wherein the content of the first and second substances,
represents rounding up;
when a plurality of data records are stored locally, the sending end continuously sends data at the fastest sending frequency of 1 minute/time, and the condition that the data is lost needs to be obtained as soon as possible and retransmitted as soon as possible, then:
n*(1-p)>=1
obtaining:
therefore, the frequency of the application confirmation of the sending end is obtained according to whether the data is stored locally, namely the sending end requests the receiving end for one confirmation after sending n times of data; then there are:
wherein, X is the number of times of transmission, that is, the frequency of applying for acknowledgement to the transmitting end is obtained according to the success rate p of the transmitting end, when the number of times of transmission X is less than n, data is continuously transmitted, when the number of times of transmission X is equal to n, that is, acknowledgement is applied when data is transmitted this time, and the number of times of transmission X is cleared after acknowledgement is transmitted.
Further, the specific method of the dynamic accumulation acknowledgement mechanism adopted by the receiving end of the present invention is as follows:
the receiving end dynamically adjusts response frequency according to the number of the sending ends and sends the maximum waiting time to the sending ends, so that the situation that the sending ends judge that data is lost and repeatedly sent due to overlong waiting is avoided;
if m sending devices send data to one receiving end, the success probability of word communication of each receiving end is PiWhether the local storage data exists is obtained according to the sending frequency of each sender, and if m1 senders do not store data, m2 senders have storage data, wherein m1+ m2 is m; n is the interval number of the request confirmation of each transmitting terminal, and the transmitting terminal does not store dataSince the time interval for transmitting data is t minutes, the frequency of application confirmation is:
for a sending end with stored data, the time interval for sending the data is 1 minute, and the frequency of application confirmation is as follows:
all requests are accumulated to the receiving end, so the acknowledgement frequency of the receiving end is:
maximum wait for acknowledgement interval:
wherein n isiAnd njIndicating the number of request acknowledgement intervals, n, of the ith sender that has no stored datajIndicating the request confirmation interval times of the jth sending end with the stored data; and the receiving end sends the maximum waiting time calculated according to the current real-time condition to the sending end when confirming to the sending end each time.
The invention provides an agricultural environment data acquisition method based on Beidou short messages, which comprises the following steps:
s1, after the system is started, the Beidou satellite signals are received and analyzed through the Beidou short message all-in-one machine to obtain accurate time, then the system time is set, and time service operation is executed regularly;
s2, collecting various agricultural environment data through various environment sensors, collecting various data for many times, and carrying out abnormal value detection and average value processing;
s3, processing the acquired multiple agricultural environment data into a key value pair form by format processing through the control terminal, and storing the key value pair form into a local database on the control terminal;
s4, the Beidou short message all-in-one machine of the sending end takes out agricultural environment data to be sent from a local database, carries out environment data coding and zone bit coding on the data according to a reliable communication protocol of the Beidou short message of the sending end, adjusts the sending frequency according to different dynamic states of the environment through a request confirmation mechanism based on probability judgment, and sends the data to a Beidou satellite in the form of short messages;
s5, the Beidou short message all-in-one machine of the receiving end receives short message data forwarded by a Beidou satellite, sets environment data receiving end codes according to the reliable communication protocol of the Beidou short message of the receiving end, and dynamically adjusts response frequency according to the number of the sending ends through a dynamic accumulation confirmation mechanism to realize the receiving of the short message data;
s6, the data processor performs inverse coding extraction on the received short message data to obtain agricultural environment data;
s7, carrying out cloud storage on the agricultural environment data through the cloud database, and realizing remote checking of the user anytime and anywhere.
Further, the request acknowledgement mechanism based on probability judgment at the sending end of the present invention specifically comprises the following steps:
s41, the sending end inquires a local database, and calculates the interval n of the request confirmation according to whether the sending end has the stored data, namely, the sending end requests a confirmation to the receiving end every time the sending end sends n times of data; setting the sending times X as 0;
s42, taking out a set of data with the minimum time stamp;
s43, judging whether the current data is the data to be retransmitted; if yes, setting the retransmission counting flag bit as 1 and setting the data identification flag bit as 1; if not, setting the retransmission counting flag bit as 0 and setting the data identification flag bit as 0;
s44, judging whether the current sending times X are less than n; if yes, the request is confirmed to mark the position 0, data coding is carried out, X is added with 1, data are sent, and the S42 is returned; if not, the request is confirmed to mark position 1, data coding is carried out, and X is made to be 0;
s45, sending data, waiting for the confirmation of the receiving end, and starting timing;
s46, judging whether the data is received before overtime; if yes, processing the received data, extracting the number m of the lost data and the time stamp, and deleting the data records successfully received in the database; and returns to step S41; if not, the process returns to step S45.
Further, the specific steps of the dynamic accumulation acknowledgement mechanism of the receiving end of the present invention are:
s51, waiting for receiving data;
s52, decoding and extracting the data after receiving the data;
s53, judging whether the retransmission counting flag bit is larger than 0; if yes, deleting the data from the loss record, and storing the environment data; if not, judging that the data represents a flag bit;
s54, judging whether the data identification flag bit is 0 or not; if yes, inquiring a difference value t between the data time stamp and the last data time stamp; if not, saving the environment data;
s55, judging whether t is larger than the time interval of data acquisition; if so, recording the previous data of the data as lost data, and storing the environmental data; if not, directly storing the environmental data;
s56, judging whether the flag bit of the request confirmation is 1; if not, returning to the step S51; if yes, generating data of confirmation reply, including setting the confirmation flag bit of the request to be 1; updating the success rate of the equipment; adding a lost data number; adding the longest latency; adding the acknowledgment data to a send queue; return is made to step S51.
The invention has the following beneficial effects: according to the agricultural environment data acquisition system and method based on the Beidou short message, the electric energy converted by solar energy is used for supplying power to the whole system, Beidou short message communication is improved to ensure reliable data transmission, coding design is carried out on a data section of the Beidou short message communication to ensure environment data transmission and analysis, and meanwhile, a plurality of flag bits are added to assist in realizing a reliable communication protocol; at a sending end of the environmental data, a request confirmation mechanism based on probability judgment is provided; at the receiving end of the environment data, under the condition of many-to-one communication, a dynamic accumulation confirmation mechanism for dynamically adjusting the response frequency according to the number of data transmitting parties is provided.
The invention is not limited by the environments such as lag of wired network construction, unstable or uncovered GPRS signals, local power supply and the like, has the characteristics of low implementation difficulty, wide application range, good system expandability and no regional environment limitation, can be deployed in any place of domestic agricultural planting areas, and can ensure the continuous and stable work of the system.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
As shown in fig. 1, the agricultural environment data acquisition system based on the beidou short message in the embodiment of the present invention includes: control terminal, solar cell panel, energy memory, big dipper short message all-in-one, multiple environmental sensor, like air temperature, humidity etc.. In the system, the solar panel is used as an electric energy source of the system by converting light energy into electric energy and storing the electric energy in the energy storage device; the control terminal is used as a controller of the data acquisition part, acquires data environment data from a plurality of environment sensors, processes the data, stores the data locally and the like; the various sensors can be accessed to the controller through various communication protocols, such as ADC, I2C, serial ports (TTL, RS232, RS485) and the like. The Beidou short message all-in-one machine is used for transmitting data through a Beidou system, and positioning, time service and the like can also be carried out through the all-in-one machine.
Firstly, a transmitting end comprises the following parts:
(1) setting system time: since the control terminal does not have access to the ethernet, it is not possible to synchronize the time through the network service. However, the accessed Beidou short message all-in-one machine has a time service function and can be used for setting the time of a control terminal system.
After the system is started, firstly, the Beidou satellite short message all-in-one machine is communicated, the Beidou satellite signals are received and analyzed through the Beidou short message all-in-one machine to obtain accurate time, and then the system time is set. And the system can execute the operation regularly to ensure the accuracy of the system time.
(2) Data acquisition: a plurality of environmental sensors access to the control terminal through different ports, and the environmental sensors convert the physical quantity of environment into level signals or data signals, and the control terminal acquires data through different communication modes and processes the data.
The system designs a plurality of communication ports including an ADC, an I2C and serial ports (TTL, RS232 and RS485), ensures that common sensors can be accessed, and can be reduced at will as long as the number of the sensors meeting the communication modes is reduced. In order to ensure the accuracy of the data, the data are collected for multiple times, and abnormal value detection and average value processing are carried out. For the working characteristics of different sensors, such as the rainfall sensor, long-time continuous sampling is needed, a multi-thread mode can be adopted, and the efficiency and the accuracy of sampling data are improved.
The agricultural environment data refers to the environment data which influences the growth of crops and the activities of agriculture, such as air temperature, humidity, illumination, soil humidity, soil pH value, carbon dioxide content, wind speed and wind direction and the like in the growing environment of the crops. The most important of them are the following items. Thereby obtaining the growth and development state of crops, the use condition of water and fertilizer and the real-time information of corresponding ecological environment.
The agricultural environment data has many kinds, and the key is the following:
and (3) temperature. Temperature is one of the growth of crops and important environmental factors thereof, and if the temperature is too low or too high to a certain extent, the crops stop growing or die. Temperature affects the rate of photosynthesis by altering the activity of enzymes associated with photosynthesis, directly affecting crop yield.
Humidity. The humidity indirectly influences the photosynthesis of crops, and when the humidity is lower, the air holes of the crops are partially closed, so that the carbon dioxide entering the leaves is reduced, the shortage of carbon dioxide raw materials is caused, and the photosynthetic rate is reduced.
Carbon dioxide content. Carbon oxide is one of the main raw materials for photosynthesis of crops, and has a great influence on photosynthesis rate. The concentration of carbon dioxide is monitored and controlled in real time, and the growth and development of crops are scientifically promoted.
The intensity of the light. Illumination is one of the main environmental factors for crop growth, and is the dominant factor of photosynthesis. When the light intensity is between the light compensation point and the light saturation point, the photosynthetic rate increases with the increase of the illumination intensity.
The soil moisture. The key factor of crop growth is moisture, and soil information sensors are used for sensing soil dryness and accurately using water.
Besides the key data, the data also comprises common data types such as wind speed and wind direction, rainfall and the like, and the total 12 data can meet the planting requirements of various crops. In agricultural planting, the requirement on the sampling frequency of data is low, generally 5 minutes each time, so that the communication interval of one minute of a short message can meet the requirement on data transmission of agricultural environment.
(3) Data local storage: a whole set of data is acquired through data acquisition, and a time stamp is added to the set of data to record the timeliness of the data.
In the control terminal, a database is built for conveniently storing the collected data. Before storage, the format of the data is processed into a dictionary (namely, a key value pair) mode and then stored into a database. Data is stored locally and is separated from data uploading, so that the data acquisition and transmission processes are decoupled, and the stability and functionality of the system are improved.
(4) And (5) data transmission. And the data transmission is completed through the Beidou short message all-in-one machine.
And taking out a set of data from the database, carrying out data coding according to coding environment data and the zone bits designed by the reliable communication protocol of the Beidou short message, and packaging into a complete message. The control terminal is communicated with the Beidou integrated short message machine through an RS232 communication protocol, and sends data to the integrated short message machine and controls the integrated short message machine to send the data out.
And after the data is successfully transmitted, deleting the transmitted data from the local database. The process is carried out in a circulating mode, and when the data record exists in the local database, the operation of uploading the data is executed.
Secondly, the receiving end comprises the following parts:
the Beidou short message all-in-one machine at the receiving end comprises a data processor and a cloud database. In the system, the Beidou short message all-in-one machine is used for receiving environmental data information sent by the data acquisition part through the Beidou short message all-in-one machine. The data processor acquires the acquired environmental data from the Beidou short message all-in-one machine for receiving the data through the RS232, decompresses and processes the data, and stores the data into the cloud database in a corresponding format. The cloud database is used for storing remotely acquired environment data, and is convenient for different users to access and utilize the data.
(1) Data reception: and receiving data through a specific Beidou short message.
In combination with the previous data transmission, the complete short message work flow is as follows: 1. the Beidou short message all-in-one machine sender user machine firstly encrypts a communication application signal containing a receiver ID number and communication contents and then forwards the communication application signal to an inbound station through a satellite; 2. after receiving the communication application signal, the ground central station adds the decrypted and encrypted information into the continuously broadcasted outbound broadcast message and broadcasts the message to users through a satellite; 3. and the receiver user machine of the Beidou short message all-in-one machine receives the outbound signal, demodulates and decrypts the outbound telegraph message, and completes one-time communication. The data is then sent to the data processor via RS 232.
(2) Data processing: the data processor receives data sent by the Beidou short message all-in-one machine and needs to extract the data in an appointed mode.
The received information data is a character string of a set of environment data which is combined by the data acquisition part and contains a plurality of data, and the data is extracted according to the mode of the previous combination. And then through numbering, the specific place from which the environment data record comes is searched, and the affiliated information is added to the data, so that the data is clearer.
(3) Data storage: the remotely collected environmental data is stored in a cloud database.
The data processor is connected with the cloud database, and stores the newly acquired environmental data into the cloud database, so that a user can conveniently check the data at any time and any place.
Thirdly, a reliable communication protocol based on the Beidou short message:
the Beidou short message can provide all-weather blind-area-free communication service, so that the short message is a good communication scheme when the current communication network cannot meet the requirements. However, if three defects of the big dipper short message can not be solved well, a new problem can be brought in practical application. At present, researches on improvement of unreliable communication of Beidou short messages have great defects. The problem that Beidou short message communication is unreliable is not considered, or the solution mode is simple, if the Beidou short message communication is simply and repeatedly sent, communication resources are wasted; by adopting a confirmation response mechanism, the waiting time is too long due to the limitation of the communication frequency of the Beidou short message; meanwhile, a control scheme of carrying out many-to-one scene by using the Beidou short message is not adopted. In the invention, a solution is provided for the defects, so that the agricultural environment data acquisition based on the Beidou short message has better practicability.
The Beidou short message communication data segment is subjected to coding design to ensure transmission and analysis of environmental data, and meanwhile, a plurality of flag bits are added to assist in realization of a reliable communication protocol. At a sending end of the environmental data, a request confirmation mechanism based on probability judgment is provided; at the receiving end of the environment data, under the condition of many-to-one communication, a dynamic accumulation confirmation mechanism for dynamically adjusting the response frequency according to the number of data transmitting parties is provided.
The data coding is divided into two parts, namely, the environment data sending end coding and the environment data receiving end coding.
1. Environmental data transmitting end coding
The environment data sending end codes are divided into environment data codes and flag bit codes.
In the environment data coding, the number of bytes occupied by the environment data coding is distributed according to the range of different data, and the transmission space is occupied as little as possible under the condition of ensuring no data loss. To further reduce the consumption of data, the following rules are applied:
the sequence of the data items is fixed, and the length occupied by each data item is fixed, so that a receiver can analyze and extract the data according to the coding sequence without distinguishing each data item by using a separator;
(1) the Beidou short message communication adopts a code transmission mode, and hexadecimal data is transmitted by using ASCII codes.
(2) Only transmitting numerical values and not transmitting units for each item of environment data;
(3) for data items with decimal numbers, the data items are divided into an integer part and a decimal part, decimal points are not transmitted, two decimal parts are uniformly reserved in the decimal part, and the decimal part is multiplied by 100 to form an integer to be transmitted.
The byte allocation of each item of data is shown in table 1, and the environment data encoding is shown in table 2, for example.
TABLE 1 environmental data encoding format
Table 2 environment data encoding example
In order to realize reliable transmission based on the beidou short message, a part of the information used for transmitting non-environmental data, namely a plurality of flag bits, needs to be taken out in limited communication capacity. The flag bit part occupies a certain length of bytes and is used for recording some information of the data. The sending end and the receiving end of the environment data carry different data, so that the flag bits of the environment data are different.
Table 3 flag bit coding format of environment data transmitting end
Table 4 example of flag bit encoding at sending end of environment data
2. And the environment data receiving end encodes.
Table 5 environment data transmitting end flag bit coding format
Table 6 example of flag bit encoding at sending end of environment data
At the environment data sending end, the environment data plus the flag bit plus the separator have 43 bytes and are less than 78 bytes, so that the communication capacity limit is met, and sufficient capacity is reserved for the later expansion. At the environment data receiving end, 16 bytes are totally used, and the communication capacity limit is also met.
3. A request acknowledgement mechanism based on a probabilistic judgment.
At a data acquisition end, the current frequency of environment data acquisition is 5 min/time, under a normal condition, the limitation of communication frequency (1 min/time) of Beidou short messages is met, and considering that the equipment acquisition end stores a certain amount of data due to other reasons, the data needs to be sent out as soon as possible. Therefore, the success rate of data transmission cannot be improved by simple repeated sending, but the problem of unreliable communication is solved to a certain extent by adopting a more complete mechanism, and the data transmission efficiency is improved.
At present, the Beidou terminal in a real scene can be influenced by various reasons when communicating, and the communication success rate is greatly reduced. When the Beidou terminal is tested and counted to carry out short message communication, if interference such as weather, obstacles, clutter and the like is eliminated, the receiving and sending success rate is 95%, and the success rate can be reduced to 85% or even lower under the condition that the Beidou terminal is frequently subjected to comprehensive influence of various environmental factors.
Whether short message communication succeeds or not is directly related to whether buildings shelter in the environment and weather, so that the receiver can deploy the Beidou short message equipment at an open and non-shelter position to better receive Beidou signals and ensure normal data receiving. For the sender, the success rate of communication is influenced by the environment, but the deployment direction can be adjusted only under limited conditions. The success rate of communication for different devices varies due to differences in the environment of deployment. Here, a request confirmation mechanism based on probability judgment is proposed, and the frequency of the request is dynamically adjusted according to different environments.
For a certain Beidou short message communication integrated machine, the average communication probability of the Beidou short message communication integrated machine can be calculated by carrying out continuous testing for a period of time, and after the testing stage is completed, success rate statistics is continuously carried out in actual communication, so that the success rate is kept updated. This part of the functionality is performed at the receiving end.
And setting a communication success rate p of a Beidou integrated short message communication machine, and dividing a sending end into two modes according to whether the locally stored data exists or not, wherein the data does not exist locally and is stored locally.
When the data stored in the local area is not accumulated, namely all the data are sent out, the communication times are sufficient, and the data can be sent out immediately as long as the data exist; the time interval of data sampling is t minutes, and in consideration of communication delay and time required by equipment processing, t-1 communication can be carried out in the t minutes, wherein 1 time is used for transmitting newly generated data, t-2 times is used for transmitting lost data, and t > is 5, then:
n*(1-p)>=t-2
wherein n is the interval times of sending the confirmation application to the receiving end, namely, the sending end requests the receiving end for one confirmation after sending n times of data; since n is an integer, we obtain:
wherein the content of the first and second substances,
represents rounding up;
when a plurality of data records are stored locally, the sending end continuously sends data at the fastest sending frequency of 1 minute/time, and the condition that the data is lost needs to be obtained as soon as possible and retransmitted as soon as possible, then:
n*(1-p)>=1
obtaining:
therefore, the frequency of the application confirmation of the sending end is obtained according to whether the data is stored locally, namely the sending end requests the receiving end for one confirmation after sending n times of data; then there are:
wherein, X is the number of times of transmission, that is, the frequency of applying for acknowledgement to the transmitting end is obtained according to the success rate p of the transmitting end, when the number of times of transmission X is less than n, data is continuously transmitted, when the number of times of transmission X is equal to n, that is, acknowledgement is applied when data is transmitted this time, and the number of times of transmission X is cleared after acknowledgement is transmitted.
4. A dynamic accumulation validation mechanism.
At the receiving end, one all-in-one machine device receives data of a plurality of sending ends, and the number of the sending ends is changed, so that the time for the sending end to wait for the confirmation of the receiving end is directly related to the number of the sending ends. Therefore, a dynamic accumulation confirmation mechanism is provided at the receiver, the response frequency is dynamically adjusted according to the number of the data transmitters, and the maximum waiting time is sent to the sending end, so that the situation that the sending end judges that the data is lost and repeatedly sends the data due to overlong waiting is avoided.
If m sending devices send data to one receiving end, the success probability of word communication of each receiving end is PiAnd knowing whether the local storage data exists according to the transmission frequency of each sender, and assuming that m1 senders have no storage data and m2 senders have storage data, wherein m1+ m2 is m. n is the interval number of request confirmation of each sending end, and the calculation mode is provided in a request confirmation mechanism based on probability judgment. For the sender not storing data, the time interval for sending data is t minutes, so the frequency of applying for confirmation is:
for a sending end with stored data, the time interval for sending the data is 1 minute, and the frequency of application confirmation is as follows:
all requests are accumulated to the receiving end, so the acknowledgement frequency of the receiving end is:
maximum wait for acknowledgement interval
niAnd njIndicating the number of request acknowledgement intervals, n, of the ith sender that has no stored datajIndicating the request confirmation interval times of the jth sending end with the stored data; the receiving end sends the maximum waiting time calculated according to the current real-time condition to the sending end when confirming to the sending end each time.
The agricultural environment data acquisition method based on the Beidou short message comprises the following steps:
s1, after the system is started, the Beidou satellite signals are received and analyzed through the Beidou short message all-in-one machine to obtain accurate time, then the system time is set, and time service operation is executed regularly;
s2, collecting various agricultural environment data through various environment sensors, collecting various data for many times, and carrying out abnormal value detection and average value processing;
s3, processing the acquired multiple agricultural environment data into a key value pair form by format processing through the control terminal, and storing the key value pair form into a local database on the control terminal;
s4, the Beidou short message all-in-one machine of the sending end takes out agricultural environment data to be sent from a local database, carries out environment data coding and zone bit coding on the data according to a reliable communication protocol of the Beidou short message of the sending end, adjusts the sending frequency according to different dynamic states of the environment through a request confirmation mechanism based on probability judgment, and sends the data to a Beidou satellite in the form of short messages;
s5, the Beidou short message all-in-one machine of the receiving end receives short message data forwarded by a Beidou satellite, sets environment data receiving end codes according to the reliable communication protocol of the Beidou short message of the receiving end, and dynamically adjusts response frequency according to the number of the sending ends through a dynamic accumulation confirmation mechanism to realize the receiving of the short message data;
s6, the data processor performs inverse coding extraction on the received short message data to obtain agricultural environment data;
s7, carrying out cloud storage on the agricultural environment data through the cloud database, and realizing remote checking of the user anytime and anywhere.
As shown in fig. 2, the request acknowledgement mechanism based on probability judgment at the sending end specifically includes the following steps:
the request confirmation mechanism based on probability judgment at the sending end comprises the following specific steps:
s41, the sending end inquires a local database, and calculates the interval n of the request confirmation according to whether the sending end has the stored data, namely, the sending end requests a confirmation to the receiving end every time the sending end sends n times of data; setting the sending times X as 0;
s42, taking out a set of data with the minimum time stamp;
s43, judging whether the current data is the data to be retransmitted; if yes, setting the retransmission counting flag bit as 1 and setting the data identification flag bit as 1; if not, setting the retransmission counting flag bit as 0 and setting the data identification flag bit as 0;
s44, judging whether the current sending times X are less than n; if yes, the request is confirmed to mark the position 0, data coding is carried out, X is added with 1, data are sent, and the S42 is returned; if not, the request is confirmed to mark position 1, data coding is carried out, and X is made to be 0;
s45, sending data, waiting for the confirmation of the receiving end, and starting timing;
s46, judging whether the data is received before overtime; if yes, processing the received data, extracting the number m of the lost data and the time stamp, and deleting the data records successfully received in the database; and returns to step S41; if not, the process returns to step S45.
As shown in fig. 3, the specific steps of the dynamic accumulation acknowledgement mechanism at the receiving end are as follows:
s51, waiting for receiving data;
s52, decoding and extracting the data after receiving the data;
s53, judging whether the retransmission counting flag bit is larger than 0; if yes, deleting the data from the loss record, and storing the environment data; if not, judging that the data represents a flag bit;
s54, judging whether the data identification flag bit is 0 or not; if yes, inquiring a difference value t between the data time stamp and the last data time stamp; if not, saving the environment data;
s55, judging whether t is larger than the time interval of data acquisition; if so, recording the previous data of the data as lost data, and storing the environmental data; if not, directly storing the environmental data;
s56, judging whether the flag bit of the request confirmation is 1; if not, returning to the step S51; if yes, generating data of confirmation reply, including setting the confirmation flag bit of the request to be 1; updating the success rate of the equipment; adding a lost data number; adding the longest latency; adding the acknowledgment data to a send queue; return is made to step S51.
The agricultural environment data acquisition system based on the Beidou short message takes the Beidou short message system as a data transmission way, is not limited by environments such as lag of wired network construction, unstable or no coverage of GPRS signals, local power supply and the like, has the characteristics of low implementation difficulty, wide application range and good system expandability, can be deployed in any domestic agricultural planting area with complex and remote environments, and can ensure the continuous and stable acquisition of the environment data. The control terminal acquires data with the sensors through various protocols, the number of the sensors which meet the communication mode can be reduced at will, the abnormal condition processing function is realized, and the stability of the system is higher; the Beidou short message system is a special function of the Beidou system, can provide all-weather non-blind area service for the whole Asia-Pacific region, and solves the problem that a wired network and a GRPS network cannot cover the system. Therefore, the system and the method for acquiring the environmental data are low in implementation difficulty, wide in application range, good in system expandability and not limited by regional environments, and can be used for acquiring the environmental data in remote agricultural planting areas with complex environments.
It will be understood that modifications and variations can be made by persons skilled in the art in light of the above teachings and all such modifications and variations are intended to be included within the scope of the invention as defined in the appended claims.