I have two ways to connect to a device over wifi:-
A usb cable is required to create a tcp connection and then the cable can be removed(works for both rooted and unrooted devices).
https://developer.android.com/studio/command-line/adb#wireless
In this case it doesn't require a usb cable but works only for rooted devices.