Modifications

Sauter à la navigation Sauter à la recherche
1 278 octets ajoutés ,  29 octobre 2018 à 21:44
Ligne 72 : Ligne 72 :     
The code proposed here under has been tested up to 22620128 (22.6 millions) iterations without issue, time when we decided to ends the test :-) .
 
The code proposed here under has been tested up to 22620128 (22.6 millions) iterations without issue, time when we decided to ends the test :-) .
 +
 +
== Structure the data ==
 +
The radio module only sends buffer of binary data to the receiver. This is a bit rough but efficient.
 +
 +
So to transport the data to the receiver, we need to transform the values (float, integer) into their string representation.
 +
 +
But having multiple data in string representation is not enough, they must be organized. '''They final format must be easy to parse and very compact''' (smaller is the radio message and higher is the chance for him to get to the ground without error).
 +
 +
We propose the following format:
 +
<nowiki>:data1|data2|data3|data4;/r/n
 +
 +
where:
 +
* : is the begin of data stream
 +
* ; is the end of data stream
 +
* /r/n are optional a carriage return + line feed. This will would make the messages user friendly when the the messages are viewed in a console or terminal.
 +
* | is the separator between data items.
 +
* datax are the string representation of data. The characters ;:| are forbidden in this area.
 +
</nowiki>
 +
 
 +
<syntaxhighlight lang="c">
 +
    String packet_str = String( ":"+String(packetnum,DEC)+"|" );
 +
    packet_str.concat( String( ms,DEC)+"|" );
 +
    packet_str.concat( String( temperature, 2 )+"|" );
 +
    packet_str.concat( String( bme_hpa, 2 )+"|" );
 +
    packet_str.concat( String( bme_temp, 2 )+";\r\n" );
 +
</syntaxhighlight>
    
== Understand the code ==
 
== Understand the code ==
29 910

modifications

Menu de navigation