-Connect your laptop to your phone (the phone the host, and its IP doesn t change in our hands)

Ok, the plugging and unplugging is getting boring. We’ve gathered different bits of information, and tried to make it as easy as possible to develop p...
2 downloads 3 Views 1MB Size
Ok, the plugging and unplugging is getting boring. We’ve gathered different bits of information, and tried to make it as easy as possible to develop programs wirelessly. We’re working with windows and Android Studio. If you have a 64 bit machine – check out BotBug, it’ll take care of things automagically. The best we could do in the 32 bit world, is having to plug in the phone once, then running a small batch file and the phone stays connected wirelessly for the entire session. (We’re team 8045, so take that into account for the example) The Goal is to connect your laptop running Android Studio directly to your Robot controller phone, no wires, no routers. This is easier than it looks, and SOOO worth setting up. We couldn’t find a clear, easy to follow guide to doing this, so hopefully it will help others… There are two basic steps: -Connect your laptop to your phone (the phone the host, and its IP doesn’t change in our hands) -Connect the Android Studio software to your phone. Just like any other wireless connection, you can have Windows ‘remember’ your password/connection. If you do this, and edit the two lines in the adb_wireless script with your IP & SSID you can have one click wireless.

Plug in your phone to the laptop via USB, it’ll show up in Android Studio. Start the FTC Robot Controller App on the Robot Controller phone.

Tap on the three dots in the upper left.

Tap ‘About’

Keep this Screen Handy, you’ll need the PassPhrase (once) and the IP number to edit the script.

On your Laptop, click on your WiFi connection bars, or look for WiFi signals, you should see a service like DIRECT-xx-8045-RC; (the xx are are random letters, 8045 is our team number, find yoursYou’ll need that name to edit the adb_wireless batch file as well.)

Highlight the ‘Connect Automatically’ and then Click ‘connect’. Again – remember the connection name, this is the SSID.

Enter the Pass phrase you see on the phone Screen. Not sure if this ever changes, but it seems very stable in our use!

Now your laptop should be connected to the phone, the wireless connections can be checked:

Now you should be ready to edit the script with your information: Right click on the adb_wireless.bat file/icon and select edit: Change the IP and SSID to your values. @echo off rem Edit these two parameters, On the Robot Controller, tap … , 'about' rem ----------------------------------------------@SET IP=192.168.49.1 @SET SSID=DIRECT-z8-8045-RC rem ----------------------------------------------rem Thanks to John McDonnell's initial script. Click file, exit & save your new file.

Here is the usual connection scenario after you’ve saved wireless connection profile (SSID) for your phone and edited the batch file. Run Android Studio, and plug in your phone via USB. Once it is recognized, double click/run your batch file you just created. This should connect to your phone wirelessly, and then set up the adb bridge via this wireless connection. Unplug, and program for the rest of the day with no more plugging and unplugging! See the manual connection notes below to help trouble shoot

ADB_WIRELESS.BAT @echo off rem Edit these two parameters, On the Robot Controller, tap ... and 'about' rem ----------------------------------------------@SET IP=192.168.49.1 @SET SSID=DIRECT-z8-8045-RC rem ----------------------------------------------rem Thanks to John McDonnell's initial script. rem Wifi Direct to the phone from laptop, must be disabled during matches. see ruling 22 rem http://ftcforum.usfirst.org/showthread.php?4632-Tournament-Rules-AnswerThread&p=21652&viewfull=1#post21652 rem rem Team 8045 Gromit's Grommets, Rick Faber echo. echo. echo This script tries to configure your phone to use Wireless Android Debugging. echo. echo One time you must connect to your phone's wifi manually and have windows echo save the configuration. Then you can edit the first two lines of this echo file to include the phones' IP and SSID. echo. echo You will still need to plug in a USB cable, you can do that before starting. echo. echo %SSID% echo.

%IP%

rem Look if SSID profile exists netsh wlan show networks | findstr %SSID% IF NOT ERRORLEVEL 1 GOTO connect echo Your phone default SSID doesn't show up, ( %SSID%) : set /p SSID=Type in the SSID for your phone, (%SSID%) : SET ERROR_MESSAGE=Your phone is not broadcasting at %SSID% netsh wlan show networks | findstr %SSID% IF ERRORLEVEL 1 GOTO oops REm Connect to the phone's wireless :connect SET ERROR_MESSAGE=Couldn't connect to your phone using profile %SSID% password and 'remember' it netsh wlan connect %SSID% IF ERRORLEVEL 1 GOTO oops rem seems like you need to wait for the connection to show up.. timeout /t 3 echo. ipconfig | findstr %IP% echo. IF NOT ERRORLEVEL 1 GOTO adb echo Your phone at IP %IP% does not seem to be connected : set /p IP=Type in the IP address of the phone, (%IP%) :

- Check, name,

SET ERROR_MESSAGE=Your phone at %IP% does not look to be connected? Try FTC robot controller, ..., About. Connect directly to the phone and wireless connect ipconfig | findstr Gateway|findstr %IP%' ' IF ERRORLEVEL 1 GOTO oops :adb echo Connect your phone via USB echo . rem removed ping test -redundant with IPCONFIG above

and needs to wait.

SET ERROR_MESSAGE=Failure to set up debugging while checking ADB version - check that you installed the ZTE Speed USB driver. adb version | findstr "Android Debug Bridge" IF ERRORLEVEL 1 GOTO oops rem adb kill-server echo. echo Connect the USB cable to the phone. echo. pause SET ERROR_MESSAGE=Failure to set up debugging while starting daemon over TCP/IP (USB not connected?) adb tcpip 5555 IF ERRORLEVEL 1 GOTO oops echo Disconnect the USB cable from the phone. rem pause SET ERROR_MESSAGE=Failure to set up debugging while connecting to the device on TCP/IP adb connect %IP% IF ERRORLEVEL 1 GOTO oops SET ERROR_MESSAGE=Failure to set up debugging - do not see device listed. adb devices | FINDSTR 5555 IF ERRORLEVEL 1 GOTO oops :success echo . echo Success! @echo . goto finished :oops echo . echo An error occurred. The message is: echo %ERROR_MESSAGE%. :finished Pause

Here’s the Manual Method for attaching the ADB bridge: (you don’t need this if the batch file works) Now Android Studio has to connect to the phone. On your laptop, click the windows button, and ‘run’. Type ‘cmd’ in the search box and hit enter.

In the command shell type ‘adb tcpip 5555’ hit enter Then type ‘adb connect 192.168.xx.xx’ Use the IP address that is displayed on the about window of the phone!

You can see Android Studio now has two connections if you click on the little drop down arrow:

CUT the Cord! (well unplug it), One connection is left.

Viola, bust out that Autonomous program!