Hi;
I have a webservice, that when i do something like this:
http://www.park4u.pt/park4u/Servico?action=setLugar&codigo=1&status=U
or
http://www.park4u.pt/park4u/Servico?action=setLugar&codigo=2&status=L
I'm using the ethernet library but with no success until now. I'm connected to the internet, but my code don't work.
The webservice is online, so if somebody want, can try it.
Can somebody help me:
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char server[] = "www.park4u.pt/park4u/";
// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 1, 123);
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;
void setup() {
Serial.begin(9600);
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
Ethernet.begin(mac, ip);
}
delay(1000);
Serial.println("connecting...");
if (client.connect(server, 80)) {
Serial.println("connected");
client.println("www.park4u.pt//park4u/Servico?action=setLugar&codigo=1&status=L HTTP/1.0");
client.println("Host: www.park4u.pt");
client.println("Connection: close");
client.println();
}
else {
Serial.println("connection failed");
}
}
void loop()
{
if (client.available()) {
char c = client.read();
Serial.print(c);
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
while (true);
}
}
Thank you