My goal is to automatically recognize and connect a USB 3G key (Onda TM201 or Huawei E173). This example is related to the following environment:
- CentOS 6.3
- Onda TM201 14.4 (TIM – Telecom Italia Mobile operator)
- Huawei E173 (TRE – H3G operator)
#uname -a Linux localhost.localdomain 2.6.32-279.el6.i686 #1 SMP Fri Jun 22 10:59:55 UTC 2012 i686 i686 i386 GNU/Linux
# cat /etc/redhat-release CentOS release 6.3 (Final)
The proposed solution is based on udev, usb_modeswitch and a service able to monitor the connection.
Once the USB 3G key is inserted int the USB port, the udev detects and the key (see /etc/udev/rules.d/10-wlan-3g.rules) and call the script /usr/sbin/3g_switch. The script 3g_switch use usb_modeswitch to switch the USB key in 3G modem mode. The service /etc/init.d/3gservice monitors the USB 3G key state and connect the line when the key is ready or clean everything if the key is removed.