[
Update: For people who reached here to get airdroid working, there is an easier way! Scroll down all the way to the
updated section to read that]
Android phones cannot find ubuntu's hotspot or wireless connection
(At least my HTC explorer with android 2.3.5 with my Ubuntu 11.10 and ath9k AR9285 wireless adaptor)
But as you know, I got it working (after a veryyyyyyyyyyyyyyyy long google research with no time to do it, actually)
I had to do this for setting up airdroid on my ubuntu. airdroid is an awesome application to manage android phones from ubuntu linux, by the way.
And configuring airdroid means that you've got a pain in the ass because, airdroid needs that the laptop and the phone be connected to the same wifi network, and when I create a wifi hotspot from ubuntu, using the default options, android doesn't detect it because it's ad-hoc and when i change it to infrastructure, android still doesn't detect it.
All the story aside, let's get into the code.
sudo apt-get install hostapd
#this is the killer!
hostapd is designed for this job alone
sudo apt-get install dhcp3-server
#I'm not sure whether this is required, but I installed it reading some guide. Try skipping this step and let me know if it's redundant
(A small digression,
I had tried
sudo iwconfig wlan0 mode master
and got
Error for wireless request "Set Mode" (8B06) :
SET failed on device wlan0 ; Invalid argument.
But, as you guessed, persistence wins!)
That's when I headed to the hostapd documentation I linked to already, and found the simple configuration instructions.
Create a configuration file hostapd.conf anywhere
sudo gedit hostapd.conf
Fill it with the following
interface=wlan0
driver=nl80211
ssid=Any_SSID_name
hw_mode=g
channel=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=Any_password
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
The driver, if you noticed, is not athk9, though that's the driver for my wireless adapter. This is just a reference for hostapd to know which mode to use.
Then, run
hostapd with that
configuration file.
sudo hostapd ./hostapd.conf
That's it! Go to your wifi settings in your android phone, and you'll instantly see the ssid coming up!
Updated Section
I know this is stupid, but, for airdroid users, all this hassle is not required. You can just do the reverse - make your android phone the hotspot and let the ubuntu system connect to the phone. ONLY that you should be lucky enough to remember to press the menu button on the airdroid home screen from the android app. And you see the tethering and hotspot option, you press that button and lo! You get the url to visit, instantly!!!