Data Call – AT commands to set up GPRS/EDGE/UMTS/LTE data call
How to set up data call with AT commands?
With Online AT Command Tester tool, it is easy to test data calls. First, the tool provides an interface to read/edit/delete PDP profiles which contain necessary call set up parameters such as APN, data call type (IPV4 or IPv6) etc. Then you can select a PDP profile and connect. The AT Command tester tool will then check whether the device is already registered in the network. If so, it will then send the necessary AT commands to the device to start the data call.
Once the device us powered up, check whether SIM card is present. If the SIM is not inserted properly or if the SIM card is locked, please correct those issues.
AT+CPIN?
+CPIN: READY
OK
The device above returns that the SIM is ready to use.
Then check the registration status of the device.
If the regisration status is “Searching” or “Not Registered”, that means that the device is not able to acquire the signal from the base station. The device should usually find the nearest base station within few minutes (max 15min). If you dont get “Registered” response for the AT+CGREG command,
– Verify that the antenna is properly connected on the device
– Verify that the bands supported by the device match the bands of the network provider
AT+CGREG?
+CGREG: 0,1
OK
In the above case, the device returns that it is registred in the home network.
After verifying the network registration status, you can get the network information. If teh device is registered on the home network, the network info on the SIM card used should match the network info returned by the AT+COPS command,
AT+COPS?
+COPS: 0,0,”T-Mobile”
OK
Now check the signal quality.
AT+CSQ
+CSQ: 10,0
OK
That return corresponds to a RSSI value of -93 dBm. This is only slightly better than marginal coverage. We should still be able to make a data call on this signal condition, but the throughput may not be that good.
Once the registration is sucessful, GPRS Attach is performed.
AT+cgatt=1
OK
Even if the GPRS Attach is sucessful, it doesn’t mean that the data call has been established.In GPRS, a Packet Data Protocol (PDP) defines the data session. The PDP context establishes the data path between the device and the GGSN (Gateway GPRS Support Node). GGSN acts like a gateway between the device and rest of the world. So the should establish a PDP context before it can send/receive data on the internet.
The GGSN is identified through Access Point Name (APN). Each carrier will have their own APNs and are usually available on the internet. The device can define multiple PDP contexts that are uniquely stored in context ids.
For examples,
AT+CGDCONT=1,”IP”,”epc.tmobile.com”
OK
Above defines a PDP context for T-Mobile. The context ID is 1, it will use a IP connection and the APN is set as
AT+CGDCONT=1,”IP”,”epc.tmobile.com”
OK
AT+CGDCONT=2,”IP”,”isp.cingular”
OK
Above defines another PDP context with a different APN. To list all the PDP contexts that are defined,
at+cgdcont?
+CGDCONT: 1,”IP”,”epc.tmobile.com”,”0.0.0.0″,0,0
+CGDCONT: 2,”IP”,”isp.cingular”,”0.0.0.0″,0,0
+CGDCONT: 3,”IP”,””,”0.0.0.0″,0,0
OK
Now that the PDP contexts are defined, please use the correct PDP context that matches the SIM card. For example, if we’re using the T-Mobile SIM card, the PDP context that has the corresponding APN should be used to connect.
Now to set up the session, the appropriate PDP context needs to be activated.
AT+CGACT=1,1
OK
The first parameter(1) is to activate the context and the second parameter is teh context ID. Once the PDP Context is activated sucessfully, the device can send/receive data on the internet. To check if there were any issues with teh PDP activation, send the AT+CEER command. Check the error code and take next steps.
To deactivate the PDP context,
AT+CGACT=0,1
OK
Deactivating the PDP context would ensure that no additional data is sent or received by the device.
To detach from the GPRS network,
AT+CGATT=0
OK
Detaching from the GPRS network will conserve network resources.
Try this script included in AT Command Tester Tool.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Script-initiate_data_call.at
//Procedure to setup data call
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//First check SIM is not locked and it is ready
AT+CPIN?
//Wait
WAIT=1
//Check the signal strength. In weak signal conditions, data throughput will be low
AT+CSQ
//Check what network is the device on
AT+COPS?
//Wait for few seconds as AT+COPS command can take time
WAIT=3
//Get the registration status of the device. If the status is ‘1’, the device is registered and in home network
AT+CGREG?
//Wait
WAIT=3
//Set up PDP context. Refer to the service provider for APN info
AT+CGDCONT=1,”IP”,”epc.tmobile.com”
//Wait
WAIT=1
//Confirm setting by reading PDP profile
AT+CGDCONT?
//Perform a GPRS Attach
AT+CGATT=1
//Wait
WAIT=3
//Check the status of attach
AT+CGATT?
//Activate the PDP context
AT+CGACT=1,1
//Wait
WAIT=3
//Get the assigned IP Address
AT+CGPADDR=1
//Wait
WAIT=3
//Check PDP profile.
AT+CGDCONT?
//Deactivate PDP Context
AT+CGACT=0,1
//Wait
WAIT=3
//Detach from network
AT+CGATT=0
Response to above output script in AT Command Tester Tool.
AT+CPIN?
+CPIN: READY
OK
SIM is ready.
AT+CSQ
+CSQ: 18,0
OK
Signal level is -77 dbm. Signal condition is good.The signal strength range is -53 dbm (Excellent) to -109 dbm (Marginal).
AT+COPS?
+COPS: 0,0,”T-Mobile USA”
OK
Device is currently on “T-Mobile USA” network.
AT+CGREG?
+CGREG: 0,1
OK
AT+CGDCONT=1,”IP”,”epc.tmobile.com”
OK
PDP Context list updated sucessfully
AT+CGDCONT?
+CGDCONT: 1,”IP”,”epc.tmobile.com”,”0.0.0.0″,0,0
OK
Following connection profiles are available,
CID-> 1
PDP Type->IP
APN->epc.tmobile.com
PDP Address->0.0.0.0
Data Compression->0
Header Compression->0
AT+CGDCONT?
+CGDCONT: 1,”IP”,”epc.tmobile.com”,”0.0.0.0″,0,0
OK
Following connection profiles are available,
CID-> 1
PDP Type->IP
APN->epc.tmobile.com
PDP Address->0.0.0.0
Data Compression->0
Header Compression->0
AT+CGATT=1
OK
AT+CGATT?
+CGATT: 1
OK
Device is attached to the network
AT+CGACT=1,1
OK
Dis-connect is successful
AT+CGPADDR=1
+CGPADDR: 1,”30.38.217.74″
OK
IP Address of the connected profile is “30.38.217.74”
AT+CGDCONT?
+CGDCONT: 1,”IP”,”epc.tmobile.com”,”30.38.217.74″,0,0
OK
Following connection profiles are available,
CID-> 1
PDP Type->IP
APN->epc.tmobile.com
PDP Address->30.38.217.74
Data Compression->0
Header Compression->0
AT+CGACT=0,1
OK
Dis-connect is successful
AT+CGATT=0
OK