WIFI does not work when connected to power supply

Hi guys,
I have a dlink dwa 123 wirless adapter. I have edited the /etc/network/ interfaces and rc.local to get the wlan0 interface up at bootime-(nohup sh -c “ifdown wlan0 && ifup wlan0”)
My dhcp asigns an ip address to it and all goes fine. Now if I remove the usb and directly connect the mains power supply to the beagle bone using the adpater the wifi does not seem to work. The light glow on the stick showing that it has been recognized. But an ip address is not being issued to it. Does anyone have any ideas why this is happening?

Okay. I realized that beacause the Wifi signal was weak it was unable to connect to it. (The place where I connected to the usb and wifif were different). It seems to work now!