CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Send file FTP with SIM900
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
NVergunst



Joined: 20 Oct 2017
Posts: 7
Location: Canada

View user's profile Send private message

PostPosted: Sun Oct 22, 2017 1:52 am     Reply with quote

Ttelmah wrote:
You seem to be sending an FTPPUT=1 before the FTPEXTPUT. The FTPPUT=1 is what triggers the transfer. You can't setup the extended transfer after having triggered the transfer.

Look at the application notes for FTP transfers on this modem. Follow the sequence exactly.


Yes I know. Further in my code, I do another transfer.

That FTPPUT=1 clears whatever buffer might have been in there before. I found that if it was still doing something FTP-related, I would get other errors some of the time.

As I said, I have gotten this to work. The problem is it is extremely unreliable.

The whole code-flow (TX side) looks like:

Code:
AT+SAPBR=0,1
AT+FTPPUT=1
AT+FTPEXTPUT=0
AT+SAPBR=3,1,"Contype","GPRS";
AT+SAPBR=3,1,"APN","wholesale"
AT+SAPBR=1,1
AT+SAPBR=2,1
AT+FTPCID=1
AT+FTPTYPE=I
AT+FTPSERV="ftp***.com"
AT+FTPUN="***"
AT+FTPPW="***"
AT+FTPGETPATH="/FTPEXTPUT_TEST/2017-10-20/"
AT+FTPMKD

AT+CGREG?
AT+SAPBR=0,1
AT+FTPPUT=1
AT+FTPEXTPUT=0
AT+SAPBR=3,1,"Contype","GPRS";
AT+SAPBR=3,1,"APN","wholesale"
AT+SAPBR=1,1
AT+SAPBR=2,1
AT+FTPCID=1
AT+FTPTYPE=I
AT+FTPSERV="ftp.***.com"
AT+FTPUN="***"
AT+FTPPW="***"
AT+FTPPUTNAME="FTPEXT.txt"
AT+FTPPUTPATH="/"
AT+FTPEXTPUT=1
AT+FTPEXTPUT=2,0,100,10000
AT+FTPPUT=1
AT+FTPEXTPUT=0


As you can see, setting up the bearer profile and all that is not required. However I am attempting to make "anything-to-anything" type code. I have noticed that the SIMCOM module does not always report what it's doing and if I think it is in a different state than it is, random error. So everywhere I explicitly tell it to do things like finish transfers, close connections, etc so that it is in a proper state when I do something I want to happen.


Last edited by NVergunst on Sun Oct 22, 2017 3:25 am; edited 1 time in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Sun Oct 22, 2017 2:49 am     Reply with quote

Some things need to happen in order.

It is the FTPCID command that associates the transfer session with the number '1'. This needs to be before you send the SAPBR stuff linked to this number.
You are setting up parameters out of order so the modem almost certainly does not have a proper configuration hence 'ERROR'.

Use the FTP application note, and follow the sequence exactly in the order shown. It does work.
The only problem is that with GPRS, when doing repeated transfers the connection will remain open, and intermittently will drop when the bearer decides. Therefore you need to decide whether to restart or continue without relaunching for each transfer.
Set up with the order I show I've got three units here that have each been making transfers every five minutes for the last couple of weeks without a single problem.
NVergunst



Joined: 20 Oct 2017
Posts: 7
Location: Canada

View user's profile Send private message

PostPosted: Sun Oct 22, 2017 3:07 am     Reply with quote

Ttelmah wrote:
Some things need to happen in order.

It is the FTPCID command that associates the transfer session with the number '1'. This needs to be before you send the SAPBR stuff linked to this number.
You are setting up parameters out of order so the modem almost certainly does not have a proper configuration hence 'ERROR'.

Use the FTP application note, and follow the sequence exactly in the order shown. It does work.
The only problem is that with GPRS, when doing repeated transfers the connection will remain open, and intermittently will drop when the bearer decides. Therefore you need to decide whether to restart or continue without relaunching for each transfer.
Set up with the order I show I've got three units here that have each been making transfers every five minutes for the last couple of weeks without a single problem.


