Using the GSM

From CAEN RFID support

Jump to: navigation, search

Ion has an internal GSM module who can be used as SMS send/receive system or as Internet gatway. Here some basic instruction about how to send SMS and how to connect to the Internet.

Contents

Setting up the GSM module

In order to setup the serial GSM module connected with your system you must verify the serial port setting by using the stty command:

root@ion:~# stty -F /dev/ttyS1 
speed 9600 baud; line = 0;
susp = <undef>; min = 1; time = 0;
-brkint -icrnl -imaxbel
-opost
-isig -icanon -iexten -echo -echoe -echok noflsh -echoctl -echoke

then it's useful creating a symbolic link as follow in order to avoid typing the serial device each time:

root@ion:~# ln -s /dev/ttyS1 /dev/mobilephone

If you are using the ION system you may wish switching it on by using:

root@ion:~# ion-manager gsm switch
ion-manager; switching the GSM on/off... ok

Now, if everything is ok you can inquiry the serial GSM module:

root@ion:~# gsmctl all
gsmctl[ERROR]: ME/TA error 'SIM PIN required' (code 311)

Ok, the GSM is alive.

Now we supply the GSM's PIN:

root@ion:~# gsmctl -I "+cpin=NNNN"
root@ion:~# gsmctl all
<ME0>  Manufacturer: Telit
<ME1>  Model: GC864-QUAD
<ME2>  Revision: 10.00.063
<ME3>  Serial Number: 359294031006030
<FUN>  Functionality Level: 1
...

Sending a SMS message

Once the system is well configured you can send an SMS message just using the command:

root@ion:~# gsmsendsms <phone_number> 'Hello world!'

where <phone_number> is the recipient's phone number (eg. +393201234567).

C language

If you need sending a SMS into a C program the easiest way is by using the system(3) function with the command above. Please refer to system's man pages for further info.

Surfing the Internet

In order to connect to the Internet you can use the wvdial program. Just edit its configuration file named /etc/wvdial.conf as follow:

[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init3 = AT+CGDCONT=1,"IP","<YOUR APN>"
Modem Type = Analog Modem
Baud = 115200
New PPPD = yes
Modem = /dev/ttyS1
ISDN = 0
Phone = "<YOUR PHONE NUMBER>"
Password = <YOUR PASSWORD>
Username = <YOUR USERNAME>

by replacing parameters <YOUR APN>, <YOUR PHONE NUMBER>, <YOUR PASSWORD> and <YOUR USERNAME> according to your network provider.

If everything is ok just type the wvdial command to start the connection:

root@ion:~# wvdial
'--> WvDial: Internet dialer version 1.60
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Sending: AT+CGDCONT=1,"IP","web.omnitel.it"
AT+CGDCONT=1,"IP","web.omnitel.it"
OK
--> Modem initialized.
--> Sending: ATDT*99***1#
--> Waiting for carrier.
ATDT*99***1#
CONNECT
--> Carrier detected.  Waiting for prompt.

Here the program may hang for a while but then the output continues:

--> Don't know what to do!  Starting pppd and hoping for the best.
--> Starting pppd at Fri Oct  7 10:11:43 2011
--> Pid of pppd: 1949
--> Using interface ppp0
--> pppd: (~U[07][08]@~S[07][08]~H~[[07][08]
--> pppd: (~U[07][08]@~S[07][08]~H~[[07][08]
--> pppd: (~U[07][08]@~S[07][08]~H~[[07][08]
--> pppd: (~U[07][08]@~S[07][08]~H~[[07][08]
--> pppd: (~U[07][08]@~S[07][08]~H~[[07][08]
--> local  IP address 109.114.117.107
--> pppd: (~U[07][08]@~S[07][08]~H~[[07][08]
--> remote IP address 109.114.126.226
--> pppd: (~U[07][08]@~S[07][08]~H~[[07][08]
--> primary   DNS address 83.224.70.54
--> pppd: (~U[07][08]@~S[07][08]~H~[[07][08]
--> secondary DNS address 83.224.70.77
--> pppd: (~U[07][08]@~S[07][08]~H~[[07][08]

After that you can check the new pppX network adapter:

root@ion:~# ifconfig
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

ppp0      Link encap:Point-to-Point Protocol  
          inet addr:109.114.117.107  P-t-P:109.114.126.226  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:64 (64.0 B)  TX bytes:97 (97.0 B)

the routing table and the file /etc/resolv.conf should be modified accordingly too.

Note: In some cases, especially when eth0 is just configured and up&running, the wvdial may not updates the routing table properly: in this case it could be uselful to add those two lines at the end of /etc/ppp/peers/wvdial :

defaultroute
replacedefaultroute

After that pppd is now able to update the routing table according with the value assigned by ISP.

Personal tools