Friday, December 2, 2011

Exploring ways to connect Droid and PC



The curious cat inside me told that it wanted to download and play with some funny talking-cat app. (I ain't kidding. Curious cats love to play with Android apps ;) )  Damn, that app was so heavy (nearly 35MB) which I couldn't afford to download from 3G. Now I'm trying to investigate about sharing the DSL connection of my PC with my Anroid. Sounds interesting, but how? I don't even have a wireless router at home. I can't plug in the phone to the wired connection unless the wire can be plugged in to a Fire-wire port instead of an RJ-45.

Below are some methods I tried but none of them actually worked for my phone. (I hope sharing it may avoid someone else from going up the blind alley. Besides, who knows, it might work in other phones and wireless adapters which are different than mine.)
  1. Connect the phone to the wireless ad-hoc network created in the PC
  2. Install a "virtual router" software in my PC and connect the phone to that access point
  3. Tether phone to PC
Lets go through it one by one.
Note: All the methods below are tested on Samsung Galaxy Mini S5570 with Intel PRO/Wireless 3945 AGB wireless adapter.

1. Creating a wireless ad-hoc network in the PC

Ever tried to connect your smart phone to an ad-hoc network? Don't worry, this is my first time too.
So, what does an ad-hoc network do?
It simply creates a local area network between two devices allowing them to communicate directly. It doesn’t matter whether both the devices are PCs, or one device is a PC and the other is a smart device, or both are smart devices.

Of course you can create a wired LAN between two devices, which I’m gonna discuss under the topic “tethering”, but here I tried a wireless ad-hoc network because it's much more portable.
An ad-hoc network can be used to connect many devices together as shown below.


An ad-hoc network


Note: The diagram is taken from here.


After connecting phone to the PC, I will also be able to use my PCs internet connection and connect to internet as usual. First of all I needed to create a Wi-Fi ad-hoc network in my PC. Here are the steps I followed in doing so. I turned on Wi-Fi in my Android and waited until it detects my PC's ad-hoc network. Wow, my phone actually did NOT detect it. I sometimes wonder why some phones are so dumb!

It's the searching time now. Sneaking a peek through some web sites I was able to find out that Android does not support wireless ad-hoc yet! But still there's some hope left. Underlying hardware can detect Wi-Fi. Only the operating system resting upon the hardware does not allow the hardware to detect the wireless ad-hoc.
Android uses wpa_supplicant file as an interface to connect to Wi-Fi. Thus, we have to edit wpa_supplicant file to poke the Android and say, "hey here's an actual network you can try connecting to".

Okay, to edit wpa-supplicant file (which is a system file) I needed a shell prompt. In order to access Android through a shell prompt, you have to do the following steps in your PC.

  1. Install adb in to your PC. (This comes by default if you've installed Android-SDK)
  2. Connect your phone to PC via USB.
  3. "cd" to the directory where adb.exe is situated
  4. Type "adb devices" and see whether your device is listed.
  5. Type "adb shell". Voila! You just got a command prompt for Android.

When I tried to change directory (cd) to where my wpa_supplicant file is located in, it said that I needed root permission to proceed further. Well, my Galaxy S5570 does not give root access by default (If you already have a rooted phone you will be able to change the wpa_supplicant fiile). I would have to root my phone and grab the root permission for my self. Going through lot of articles I found out that rooting may harm your phone. So I went on searching for a new answer, and would later come back to rooting if it leaves me no choice.

For the folks with rooted phones, you can try downloading a patch for wpa_supplicant file which can be found here. Then you can follow the steps I'm gonna describe now.

  1. In the shell prompt you obtained by typing "adb shell", type "locate wpa_supplicant"
  2. Copy the path (which indicates the directory inside which lies your wpa_supplicant). Usually the path would be /system/bin
  3. Type the following in cmd.
    • "adb push <source file> <destination directory>"
    • Eg: If the wpa_supplicant patch is located in "C:\Users",
      • "adb push C:\Users\wpa_supplicant /system/bin"
Now you can turn on Wi-Fi and check whether your Droid detects the ad-hoc network created by you. If yes, mission accomplished!
Note: I wasn't permitted to do this in my unrooted phone. Hence I cannot guarantee the output of the above method.

Since my phone cannot detect a wireless ad-hoc connection, my second attempt was to make my PC act as a wireless access point (Wi-Fi hospot). That means, I wanted my computer to act as a virtual wireless router. In doing so, you just have to install some software which makes your wireless network adapter a wireless access point.
Diagram above shows how a wireless router act as a wireless access point. Each device connected to the access point becomes a part of one local area network. Virtual router software makes your computer act like the wireless router shown above.
Note: The diagram is taken from here.

Following are some of the software I found out by Googling.

After installing the software I tried to create an access point but the software didn't allow me to create one. So I tried one of their official websites, which included the unsupported wireless cards. Yep, my wireless card, Intel PRO/Wireless 3945 AGB, was one of them. Why me!!!
Check the list here to see whether your wireless adapter is in the victims list.

If it's not included in the list, you can consider your self lucky. You can install virtual router software given above, and create a Wi-Fi access point as illustrated here. Voila, your machine is a Wi-Fi hot spot now. Go ahead, connect your phone to that access point, and ENJOY!

3. Tether Android to the PC

Since none of the wireless methods worked for me I thought of switching in to traditional wired mode. Tethering is another method to bring the phone and computer in to one local area network.
But there's one problem. Computer becomes the client there and my phone becomes the server. It means that my PC will be able to use my phone's network connection, but my phone will not be able to use the PC's internet  connection. Okay, this isn't exactly what I wanted. But lets explore it anyway.

Tethering is super easy. Follow these steps,

  1. Connect your phone to PC via USB.
  2. Make sure your phone is been detected by your PC. If it's not, you have to install the drivers which is normally shipped with the phone. (For Samsung they distribute a software called "Kies".)
  3. Go to Settings --> Wireless and Networks --> Tethering --> Tick "USB Tethering"
And you are done!

Tethering helped me later on, for one of my projects where I wanted to network the phone and PC locally.

Anyway, after all these effort, the next day my router got hit by thunder and I got a brand new wireless router from my ISP. How cool is that? My cat got to know about ways of connecting Droid to PC (my Curious Cat of course), and I was able to download all the apps available in the app store from anywhere inside my house. Yoo hoo :)

1 comment:

  1. really helpful :)
    but still I couldn't get my work done

    ReplyDelete