The Acme Systems shipping office will be closed for holidays from 14 august to 22 august

PPP over GPRS or HSPA link

This article illustrates how to set-up a TCP/IP link using the PPP protocol over a GPRS or HSPA network

The contents are tested on a Terra-M Board with the embedded GPRS modem

Enabling the PPP Kernel support

Follow this article to set up a cross compilation environment on your PC to compile the Linux Kernel image for your board:

Run make menuconfig and set-up the follow configuration:

Device Drivers ---> 
  [*] Network device support --->
    <*>   PPP (point-to-point protocol) support
      [ ]     PPP multilink support (EXPERIMENTAL)
      [*]     PPP filtering
      <*>     PPP support for async serial ports
      < >     PPP support for sync tty ports
      < >     PPP Deflate compression
      < >     PPP BSD-Compress compression
      < >     PPP MPPE compression (encryption) (EXPERIMENTAL)
      < >     PPP over Ethernet (EXPERIMENTAL)
      < >     PPP over ATM

Create the new Kernel image and copy it on the first partition of your bootable microSD then reboot the board.

Install and configure the ppp package

Install the ppp package by typing:

sudo apt update
sudo apt install ppp

Edit the /etc/ppp/peers/provider file and insert the number to call changing this line:

connect "/usr/sbin/chat -v -f /etc/chatscripts/pap -T ********"

in that way:

connect "/usr/sbin/chat -v -f /etc/chatscripts/pap -T *99***1#"

Set the serial line where is wired GPRS modem changing /dev/modem in:

  • /dev/ttyS1 If you are using a Terra-M board
  • /dev/ttyACM0 If you are using Huawei HSPA USB Stick K3806-Z

Set the speed of the serial line in:

# Speed of the serial line.
115200

Using:

  • 115200

Edit the /etc/chatscripts/pap file as shown below:

# You can use this script unmodified to connect to sites which allow
# authentication via PAP, CHAP and similar protocols.
# This script can be shared among different pppd peer configurations.
# To use it, add something like this to your /etc/ppp/peers/ file:
#
# connect "/usr/sbin/chat -v -f /etc/chatscripts/pap -T PHONE-NUMBER"
# user YOUR-USERNAME-IN-PAP-SECRETS
# noauth

# Uncomment the following line to see the connect speed.
# It will be logged to stderr or to the file specified with the -r chat option.
#REPORT        CONNECT

TIMEOUT     60
ABORT       BUSY
ABORT       VOICE
ABORT       "ERROR"
ABORT       "NO CARRIER"
ABORT       "NO DIALTONE"
ABORT       "NO DIAL TONE"
""          ATZ
#Insert this line if you are using a Huawei K3806 HSPA USB Stick
#OK         ATQ0V1E1S0=0&C1&D2+FCLASS=0
OK          AT+CGDCONT=1,"IP","web.omnitel.it","0.0.0.0",0,0
OK          ATDT\T
CONNECT        ""

Change web.omnitel.it with the APN address of your provider. For example in Italy the Telecom APN is ibox.tim.it.

Turn-on the modem

If you are using a Terra Board turn-on the GPRS modem using these programs:

modem_on.py

from time import sleep
from ablib import Pin

print "Modem ON"

quectel_power = Pin('W10','HIGH')
quectel_power_key = Pin('E10','LOW')

quectel_power_key.on()
sleep(1)
quectel_power_key.off()

modem_off.py

from time import sleep
from ablib import Pin

print "Modem OFF"

quectel_power = Pin('W10','LOW')
quectel_power_key = Pin('E10','LOW')

Link up the GPRS connection

Now you are ready to link-up the GPRS connection. To check what will happen open a new SSH session and type:

tail -f /var/log/messages

If /var/log/messages doesn't exist probably you have to install rsyslog by typing:

sudo apt update
sudo apt install rsyslog

On the original terminal session type:

pon

to link-up the ppp session.

You could see the following messages on the /var/log/messages terminal session:

