Proper sequence for TCP

This post states that the proper sequence for establishing a TCP connection is:

AT+CGATT=1
AT+KCNXCFG=0,“GPRS”,"internet.beeline.ru,“beeline”,“beeline”,“0.0.0.0”,“0.0.0.0”,“0.0.0.0”
AT+KTCPCFG=0,0,“server.ru”,“4444”
AT+KTCPCNX=1 —Activate the PDP context and then connect with the TCP server.

Do I need to run +CGATT and +KCNXCFG every time I create a TCP connection?
Right now I run them during system startup and when I run into problems creating a TCP connection in order to fix connection issues.

You can query these command and see if they are having proper values.

@sguerreri,

You don’t state what unit or firmware version number but generically speaking, you don’t need to send at+cgatt=1 to the unit, this is something legacy left over from 2G days, the kcnxcfg is not persistent across power cycles so if you don’t power the unit down (or delete it) then no you don’t have to resend it, otherwise yes you do.

Regards

Matt

I’m using the HL7588.
So best practice would be to:
check and attach to the PS if not already with AT+CGATT
check that the GPRS connection is configured with AT+KCNXCFG (define it if not)
Create my TCP connection (AT+KTCPCFG)
Start the TCP connection (AT+KTCPCNX)

Am I reading this right that +KTCPCNX will activate the PDP so there is no need to check and run AT+CGACT?

Does Sierra Wireless have Flow Diagrams made up for the different problems that might occur? I’m just wondering how I will go about recovering from each of these steps if an error occurs.

@sguerreri,

Yes the unit will start a session if it has not already been done so. The reasons the unit might not connect are all given in the manual (in that command) as per the below, the bottom line is that if any of them are given the unit has failed to connect and it is not going to try again until it is commanded to again. The actions that the application should take are dependent on the error and the setup of the system which the unit cannot determine.

0 Network error
1 No more sockets available; max. number already reached
2 Memory problem
3 DNS error
4 TCP disconnection by the server or remote client
5 TCP connection error
6 Generic error
7 Fail to accept client request’s
8 Data sending is OK but KTCPSND was waiting more or less characters
9 Bad session ID
10 Session is already running
11 All sessions are used
12 Socket connection timer timeout
13 SSL connection error
14 SSL initialization error

Regards

Matt

Is there an application programmers document that tells me what I should do with each error case?
Most I understand what to do but some are rather vague.
0 - Go through checking the network connection (CREG,CGREG,CEREG, GATT, GACT), the APN, then SIM, sig quality
1 - Delete TCP sockets that might be allocated but not used anymore
2 - NO IDEA
3 - check the DNS server IP address and try to fix if no defined
4 - nothing for me to do
5 - I’m guessing I should handle this like ‘0’
6 - NO IDEA
7 - NO IDEA
8 - I think I just do nothing for this one but wait
9 - ID is bad, close and delete it, open a new session
10 - Session is already defined, go ahead and use it
11 - Close old unused Sessions to free up resources
12 - NO IDEA
13 - NO IDEA
14 - NO IDEA