Cell Network generic: Difference between revisions

From embeddedTS Manuals
(Added -echo to stty options)
(Added information on changing serial data rates)
Line 55: Line 55:


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.
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.
''' 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 you would typically use the setserial command.  When the spd_cust baud rate it set Linux will re-purpose 38400 to use your custom baud rate.
{| class=wikitable
|+ 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:
<source lang=bash>
setserial /dev/ttymultidc spd_cust baud_base 921600 divisor 8
</source>
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. 
<source lang=bash>
picocom -b 38400 /dev/ttymultidc
</source>
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:
<pre>
AT+IPR=921600
</pre>
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:
<source lang=bash>
setserial /dev/ttymultidc spd_cust baud_base 921600 divisor 1
</source>
The only change now needed is in your providers file.  From the example tmobile configuration you would need to 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 '''
''' Troubleshooting '''

Revision as of 10:54, 27 October 2016

You also must install pppd, and load the required modules:

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.


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 you would typically use the setserial command. When the spd_cust baud rate it set Linux will re-purpose 38400 to use your custom baud rate.

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. From the example tmobile configuration you would need to 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.