Skip to content

Ethernet to 3G wireless

January 5, 2012

I wanted to connect a wireless router with a 3G modem to have an Ethernet–>3G adapter, letting me plug a normal network cable into a router that automatically connected to mobile internet. OpenWRT is a nice embedded OS I could customize for the Asus wl-500g router, and I could link a Huawei E1552 wireless 3G modem with it. This is a reliable hardware combination for both relatively small size and good performance in a noisy wireless environment.

There’s a great tutorial on setting up a similar modem by Josefsson, although this particular hardware configuration has its differences. I started by following the tutorial, and used the the unique manufacture and device codes from here. The E1552 can be identified as either a storage device, or a wireless modem, and it needs to be switched consistently to that of a modem on every startup. While huaweiAktBbo is a tool for many Huawei modems, it doesn’t work on E1552 and instead I found usb_modeswitch to be useful. More instructions on it are here.

Here is my init script that automatically run on startup to switch the 3G modem into Wireless setting. It has a workaround to switch the device mode twice, run lsusb, and finally bring up the wireless interface. Make this script executable (chmod +x /etc/init.d/usb_modeswitch) and enable it in the startup sequence (/etc/init.d/usb_modeswitch enable).

root@OpenWrt:~# vi /etc/init.d/usb_modeswitch

#!/bin/sh /etc/rc.common
# balaganov.wordpress.com 2012

START=70
     start() {
          rm /etc/usb-modeswitch.conf
          cp /etc/usb-modeswitch.conf.1 /etc/usb-modeswitch.conf
          usb_modeswitch -W
          rm /etc/usb-modeswitch.conf
          cp /etc/usb-modeswitch.conf.2 /etc/usb-modeswitch.conf
          usb_modeswitch -W
          lsusb
          ifup wan
}
Here is the first configuration file, for the device identified as 0x1446
root@OpenWrt:~# vi /etc/usb-modeswitch.conf.1

################################################## ######
# Huawei e1552
# File 1 of 2
#
# balaganov.wordpress.com 2012

# ########
# For some reason the device shows up first as 0x1446,
# then usb_modeswitch does something and it switches to 0x140c,
# and usb_modeswitch needs to run again to switch the device
# from USB drive to Wireless mode. A workaround is to create
# two separate conf files with both settings.
# ########
DefaultVendor = 0x12d1
DefaultProduct=0x1446
; DefaultProduct = 0x140c
TargetVendor = 0x12d1
TargetProduct = 0x1001

# Only for reference and 0.x versions
MessageEndpoint = 0x01

MessageContent = "55534243123456780000000000000011060000000000000000000000000000"

And here is the second, when the E1552 comes up as 0x140c

root@OpenWrt:~# vi /etc/usb-modeswitch.conf.2

# File 2 of 2
#
# balaganov.wordpress.com 2012

DefaultVendor = 0x12d1

# Yeah so this is the other setting
DefaultProduct = 0x140c
; DefaultProduct=0x1446
TargetVendor = 0x12d1
TargetProduct = 0x1001

# Only for reference and 0.x versions
MessageEndpoint = 0x01

MessageContent = "55534243123456780000000000000011060000000000000000000000000000"

This should bring up the wireless interface and make it available for OpenWRT to link with the wireless access point. Finally, to optimize the router for faster startup time, I removed unnecessary services. It now takes 110 seconds to bring up both the wifi and the 3G interface ready in usable states.


root@OpenWrt:~# /etc/init.d/uhttpd disable
root@OpenWrt:~# /etc/init.d/watchdog disable
root@OpenWrt:~# /etc/init.d/telnet disable

That’s it, this is a simple way to have an adapter to convert wired ethernet to wireless 3G.

Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: