Connecting APN using AT Commands

52.5k views Asked by At

I need to connect in internet with a usb 3g dongle using at commands.

My apn provider is:

APN = tim.br
Username = tim
Password = tim

How can I connect using only at commands? It's possible?

Thanks.

3

There are 3 answers

4
Rahul Tripathi On BEST ANSWER

Try something like this:-

AT+CGDCONT=1,"IP","tim.br"
ATD*99***1#
0
Divide On

To connect, you need to use AT commands:

AT+CGDCONT=1,"IP","tim.br"

to configure APN, and then

ATD*99***1#

to actually connect. This will open a PPP session, and the username and password is usually provided over PAP in the PPP session itself, so you'll need to put them in your PPP client.

0
charles On

The steps to connect to internet using 3G modem are the following, assuming you will use a serial command which includes two programs: 'chat' for send AT commands to the modem; 'pppd' for managing the data connection and configure a interface that you can use for the IP packet communication.

STEPS:

  1. Put the USB device on modem mode, it is archieved with usb_modswitch, generally its automatic at USB plugging.

  2. Configure the AT comands using a chat script:

# cat /var/usb3g.chat
ABORT 'NO DIAL TONE'
ABORT 'NO ANSWER'
ABORT 'NO CARRIER'
ABORT DELAYED
ABORT 'COMMAND NOT SUPPORT'

SAY 'ola'
'' ''
'' 'ATZ'
SAY 'set APN...\n'
'OK' 'AT+CGDCONT=1,"IP","timbrasil.br"'

SAY 'dialing...\n\n'
'OK' 'ATD*99***1#'
#'OK' 'ATD*99#' # for 2G dialling
'CONNECT' ''

  1. Configure pppd to use the chat and negotiate the connection parameters:
# cat pppd.conf
hide-password
persist
nodetach
lcp-echo-interval 20
lcp-echo-failure 3
holdoff 2
connect-delay 100
noauth
/dev/ttyUSB0
115200
debug
defaultroute
ipcp-accept-local
ipcp-accept-remote
usepeerdns
crtscts
lock
noccp
noipdefault
user tim
password tim
mtu 1490
mru 1490

# disable compression if not getting IP
#novj

connect 'chat -v -t10 -f /var/usb3g.chat'

If you see valid IPs on the output when calling pppd file pppd.conf, in an network interface called ppp0, all should be working well.

The above configuration I just tested for TIM Brazil, using a E3131 3G modem, and all worked fine.