Configure and use PPP with a Digi XBee 3 Cellular LTE-M/NB-IoT modem

Your XBee 3 Cellular device can communicate directly with the modem and can drop into PPP mode.

Prerequisites

Step 1: Configure the device for PPP

USB direct is used to gain access to the underlying modem, which enables the use of PPP.

  1. Set up USB direct mode.
  2. Issue the WR command to save the settings.

Once USB direct is configured, an additional USB device should be attached to the Linux machine. In order to have a consistent device name on the Linux machine, you should set up a udev rule for the device, as described in the next step.

Step 2: Set up the USB device for use with PPP

A udev rule is needed to give the USB connection a constant name using a symlink.

  1. Make sure that the modem is plugged in.
  2. Place the following ppp-setup.rules file here: /etc/udev/rules.d
    # Sara-R410 rule
    SUBSYSTEM=="tty", ATTRS{bInterfaceNumber}=="02", ENV{ID_VENDOR_ID}=="05c6", ENV{ID_MODEL_ID}=="90b2", SYMLINK+="ppp_direct_usb"
  3. You must run the two commands shown below to restart the udev daemon to apply the new rule.
    sudo udevadm control --reload-rules
    sudo udevadm trigger
  4. Verify that the new device has been created: /dev/ppp_direct_usb. If was not, make sure the modem is plugged in and then repeat this process.

Step 3: Configure PPPD

PPPD by default looks in the /etc/ppp/ directory for an options file and a chat script. The option file configures and specifies the chat script for PPPD. The chat script configures and dials the modem for the PPP connection.

  1. Below is an example of an options file. This file must be in the /etc/ppp/ directory.
    ## Show debug info
    debug
    ## Modem serial port
    /dev/ppp_direct_usb
    ## Baud-rate
    921600
    ## Hardware flow control using rts/cts
    crtscts
    ## For debugging purposes
    nodetach
    ## Bring up the connection if it gets shutdown
    persist
    ## Disable remote authentication
    noauth
    ## Control character map
    asyncmap 0
    ## Setup interface as default route
    defaultroute
    replacedefaultroute
    ## disable getting the local IP address from the host-name
    noipdefault
    ## Accept new IP addresses from IPCP negotiations (default)
    ipcp-accept-local
    ipcp-accept-remote
    ## Lock the serial device
    lock
    ## Let the remote designate the name-servers
    usepeerdns
    ## Enable IPv6 and use provided address
    +ipv6 ipv6cp-use-ipaddr
    ## Connect script (chat script)
    connect "/usr/sbin/chat -V -t 60 -f net-chat"
  2. Place the chat script in the /etc/ppp/ directory. An example is shown below. The net-chat script is an automated script that both configures and dials the modem for the PPP connection. This script turns on hardware flow-control, sets the APN, sets the DSR line to ON, and dials the peer.

    Note In the net-chat script below, you must replace <APN> with the correct APN for your network and SIM.

    ABORT 'ERROR'
    ABORT 'BUSY'
    ABORT 'NO CARRIER'
    '' AT
    OK AT+IFC=2,2
    OK ATE0
    OK AT+CGDCONT=1,"IP","<APN>"
    OK AT&S0
    OK ATD*99***1#
    CONNECT

Step 4: Run PPPD

PPPD is the program that brings up the PPP interface.

  1. You should bring down any other network interfaces that may complicate routing.
  2. Run PPPD to bring up the PPP interface.
    sudo pppd
  3. Various LCP, PAP and IPCP messages should be output. If the interface was brought up correctly ifconfig should list a PPP interface as pppx (where x is a number).

  4. Ping a web server from the PPP interface.
    ping www.digi.com

Step 5: Low power use case

You may want to reduce power consumption by turning off the XBee modem. Follow this process to properly bring down the PPP connection and shut down the modem.

  1. Terminate PPPD by sending a terminate signal: Ctrl+C

  2. Issue the shutdown command to the modem over the USB connection.

    AT+CPWROFF

     

  3. Wait for an OK response.
  4. When received, remove power from the XBee.
  5. Restart the PPP connection.
    1. Power on the XBee.
    2. Issue the ppp command.
      sudo pppd

Note Do not power cycle the modem too often as it can lead to network registration rejection. Cycling should not be performed more than a few times an hour. Check with your network carrier for the exact limits.

Troubleshooting

Error after running sudo pppd

+CME ERRORScript /usr/sbin/chat -V -t 60 -f net-chat finished (pid 5523), status = 0x4
Connect script failed

This indicates that the <APN> field was most likely not set correctly in the net-chat script.

Error after running sudo pppd

pppd: In file /etc/ppp/options: unrecognized option '/dev/ppp_direct_usb'

This indicates pppd could not open up the USB port to the modem. Make sure that the modem is plugged in and shows up under the /dev/ directory as ppp_direct_usb.

Error after running "ping www.digi.com"

ping: unknown host www.digi.com

The name server was not setup correctly for the PPP interface. Make sure there is a valid name server in /etc/resolv.conf.