Hello all,
I am having some trouble with my latest project.
I am trying to use an HTML form to capture data using an Ethernet shield, and relaying that information through a yaler server. I am using an arduino duemilanove, with the arduino Ethernet shield.
#include <Dhcp.h>
#include <Dns.h>
#include <EthernetClient.h>
#include <EthernetServer.h>
#include <EthernetUdp.h>
#include <util.h>
// Copyright (c) 2013, Oberon microsystems AG, Switzerland
// All rights reserved
#include <SPI.h>
#include <Ethernet.h>
#include <YalerEthernetServer.h>
// Enter a MAC address for your controller below.
// Some Ethernet shields have a MAC address printed on a sticker
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// Local EthernetServer at http://LOCAL_IP/ (e.g. http://192.168.0.7/)
//EthernetServer server(80);
// Get a free relay domain at http://yaler.net/ to replace RELAY_DOMAIN below
// Public YalerEthernetServer is accessible at http://RELAY_DOMAIN.yaler.net/
YalerEthernetServer server("try.yaler.net", 80, “XXXXX-XXXX-XXXX");
String readString = String(100);
void setup() {
Serial.begin(9600);
Serial.println("Aquiring IP address...");
if (Ethernet.begin(mac) == 0) {
Serial.println("DHCP failed.");
}
else {
Serial.println(Ethernet.localIP());
server.begin();
}
}
void sendResponse(EthernetClient client) {
//create the web interface.
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.print("<html><body>");
client.println("<form method=get name= pin> PIN: <input type=password name=pwd>
");
client.println("<input type=submit value=submit> </form>");
client.println("</body></html>");
}
void loop()
{
EthernetClient client = server.available();
if (client && client.connected()) {
client.find("\r\n\r\n"); // Consume incoming request
sendResponse(client);
Serial.println("Web Page Sent");
delay(1); // Give the Web browser time to receive the data
char c = client.read();
Serial.println(c);
if (readString.length() < 100)
{
readString.concat(c);
}
Serial.println("String = ");
Serial.println(readString);
client.stop();
}
else
{
Serial.println("FAIL");
}
}
I get the following in the serial monitor.
Aquiring IP address...
192.168.1.XXX
Web Page Sent
(Text entered, submit clicked)
ÿ
String =
100ÿ
I can see that the client.read() function is not working, as the value of the string never changes, regardless of the text entered. But I have tried everything that I can think of.
I am not tremendously experienced with the Ethernet shield, only having done some limited web interfacing, never with a form.
Thanks in advance for your help!