Yesterday I wrote a command line tool in C + +, I compiled it with g++ under Linux. Enables wireless ADB to quickly connect to Android devices, but other platforms need to recompile the source code.
Requires that the computer has added ADB to the system environment variable, the Android device gets root privileges and turns on wireless debugging, it is recommended to use adbwirless.
Enter the following command in the shell to connect to the 192.168.1.10 device and list the devices that are currently connected
$AndroidConnector-C 192.168.1.10$androidconnector 192.168.1.10
$AndroidConnector-C 1.10
$AndroidConnector 1.10
Enter the following command in the shell to disconnect the connected device and list the devices that are currently connected
$AndroidConnector-D 192.168.1.10$androidconnector-d 1.10
You can view the Help document by entering the following command in the shell
$AndroidConnector--help
The following is the source code for this command-line tool and needs to be compiled by itself.
/******************* androidconnector *************************//* by Geequlim *//*************** *****************************/#include <iostream> #include <string> #include <cstdlib > #include <cstring>using namespace std;///show informations bool Showinfo (const char* arg) {if (strcmp (ARG, "-- Help ") ==0)//show help{cout<<" wirless adb helper \ n "" notic:\n "" You must keep debugable for Android device F irst!\n "" Your system should added the ADB to the path!\n\n "" To connect device:\n ""-C IP ($AndroidConnecter-C 192.1 68.1.10) \ n "" or the device IP ($AndroidConnector 192.168.1.10) \ n \ nthe "" To disconnect device:\n ""-D IP ($AndroidCon nector-d 192.168.1.10) \ n \ Disconnect all devices:\n ""-D all\n ""-d\n\n "" If your The IP starts with \ "192.168\": \ n "" ($AndroidConnector-D 1.10) \ n "" It is the same as ($AndroidConnector-d 192.168.1.10) \ n "<<endl;return true; }else if (strcmp (ARG, "--version ") ==0)//show version{cout<<" Androidconnector 0.1.1\n "" Copyright (C) geequlim\t "" Compile on "__dat E__<<endl;return true;} return false;} int main (int argc, char * argv[]) {string command= "adb connect"; string input;string ipadress= "192.168."; if (argc>=2 {if (argc>=3)//more than 2 arguments{if (strcmp (argv[1], "-D") ==0) command = "adb disconnect";//disconnect Alli F (strcmp (argv[2], "all") ==0) ipadress= "", else//disconnect target input = argv[2];} ELSE//1 or 2 arguments{//if The second argument is not--help or--version but-d or IP adressif (showinfo (argv[1)) ==false) {if (strcmp (argv[1], "-D") ==0)//disconnet All Devices{command = "adb disconnect"; ipadress = "";} Elseinput = argv[1];} else return 0;}} else{cout<< "Input your phone IP adress:" <<flush;cin>>input;} if (argc>1 && strcmp (argv[1], "-D") && Input.size () <3) {cerr<< "Worr input!" <<endl;return 1;} else if (input.size () <8) ipadress+=inPut;else if (input.size () >15 | | (Input.size () < 11&& (Input.size () >=8))) {cerr<< "Worr input!" <<endl; return 1;} Elseipadress = Input;cout<<command+ipadress<<endl;system ((command+ipadress). C_STR ()), System ("adb Devices "); return 0;}