Code: Select all
WiFiClient* stream = http.getStreamPtr();
stream->readBytes();
Parameters:
Code: Select all
WiFi.mode(WIFI_STA);
WiFi.setSleep(false);
What could be causing this issue, and how can it be resolved?
Thank you!
Code: Select all
WiFiClient* stream = http.getStreamPtr();
stream->readBytes();
Code: Select all
WiFi.mode(WIFI_STA);
WiFi.setSleep(false);
aliarifat794, thank you for your involvement!Check your router's settings, specifically the DTIM (Delivery Traffic Indication Message) interval. A lower DTIM interval can improve connectivity for IoT devices.
The question is what is different at the start.The download starts off well, with the first few MB being downloaded quickly and efficiently.
Thank you for the reasonable question. The data is immediately written to the file, the buffer is in static memory, i.e. the allocation occurs only once. The available memory of the task stack is monitored, its amount is sufficient. The size of the total free heap is also monitored and OK. Subjectively, the CPU is not overloaded, because I do not see any signs indicating this, everything else is performed without lags.The question is what is different at the start.
Where do those megabytes go? Could you be exhausting some resource (RAM or CPU) by accumulating some stuff over the transfer?
File system is FAT32.What file system are you using? Where is it stored? Internal flash?
Do you close and re-open the file repeatedly for appending?
It opens the file once and then closes it at the end of downloading.SD NAND consists of NAND flash and a high-performance controller. 3.3V supply voltage is required for the NAND area (VCC). SD NAND is fully compliant with SD2.0 interface. Designed in a LGA8 package form. Supports up to 50Mhz.
Code: Untitled.cpp Select all
HTTPClient httpDl[DL_THREADS];
httpDl[threadId].begin(url);
int httpCode = httpDl[threadId].GET();
static constexpr size_t DL_BUFFER_SIZE = 2760;
FsFile filePart;
filePart.open(filepartPath.c_str(), O_WRONLY | O_CREAT | O_TRUNC);
filePart.preAllocate(filePartSize);
WiFiClient* stream = httpDl[threadId].getStreamPtr();
while (bytesRecd < filePartSize) {
size_t size = stream->available();
int bytesRead = stream->readBytes(buff, min(size, DL_BUFFER_SIZE));
written = filePart.write(buff, bytesRead);
}
filePart.sync();
filePart.close();
httpDl[threadId].end();Are you sure filePartSize has the correct value?Code: Select all
while (bytesRecd < filePartSize) {
Yes, for now I test on files only that I know the exact size of.Are you sure filePartSize has the correct value?
It's true, in my full version of this code I do exactly this checking: it retries after some short delay.Do you check for premature end-of-stream?
As I understand it, stream->available() may also intermittently return 0, which may be worth explicitly dealing with, e.g. by a short delay before retrying.
Users browsing this forum: No registered users and 1 guest