Option Icon 225
The Option Icon 225 is a usb key to connect to internet via a mobile network.
Contents |
[edit] ZeroCD
When you plug in the key, it is recognized as a usb storage key containing drivers for Windows and Mac OS (this functionality is known as ZeroCD). Obviously this is not good, you need to switch the key from the ZeroCD mode to the modem mode. That can be done with a small utility called ozerocdoff.
[edit] Kernel configuration
The driver for the modem is hso, it is included in the kernel since 2.6.27
| Linux Kernel Configuration: hso |
[*] Networking support ---> <*> RF switch subsystem support ---> Device Drivers --->
[*] Network device support --->
USB Network Adapters --->
<*> Option USB High Speed Mobile Devices
|
[edit] Installation
ozerocdoff is not yet in portage, but there is bug 253869 in bugzilla with ebuild. You cound place it to your local overlay.
Alternativly, you cound install it manually.
[edit] Manual install
Get the latest version from pharscape.org
cd udev
make
Using this command everytime you plug-in the key would be quite tiresome, so you can had a udev rule to do it for you.
ACTION!="add", GOTO="hso_end"
# enable Selective suspend in USB core system by a helper script
### SUBSYSTEM=="usb", ATTR{idVendor}=="0af0", ATTR{bDeviceClass}=="ff", RUN+="osetsuspend udev %k"
# usb_device switch need for kernel 2.6.24 and newer, which does no longer support usb_device directly
# send rezero command via ozerocdoff, which uses usblib for all known ZCOPTION devices, supported by bundled driver
SUBSYSTEM=="usb_device", ATTR{bDeviceClass}!="ff", GOTO="hso_zerocd_disabler"
SUBSYSTEM=="usb", ATTR{bDeviceClass}!="ff" ,ENV{DEVTYPE}=="usb_device", GOTO="hso_zerocd_disabler"
SUBSYSTEM=="scsi", ENV{DEVTYPE}=="scsi_device", GOTO="hso_zerocd_disabler"
GOTO="hso_device_links"
LABEL="hso_zerocd_disabler"
ATTRS{idVendor}=="0af0", ATTRS{idProduct}=="6971", RUN+="ozerocdoff -wi 0x%s{idProduct}"
GOTO="hso_end"
LABEL="hso_device_links"
# add device node links to all possible device
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTR{hsotype}=="Control", SYMLINK+="wctrl0"
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTR{hsotype}=="Application", SYMLINK+="wapp0"
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTR{hsotype}=="Application", SYMLINK+="wappa0"
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTR{hsotype}=="Application2",SYMLINK+="wappb0"
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTR{hsotype}=="Diagnostic", SYMLINK+="wdiag0"
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTR{hsotype}=="Diagnostic", SYMLINK+="wdiaga0"
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTR{hsotype}=="Diagnostic2", SYMLINK+="wdiagb0"
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTR{hsotype}=="Modem", SYMLINK+="wmodem0"
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTR{hsotype}=="GPS", SYMLINK+="wgps0"
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTR{hsotype}=="GPS_Control", SYMLINK+="wgpsc0"
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTR{hsotype}=="PCSC", SYMLINK+="wpcsc0"
# setup group proper group rights
KERNEL=="ttyHS[0-9]*", NAME="%k", GROUP="plugdev", MODE="0660"
LABEL="hso_end"
[edit] Configuration
The last thing needed is a connection script.
#!/bin/sh
# checking for root
USERID=`id -u`
if [ "$USERID" != "0" ]
then
echo "Need root permissions to run this script"
exit
fi
APN=orange.ie
#USER=
#PASS=
#PIN=
DEVICE=/dev/ttyHS0
NETDEV=hso0
TMPFIL=/tmp/connect.$$
OUTPUTFILE=/tmp/output.$$
SCRIPTFILE=/tmp/scriptfile.$$
#################################################################################################
# METHOD: Connect
# PURPOSE:Connect to the specified APN with the specified user and pass and get the ip
# set the IP to the interface
#################################################################################################
Connect()
{
echo "Initializing..."
#============================================================
# send the PIN, APN, USER and PASS
#============================================================
rm -f $SCRIPTFILE
echo "ABORT ERROR" > $SCRIPTFILE
echo "TIMEOUT 10" >> $SCRIPTFILE
echo "\"\" ATZ" >> $SCRIPTFILE
if [ -n "$PIN" ]
then
echo "OK \"AT+CPIN=\\\"$PIN\\\"^m\"" >> $SCRIPTFILE
fi
echo "OK \"AT+COPS=0^m\"" >> $SCRIPTFILE
echo "OK \"\d\d\d\d\d\d\dAT+COPS=?^m\"" >> $SCRIPTFILE
echo "OK \"AT+CGDCONT=1,,\\\"$APN\\\"^m\"" >> $SCRIPTFILE
if [ -n "$USER" -a -n "$PASS" ]
then
echo "OK \"AT\\\$QCPDPP=1,1,\\\"$PASS\\\",\\\"$USER\\\"^m\"" >> $SCRIPTFILE
fi
echo "OK \"\"" >> $SCRIPTFILE
#============================================================
# run the script
#============================================================
echo "Trying $APN ..."
rm -f $OUTPUTFILE
( /usr/sbin/chat -E -s -V -f $SCRIPTFILE <$DEVICE >$DEVICE ) 2> $OUTPUTFILE
ISERROR="`grep '^ERROR' $OUTPUTFILE`"
if [ -n "$ISERROR" ]
then
echo "Failed to initialize connection"
cat $OUTPUTFILE
echo " "
rm -f $OUTPUTFILE
exit
fi
ISERROR="`grep '^+CME' $OUTPUTFILE`"
if [ -n "$ISERROR" ]
then
echo "Failed to initialize connection"
cat $OUTPUTFILE
echo " "
rm -f $OUTPUTFILE
exit
fi
rm -f $SCRIPTFILE
sleep 2
#============================================================
# now actually connect
#============================================================
echo "Connecting..."
stty 19200 -tostop
# make the call script
echo "ABORT ERROR" > $SCRIPTFILE
echo "TIMEOUT 10" >> $SCRIPTFILE
echo "\"\" ATZ" >> $SCRIPTFILE
echo "OK \"AT_OWANCALL=1,1,0^m\"" >> $SCRIPTFILE
echo "OK \"\d\d\d\d\dAT_OWANDATA=1^m\"" >> $SCRIPTFILE
echo "OK \"\"" >> $SCRIPTFILE
PIP=""
COUNTER=""
while [ -z "$PIP" -a "$COUNTER" != "-----" ]
do
echo "trying$COUNTER"
sleep 2
rm -f $OUTPUTFILE
( /usr/sbin/chat -E -s -V -f $SCRIPTFILE <$DEVICE > $DEVICE ) 2> $OUTPUTFILE
ISERROR=`grep '^ERROR' $OUTPUTFILE`
if [ -z "$ISERROR" ]
then
PIP="`grep '^_OWANDATA' $OUTPUTFILE | cut -d, -f2`"
NS1="`grep '^_OWANDATA' $OUTPUTFILE | cut -d, -f4`"
NS2="`grep '^_OWANDATA' $OUTPUTFILE | cut -d, -f5`"
fi
COUNTER="${COUNTER}-"
done
echo Connected
#============================================================
# always check the IP address
#============================================================
if [ -z "$PIP" ]
then
echo "We did not get an IP address from the provider, bailing ..."
cat $OUTPUTFILE
rm -f $OUTPUTFILE
exit
fi
rm -f $OUTPUTFILE
#============================================================
# setting network settings
#============================================================
echo "Setting IP address to $PIP"
ifconfig $NETDEV $PIP netmask 255.255.255.255 up
echo "Adding route"
route add default dev $NETDEV
mv -f /etc/resolv.conf /tmp/resolv.conf.hso
echo "Setting nameserver"
echo "nameserver $NS1" > $OUTPUTFILE
echo "nameserver $NS2" >> $OUTPUTFILE
mv $OUTPUTFILE /etc/resolv.conf
echo "Done."
}
#################################################################################################
# METHOD: Disconnect
# PURPOSE:disconnect from the providers network
#################################################################################################
Disconnect()
{
echo "Bringing interface down..."
ifconfig $NETDEV down
echo "Disconnecting..."
# make the disconnect script
rm -f $SCRIPTFILE
echo "TIMEOUT 10" >> $SCRIPTFILE
echo "ABORT ERROR" >> $SCRIPTFILE
echo "\"\" ATZ" >> $SCRIPTFILE
echo "OK \"AT_OWANCALL=1,0,0^m\"" >> $SCRIPTFILE
echo "OK \"\"" >> $SCRIPTFILE
#============================================================
# run the script
#============================================================
/usr/sbin/chat -V -f $SCRIPTFILE <$DEVICE >$DEVICE 2> /dev/null
if [ -f /tmp/resolv.conf.hso ]
then
echo "Reset nameserver..."
mv -f /tmp/resolv.conf.hso /etc/resolv.conf
fi
echo "Done."
}
#################################################################################################
# METHOD: usage
# PURPOSE:
#################################################################################################
usage()
{
echo Usage: $0 \(up\|down\|restart\)
}
#################################################################################################
# Choose your action
#################################################################################################
case "$1" in
up)
Connect
;;
down)
Disconnect
;;
restart)
Disconnect
Connect
;;
*)
usage
;;
esac
Modify the variables APN/USER/PASS/PIN to fit your configuration and run the script
[edit] NetworkManager
The device works with a very recent version of Networkmanager from the rbu overlay (http://overlays.gentoo.org/dev/rbu/browser/overlay/net-misc). The bug concerning this is here (http://bugs.gentoo.org/show_bug.cgi?id=257661).
The Networkmanager version from the overlay has to be compiled with the "modemmanager" USE flag enabled. After that any Networkmanager frontend can be used to configure the connection.
[edit] External links
Last versions of pretty much everything : http://www.pharscape.org/