i have some problem about SIM800L. i try to upload TXT file to FTP server via GPRS. All AT command work perfectly except this one (FTPPUT). can anyone help me
note : server,user,password replaced by "X"
String apn = "internet";
String gprsUser = "";
String gprsPass = "";
String server = "xxxxxxxxxx";
String username = "xxxxxx";
String password = "xxxxxxxx";
int8_t answer;
char aux_str[50];
String namaFile = "datalog.txt";
void setup() {
Serial.begin(9600);
Serial2.begin(115200);
delay(1000);
sendATcommand("AT", "OK", 5000);
i("GSM modem working!");
delay(3000);
while ( (sendATcommand("AT+CREG?", "+CREG: 0,1", 500) ||
sendATcommand("AT+CREG?", "+CREG: 0,5", 500)) == 0 );
i("Signal OK");
i("Mematikan GPRS");
sendATcommand("AT+CIPSHUT", "OK", 500);
sendATcommand("AT+CGATT=0", "OK", 500);
i("Deklarasi GPRS");
sendATcommand("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"", "OK", 500);
i("Set APN");
sendATcommand("AT+SAPBR=3,1,\"APN\",\"" + apn + "\"", "OK", 2000);
i("Set IP");
sendATcommand("AT+CGDCONT=1,\"IP\",\"" + apn + "\"", "OK", 2000);
i("Bearer setting");
sendATcommand("AT+SAPBR=1,1", "OK", 500);
sendATcommand("AT+SAPBR=2,1", "OK", 500);
i("Turn on GPRS");
sendATcommand("AT+CGATT=1", "OK", 500);
i("Start multi IP connection");
sendATcommand("AT+CIPMUX=1", "OK", 500);
i("Select Data Transmitting Mode = 1 (Quick)");
sendATcommand("AT+CIPQSEND=1", "OK", 500);
i("Get Data from Network Manually");
sendATcommand("AT+CIPRXGET=1", "OK", 500);
delay(2000);
i("Start task");
sendATcommand("AT+CSTT=\"" + apn + "\",\"" + gprsUser + "\",\"" + gprsPass + "\"", "OK", 2000);
i("Bring Up Wireless Connection with GPRS");
sendATcommand("AT+CIICR", "OK", 500);
i("Get Local IP Address");
sendATcommand("AT+CIFSR;E0", "OK", 500);
i("Configure Domain Name Server");
sendATcommand("AT+CDNSCFG=\"8.8.8.8\",\"8.8.4.4\"", "OK", 500);
delay(500);
i("Set FTP Server Address");
sendATcommand("AT+FTPSERV=\"" + server + "\"", "OK", 2000);
i("Set FTP Server Address");
sendATcommand("AT+FTPPORT=21", "OK", 2000);
i("Set Passive FTP Mode");
sendATcommand("AT+CFTPMODE=1", "OK", 2000);
i("Set FTP User Name");
sendATcommand("AT+FTPUN=\"" + username + "\"", "OK", 2000);
i("Set FTP User Password");
sendATcommand("AT+FTPPW=\"" + password + "\"", "OK", 2000);
i("Set Upload File Name");
sendATcommand("AT+FTPPUTNAME=\"" + namaFile + "\"", "OK", 1000);
i("Set Upload File path");
sendATcommand("AT+FTPPUTPATH=\"/\"", "OK", 2000);
i("Upload File path");
sendATcommand("AT+FTPPUT=2,5", "OK", 2000);
i("DONE");
}
void loop() {
if (Serial2.available()) {
Serial.write(Serial2.read());
}
if (Serial.available()) {
Serial2.write(Serial.read());
}
}
unsigned char sendATcommand(String ATcommand, char* expected_answer1, unsigned int timeout)
{
unsigned char x = 0, answer = 0;
char response[100];
unsigned long previous;
memset(response, '\0', 100); // Initialize the string
delay(100);
while ( Serial1.available() > 0) Serial1.read(); // Clean the input buffer
Serial2.println(ATcommand); // Send the AT command
x = 0;
previous = millis();
// this loop waits for the answer
do {
if (Serial2.available() != 0) {
response[x] = Serial2.read();
x++;
// check if the desired answer is in the response of the module
if (strstr(response, expected_answer1) != NULL)
{
answer = 1;
}
}
// Waits for the asnwer with time out
}
while ((answer == 0) && ((millis() - previous) < timeout));
return answer;
}
void i (String j)
{
Serial.println(j);
}