i modified this codewith my domain and ip but the part of the GET it's a little bit difficult, i don't know which parts i have to delete or replace (THE PART IS: "this part |||||||||...")
if you could add in the right method this part of the code u've sent me i'll promise, we go out for dinner! XD
client.println(F("GET / HTTP/1.1"));
client.println(F("Host: www.valerioantonangeli.it"));
client.println(F("Connection: close\r\n"));
you have reason, i know, i'm a little bit retarted but in the sketch there are something like: outBuf, sprintf, %s, and something like these and i don't wanna go wrong another one!
/*
Web client sketch for IDE v1.0.1 and w5100/w5200
Uses GET method.
Posted October 2012 by SurferTim
Last modified June 17, 2013
*/
#include <SPI.h>
#include <Ethernet.h>
// this must be unique
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// change to your network settings
IPAddress ip(192,168,1,2);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
// change to your server
IPAddress server(46,4,96,70); // Google
//Change to your domain name for virtual servers
char serverName[] = "www.valerioantonangeli.it";
// If no domain name, use the ip address above
// char serverName[] = "74.125.227.16";
// change to your server's port
int serverPort = 80;
EthernetClient client;
int totalCount = 0;
int loopCount = 0;
char pageAdd[32];
void setup() {
Serial.begin(9600);
// disable SD SPI
pinMode(4,OUTPUT);
digitalWrite(4,HIGH);
// Start ethernet
Serial.println(F("provo a connettermi"));
Ethernet.begin(mac, ip, gateway, gateway, subnet);
// If using dhcp, comment out the line above
// and uncomment the next 2 lines
// if(!Ethernet.begin(mac)) Serial.println(F("failed"));
// else Serial.println(F("ok"));
digitalWrite(10,HIGH);
Serial.println(Ethernet.localIP());
delay(2000);
Serial.println(F("connesso"));
}
void loop()
{
if(loopCount < 30)
{
// if loopCount is less than 30, just delay a second
delay(1000);
}
else
{
// every thirty seconds this runs
loopCount = 0;
// Modify next line to load different page
// or pass values to server
sprintf(pageAdd,"/",totalCount);
// sprintf(pageAdd,"/arduino.php?test=%u",totalCount);
if(!getPage(server,serverPort,pageAdd)) Serial.print(F("Fail "));
else Serial.print(F("Pass "));
totalCount++;
Serial.println(totalCount,DEC);
}
loopCount++;
}
byte getPage(IPAddress ipBuf,int thisPort, char *page)
{
int inChar;
char outBuf[128];
Serial.print(F("connecting..."));
if(client.connect(ipBuf,thisPort))
{
Serial.println(F("connected"));
//this part |||||||||||||||||||||||||||||||||||||||||||||
sprintf(outBuf,"GET %s HTTP/1.1",page);
client.println(outBuf);
sprintf(outBuf,"Host: %s",serverName);
client.println(outBuf);
client.println(F("Connection: close\r\n"));
//this part|||||||||||||||||||||||||||||||||||||||||||||||
}
else
{
Serial.println(F("failed"));
return 0;
}
// connectLoop controls the hardware fail timeout
int connectLoop = 0;
while(client.connected())
{
while(client.available())
{
inChar = client.read();
Serial.write(inChar);
// set connectLoop to zero if a packet arrives
connectLoop = 0;
}
connectLoop++;
// if more than 10000 milliseconds since the last packet
if(connectLoop > 10000)
{
// then close the connection from this end.
Serial.println();
Serial.println(F("Timeout"));
client.stop();
}
// this is a delay for the connectLoop timing
delay(1);
}
Serial.println();
Serial.println(F("disconnecting."));
// close client end
client.stop();
return 1;
}