Monday, January 14, 2008

Reliance MG880 Modem Script

About two weeks ago, I bought a Reliance Netconnect connection and chose a ZTE MG 880 CDMA adapter. The device is a svelte little thing only slightly larger than a thumb drive that has a fold-out antenna. Unfortunately, unlike the Huawei PC Cards and USB adapters that are supported by OS X, this one only apparently supported Windows. There's also no information on the Internet about Mac drivers for this device, and the ZTE site is primarily in Chinese and doesn't say anything I could understand.

After a week-long nightmare while I waited for Reliance to activate the connection (supposedly, activating a NetConnect card should only take 24 hours), I called a contact at Reliance Infocomm in Coimbatore to complain and made a passing mention of reconsidering a 2MB leased line contract that we'd recently negotiated. The connection was activated in an hour and I was up and running, but only in Windows on VMWare.

I set up Internet Connection Sharing for the NetConnect interface in Windows, set the default route on Leopard to point to the vmnet interface connecting to the host-only network that I had with the guest, and fired up a browser window in Leopard. This was when I realized that Mac OS treats resolv.conf strangely - /etc/resolv.conf is a symlink to /var/run/resolv.conf, which in turn is created by pppd and other magical elves that set up the Mac's DNS. And, perhaps because the vmware interfaces aren't *really* interfaces that can be managed through System Preferences, creating /var/run/resolv.conf and pointing it to Reliance's name servers didn't have any effect. nslookup, which apparently honors resolv.conf, worked, but any other application that used OS X's lookup mechanism didn't have any effect.

For a day or two, I managed with an entry in /etc/hosts so I could fetch my work email, but it got tiring to fire up Windows every time I wanted to connect to the Internet. Besides, because the device wasn't being managed by Leopard, the MacBook would freeze every time I put it to sleep, with an error from the USB drivers. Every time I shut the lid I'd first have to shut down Windows and pull out the CDMA adapter.

Googling a little, I realized then that the Linux usbserial module worked with the MG880, when it was passed the vendor and product IDs. I tried this with Damn Small Linux running in VMWare, and it worked fine. So I started looking for a similar, generic USB-serial kext for Mac OS X.

It appears that the most common USB-serial chipset - used in the USB cables for most phones - is the Prolific Technology PL2303. I wondered if the MG880 also used the same chipset, and got lucky - yes, it did!

There is an open-source Mac OS driver for this chipset here:

http://osx-pl2303.sourceforge.net/

Download the zip archive and install. You'll be asked to restart; do so.

Open the file /System/Library/Extensions/osx-pl2303.kext/Contents/Info.plist in a text editor.

Beneath the lines:

<key>IOKitPersonalities</key>
        <dict>

Add the following entry:

                <key>19d2_fffd</key>
                <dict>
                        <key>CFBundleIdentifier</key>
                        <string>nl.bjaelectronics.driver.PL2303</string>
                        <key>IOClass</key>
                        <string>nl_bjaelectronics_driver_PL2303</string>
                        <key>IOKitDebug</key>
                        <integer>0</integer>
                        <key>IOMatchCategory</key>
                        <string>ProfilicSerialUSB</string>
                        <key>IOProviderClass</key>
                        <string>IOUSBDevice</string>
                        <key>IOResourceMatch</key>
                        <string>IOKit</string>
                        <key>bConfigurationValue</key>
                        <integer>1</integer>
                        <key>bInterfaceNumber</key>
                        <integer>0</integer>
                        <key>idProduct</key>
                        <integer>65533</integer>
                        <key>idVendor</key>
                        <integer>6610</integer>
                </dict>

This tells the PL2303 driver to watch for USB devices with the Vendor ID 0x19d2 and the Product ID 0xfffd; these are the vendor and product IDs for the MG880.

Now, type the following command into a terminal window:

sudo kextload -v /System/Library/Extensions/osx-pl2303.kext

You should see a bunch of messages, like this:

