add comments

jd-update
flavienhaas 7 years ago
parent e8baea6f4b
commit bfb7ffe288

@ -43,49 +43,49 @@ void SerialPrintElapsedTime( boolean espaceFinal=true ){ // to display the el
void loop() { void loop() {
// LoRa receiver // LoRa receiver
static byte tampon[LENMAX]={0}; // if the module receive a frame, it willnot be null static byte tampon[LENMAX]={0}; // if the module receive a frame, it willnot be null
int longueurTrame; int longueurTrame;
longueurTrame=LoRa.parsePacket(); longueurTrame=LoRa.parsePacket();
if( longueurTrame > 0 ){ if( longueurTrame > 0 ){
if( longueurTrame>LENMAX ){ // copy of the frame to cache (LENMAX) and verify if the frame is to big if( longueurTrame>LENMAX ){ // copy of the frame to cache (LENMAX) and verify if the frame is to big
Serial.print("Trame reçue trop grande : "); Serial.print("Trame reçue trop grande : ");
Serial.println(longueurTrame); Serial.println(longueurTrame);
longueurTrame=LENMAX; // troncature longueurTrame=LENMAX; // cut the frame to LENMAX size
} }
for( int i=0; i<longueurTrame; i++ ){ for( int i=0; i<longueurTrame; i++ ){
tampon[i]=(byte)LoRa.read(); tampon[i]=(byte)LoRa.read();
} }
SerialPrintElapsedTime(); // diplay the time the frame arrived SerialPrintElapsedTime(); // diplay the time the frame arrived
Serial.print("0x"); Serial.print("0x");
for( int i=0; i<longueurTrame; i++ ){ // display the frame in hexadecimal for( int i=0; i<longueurTrame; i++ ){ // display the frame in hexadecimal
if( tampon[i] < 0x0F ) Serial.print("0"); if( tampon[i] < 0x0F ) Serial.print("0");
Serial.print( tampon[i], HEX ); Serial.print( tampon[i], HEX );
} }
Serial.print( " " ); Serial.print( " " );
for( int i=0; i<longueurTrame; i++ ){ for( int i=0; i<longueurTrame; i++ ){
if( (tampon[i] < 0x20)||(tampon[i] > 0x7E) ){ if( (tampon[i] < 0x20)||(tampon[i] > 0x7E) ){
Serial.print( "."); // this character isn't printable (displayable) Serial.print( "."); // this character isn't printable (displayable)
}else{ }else{
Serial.print( (char)tampon[i] ); // display the frame in ASCII Serial.print( (char)tampon[i] ); // display the frame in ASCII
} }
} }
Serial.print( "\n" ); Serial.print( "\n" );
} // end of if LoRa.parsePacket } // end of if LoRa.parsePacket
delay(10); delay(10);
// WebServer // WebServer
EthernetClient client = server.available(); // WebServer :listen for incoming clients EthernetClient client = server.available(); // WebServer :listen for incoming clients
if (client) { if (client) {
Serial.println("new client"); Serial.println("new client");
boolean currentLineIsBlank = true; // an http request ends with a blank line boolean currentLineIsBlank = true; // an http request ends with a blank line
while (client.connected()) { while (client.connected()) {
if (client.available()) { if (client.available()) {
char c = client.read(); char c = client.read();
Serial.write(c); Serial.write(c);
if (c == '\n' && currentLineIsBlank) { // send the beginning of a standard http response header if (c == '\n' && currentLineIsBlank) { // send the beginning of a standard http response header
client.println("HTTP/1.1 200 OK"); client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html"); client.println("Content-Type: text/html");
client.println("Connection: close"); // the connection will be closed after completion of the response client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 5"); // refresh the page automatically every 5 sec client.println("Refresh: 5"); // refresh the page automatically every 5 sec
client.println(); client.println();
client.println("<!DOCTYPE HTML>"); client.println("<!DOCTYPE HTML>");
client.println("<html>"); client.println("<html>");
@ -101,14 +101,14 @@ void loop() {
client.println("</html>"); client.println("</html>");
break; break;
} }
if (c == '\n') { // send a new blank line to indicate the end of the connection if (c == '\n') { // send a new blank line to indicate the end of the connection
currentLineIsBlank = true; currentLineIsBlank = true;
} else if (c != '\r') { } else if (c != '\r') {
currentLineIsBlank = false; currentLineIsBlank = false;
} }
} }
} }
delay(1); // give the web browser time to receive the data delay(1); // give the web browser time to receive the data
client.stop(); // close the connection of the webserver client.stop(); // close the connection of the webserver
} }
} }

Loading…
Cancel
Save