Hi all. I have managed to put together a sketch which runs on an ESP32 and downloads data from a server using the HTTPClient library and writes it to SPIFFS. its based on the 'StreamHHTPClient' example sketch.
I have managed to get it to work but am now trying to increase the download speed.
I have used 2 different methods to write the data to SPIFFS, one works, the other doesnt but is much faster and i think it could work if i had better knowledge. the data im downloading is actually an animated gif which i am trying to play using a TFT screen. i believe that the problem is due to the termination character im writing which is corrupting the gif data but then it works when i use the String variant. here is the code which prints to SPIFFS:
void appendFile(fs::FS &fs, String _path, char message[], int arr_size) {
///below code works.
// String m;
// for (int i = 0; i < arr_size; i++) {
// m += message[i];
// }
char m[arr_size+1]; ////this code does not work
for(int i = 0; i < arr_size; i++){
m[i] = message[i];
}
m[arr_size] = '\0';
////////
File file = fs.open(_path, FILE_APPEND);
file.print(m); ///array is written to spiffs
}
i then use the arduino-tft-gif library to display the gif. when i put the array into a string and print it to SPIFFS the gif works but when i print the char array with termination char to SPIFFS it does not. the char array is significalntly faster so i would really like to get it to work. i have tried downloading a text file instead of a gif so i can easily inspect the data and it looked fine on both approaches. i suspect that theres something going on with the termination character which is corrupting the data. any help on this would be greatly appreciated and if the full code was required then i'll post it but its reasonably substantial so didnt want to overburden the reader initially at least. many thanks!