Hi ,
I am using arduino uno and wifi shielf. I use the wifi library and wificlient library to build up a http client.
I am trying to download data from the web server. I did not get any sample about how to use httprequest to download the file and transmit HEX. The file is a text which is full of HEX data. my code is like this. but it is not steady enough. Sometime it will stop before get all the data. 5808 bytes. Please give me some help. Thanks.
httpRequest();
uint16_t no0xdata_sign=0;
uint8_t body_sign=0;
uint8_t body_finish_sign=0;
uint8_t high=0;
uint8_t low=0;
while(connect_sign==0)
{
while (client.available())
{
uint8_t c = client.read();
if(0xd==c&&client.read()==0xa)
{
c = client.read();
if(c==0xd&&client.read()==0xa)
{
uint8_t body_sign=1;
Serial.println("Start Downloading the File");
while(body_sign==1)
{
c=client.read();
if (0x30 == c && 0x78 == client.read())
{
bytes_send+=1;
uint8_t d = client.read();
if (d >= '0' && d <= '9') {
high= d - '0';
} else if (d >= 'a' && d <= 'f') {
high= d - 'a' + 10;
} else if (d >= 'A' && d <= 'F') {
high= d - 'A' + 10;
} else {
high= -1;
}
d = client.read();
if (d >= '0' && d <= '9') {
low= d - '0';
} else if (d >= 'a' && d <= 'f') {
low= d - 'a' + 10;
} else if (d >= 'A' && d <= 'F') {
low= d - 'A' + 10;
} else {
low= -1;
}
Serial_rx_data[number_buffer+1]=(high*16) + low;;
Serial.print(Serial_rx_data[number_buffer+1]);
if(bytes_send==5808)
{
Serial.println("finished");
body_sign=0;
body_finish_sign=1;
bytes_send=0;
connect_sign=1;
break;
}
else{
}
}else{
}
}
}
}
}
}
}