Go Down

Topic: Updata a file on a FTP server via 3g (Read 1 time) previous topic - next topic


Right, So I've sent a .txt file to my FTP server via a 3G module, using the following section of code:
Code: [Select]
   Serial.println("AT+CFTPTYPE=A");    //Selects ASCII mode

   Serial.println("AT+CFTPPUT=\"/test.txt\"");    //Creates a file and sends data (ASCII)
   while(Serial.read()!='N');    //Waits 'N' from BEGIN

   Serial.println("01234567890123456789");    //Data for the file

   Serial.write(0x1A);                        //End of Data
   Serial.write(0x0D);                        //Carridge return
   Serial.write(0x0A);                        //Line Feed

   while(!(data[x-1]=='K'&&data[x-2]=='O'));    //Looks for response OK

Question is, how do I continue to add to it?
If I repeat that code, say in a loop, will it overwrite the file test.txt or will it simply tag on the data at the end?
essentially the test.txt file is going to be used as a log, collecting all data. It will get quite big over time, (the data being sent "01234567890123456789" is not representative of the data actually being sent) so downloading, editing and uploading isn't really a viable solution....  After 2hrs the estimated file size will be 5mb, downloaded and uploaded every second.....


This is a great question!  I'd also like to hear the best answer to this.  One choice is to create a new file each time.  This would be good if there were many minutes between sessions of sending data.  Another choice is to keep the file open and continue to send data every minute or less.  This is great if there is data available to send every minute.  There is a parameter to choose the timeout length.  The downside is power consumption.  I think we need more information to answer your question.

I will create another thread for my FTP question.

Go Up