Hi,
i have an Arduino Ethernet and a GSM Shield.
I would to upload a file through FTP.
There isn't a FTP function and i thought abouth using AT commands directly.
I'm able to connect with an own FTP server with authentication but i don't understand how i can upload a file that is in SD card.
#include <GSM.h>
#include <GSM3ShieldV1ModemVerification.h>
//#include <SD.h>
// set up variables using the SD utility library functions:
/*Sd2Card card;
SdVolume volume;
SdFile root;
File myFile;
*/
const int chipSelect = 4;
void setup()
{
Serial.begin(9600);
delay(2000);
Serial.begin(9600);
delay(2000);
pinMode(10, OUTPUT);
if (!SD.begin(4)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
if (SD.exists("test.txt")) {
Serial.println("example.txt exists.");
}
else {
Serial.println("example.txt doesn't exist.");
}
GSM3ShieldV1DirectModemProvider modemAccess;
int result=0;
String modemResponse;
// check modem response
modemAccess.begin();
// reset hardware
modemAccess.restartModem();
modemResponse=modemAccess.writeModemCommand("AT", 1000);
if(modemResponse.indexOf("OK")>=0)
Serial.println("OK");
modemResponse=modemAccess.writeModemCommand("ATE0", 1000);
Serial.println(modemResponse);
modemResponse=modemAccess.writeModemCommand("AT+QIFGCNT=0", 1000);
Serial.println(modemResponse);
Serial.print("USER ");
modemResponse=modemAccess.writeModemCommand("AT+QFTPUSER=\"xxxxx\"", 1000);
Serial.println(modemResponse);
modemResponse=modemAccess.writeModemCommand("AT+QFTPPASS=\"xxxxxx\"", 1000);
Serial.println(modemResponse);
long int start=millis();
while(1)
{
Serial.print((char)modemAccess.read());
if(millis()-start>10000)
break;
}
Serial.print("FTP OPEN ");
modemResponse=modemAccess.writeModemCommand("AT+QFTPOPEN=\"84.253.166.42\",21", 1000);
Serial.println(modemResponse);
delay(2000);
start=millis();
while(1)
{
Serial.print((char)modemAccess.read());
if(millis()-start>10000)
break;
}
modemResponse=modemAccess.writeModemCommand("AT+QFTPPATH=\"/\"", 1000);
Serial.println(modemResponse);
delay(2000);
start=millis();
while(1)
{
Serial.print((char)modemAccess.read());
if(millis()-start>10000)
break;
}
}
void loop()
{
}
Thank you for your attention.