AccuWeatherLibrary.cpp
/*
 *  continueDownload() function downloads data in 128 byte chunks.
 *  Returns <0 on download error, 0 on download finished, >0 if the download can be continued.
 *  This function should be called repeatedly until the returned value is 0.
 *  The function will close the connection and free resources automatically.
 */
continueDownload() function downloads data in 128 byte chunks.
Returns <0 on download error, 0 on download finished, >0 if the download can be continued.
This function should be called repeatedly until the returned value is 0.
The function will close the connection and free resources automatically.
continueDownload () function downloads data in 128 byte chunks . Returns <0 on download error 0 on download finished > 0 if the download can be continued . This function should be called repeatedly until the returned value is 0 . The function will close the connection and free resources automatically .
int Accuweather::continueDownload(){
    if (http.connected() && (length > 0 || length == -1)){
        uint8_t buff[128] = { 0 };
        WiFiClient * stream = http.getStreamPtr();
        size_t size = stream->available();
        int c = size;
        if (size) {
            c = stream->readBytes(buff, ((size > sizeof(buff)) ? sizeof(buff) : size));
            for (int i = 0; i < c; i++){
                parser.parse(buff[i]);
            }
            if (length > 0) {
                length -= c;
            }
        }
        return c+1;
    }
    else if (length == 0){
        freeConnection();
        return 0;
    }
    else {
        return -1;
    }
}
int Accuweather :: continueDownload ( ) { if ( http . connected ( ) && ( length > 0 || length == -1 ) ) { uint8_t buff [ 128 ] = { 0 } ; WiFiClient * stream = http . getStreamPtr ( ) ; size_t size = stream -> available ( ) ; int c = size ; if ( size ) { c = stream -> readBytes ( buff , ( ( size > sizeof ( buff ) ) ? sizeof ( buff ) : size ) ) ; for ( int i = 0 ; i < c ; i ++ ) { parser . parse ( buff [ i ] ) ; } if ( length > 0 ) { length -= c ; } } return c + 1 ; } else if ( length == 0 ) { freeConnection ( ) ; return 0 ; } else { return -1 ; } }
continueDownload() function downloads data in 128 byte chunks.
continueDownload () function downloads data in 128 byte chunks .
// read all data from server // create buffer for read // get tcp stream // get available data size // read up to 128 byte