Good morning everyone!
I'm using the same module in my tests. Unable to connect, unable to run AT commands. Everything is going well. Less sending data to the browser.
I get the information that the Arduino Due sends but the browser is frozen indicating "receiving data". And does not display the site. If I send a text it often displays what I send but remains locked, as if it never ended transmitting.
Does anyone know how I enclose my website for the transmission to be displayed correctly?
This happens in the notebook, celulat, tablet. Anyone and any browser.
I'll send my code, can be useful for someone.
void setup()
{
Serial1.begin(115200);
Serial.begin(115200);
Serial.println(">Inicio!");
}
void loop()
{
boolean currentLineIsBlank = true;
while(1){
if (Serial1.available()) {
char c = Serial1.read();
if (c == 'n' && currentLineIsBlank) {
// send the webpage
Serial1.println("HTTP/1.1 200 OK");
Serial1.println("Content-Type: text/html");
Serial1.println("Connection: close");
Serial1.println();
// send web page
Serial1.println("<!DOCTYPE html>");
Serial1.println("<html>");
Serial1.println("<head>");
Serial1.println("<title>Redline Web Page!</title>");
Serial1.println("</head>");
Serial1.println("<body><center>");
for(int i=0;i<2;i++) Serial1.println("A perestroica da vizinha ta presa na gaiola!!!!!
");
Serial1.println("</center></body>");
Serial1.println("</html>");
Serial.println(">Esvaziando o buffer");
while (Serial1.available()) {
Serial.print( (char)Serial1.read());
}
// entra no modo de comando
delay(2500);
Serial1.print("+++");
Serial.println(">+++");
while (Serial1.available()) {
Serial.print( (char)Serial1.read());
}
delay(600);
//faz um teste se esta ok
Serial1.println("AT+");
delay(50);
Serial.println(">AT+");
while (Serial1.available()) {
Serial.print( (char)Serial1.read());
}
/* isso mata a conexao. o browser recebe tudo mas fica incapaz de realizar outra requisicao
Serial1.println("AT+SKCLS=1");
delay(50);
Serial.println(">AT+SKCLS=1");
while (Serial1.available()) {
Serial.print( (char)Serial1.read());
}
*/
//parece que esta funcionando, se nao matar o socket ele fica aceitando requisicoes, mas nao finaliza o envio da tela
//para o browser exibir.
Serial1.println("AT+ENTM"); //volta ao modo automatico
delay(50);
Serial.println(">AT+ENTM"); //volta ao modo automatico
while (Serial1.available()) {
Serial.print( (char)Serial1.read());
}
Serial.println(">FIM"); //volta ao modo automatico
break;
}
if (c == 'n') {
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != 'r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
}