Cell Network generic

From embeddedTS Manuals

The pppd application must be installed and any required modules loaded:

apt-get update && apt-get install -y ppp

This example is configured for T-Mobile in the US:

/etc/ppp/peers/tmobile


/dev/ttymultidc
noauth
115200
debug
usepeerdns
persist
defaultroute

connect "/usr/sbin/chat -v -f /etc/ppp/chatscripts/tmobile"
disconnect "/usr/sbin/chat -v -f /etc/ppp/chatscripts/tmobile-disconnect"

/etc/ppp/chatscripts/tmobile

TIMEOUT 10
ABORT 'BUSY'
ABORT 'NO ANSWER'
ABORT 'ERROR'

"" "\p\p\p\p\p\p\p\p\p\p\p\p+++\p\p\p\p\p\p\p\p\p\p\p\p"
"" "ATH0"

"OK" 'AT+CGDCONT=1,"IP","wap.voicestream.com"'

ABORT 'NO CARRIER'
OK 'ATD*99***1#'
CONNECT

/etc/ppp/chatscripts/tmobile-disconnect

"" "\K"
"" "+++ATH0"

Using a different carrier you will likely only need to replace wap.voicestream.com with the access point for your carrier.

To start pppd:

pppd call tmobile

# Or for more logging information:
# pppd nodetach call tmobile

This will create a ppp0 interface that can now be used as a standard network interface, and should set up a default route to the internet. For other carriers, typically you will only need a different access point listed in the AT+CGDCONT call, but further adjustments may be necessary.


Note: We have observed that the MTSMC-H5 connected to some networks has issues at or below 115200 baud. The issues observed are connection timeouts with the network itself. The connection between the modem and host device remain rock solid. While many applications are tolerant to the connection being reset, we have found some network downloads will abort without being able to recover. Running the unit at a faster baud rate, 230400 or higher, has been observed to eliminate this issue entirely. This does mean, however, that every time the device is started up, the modem must be issued an AT+IPR command (as noted below) at 115200 baud, then pppd started with the matched and higher baud rate in the peer script as shown above.


Faster Data Rates

While the MTSMC-G2 (GPRS) is limited to 115200 baud, the MTSMC-H5 (HDSPA) can communicate over serial up to 921600 allowing actual transfer rates around 80-90KB/s.

To set a custom baudrate in Linux, the method depends on the CPU and kernel support. More recent UART peripherals have a higher clock and a smarter driver, and can therefore use custom baud rates inherently. However, some systems require the use of 'setserial' using the spd_cust flag and some manual settings. When the spd_cust baud rate is set, Linux will re-purpose 38400 baud to use the set custom baud rate.


First, test the unit to see if it is possible to open up the UART with a higher baud rate:

picocom -b 921600 /dev/ttymultidc

If the higher baud is unsupported, picocom will return a failure similar to the following:

FATAL: failed to add device /dev/ttymultidc: Invalid baud rate

If the above error is received, then the method below using setserial must be used.

Otherwise, the port can be closed, re-opened at 115200 baud to communicate with the modem, and then the following command can be used to tell the cell modem to enter a higher baud rate:

AT+IPR=921600

Now the port can be closed everything will function at the higher baud rate. Be sure to update the providers file. Using the example T-Mobile configuration, edit /etc/ppp/peers/tmobile and change 115200 to 38400. Starting pppd will now allow communication around 80-90KB/s (depending on your local cell tower's availability).


Common Baud Rates
Divisor Rate
1 921600
2 460800
3 307200
4 230400
5 184320
6 153600
7 131657
8 115200

Larger divisors will also work, but this should cover the common range. Using the setserial command you can specify the divisor. For example, to reach 115200 with the alternative baud base:

setserial /dev/ttymultidc spd_cust baud_base 921600 divisor 8

Next you will need to tell the modem to communicate at the faster baud rates. You can use a client like picocom or minicom to connect directly to the modem to send it commands.

picocom -b 38400 /dev/ttymultidc

Even though we are talking at 115200, 38400 must be specified since we are using a custom baud_base. You can test communication with the modem again by typing "AT", pressing enter, and receiving "OK". To reconfigure the modem to the faster 921600 baud rate you can send it this command:

AT+IPR=921600

This will respond with OK, but now you will need to quit out of picocom (ctrl a,x) and reconfigure the baud base to use divisor 1:

setserial /dev/ttymultidc spd_cust baud_base 921600 divisor 1

The only change now needed is in your providers file. Using the example T-Mobile configuration , edit /etc/ppp/peers/tmobile and change 115200 to 38400. Starting pppd will now allow communication around 80-90KB/s (depending on your local cell tower's availability).


Troubleshooting

If you are not able to obtain a ppp connection there are a few values you can check:

Troubleshooting: Cell Signal

Make sure ppp is not running, and execute these commands to check the signal strength.

stty raw -echo speed 115200 -F /dev/ttymultidc 
cat /dev/ttymultidc &
echo -e "AT+CSQ\r\n" > /dev/ttymultidc 
killall cat

The return value should be something like "+CSQ: 9,2", or with no connection, +CSQ: 99,99. The second argument is the signal strengh which follows this table:

RSSI return values
0 -113 dBm or less
1 -111 dBm
2 to 30 -109 to -53dBm
31 -51dBm or greater
99 not known or detectable

If you return 99, make sure the antenna is connected and that you are in an area with good signal from your provider. Even without a valid SIM card you can have a good connection. If you are in another country, you may need to adjust the band for those supported by your carrier. The default value is appropriate for most US based carriers. Refer to the +WMBS command in your AT command guide for more options.


Troubleshooting: SIM card

If you have a good signal strength but are not obtaining a connection you can verify that the modem is able to read the subscriber number. This proves your SIM card is valid.

stty raw -echo speed 115200 -F /dev/ttymultidc 
cat /dev/ttymultidc &
echo -e "AT+CNUM\r\n" > /dev/ttymultidc 
killall cat

With a valid SIM this will return something like:

+CNUM: "","12345678901",129

If the SIM not detected you will only read ERROR. Make sure in this case that the card is inserted in the right direction so the pads on the card line up with the socket.

Troubleshooting: Other Options

If neither of the above steps get you connected you may want to contact your service provider for more information about where your connection attempts are failing.