ArduinoGeneral

SIM908 and FTP

userHead dfrobot 2016-04-26 22:25:16 1802 Views3 Replies
Hey Everyone,

I'm having an issue where I try and send some basic text via FTP. I am at the point where I can successfully connect to the FTP server, a file is created, however the file is always empty :(
It has worked before using hardcoded value to send as a text file, but as soon as I try and send via Serial.print I get nothing.
Any ideas?
I was under the impression that once AT+FTPPUT=1 responds successfully, you can simply print content to serial, terminated with Ctrl-Z (Serial.write(32); i believe).

Thanks in advance, I can share my code if it helps.

~Rommie
2016-04-29 01:59:47 Cool, congratulation and thx for sharing!

May I know which one works at last Serial.write(32) or Serial.write(1A)? :roll:
userHeadPic Leff
2016-04-28 16:44:46 I managed to work it out!
The code that I was using was flawed. The After posting "AT+FTPPUT=1" you then need to specify the length of the content you are delivering. "AT+FTPPUT=2,(LENGTH OF CONENT)". The code I was using took a sample file of 100 byte length, the issue was, if you were sending data any less than this, it would assume you were sending an empty file. Even worse, if you had a file larger than 100 bytes, it would stop sending after the 100th.

Here is my code for the FTP functionality:
Code: Select all
void uploadFTP(){
   
    snprintf(aux_str, sizeof(aux_str), "AT+FTPPUTNAME=\"%s\"", file_name);
    sendATcommand(aux_str, "OK", 2000);
    snprintf(aux_str, sizeof(aux_str), "AT+FTPPUTPATH=\"%s\"", path);
    sendATcommand(aux_str, "OK", 2000); 
    if (sendATcommand("AT+FTPPUT=1", "+FTPPUT:1,1,", 30000) == 1)
    {
      snprintf(aux_str, sizeof(aux_str), "AT+FTPPUT=2,%d", sizeof(test_str));
        snprintf(aux_str2, sizeof(aux_str2), "+FTPPUT:2,%d", sizeof(test_str));
        if (sendATcommand(aux_str, aux_str2, 30000) == 1)
            {
              sendATcommand(test_str, "+FTPPUT:1,1", 30000);         
              sendATcommand("AT+FTPPUT=2,0", "+FTPPUT:1,0", 30000);
              //Upload Completed
            }
         else
            {
              Serial.println("Error opening the FTP session");
             }
    }
    else
    {
        Serial.println("Error opening the FTP session");
    }
}
userHeadPic dfrobot
2016-04-27 00:24:25 Ctrl-Z is (Serial.write(1A) in HEX, 32 is its OCT. see from http://www.asciitable.com/

So you could try it again to see if it works? If it works, would you minding sharing your code here? I have not much experience on FTP, I could learn it some. Thanks in advance.
userHeadPic Leff