16-03-2017, 12:31
Próbuję pobrać dane ze strony WWW ale mi obcina początkowy ciąg znaków .
Na serial monitorze otrzymuje taki wynik:
A chciałbym aby cały ciąg był wyświetlony tj.
Proszę o naprowadzenie co robię nie tak że obcina mi ciąg znaków.
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.
6
wylacz
0
lacz
.....
A chciałbym aby cały ciąg był wyświetlony tj.
Cytat:.....
[HTTP] connection closed or file end.
6
wylacz
0
wylacz
.....
Proszę o naprowadzenie co robię nie tak że obcina mi ciąg znaków.