Debugging Android app wirelessly (over wifi).

While working on USB-OTG code for interfacing microcontroller with android phones, I faced a problem that your USB client interface of the phone is reserved with MCU powering and communication via OTG.
So, I came across this solution after surfing the web, for debugging while developing with MCU.

Note add adb to path :-

export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
view raw wifi_adb.sh hosted with ❤ by GitHub

-NO ROOT is required for this process.
While connected Android device on PC, use this command.

#On the HOST side ie. your PC
#Initiate the connection on port 5555
adb tcpip 5555
view raw wifi_adb.sh hosted with ❤ by GitHub

After that de-attaching the USB connection from PC use these command to connect to android wirelessly

#Replace <DEVICE_IP_ADDRESS> with IP of mobile
adb connect <DEVICE_IP_ADDRESS>:5555
view raw wifi_adb.sh hosted with ❤ by GitHub

You can find the android device IP address from Setting>About Phone>Status> IP address
Also, you can use following commands before line 5 command was intiated to know the IP.

#To check the android device's IP from Host PC
adb shell netcfg
view raw wifi_adb.sh hosted with ❤ by GitHub

In case, you want to revert back to USB debugging, you can use following commands

#To revert back the debugging via USB use
adb -s <DEVICE_IP_ADDRESS>:5555 usb
view raw wifi_adb.sh hosted with ❤ by GitHub