Monday, 21 October 2013

3G Dongle, the Pi and Staying Alive

Task 3: Establish a 3G Connection on Boot and Stay Connected

Setting up a 3G connection and keeping it live hasn't been an easy task and remains largely unsolved. The principle hurdles are listed below. I've drawn quite a bit of inspiration from forums and blogs, one particularly good source is the Big Cow Pi.

Ensure you have a command line text editor installed before you go any further. I can't remeber if its installed as default in Wheezy, but I use nano:

sudo apt-get install nano

You can read most text files usign the following commands (sudo used only to access files requiring root user priviledges, i.e. most system files.

sudo nano path/of/file 
  • Ensuring the dongle is compatible with the Pi (website here: )
The Huawei 353 seems fine, but there may be a number of issues with other dongles. Rule of thumb should be to keep to  tried and tested list. I picked a used 353 up from ebay for £20, unlocked. This dongle has a connection for an external aerial, hence my choice. You can unlock yourself it you want to save a few quid but the cost difference between used and locked vs used and unlocked was not worth the risk.
  • Power 
The power draw from a 3G dongle can't be sustained, reliably atleast, from the Pi itself. Once more I want to add one or more Wifi dongles. So I bought a 2.1mA 5.5v adaptor with two USB power outlets, allowing a powered USB hub and  Pi to be connected to a single plug, neater. If  your having problems getting the dongle to register as a device at all than this may be your problem.

  • Ensuring the device is recognised and operates as modem rather than a usb storage device
Most dongles, including the 353 have a port for a mini SD card. Mine didn't have a card in it from the seler but the first time I plugged it in it was recognised as a storage device. You can tell what mode its currently in by looking at the output from:

lsusb

Example output:

Bus 001 Device 007: ID 12d1:1506 Huawei Technologies Co., Ltd. E398 LTE/UMTS/GSM Modem/Networkcard

There is a program specifcally designed to manage this situation called 'usb-modeswitch'. Some say its already included in Wheezy but didn't seem to be in my case. There is quite alot information out there on configuring usb-modeswitch but it seemed, on face value atleast, to work out of the box for me. I may however need to revisit it later as I understand more of how it works as there are some niggling issues I haven't resolved yet. To install and setup with minimal configuration here's what you do:

sudo apt-get install usb-modeswitch

Once installed the device and vendor codes as well as the description of the device should be roughly correct. If not you need to find the correct profile for your device and edit the /etc/usb-modeswitch.config file, pasting in an entry such as this:

sudo nano /etc/usb-modeswitch.config

DefaultVendor= 0x12d1
DefaultProduct=0x1f01
TargetVendor= 0x12d1
TargetProduct= 0x14db
CheckSuccess=20
MessageContent="55534243123456780000000000000a11062000000000000100000000000000"


(profile for the Huawei 353 from the usb-modeswitch forum)
  • Establishing a connection from the command line

There are various means of doing this. Some work better than others, but the software of choice for alot of people appears to be 'sakis3G'.  Unfortunately the website is currently down and from what I can gather has been for sometime. I downloaded it from alterative link and setup for the giffgaff network as follows.

In order to keep the connection live you also need to use utmskeeper. This is essentially a script that keeps (I think) checking and refreshing the connection. 

There are a few prerequisites packages you also need to install. All commands assuming your in the pi home directory (/home/pi):
  
sudo apt-get install ppp wget 

sudo mkdir /usr/local/lib/3GSoftware/

cd /usr/local/lib/3GSoftware/

sudo wget "http://downloads.sourceforge.net/project/vim-n4n0/sakis3g.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fvim-n4n0%2Ffiles%2F&ts=1363537696&use_mirror=tene~t" -O sakis3g.tar.gz

sudo tar -zxvf sakis36.tar.gz

sudo chmod +x sakis3g

sudo ./sakis3g --interactive --no-probe

sudo wget "http://zool33.uni-graz.at/petz/umtskeeper/src/umtskeeper.tar.gz"

sudo tar -zxvf umtskeeper.tar.gz

sudo chmod +x utmskeeper

sudo ./umtskeeper --sakisoperators "USBINTERFACE='0' OTHER='CUSTOM_TTY' CUSTOM_TTY='ttyUSB3' APN='CUSTOM_APN' CUSTOM_APN='giffgaff.com' APN_USER='giffgaff' APN_PASS='password'" --sakisswitches "--sudo --console" --devicename 'Huawei' --log --silent --monthstart 8 --nat 'no'

 


No comments:

Post a Comment