blackcodetavern / ESP32_FTPClient

An FTP-Client for the ESP32
MIT License
35 stars 8 forks source link

Can't establish a FTP connection #11

Open superfino opened 3 years ago

superfino commented 3 years ago

Hi, I'm trying to take a snapshot with my ESP32-cam and to upload the image to my FTP server. Unfortunately i get differend results, but not what's expected. I call a funktion to do the job. This is how my code looks like.

`char ftp_server[] = "192.168.0.18"; char ftp_user[] = "sergey"; char ftp_pass[] = "fährlich"; char working_dir[] = ".";

ESP32_FTPClient ftp (ftp_server,ftp_user,ftp_pass, 5000, 2);`

void snapshot() {

camera_fb_t * fb = NULL; // Take a Snapshot with the Camera fb = esp_camera_fb_get();
if(!fb) { Serial.println("Camera capture failed"); return; } ftp.OpenConnection(); // Starting connection to ftp server //delay(500); ftp.ChangeWorkDir(working_dir); ftp.InitFile("Type I");

String Filename = timeClient.getFullFormattedTimeForFile()+".jpg"; Serial.println("Filename "+Filename); // formatting Filename int str_len = Filename.length() + 1;

char char_array[str_len]; Filename.toCharArray(char_array, str_len);

ftp.NewFile(char_array); // Upload to the ftp server ftp.WriteData( fb->buf, fb->len ); ftp.CloseFile(); ftp.CloseConnection();

esp_camera_fb_return(fb); // Free buffer }` The serial monitor shows most time: Connecting to: 192.168.0.18 FTP error: Offline Send USER FTP error: Offline Send PASSWORD FTP error: Offline Send SYST FTP error: Offline Send CWD FTP error: Offline Send TYPE FTP error: Offline Filename 20201204_171026.jpg Send STOR FTP error: Offline Writing FTP error: Offline Close File Connection closed

But sometimes i see: Connecting to: 192.168.0.18 Command connected Send USER Send PASSWORD Send SYST Send CWD Send TYPE Type I Send PASV Data port: 53686 Filename 20201204_171053.jpg Send STOR FTP error: Offline Writing FTP error: Offline Close File Connection closed

I've tried 3 diffend FTP server, all working well with other applications. Don't know why the 'offline' msg apperars. Any comment is highly appreciated. Thx. Jo