ad hoc network in android I have Android 4.2.2, Nexus 4 and I would like to setup an adhoc network. Firstly I rooted the device, secondly I tried to create an adhoc network in Android phone: I create an adhoc network in an Android smartphone like below:

shell@android:/ # ip link set dev wlan0 down
shell@android:/ # iwconfig wlan0 mode ad-hoc
shell@android:/ # iwconfig wlan0 channel 6
shell@android:/ # iwconfig wlan0 essid 'Test1'
shell@android:/ # ip link set dev wlan0 up
shell@android:/ # ifconfig wlan0 192.168.65.129


when I typed iwconfig wlan0: the result is:

Qcom:802.11n ESSID:"Test1"
Mode:Ad-Hoc Frequency:2.437 GHz Cell: 02:82:5F:C1:4B:C1
Bit Rate=0 kb/s Tx-Power=0 dBm    
RTS thr=2347 B Fragment thr=8000 B
Encryption key:off


Secondly, in my laptop, I could see "Test1", so I connected to "Test1" and I configured a static ip address 192.168.65.128. In this case, the smartphone created the ad hoc network and my laptop joined it, then I can ping from my laptop to mobile and vice-versa.

However,in other case when my laptop creates the ad hoc network and later in an Android mobile, I tried to join it :

shell@android:/ # iwconfig wlan0 mode ad-hoc
shell@android:/ # iwconfig wlan0 channel 6
shell@android:/ # iwconfig wlan0 essid 'Test1'


But, when I type iwconfig wlan0, ESSID is still off/any.

Qcom:802.11n ESSID:off/any
Mode:Ad-Hoc Frequency:2.437 GHz Cell: Not-Associated
Bit Rate:0 kb/s Tx-Power=0 dBm
RTS thr=2347 B Fragment thr=8000 B
Encryption key:off


It seems that an Android mobile can create an adhoc network but can not join an existing one. I found the same result when I tried to setup adhoc network between two Android mobiles. Can anybody tell me what is wrong here, and if there is any possible solution, I tried many methods to setup an adhoc network in Android, and only this method seems to work, but there's still something wrong that prevents an Android phone from joining an existing adhoc network.
As far as I understand your question, you have successfully created an adhoc network on your Nexus and your laptop is able to connect.
Now you want to create an adhoc network on your laptop and you want to connect your Nexus to it.
After doing some research, I've found out that Android does not work (well) with adhoc networks.
There are some custom ROMs which have enabled the Ad Hoc function.From what I've been reading, mako bb-8 and AOKP will be able to do Ad Hocs.I think CyanogenMod has also a modified wpa_supplicant to support Ad Hoc networks.
If you don't want to flash a custom ROM, you could try to rip the wpa_supplicant (from the same Android version you are using) from one of the custom ROMs mentioned before. You could also try to install WiFi Ad Hoc enabler for Android, which might work for you.If that doesn't work, you could try another method, which is harder. Check it out here.

I also found this, I don't think it'll work, but worth mentioning:
http://forum.xda-developers.com/showthread.php?t=1591207