FTPGET
Dependencies: SDFileSystem dspmodified mbed
Fork of fft_merge_main_codev1 by
Diff: main.cpp
- Revision:
- 18:4954e8028d0a
- Parent:
- 17:a5afe7677838
diff -r a5afe7677838 -r 4954e8028d0a main.cpp --- a/main.cpp Mon Jan 26 12:41:27 2015 +0000 +++ b/main.cpp Fri Jan 30 11:49:28 2015 +0000 @@ -9,6 +9,7 @@ #define freq 1 #define fft_points 16384 #define dur_sec 16.384 +#define module_name "NTF10" Serial pc(USBTX, USBRX); Serial gsm(D1, D0); @@ -21,7 +22,7 @@ SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); DigitalOut gsm_rst(D7); -char sitename[100] ="NTF4"; +char sitename[100] = module_name; char filename[100] = ""; char filepath[100] = ""; char timestamp[100]=""; @@ -69,7 +70,7 @@ //--------------------------------------------------------------------------------------------------// bool sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout, bool clk_flag) { - int x=0, + int x=0; bool answer=0; //x=0 and answer=0, if not put, AT+CCLK?\r is not executed char response[100]; memset(response, '\0', 100); // Initialize the string @@ -101,6 +102,7 @@ } return answer; + } //--------------------------------------------------------------------------------------------------// @@ -413,7 +415,7 @@ fft(fft_points,0,1,1); pc.printf("\r\nfftdone"); prepare_fft_array(fft_start_index,fft_points_count,fft_maximas_required,fft_segments,1); - pc.printf("\n storage done"); + pc.printf("storage done\r\n"); //osSignalSet(tid6, 0x1); // } @@ -446,6 +448,7 @@ { int ftp_connect_attempt=0; int ftp_close_attempt=0; + sendATcommand("AT+CGATT=1", "OK", 10,0); /*if(sendATcommand("AT+SAPBR=2,1", "+SAPBR: 1,3,\"0.0.0.0\"", 5,0)) { } else {*/ while(!sendATcommand("AT+SAPBR=2,1", "+SAPBR: 1,3,\"0.0.0.0\"", 5,0)) { @@ -485,16 +488,13 @@ char command1[40]; char result1[20]; - char command2 [100]; - char result2 [20]; + //char command2 [100]; + //char result2 [20]; - sendATcommand("AT+FTPMKD=?\r\n", "OK", 5,0); + sprintf(command1,"%s\"%s\"", "AT+FTPPUTNAME=", ftpfilename); sprintf(result1,"%s", "OK"); - pc.printf("ftpfilepath is \n\r %s \n\r",ftpfilepath); - //sprintf(ftpfilepath1,"%s",ftpfilepath); - //memset(ftpfilepath1,'\0',3); - //pc.printf("Filepath1 is \n\r %s \n\r",ftpfilepath1); + //pc.printf("ftpfilepath is \n\r %s \n\r",ftpfilepath); //sd card @@ -515,19 +515,16 @@ fclose(fp8); } for(int putname_attempt=0; putname_attempt<2; putname_attempt++) { - pc.printf("\r\nftp_put attempt\n\r"); + //pc.printf("\r\nftp_put attempt\n\r"); + if(sendATcommand(command1,result1, 10,0)) { - sprintf(command2,"%s\%s/\"", "AT+FTPPUTPATH=\"", filepath); - sprintf(result2,"%s", "OK"); - sendATcommand(command2,result2, 10,0); + //sprintf(command2,"%s\%s/\"", "AT+FTPPUTPATH=\"", filepath); + // sprintf(result2,"%s", "OK"); + //sendATcommand(command2,result2, 10,0); + //sendATcommand(command1,result1, 10,0); + sendATcommand("AT+FTPPUTPATH=\"/NTF2/\"", "OK", 5,0); if(sendATcommand("AT+FTPPUT=1", "OK", 5,0)) { wait(8); - // pc.printf("in loop"); - // pc.printf("\n\r %s",ftpfilepath); - /*FILE *fp9 = fopen(ftpfilepath, "r"); - if(fp9==NULL)return; - else - {*/ int trialcount=0; int allowedtrials=3; char command[40];