Tuesday, 3 December 2013

Flat Network 1: USB Internet Dongle

The steps to set up your dongle is explained on the OpenWRT wiki. But I had some problems because of the Specific dongle I was using (The Nokia dongle you get from CellC). So here is how to get it working.

ssh into the router then install packages with the following command:
opkg install comgt usbutils kmod-usb2 kmod-usb-ohci kmod-usb-serial \
kmod-usb-serial-option kmod-usb-acm usb-modeswitch usb-modeswitch-data
optionally also
opkg install luci-proto-3g
for the gui. Run lsusb, plug the dongle into the USB port of the router and run lsusb again. You should see a new device. Take note of the ID. The first part is the Vendor and the second part is the Product ID. Run:
ls /dev/
You will see that no new tty devices appear when you insert the dongle, this is because the dongle is not in the correct mode. This product's mode needs to be changed and it is not known to modeswitch, so it does not know what to do with it. Run:
ls /etc/usb_modeswitch.d
You will see that your ID is not there. But there are other devices from the same vendor (Nokia). A few of these devices run as the same product, so just copy one of these files to a file with your ID as the name and edit the product ID field to match yours.

Remove the dongle and plug it in again and you will see that the ID lsusb gives you is now different and you have two new devices in /dev/, ttyACM0 and ttyACM1. If you run:
gcom -d /dev/ttyACM0
You should see something like:
SIM ready
Waiting for Registration..(120 sec max)
Registered on Home network: "Cell C",2
Signal Quality: 9,0
So you know the device is communicating correctly. Now edit your /etc/config/network file and edit the wan section:
config interface wan
        option ifname  ppp0
        option pincode 1234
        option device  /dev/ttyACM0
        option apn     internet
        option service umts
        option proto   3g
        option pppd_options "noipdefault refuse-chap refuse-mschap \
                refuse-mschap-v2 refuse-eap"

Most websites recommend that you set a pin code for the dongle's SIM if it does not have one already, as some OpenWrt builds do not connect correctly without it. Run:
ifup wan
If it runs successfully it should give the output:
SIM ready
PIN set successfully
You should now have a working internet connection.