GPRS Data

From IPLOG
Jump to: navigation, search

How to Set Up GPRS Data on IPLOG-GAMA G2

IPLOG-GAMA G2

The property GPRS data is disabled from the default configuration. However, the system has everything that you need to successfully establish a PPP connection. This allows the IPLOG-GAMA G2 unit to access the mobile Internet.


GPRS Data Enable

1. Edit the Configuration File

Open the file /etc/init.d/S41gprs by default text editor Vi.

root@iplog:~# vi /etc/init.d/S41gprs


The file contains two commented lines 45 and 52 (#pon and #poff), delete the comment character # before.

The resulting file should look like this:
 1 #!/bin/sh
 2 #
 3 # Starts the GPRS
 4 #
 5 
 6 NAME=gprs
 7 CONN=vodafone
 8 PRODUCT=`metel-eeprom -c read product`
 9 PCB_ASS=`metel-eeprom -c read assembly-pcb`
10 
11 PRODUCT=${PRODUCT##* }
12 PCB_ASS=${PCB_ASS##* }
13 
14 join()
15 {
16  # $1 - file
17  # $2 - wait for $2 seconds
18 
19    for i in $(seq 1 $2)
20    do
21         if [ -e $1 ]
22         then
23                 # Telit found
24                 return 0
25         else
26                 # Wait: 1s
27                 sleep 1
28         fi
29    done
30 
31    return 1
32 }
33 
34 start()
35 {
36         printf "Starting $NAME: "
37         # For IPLOG_GAMA_G2_10052018 and newer wait for supply power ON and Teli
38         if [ $PRODUCT == 0x494702 ]; then
39           if [ ${PCB_ASS%%_*} != 27042017 ] && [ ${PCB_ASS%%_*} != 18092017 ]; t
40             join "/dev/ttyACM0" 15
41             # wait 5s for catch GSM signal
42             sleep 5
43           fi
44         fi
45         pon gprs
46         [ $? = 0 ] && echo "OK" || echo "FAIL"
47 }
48 
49 stop()
50 {
51         printf "Stopping $NAME: "
52         poff
53         [ $? = 0 ] && echo "OK" || echo "FAIL"
54 }
55 
56 case "$1" in
57         start)
58                 start
59                 ;;
60         stop)
61                 stop
62                 ;;
63         restart|reload)
64                 stop
65                 start
66                 ;;
67         *)
68                 echo "Usage: $0 {start|stop|restart}"
69                 exit 1
70 esac
71 
72 exit $?
73 
74 #end-of-file

Tip:
Text editing - Hit the i (insert mode).
Save and Exit - Write the charakters :wq (write and quit). The cursor moves to bottom of screen whenever a colon (:) is typed. This type of command is completed by hitting the Enter key.


3. Device Reboot

It is strongly recommended to do a reboot.

root@buildroot:~# reboot

4. Check the Connection

After system reboot to see that the GPRS connection is working.

root@buildroot:~# ifconfig ppp0

If a connection was established the output will looks like:

ppp0      Link encap:Point-to-Point Protocol
          inet addr:100.91.38.191  P-t-P:100.91.38.191  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:5 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:68 (68.0 B)  TX bytes:120 (120.0 B)

If the connection is not working:

ifconfig: ppp0: error fetching interface information: Device not found


Error Posibilities:

SIM card PIN configuration.

GSM LED on the front panel flash or shines = it is not a registered to GSM network.

Antenna is connected and a 2G/3G signal is available on site.

The APN configuration corresponds to the local operator.

The SIM card contains a credit and mobile data are enable.



APN Configuration

An Access Point Name (APN) is the name of the gateway between the GSM, GPRS, 3G or 4G mobile networks and another computer network, frequently called public Internet. In the Czech Republic, the most commonly used name for the APN point is the "internet". The "internet" is a default APN point name, if your operator has the same APN name, use the default configuration. It can be different in other countries. Below you can find the easy way how to change name of an APN point.

1. Edit the Configuration File

