Difference between revisions of "Configuring for Data Connection"
(Created page with "== Configure for 2G Module/SIM900A in Debian Wheezy == '''Note:''' All commands are executed as root unless otherwise mentioned. First step would be to check that the Modem ...") |
|||
Line 50: | Line 50: | ||
<pre> | <pre> | ||
− | |||
$ apt-get install wvdial | $ apt-get install wvdial | ||
− | |||
</pre> | </pre> | ||
Line 58: | Line 56: | ||
<pre> | <pre> | ||
− | |||
$ wvdialconf | $ wvdialconf | ||
− | |||
</pre> | </pre> | ||
Line 66: | Line 62: | ||
<pre> | <pre> | ||
− | |||
$ nano /etc/wvdial.conf | $ nano /etc/wvdial.conf | ||
− | |||
</pre> | </pre> | ||
− | + | Considering that, you have the USERNAME, PASSWORD and APN available for the service provider of the sim card being used, edit and make wvdial.conf file like this. | |
− | + | ||
− | + | ||
<pre> | <pre> | ||
− | |||
[Dialer Defaults] | [Dialer Defaults] | ||
− | |||
Modem Type = Analog | Modem Type = Analog | ||
− | |||
ModemPhone = *99# | ModemPhone = *99# | ||
− | |||
ISDN = 0 | ISDN = 0 | ||
− | |||
Baud = 115200 | Baud = 115200 | ||
− | |||
Username = USERNAME | Username = USERNAME | ||
− | |||
Password = PASSWORD | Password = PASSWORD | ||
− | |||
Modem = /dev/ttyO1 | Modem = /dev/ttyO1 | ||
− | |||
Init1 = ATZ | Init1 = ATZ | ||
− | |||
Init2 = at+cgdcont=1,"ip","APN" | Init2 = at+cgdcont=1,"ip","APN" | ||
− | |||
Stupid Mode = 1 | Stupid Mode = 1 | ||
− | |||
</pre> | </pre> | ||
− | Usually for GSM Networks, Phone is *99# or *99***1# | + | Usually for the GSM Networks, Phone is *99# or *99***1# |
− | + | ||
After editing save and exit | After editing save and exit | ||
− | |||
Now run wvdial for establishing communication. | Now run wvdial for establishing communication. | ||
<pre> | <pre> | ||
− | |||
$ wvdial | $ wvdial | ||
− | |||
</pre> | </pre> | ||
− | |||
You can also edit the wvdial.conf file for multiple service providers by providing its name here [Dialer Defaults] : | You can also edit the wvdial.conf file for multiple service providers by providing its name here [Dialer Defaults] : | ||
− | |||
<pre> | <pre> | ||
− | |||
[Dialer Vodafone] | [Dialer Vodafone] | ||
− | |||
Modem Type = Analog Modem | Modem Type = Analog Modem | ||
− | |||
Phone = *99# | Phone = *99# | ||
− | |||
ISDN = 0 | ISDN = 0 | ||
− | |||
Baud = 115200 | Baud = 115200 | ||
Revision as of 00:46, 24 February 2014
Contents
Configure for 2G Module/SIM900A in Debian Wheezy
Note: All commands are executed as root unless otherwise mentioned.
First step would be to check that the Modem port for SIM900A is enabled in Beaglebone Black on Debian Wheezy. The modem port is UART1 , which is visible as ttyO1 in devices so ,
ls /dev/ttyO*
ttyO1 should also be listed here alongwith ttyO0 atleast.
Now, on the Vayu Cape, there are two Leds which indicate status of 2G module :
i. STATUS LED D3 : This Led gives the state of the Modem. It is on when the module is turned on and off when it is turned off.
ii. NETLIGHT LED D4 : It has different states depending on the mode of operation of the Modem -
a. Off when Modem is off
b. 64ms ON/800ms OFF when Modem is on but it is not registered on a network i.e. sim card has not been detected or is not present
c. 64ms ON/3000ms OFF when Modem is on and is registered to a network i.e. sim card has been detected but a network connection has not been established.
d. 64ms ON/300ms OFF when Modem is on and GPRS communication has been established.
The SIM900A modem on the cape has been shipped pre-set with settings so that its serial port is working and appropriate settings has been stored in the modem. For more details about its operation modes refer to datasheet.
Currently module has Data communication enabled and is fully functional (+CFUN=1) and in sleep mode 0 (+CSCLK=0) and will not go to sleep ever.
To change the modes or any settings related to modem , you need access to AT ports and run AT commands there. For more details on AT commands and operation modes of modem refer to its AT command sheet and Datasheet.
AT port settings for SIM900A is "ttyO1 115200 8N1"
Considering that, Cape is connected properly to Beaglebone black and user is logged in as root and has checked for UART1 port, we check that the Modem is turned on properly before trying to establish a connection, so:
i. D3 is continuously on and D4 is blinking as 64ms ON/800ms OFF, when SIM card is not present or not detected/inserted properly.
ii. D3 is continuously on and D4 is blinking as 64ms ON/3000 ms OFF when a valid SIM card is present. If SIM card was inserted while the modem was on, please software reset the modem by turning it OFF and then ON again using Software GPIO commands or Push button switch. [refer to]
If any other state of LEDs is present, please soft reset the modem using push button switch or GPIOs.
So when it is established that modem is in ii we try to establish connection
Wvdial Configuration
Download and install Wvdial
$ apt-get install wvdial
Executing the following command usually sets the wvdial.conf file which is used for dialing to GPRS communication, but since here our modem port is on a UART, we will have to manually configure it.
$ wvdialconf
So, open the wvdial.conf file
$ nano /etc/wvdial.conf
Considering that, you have the USERNAME, PASSWORD and APN available for the service provider of the sim card being used, edit and make wvdial.conf file like this.
[Dialer Defaults] Modem Type = Analog ModemPhone = *99# ISDN = 0 Baud = 115200 Username = USERNAME Password = PASSWORD Modem = /dev/ttyO1 Init1 = ATZ Init2 = at+cgdcont=1,"ip","APN" Stupid Mode = 1
Usually for the GSM Networks, Phone is *99# or *99***1# After editing save and exit Now run wvdial for establishing communication.
$ wvdial
You can also edit the wvdial.conf file for multiple service providers by providing its name here [Dialer Defaults] :
[Dialer Vodafone] Modem Type = Analog Modem Phone = *99# ISDN = 0 Baud = 115200 Username = 0 Password = 0 Modem = /dev/ttyO1 Init1 = ATZ Init2 = at+cgdcont=1,"ip","www" Stupid Mode = 1 [Dialer Airtel] Modem Type = Analog Modem Phone = *99# ISDN = 0 Baud = 115200 Username = airtel Password = airtel Modem = /dev/ttyO1 Init1 = ATZ Init2 = at+cgdcont=1,"ip","airtelgprs.com" Stupid Mode = 1
And run wvdial for the required service provider as follows:
wvdial airtel
A list of running commands should be visible on the shell, trying to establish ppp connection.
once PPP connection has been established, you will see a ppp0 IP.
# wvdial airtel --> WvDial: Internet dialer version 1.61 --> Cannot set information for serial port. --> Initializing modem. --> Sending: ATZ ATZ OK --> Sending: at+cgdcont=1,"ip","airtelgprs.com" at+cgdcont=1,"ip","airtelgprs.com" OK --> Modem initialized. --> Sending: ATDT*99# --> Waiting for carrier. ATDT*99# CONNECT --> Carrier detected. Starting PPP immediately. --> Starting pppd at Fri Jan 31 08:49:33 2014 --> Pid of pppd: 2522 --> pppd: `�[02] --> Using interface ppp0 --> pppd: `�[02] --> pppd: `�[02] --> pppd: `�[02] --> pppd: `�[02] --> pppd: `�[02] --> pppd: `�[02] --> pppd: `�[02] --> pppd: `�[02] --> Authentication (PAP) started --> pppd: `�[02] --> Authentication (PAP) successful --> pppd: `�[02] --> pppd: `�[02] --> pppd: `�[02] --> pppd: `�[02] --> pppd: `�[02] --> pppd: `�[02] --> pppd: `�[02] --> pppd: `�[02] --> pppd: `�[02] --> pppd: `�[02] --> pppd: `�[02] --> pppd: `�[02] --> pppd: `�[02] --> pppd: `�[02] --> pppd: `�[02] --> pppd: `�[02] --> local IP address 106.223.90.222 --> pppd: `�[02] --> remote IP address 192.200.1.21 --> pppd: `�[02] --> primary DNS address 122.160.120.56 --> pppd: `�[02] --> secondary DNS address 202.56.230.7 --> pppd: `�[02] --> pppd: `�[02] --> Script /etc/ppp/ip-up run successful --> Default route Ok. --> Nameserver (DNS) Ok. --> Connected... Press Ctrl-C to disconnect --> pppd: `�[02]
To check the status of wvdial and find out its IP open a new shell and use either of following:
1. Run ifconfig and find ppp0 in the list of network connections.
$ ifconfig
or
$ ifconfig ppp0
2. Check the network statistics for IP and their gateways and check the Iface column for ppp0
$ netstat -arn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.7.0 0.0.0.0 255.255.255.252 U 0 0 0 usb0 192.200.1.21 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
3. Read the system messages as
$ cat /var/log/messages
It lists all the attempts at establishing ppp communication using the modem and ips for the successful attempt.
Now all that is left is to route the network traffic over the gateway of ppp0 instead of eth0 so that GPRS communication is fully completed.
For that, download and run this script
$ chmod +x 0000routefix $ ./0000routefix
Now on Ip table should look like this :
$ netstat -arn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.7.0 0.0.0.0 255.255.255.252 U 0 0 0 usb0 192.200.1.21 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
PPP connection has been established over GPRS using 2G module and wvdial.
You can alternately run wvdial for multiple service providers and store their wvdial.conf files too by this way also
$ wvdial -C /etc/wvdial.conf.provider_name
where wvdial.conf.provider_name is wvdial.conf for the SIM card currently inserted.
Also, you can Wvdial in background to free up the shell instead of opening another new shell by :
$ wvdial & disown
PPPd Configuration
Using PPPd requires manual configuration of few files.
Usually following files are involved :
- /etc/ppp/options - PPPd system options file.
- /etc/ppp/pap-secrets - System PAP passwords file.
- /etc/ppp/chap-secrets - System CHAP passwords file.
- /etc/ppp/peers/ - Directory holding the peer options files.The default file is called provider.
- /etc/chatscripts/provider - The chat script invoked from the default /etc/ppp/peers/provider.
Prior to editing the files, USERNAME, PASSWORD and APN for the service provider are required.
PPPd should be already installed. Check :
# dpkg -l ppp ||/ Name Version Architecture Description +++-================================-=====================-=====================- ===================================================================== ii ppp 2.4.5-5.1+b1 armhf Point-to-Point Protocol (PPP) - daemon
If PPPd is not installed, use :
# apt-get install ppp
Now, open or create a options file for the service provider
# nano /etc/ppp/peers/PROVIDER_NAME
And edit the contents as this
hide-password noauth connect "/usr/sbin/chat -v -f /etc/chatscripts/airtel" debug /dev/ttyO1 115200 defaultroute noipdefault user "USERNAME" remotename USERNAME
Open/create and edit chat script for the service provider with chatscripts file of same name as in peers :
# nano /etc/chatscripts/PROVIDER_NAME ABORT BUSY ABORT 'NO CARRIER' ABORT VOICE ABORT 'NO DIALTONE' ABORT 'NO DIAL TONE' ABORT 'NO ANSWER' ABORT DELAYED REPORT CONN #REPORT CONNECT # modeminit '' ATZ OK 'ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0' OK 'AT+CGDCONT=1,"IP","APN"' # ispnumber OK-AT-OK "ATDT*99#" # ispconnect CONN \d\c
And Lastly edit Pap-secrets or Chap-secrets depending on the type of authentication that is preferred by your service provider. Usually it is PAP, so
# nano /etc/ppp/pap-secrets And edit the table with the USERNAME and PASSWORD
There is an alternate way of configuring PPPd too, follow these :
# apt-get install pppconfig # pppconfig
And follow the onscreen interactive steps to configure for your service provider
Now considering all files are properly written we can now start the connection
# pon PROVIDER_NAME
if created a new file in /etc/ppp/peers/ and /etc/chatscripts of PROVIDER_NAME
or else if using the default provider file then simply
# pon
Check for PPP0 connection using the same methods suggested with Wvdial
Configure for 3G Module(HSPA)/SEW290
Note: All commands are executed as root unless otherwise mentioned.
It is assumed that USB drivers patch was applied in the Debian image that is being used.
First check that the SEW290 is turned on or not. LED D4 should be blinking 1s ON/100ms OFF and SEW290 should be available at USB port on Beaglebone black :
# lsusb Bus 001 Device 002: ID 0424:2412 Standard Microsystems Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 007: ID 21f5:2012
21f5:2012 denotes VendorID and ProductID for SEW290.
Now that SEW290 is connected to Beaglebone black, its Modem ports should come up in /dev if USB drivers patch was correctly applied. The modem ports are ttyUSB0 , ttyUSB1 and ttyUSB2 .
ls /dev/ttyU*
ttyUSB0, ttyUSB1 and ttyUSB2 should be listed here.
One more thing to check is the value of GPIO45. It is the ON/OFF pin for the SEW290 module. When Beaglebone Black boots up it is usually set to 0. SEW290 requires a cycle of high, delay 4s, low, delay 4s, high to turn ON or OFF.
So when SEW290 is visible on USB port, then GPIO45 should be 1. If it is 0, then also module is visible, but on completing the whole cycle i.e. turning GPIO45 to 1 can either turn the module off or properly put it in ON state.
So, cycling of values at GPIO45 should be done carefully while observing USB device list.
As a rule of thumb, when Beaglebone Black boots up, GPIO45 is 0, then turning it to 1 turns off SEW290. So, recycle GPIO45 with High, Low, High; basically follow this :
# pinread 45 0
This checks the GPIO45 for its value. Now to set its value, for the first time follow this and for subsequent resets do similar :
# setout 45 high; sleep 4; setout 45 low; sleep 4; setout 45 high; setting 45 to 1 setting 45 to 0 setting 45 to 1
Now, after all these steps and considering that SEW290 is properly ON and connected to Beaglebone Black with its Modem ports created we can proceed with establishing Data Connection with SIM card properly inserted.
For SEW290, all data mode settings and text mode settings have been set in the modem.
To check or issue any AT commands, the AT Port settings are ttyUSB2 , 8N1, 115200.
It only responds when Board is properly turned on.
The Data port for SEW290 is ttyUSB0.
The Behaviors of the LED D4 w.r.t. Module state and SIM card state are as :
- LED always on in dimmed mode : SEW290 Module is OFF
- LED always on in Bright mode : SEW290 Module is ON, no SIM Card detected or inserted
- LED Blinks 1s ON/100ms OFF : SEW290 Module is ON, SIM card has been detected
- LED Blinks 3s ON/1s OFF : SEW290 Module is ON and Data connections is established
PPPd Configuration
All the steps are same here for establishing ppp connection using PPPd and the related files needed for it and methods to check for ppp0.
For SEW290, the Modem port and Baud rate are different and only this has to be edited in /etc/ppp/peers/PROVIDER_NAME after everything has been configured.
# nano /etc/ppp/peers/PROVIDER_NAME hide-password noauth connect "/usr/sbin/chat -v -f /etc/chatscripts/airtel" debug /dev/ttyUSB0 460800 defaultroute noipdefault user "USERNAME" remotename USERNAME
Save and exit and establish ppp Connection.
Wvdial Configuration
All steps are similar as mentioned earlier for SIM900A section.
Only Modem port and Baud rate have to be changed in wvdial.conf file to use it with SEW290.
Additionally, wvdialconf will work for SEW290 and will automatically configure wvdial.conf file for use.
# wvdialconf Scanning your serial ports for a modem.
After wvdialconf is finished configuring wvdial.conf, edit it with PROVIDER_NAME, USERNAME and PASSWORD for the service provider of the SIM card.
[Dialer Defaults] Modem Type = Analog Modem Phone = *99# ISDN = 0 Baud = 115200 Username = USERNAME Password = PASSWORD Modem = /dev/ttyO1 Init1 = ATZ Init2 = at+cgdcont=1,"ip","APN" Stupid Mode = 1
o
Adding a DNS if BBB doesnt get it
nano /etc/resolv.conf add following
nameserver 8.8.8.8 nameserver 208.67.222.222