Arduino Polska Forum
Pobranie ciągu ze strony WWW - Wersja do druku

+- Arduino Polska Forum (https://forum.arduinopolska.pl)
+-- Dział: Korzystanie z Arduino (https://forum.arduinopolska.pl/dzial-korzystanie-z-arduino)
+--- Dział: Piaskownica (https://forum.arduinopolska.pl/dzial-piaskownica)
+--- Wątek: Pobranie ciągu ze strony WWW (/watek-pobranie-ci%C4%85gu-ze-strony-www)



Pobranie ciągu ze strony WWW - globalinfo - 16-03-2017

Próbuję pobrać dane ze strony WWW ale mi obcina początkowy ciąg znaków .  Sad


Kod:
....
// file found at server
if(httpCode == HTTP_CODE_OK) {

// get lenght of document (is -1 when Server sends no Content-Length header)
int len = http.getSize();

// create buffer for read
uint8_t buff[128] = { 0 };

// get tcp stream
WiFiClient * stream = http.getStreamPtr();

// read all data from server
while(http.connected() && (len > 0 || len == -1)) {
// get available data size
size_t size = stream->available();
if(size) {
// read up to 128 byte
int c = stream->readBytes(buff, ((size > sizeof(buff)) ? sizeof(buff) : size));
// write it to Serial
USE_SERIAL.write(buff, c);
if(len > 0) {
len -= c;
}
}
delay(1);
for(int x = 0;x < 25;x++){calosc += (char)buff[x]; } // pętla pobierająca ciąg
}
USE_SERIAL.print("[HTTP] connection closed or file end.\n");
}
} else {
printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end();
}
USE_SERIAL.println(calosc);
delay(6000);
calosc="";
....

Na serial monitorze otrzymuje taki wynik:

Cytat:..... 
[HTTP] connection closed or file end. 

wylacz 


lacz 
.....

A chciałbym aby cały ciąg był wyświetlony tj. 
 
Cytat:..... 
[HTTP] connection closed or file end. 

wylacz 


wylacz 
..... 

Proszę o naprowadzenie co robię nie tak że obcina mi ciąg znaków.