Open the file /etc/ppp/peers/gprs-chat by the default text editor Vi.

root@buildroot:~# vi /etc/ppp/peers/gprs-chat

File gprs-chat template. Important is the row 13 begins 'OK AT+CGDCONT=...', where the "YOUR_APN_NAME" is the name of your APN (including quotes).

 1 TIMEOUT 35
 2 ECHO ON
 3 ABORT '\nBUSY\r'
 4 ABORT '\nERROR\r'
 5 ABORT '\nNO  ANSWER\r'
 6 ABORT '\nNO  CARRIER\r'
 7 ABORT '\nNO  DIALTONE\r'
 8 ABORT '\nRINGING\r\n\r\nRINGING\r'
 9 '' \rAT
10 OK-+++\c-OK   ATH0
11 OK \rATZ
12 OK 'ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0'
13 OK AT+CGDCONT=3,"IP","YOUR_APN_NAME","0.0.0.0",0,0
14 OK ATD*99***3#
15 CONNECT ''

Tip:
Text editing - Hit the i (insert mode).
Save and Exit - Write characters :wq (write and quit). The cursor moves to bottom of screen whenever a colon (:) is typed. This type of command is completed by hitting the Enter key.


2. Device Reboot

It is strongly recommended to do a reboot.

root@buildroot:~# reboot



Monitoring of Active Data Connection

The PPP connection is established only once until the time of a GSM connection failure. Such outages in mobile networks actually occur, and as a result the PPP connection can interrupted. To enable automatic re-connection after the interruption occurred, you will need to upload the appropriate scripts to the device.

1. Create and Save Script

Save the script to the directory /home/gsm_wdg.sh.

 1 #!/bin/bash
 2 
 3 LOGFILE=/var/log/gsm_wdg.log
 4 NOW=$(date +"%Y%m%d_%H%M%S")
 5 PPP_CONECT=$(ifconfig | grep ppp0 | wc -l)
 6 
 7 lsusb | grep -q 1bc7:0021
 8 if [[ $? == 0 ]]; then
 9 	echo $NOW :: GSM ok >> $LOGFILE
10 	if [[ $PPP_CONECT == "1" ]]; then
11 		echo $NOW :: "PPP is OK" >> $LOGFILE
12 		exit 0
13 	else
14 		/etc/init.d/S41gprs start
15 		echo $NOW :: "PPP was repaired" >> $LOGFILE
16 		exit 0
17 	fi
18 fi
19 
20 echo $NOW :: GSM err, try to fix >> $LOGFILE
21 
22 /etc/init.d/S41gprs stop
23 /etc/init.d/S50smsd stop
24 
25 /etc/init.d/S38gsm restart
26 
27 NOW=$(date +"%Y%m%d_%H%M%S")
28 echo $NOW :: GSM HW reset >> $LOGFILE
29 
30 sleep 10
31 
32 NOW=$(date +"%Y%m%d_%H%M%S")
33 
34 lsusb | grep -q 1bc7:0021
35 if [[ $? == 0 ]]; then
36 	echo $NOW :: GSM ok, try to restart services >> $LOGFILE
37 
38 	/etc/init.d/S41gprs restart
39 	/etc/init.d/S50smsd restart
40 	NOW=$(date +"%Y%m%d_%H%M%S")
41 	echo $NOW :: GSM SW reset >> $LOGFILE
42 
43 	exit 0
44 fi
45 
46 echo $NOW :: GSM err, quit >> $LOGFILE

This script checks the internal GSM module connection activity and PPP connection activity. In the event, of any error, the cript will try to resolve the problem. By running this script the controlling process will begin and then the script will end. Therefore, it is necessary to run it automatically, for example by using CRON.

2. Automatic Start - CRON

To the end of file /etc/crontabs/root add the line: */5 * * * * /home/gsm_wdg.sh

Meaning: The CRON application automattically runs the scrip /home/gsm_wdg.sh every 5 minutes.


After CRON configuration update and restart the CRON script.

root@buildroot:~# /etc/init.d/S80crond restart