PaulS:
How much memory is the Streaming library using to do what you could do with multiple statements?
There is a way to measure it? when i use multiple statements does not see much difference betweeen that and the library (probably because my program its not much complex yet).
I have client code on the playground that is easily adapted to request two or more pages. It doesn't use streaming, but it does work well. http://playground.arduino.cc/Code/WebClient
If that looks like something you could use, I can help you set that up to do both pages.
Thanks surfer, looking the code but sorry not much understanding hehe.
I have solved in this way, really ugly i think
void comWeb()
{
int j;
for (j=0;j<2;j++){
switch (j) {
case 0:
//Recepcion de datos del servidor
client.connect(server, 80);
client << "GET /ordenes.txt" << endl;
client.stop();
break;
case 1:
//Envio al servidor de los datos
client.connect(server, 80);
client << "GET /tesis/datos.php?id=" << iden << "&estado=" << estado << "&temp1=" << temp1 << "&temp2=" << temp2 <<
"&temp3="<< temp3 << "&humedad=" << humedad << "&presion=" << presion << endl;
break;
client.stop();
}
delay(200);
}
Serial.println("desconectando");
client.stop();
}
If i use only one client.connect(server, 80); outside the switch or in fact without the switch (like in the first post). Does not work. with this code i can see the request in server of both order.
At least you figured out there are two client.connect() and client.stop() calls required. If you don't run out of sockets, it should run ok for a day or two.
SurferTim:
At least you figured out there are two client.connect() and client.stop() calls required. If you don't run out of sockets, it should run ok for a day or two.
The functions its called every 1 minut, but you mean that eventually the arduino will ran out of sockets to the server and crash? sorry where i can read a more detailed info of the way of work for this function?
The w5100 is notorious for locking sockets if there are characters left in the rx buffer. Since you are not reading the response, there is a possibility you will lose sockets. There are only 4 in the w5100. When they are all used, the shield will always fail to make the connection to the server until you reboot it.
However, if you do not read the rx buffer correctly, a stalled or broken connection could lock up the code that reads the response.
So there is the dilemma.
edit: That is why my code seems a bit complex. It will neither lose sockets nor will it lock up if the connection stalls or breaks.
SurferTim:
The w5100 is notorious for locking sockets if there are characters left in the rx buffer. Since you are not reading the response, there is a possibility you will lose sockets. There are only 4 in the w5100. When they are all used, the shield will always fail to make the connection to the server until you reboot it.
However, if you do not read the rx buffer correctly, a stalled or broken connection could lock up the code that reads the response.
So there is the dilemma.
I see, in this case, i will read info for "ordenes.txt" that its needed to be saved in a variable and datos.php.. its only for saving values in database, does not return nothing from the webserver to arduino.
So the best way its back to the example in playground and check how to modify for my needs? avoiding double client and stop?
If the data types of the variables (ident, temp1, etc) are integers, this should do it.
// in global declarations, increase pageAdd array to 128
// because your request is almost that size.
char pageAdd[128];
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;
// request first page
sprintf(pageAdd,"/tesis/datos.php?id=%u"&estado=%u&temp1=%u&temp2=%u&temp3=%u&humedad=%u&presion=%u",iden,estado,temp1,temp2,temp3,humidad,presion);
if(!getPage(server,serverPort,pageAdd)) Serial.print(F("Fail first page"));
else Serial.print(F("Pass first page"));
// request second page
strcpy(pageAdd,"/latest.txt");
if(!getPage(server,serverPort,pageAdd)) Serial.print(F("Fail second page"));
else Serial.print(F("Pass second page"));
totalCount++;
Serial.print(F("Total request count: "));
Serial.println(totalCount,DEC);
}
loopCount++;
}