Oct  5 12:37:33 localhost pppd[1289]: pppd 2.4.4 started by root, uid 0
Oct  5 12:37:34 localhost chat[1290]: timeout set to 60 seconds
Oct  5 12:37:34 localhost chat[1290]: abort on (BUSY)
Oct  5 12:37:34 localhost chat[1290]: abort on (VOICE)
Oct  5 12:37:34 localhost chat[1290]: abort on (ERROR)
Oct  5 12:37:34 localhost chat[1290]: abort on (NO CARRIER)
Oct  5 12:37:34 localhost chat[1290]: abort on (NO DIALTONE)
Oct  5 12:37:34 localhost chat[1290]: abort on (NO DIAL TONE)
Oct  5 12:37:34 localhost chat[1290]: send (ATZ^M)
Oct  5 12:37:34 localhost chat[1290]: expect (OK)
Oct  5 12:37:34 localhost chat[1290]: ATZ^M^M
Oct  5 12:37:34 localhost chat[1290]: OK
Oct  5 12:37:34 localhost chat[1290]:  -- got it
Oct  5 12:37:34 localhost chat[1290]: send (AT+CGDCONT=1,"IP","web.omnitel.it","0.0.0.0",0,0^M)
Oct  5 12:37:35 localhost chat[1290]: expect (OK)
Oct  5 12:37:35 localhost chat[1290]: ^M
Oct  5 12:37:35 localhost chat[1290]: AT+CGDCONT=1,"IP","web.omnitel.it","0.0.0.0",0,0^M^M
Oct  5 12:37:35 localhost chat[1290]: OK
Oct  5 12:37:35 localhost chat[1290]:  -- got it
Oct  5 12:37:35 localhost chat[1290]: send (ATD*99***1#^M)
Oct  5 12:37:35 localhost chat[1290]: expect (CONNECT)
Oct  5 12:37:35 localhost chat[1290]: ^M
Oct  5 12:37:35 localhost chat[1290]: ATD*99***1#^M^M
Oct  5 12:37:35 localhost chat[1290]: CONNECT
Oct  5 12:37:35 localhost chat[1290]:  -- got it
Oct  5 12:37:35 localhost chat[1290]: send (^M)
Oct  5 12:37:35 localhost pppd[1289]: Serial connection established.
Oct  5 12:37:35 localhost pppd[1289]: Using interface ppp0
Oct  5 12:37:35 localhost pppd[1289]: Connect: ppp0 <--> /dev/ttyS1
Oct  5 12:37:36 localhost pppd[1289]: Remote message: Welcome!
Oct  5 12:37:36 localhost pppd[1289]: PAP authentication succeeded
Oct  5 12:37:40 localhost pppd[1289]: local  IP address 109.112.53.134
Oct  5 12:37:40 localhost pppd[1289]: remote IP address 109.112.235.129
Oct  5 12:37:40 localhost pppd[1289]: primary   DNS address 83.224.66.134
Oct  5 12:37:40 localhost pppd[1289]: secondary DNS address 83.224.65.134

Typing:

sudo ifconfig                                                              

You could see a new network interface called ppp0.

sudo ifconfig                                                              

eth0      Link encap:Ethernet  HWaddr 00:04:25:78:9b:9a                         
          inet addr:192.168.1.90  Bcast:192.168.1.255  Mask:255.255.255.0       
          inet6 addr: fe80::204:25ff:fe78:9b9a/64 Scope:Link                    
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1                    
          RX packets:2985 errors:0 dropped:0 overruns:0 frame:0                 
          TX packets:269 errors:0 dropped:0 overruns:0 carrier:0                
          collisions:0 txqueuelen:1000                                          
          RX bytes:204683 (199.8 KiB)  TX bytes:28898 (28.2 KiB)                
          Interrupt:21 Base address:0x4000                                      

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:4 errors:0 dropped:0 overruns:0 frame:0                    
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0                  
          collisions:0 txqueuelen:0                                             
          RX bytes:280 (280.0 B)  TX bytes:280 (280.0 B)                        

ppp0      Link encap:Point-to-Point Protocol                                    
          inet addr:109.112.53.134  P-t-P:109.112.235.129  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:5 errors:0 dropped:0 overruns:0 carrier:0                  
          collisions:0 txqueuelen:3                                             
          RX bytes:74 (74.0 B)  TX bytes:92 (92.0 B)   

To link down the connection type poff.

Oct  5 12:39:08 localhost pppd[1289]: Terminating on signal 15
Oct  5 12:39:08 localhost pppd[1289]: Connect time 1.5 minutes.
Oct  5 12:39:08 localhost pppd[1289]: Sent 0 bytes, received 0 bytes.
Oct  5 12:39:08 localhost pppd[1289]: Connection terminated.
Oct  5 12:39:10 localhost pppd[1289]: Exit.       

ppp commands

pon     Bring link up. Executes pppd (you may specify the ISP name
        on the command line), and will immediately return the
        command prompt while still dialing.

plog    Shows the last lines of the pppd log. Basically, does
        tail ppp.log.

poff    Bring link down. Terminates connection by killing pppd.

Links

Sergio Tanzilli
System designer, webmaster and Acme Systems co-founder

Personal email: tanzilli@acmesystems.it
Webpage: https://www.acmesystems.it
Github repositories: https://github.com/tanzilli and https://github.com/acmesystems
Telegram group dedicated to the Acme Systems boards: https://t.me/acmesystemssrl

Buy