| Ligne 200 : |
Ligne 200 : |
| | Now, we can focus on the main loop. | | Now, we can focus on the main loop. |
| | | | |
| − | The first step is to send the header if not done yet. | + | The first step is to send the column header (so we know what are the data) if not done yet. |
| | | | |
| | Then we reads the sensors (as we have tested them, this should not be a surprise). We also capture the time with the function {{fname|millis()}}, so the {{fname|ms}} variable contains the number of milliseconds since the last reset. | | Then we reads the sensors (as we have tested them, this should not be a surprise). We also capture the time with the function {{fname|millis()}}, so the {{fname|ms}} variable contains the number of milliseconds since the last reset. |
| Ligne 208 : |
Ligne 208 : |
| | {{fname|packet_str}} is the message to send via radio. It is composed with {{fname|String}} objects and concatenation operations. {{fname|String}} are welcome to transform '''float''' into string representation since most common float to string C standard functions would fail to work properly onto Arduino alike plateforms. | | {{fname|packet_str}} is the message to send via radio. It is composed with {{fname|String}} objects and concatenation operations. {{fname|String}} are welcome to transform '''float''' into string representation since most common float to string C standard functions would fail to work properly onto Arduino alike plateforms. |
| | | | |
| − | The key function to transform the '''String object''' into a '''C buffer'' is {{fname|packet_str.c_str()}} which offer an access to the underlying array of bytes (exactly what we would need for the radio module library). | + | The key function to transform the '''String object''' into a '''C buffer'' is {{fname|packet_str.c_str()}} which offer an access to the underlying array of bytes (exactly what the radio module library would need). |
| | + | |
| | + | The remaining of the radio transmission code is almost the same as the RFM69HCW module testing code (except that error messages are remplaced by Blinking LED). |
| | | | |
| | <syntaxhighlight lang="c"> | | <syntaxhighlight lang="c"> |
| − | bool header_send = false; // if header has not been send yet... | + | bool header_send = false; |
| − | int16_t packetnum = 0; // packet number increment at each data emission
| + | // packet number increment at each data transmission |
| | + | int16_t packetnum = 0; |
| | void loop() { | | void loop() { |
| | // --- SEND COLUMNS HEADER ------------------- | | // --- SEND COLUMNS HEADER ------------------- |
| Ligne 264 : |
Ligne 267 : |
| | // Going to next round | | // Going to next round |
| | } | | } |
| | + | </syntaxhighlight> |
| | | | |
| | + | <syntaxhighlight lang="c"> |
| | void init_radio_module() { | | void init_radio_module() { |
| | pinMode(RADIO_LED, OUTPUT); | | pinMode(RADIO_LED, OUTPUT); |