bash-3.2# sudo kextload -v /System/Library/Extensions/osx-pl2303.kext
kextload: extension /System/Library/Extensions/osx-pl2303.kext appears to be loadable
kextload: loading extension /System/Library/Extensions/osx-pl2303.kext
kextload: /System/Library/Extensions/osx-pl2303.kext loaded successfully
kextload: sending personalities to kernel:
kextload:     from extension /System/Library/Extensions/IOSerialFamily.kext:
kextload:         IOSerialBSDClientSync
kextload:         IOSerialBSDClient
kextload:     from extension /System/Library/Extensions/osx-pl2303.kext:
kextload:         0745_0001
kextload:         056e_5003
kextload:         056e_5004
kextload:         2303_1659
kextload:         0731_0528
kextload:         04e8_8001
kextload:         2478_2008
kextload:         067b_aaa2
kextload:         0547_2008
kextload:         19d2_fffd
kextload:         04bb_0a03
kextload:         0df7_0620
kextload:         067b_04bb
kextload:         0584_b000
kextload:         067b_aaa0
kextload:         6189_2068
kextload:         11f5_0003
kextload:         078b_1234
kextload:         0557_2008
kextload:         067b_2303
kextload:         1453_4026
kextload:         11f7_02df
kextload:         0eba_1080
kextload: sending 25 personalities to the kernel
kextload: matching started for /System/Library/Extensions/osx-pl2303.kext

At this point, you should unplug the MG 880 if already plugged in, and plug it back in. Mac OS will now recognize the vendor and product IDs of the device and map it to the PL2303 driver.

Go to System Preferences and select Network. Click on the + sign beneath the list of interfaces (Bluetooth, Ethernet, Firewire, etc.) to create a new connection. A dialog will pop up asking for the interface to use for the connection, and the service name. In the list of interfaces, you should see "ZTE CDMA Tech". Choose that as the interface to use, and call the service "Reliance" - you can call it whatever you like; I chose Reliance. Click the "Create" button in the dialog. The "Reliance" connection will now be added to the list of interfaces in the left pane.

In the text field for Telephone Number, type #777. Type your phone number into the "Account Name" and "Password" text fields. Now, click the "Advanced..." button.

In the pane that displays, select "Generic" from the Vendor list box and "Dialup Device" from the "Model" list box. Make sure that the "Enable error correction and compression in modem" check box is checked. Hit Ok, and hit Apply when you are returned to the Connection Settings pane. You should now be able to hit Connect and connect to the Internet!

I hope this helps people who have the MG880 but can't use it on OS X. Many thanks to the people who created the PL2303 driver and open-sourced it, without which this wouldn't be possible.

Got details from : http://hari.selvarajan.googlepages.com/gettingaztemg880toworkwithleopard2

7 comments:

southpawpisces said...

firstly, thanks a million for being the first ray of hope in 3-4 months that i have been looking for help on this subject.

i'm not all too comfortable tinkering in the plumbing and typing into terminal windows.. still, i did get halfway through your lucid directions. 'cept i've left the useless modem at home, and i'll only get to try that part out in the evening. so what i wanted to know was.. (1)how come there's no + sign below the list of connections on my machine. (2)do i need to have leopard install on my mac?

lemme know. thank again.

southpawpisces said...

epilogue: went home and tried it out. it worked without any hiccups. downloaded a ton of stuff, and it worked well enough.

but this morning, it refuses to recognise the device. says it does not exist. then after repeating the entire procedure, it disconnects just after it says 'establishing connection'. any ideas?

Sandya Rodrigues said...

Rahul I tried this out and it worked well. But the next day when I tried again it refuses to recognize the device. Can you help out

When i edit the the infoplist with texteditor it does not allow me to save it.

Kindly help... appreciate your helo

Sandya

Advaitavedanti said...

I hope you're getting good speeds with ZTE. Funnily enough, after umpteen calls to Reliance, my ZTE USB modem connected but only at 28.8kbps speed! Its quite a shame that they claim 144kbps. Now, this is on Win"doze" Vista. Till I get good speed here, I don't think I wanna try Linux; I won't be able to tolerate Reliance nonsense support for Linux, if they can't give sane speeds for Windoze itself!

Cheers

Anonymous said...

Awesome stuff

Unknown said...

Is there any way to send/receive sms on mac using this device?

Thanks

rags said...

I really needed to use the ZTE modem for the next few days.

Thanks dude, you are a life saver (and hari, but couldnt get the plist from his page)

r