Muy buenas a todos,
Antes que nada daros las gracias porque he aprendido un montón de cosas gracias al foro, y espero empezar a aportar mi grano de arena también.
Quería haceros una pregunta sobre el Arduino Uno Wifi. Se que este no es el foro, pero es una duda básica en realidad de programación y seguro algún alma caritativa me saca del atasco.
Estoy intentado hacer algo básico: leer un campo de texto de un web implementada en un servidor web y mostrarla en un LCD conectado a la placa. Estoy usando un comando Get. El problema es que lo que me lee Arduino es simplemente "arduino/webserver" y no "arduino/webserver/l1?=texto+introducido". ¿A qué puede ser debido? ¿Me falta algo en el código?
Simplemente con que me llegue el text introducido ya lo procesaré y demás. Pero llevo semanas para lograr esto y no hay forma.
Como veréis en el código intento mostrar este texto en el lcd porque el serial monitor en esta placa no he logrado que funcione (pide una contraseña que no he conseguido, y he visto que le pasa a mucha gente).
Gracias de verdad por la ayuda.
#include <Wire.h>
//#include <ArduinoWiFi.h>
#include <UnoWiFiDevEd.h>
// include the library code:
#include <LiquidCrystal.h>
#define MaxHeaderLength 16 //maximum length of http header required
/*
on your borwser, you type http://<IP>/arduino/webserver/ or http://<hostname>.local/arduino/webserver/
http://www.arduino.org/learning/tutorials/webserver
*/
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(2, 3, 9, 10, 11, 12);
String HttpHeader = String(MaxHeaderLength);
void setup() {
Wifi.begin();
Wifi.println("WebServer Server is up");
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Listo!");
//initialize variable
HttpHeader="";
}
void loop() {
while(Wifi.available()){
process(Wifi);
}
delay(50);
}
void process(WifiData client) {
//Aquí muestro lo que recibe en el LCD. Solo recibe arduino/webserver
char c = client.read();
lcd.clear();
lcd.setCursor(0,0);
lcd.print(c);
delay(10);
if (HttpHeader.length() < MaxHeaderLength)
{
//store characters to string
HttpHeader = HttpHeader + c;
}
//if HTTP request has ended
if (c == '\n') {
// show the string on the monitor
Serial.println(HttpHeader);
}
// Wifi.println(HttpHeader);
//WebServer(client);
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("<html><head></head><body>");
client.println();
// client.print("<form ACTION=\"http://192.168.1.50:80\" method=get ACTION=/>");
client.print("<form method=get>");
client.print("<input type='text' name=l1 value='Linea Superior'>
");
client.print("<input type=submit value=submit></form>");
client.print("</body></html>");
//clearing string for next read
HttpHeader="";
client.print(DELIMITER); // very important to end the communication !!!
}
//}