I've been unable to FTP anything using an Arduino and SIM800L. I have reduced the code as far as possible:
#include <SoftwareSerial.h>
//Create software serial object to communicate with SIM800L
SoftwareSerial mySerial(3, 2); //SIM800L Tx & Rx is connected to Arduino #3 & #2
String moduleAnswer = "";
void setup()
{
//Begin serial communication with Arduino and Arduino IDE (Serial Monitor)
Serial.begin(9600);
//Begin serial communication with Arduino and SIM800L
mySerial.begin(9600);
Serial.println("Initializing...");
delay(1000);
SoftwareATCommand("AT"); //Once the handshake test is successful, it will back to OK
SoftwareATCommand("AT+CSQ"); //Signal quality test, value range is 0-31 , 31 is the best
SoftwareATCommand("AT+CCID"); //Read SIM information to confirm whether the SIM is plugged
SoftwareATCommand("AT+CREG?"); //Check whether it has registered in the network
//APN and GRPS Setup
SoftwareATCommand("AT+SAPBR=0,1"); //Close GPRS before connecting
SoftwareATCommand("AT+SAPBR=3,1,\"Contype\",\"GPRS\""); //Configure bearer profile
SoftwareATCommand("AT+SAPBR=1,1"); //Connect to GPRS
//FTP Connection
SoftwareATCommand("AT+FTPCID=1");
SoftwareATCommand("AT+FTPSERV=127.189.249.205"); //Not real IP
SoftwareATCommand("AT+FTPPORT=21");
SoftwareATCommand("AT+FTPUN=user");
SoftwareATCommand("AT+FTPPW=pass");
//FTP Upload
uploadFTP();
}
void loop()
{
}
void uploadFTP()
{
SoftwareATCommand("AT+FTPPUTNAME=\"test.txt\""); //Filename
SoftwareATCommand("AT+FTPPUTPATH=/home/arduino/SolarDataLogger/"); //Path
SoftwareATCommand("AT+FTPPUT=1"); //Start FTP
delay(10000);
SoftwareATCommand("AT+FTPPUT=2,100"); //Send 100 bytes of data
delay(10000);
SoftwareATCommand("Hello12345"); //Send Data
SoftwareATCommand("AT+FTPPUT=2,0"); //Close FTP
}
String SoftwareATCommand(String strAT)
{
String strNotice = "Sending: " + strAT;
Serial.println(strNotice);
mySerial.println(strAT);
delay(500);
moduleAnswer = "No Response";
while(mySerial.available())
{
moduleAnswer = mySerial.readString();
char* buf = (char*) malloc(sizeof(char)*moduleAnswer.length()+1);
moduleAnswer.toCharArray(buf, moduleAnswer.length()+1);
Serial.write(buf);//Forward what Software Serial received to Serial Port
- Module answer sent to screen
free(buf);
}
return moduleAnswer;
}
The serial output where the trouble is:
I've tried waiting longer for the +FTPPUT: 1,1,1360
response or sending something twice, but nothing seems to work. The file gets created but no other data is ever sent.