The data I got from SIMCOM was an application note for IP and the FTPEXTPUT example I guess was in the middle. I tried to follow the example in the exact order, even down to the order of sending the FTPPUTNAME and FTPPUTPATH.

I will try to follow your example, and see if that works. At the moment I have switched to using HTTP POST for the data, and it seems to be working great. Got that working in an afternoon. Been struggling with FTPEXTPUT for about 3 months on an off. SIMCOM help has been absent. Why nobody there could tell me the sequence of commands was wrong, I don't know.

Thankyou very much for your support, I really hope I can get it to work!

On an unrelated tangent, have you had success with the hardware flow control? When I enable it, every now and then it doesn't send an "OK" response to some commands.

Thankyou again.

Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Sun Oct 22, 2017 3:17 am     Reply with quote

What you show does not agree.

You have an FTP session, and send this, but then with this still active, send a EXTPUT=0. There is no sign at this point that you have actually had an EXTPUT session. No wonder it gives 'ERROR'.

You need to terminate whatever you were doing, before starting another session.
NVergunst



Joined: 20 Oct 2017
Posts: 7
Location: Canada

View user's profile Send private message

PostPosted: Sun Oct 22, 2017 3:24 am     Reply with quote

Ttelmah wrote:
What you show does not agree.

You have an FTP session, and send this, but then with this still active, send a EXTPUT=0. There is no sign at this point that you have actually had an EXTPUT session. No wonder it gives 'ERROR'.

You need to terminate whatever you were doing, before starting another session.


Perhaps I am not being clear with the flow.

This would be my whole FTPEXTPUT command sequence:

Code:
AT+CGREG?
AT+SAPBR=0,1
AT+FTPPUT=1
AT+FTPEXTPUT=0
AT+SAPBR=3,1,"Contype","GPRS";
AT+SAPBR=3,1,"APN","wholesale"
AT+SAPBR=1,1
AT+SAPBR=2,1
AT+FTPCID=1
AT+FTPTYPE=I
AT+FTPSERV="ftp.***.com"
AT+FTPUN="***"
AT+FTPPW="***"
AT+FTPPUTNAME="FTPEXT.txt"
AT+FTPPUTPATH="/"
AT+FTPEXTPUT=1
AT+FTPEXTPUT=2,0,100,10000
AT+FTPPUT=1
AT+FTPEXTPUT=0


I expect or assume that the first 3 lines will ERROR out

Code:
AT+SAPBR=0,1
AT+FTPPUT=1
AT+FTPEXTPUT=0


This is to get it into a fresh state where nothing is active. I have even tried putting FTPQUIT commands into that area. I want the module to be idle, not doing anything. No open FTP connections. On the FTP server, I can see the logs that the user disconnects and everything is good there. That's what I want.

Then I connect it back to the internet

Code:
AT+SAPBR=3,1,"Contype","GPRS";
AT+SAPBR=3,1,"APN","wholesale"
AT+SAPBR=1,1
AT+SAPBR=2,1


Then I follow the app note to make an FTP connection and transfer a large block of data by itself.

Code:
AT+FTPCID=1
AT+FTPTYPE=I
AT+FTPSERV="ftp.***.com"
AT+FTPUN="***"
AT+FTPPW="***"
AT+FTPPUTNAME="FTPEXT.txt"
AT+FTPPUTPATH="/"
AT+FTPEXTPUT=1
AT+FTPEXTPUT=2,0,100,10000
AT+FTPPUT=1
AT+FTPEXTPUT=0


That is how I interpret the app note. Obviously it is not correct, but nowhere was that obvious to me. I've never worked with AT commands before, it's a whole new world.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Sun Oct 22, 2017 5:05 am     Reply with quote

FTPPUT=1, says 'open an ftp put session'. You have not configured anything for this, so the modem is going to get into a very confused state.
The command to terminate an FTP session is FTPPUT=2,0, but even this I'd not use unless a session was active.

QUIT, is a high level command from some other languages, not in the SIM command set.

The command to hang up everything is ATH0. You can disconnect from IP services with AT+CIPSHUT, or AT+CIPCLOSE. However 'beware', depending on your service, if you insist on disconnecting, you may be charged a fee to reconnect. This is why if you once open the connection it is better to keep it open, and just test if the provider has closed it.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group