I am trying to transfer jpg file from SD card to a FTP server using Quectel M10 via GPRS.
here is some reference materials:
Quectel_M10_AT_Commands_Manual?http://www.quectel.com/product/prodetail.aspx?id=14
Quectel_M10_datasheet?http://arduino.cc/en/Main/ArduinoGSMShield
and attached files: GSM FTP AT Commands.pdf
also I have used the code here as my reference?http://www.cooking-hacks.com/documentation/tutorials/arduino-3g-gprs-gsm-gps#step13
My code segment about the at commands:
void loop()
{
//sendATcommand("AT", "OK", 5000);
power_on();
Serial.println("GSM modem working!");
delay(3000);
// waits for signal
while( (sendATcommand("AT+CREG?", "+CREG: 0,1", 500) ||
sendATcommand("AT+CREG?", "+CREG: 0,5", 500)) == 0 );
// sets APN, user name and password
answer=sendATcommand("AT+QIFGCNT=0","OK",1000);
Serial.println(answer);
answer=sendATcommand("AT+QICSGP=1,\"CMNET\"","OK",1000);
Serial.println(answer);
answer=sendATcommand("AT+QFTPUSER=\"admin\"","OK",3000);
Serial.println(answer);
answer=sendATcommand("AT+QFTPPASS=\"admin\"","OK",3000);
Serial.println(answer);
// sets the paremeters for the FTP server and the path
answer=sendATcommand("AT+QFTPOPEN=\"xx.xx.xx.xx\",21","+QFTPOPEN:0",120000);
Serial.println(answer);
answer=sendATcommand("AT+QFTPPATH=\"/\"","+QFTPPATH:0",120000);
Serial.println(answer);
sprintf(strtemp, "AT+QFTPPUT=\"%s\",%d,600", filename,filelength);
sprintf(answertemp,"+QFTPPUT:%d",filelength);
answer = sendATcommand(strtemp, answertemp, 900000);
Serial.println("send data to buff");
while(mFile.position()<filelength)
{
for(int i=0; i<3; i++)
{
mFile.read(filedata,1024);
for(int j=0; j<sizeof(filedata); j++)
{
Serial.println(filedata[j],HEX); // observe the image data through serial port
mySerial.write(filedata[j]);
}
}
delayMicroseconds(1000);
}
mFile.close();
}
and this is the infomation I get from the Serial Monitor.
(13266 is the length of the jpg file.)
Initializing SD card...card initialized.
2.jpg is opened successful.
13266
AT
OK
1
GSM modem working!
AT+CREG?
+CREG: 0,1
AT+QIFGCNT=0
OK
1
AT+QICSGP=1,"CMNET"
OK
1
AT+QFTPUSER="admin"
OK
1
AT+QFTPPASS="admin"
OK
1
AT+QFTPOPEN="xx.xx.xx.xx",21
OK
+QFTPOPEN:0
1
AT+QFTPPATH="/"
OK
+QFTPPATH:0
1
AT+QFTPPUT="2.jpg",13266,600
+QFTPPUT:13266
AT+QFTPPUT="2.jpg",13266,600
OK
CONNECT
1
send data to buff
FF
D8
FF
E0
0
10
4A
46
49
46
0
1
1
1
0
60
0
60
.
.
.
.
.
.
Problem:
I get the data in the ftp server,not all the hex data of picture is right, the beginning about 10k byte data is right, the else is wrong.
Is the data send too fast? I mean is there a receive buffer of GPRS model ,and is there a limitation of the data of the M10 model transfer? if there is a limit size,how to solve it?
Maybe something wrong in the code.
Want your help!
GSM_FTP_ATC_V1.01.pdf (587 KB)