Hi, I am trying to use GPRS to send an image to FTP.
Using WiFi it works well but my project won't heve WiFi.
The problem is how to make the FTP library understand it has to use the GPRS connection.
The FTP library keeps reporting: FTP error: Offline
The segment of code that does that is below:
// TinyGSM Client for Internet connection
TinyGsmClient client(modem);
pDBG("Connect GPRS. ");
if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
return("Modem connect fail");
}else{
char ftp_server[] = "ftp.myftpserver.com";
if(!client.connect(ftp_server, 21)) { //that is something I added just to try
pDBGln("Client connect fail"); // it runs FTP_upload() below so FTP is there
}else{
FTP_upload();
// Close client and disconnect
client.stop();
pDBGln("Server disconnected");
modem.gprsDisconnect();
pDBGln("GPRS disconnected");
}
}
And the FTP function is below, it is the same I use for WiFI and works ok.
void FTP_upload(){
// FTP Server credentials
char ftp_server[] = "ftp.myftpserver.com";
char ftp_user[] = "myftpaccount@hidroflux.com";
char ftp_pass[] = "myftppass";
ESP32_FTPClient ftp(ftp_server, ftp_user, ftp_pass);
pDBG("Uploading via FTP: ");
ftp.OpenConnection();
//ftp.ChangeWorkDir("/public_html/zyro/");
//Create a file and write the image data to it;
ftp.InitFile("Type I");
//String pic_name = String(devid) + ".jpg";
const char *f_name = "myPicNew.jpg"; //pic_name.c_str();
ftp.NewFile( f_name );
pDBGln( f_name );
ftp.WriteData((unsigned char*)tempImageBuffer, ImgMetaData.imSize);
ftp.CloseFile();
// Breath, withouth delay URL failed to update.
pDBGln("Done... Waiting next transfer...");
delay(100);
}
By the way, GPRS is working fine, I can post data into MySQL database flawlessly.
Assistance welcome.
Thanks in advance
Paulo