Announcement

Collapse
No announcement yet.

[Tutorial] Bluetooth ADB Debugging Moto G Titan Stock Android 6.0 No Root

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Tutorial] Bluetooth ADB Debugging Moto G Titan Stock Android 6.0 No Root

    Hello everyone,

    7837's sister team 11153 received in their rookie kit of parts a Moto G 2nd gen (Also known as Moto G Titan). When setting up that phone, we realized that the Wifi Direct connection between the Driverstation and the Robot Controller wasn't able to coexist with a connection to a Wifi network for wireless debugging. We figured out a way to establish ADB through Bluetooth instead. It uses a modified version of the batch script Philbot made for wireless ADB connections over Wifi.

    (This is also tested working with the ZTE speed, though WiFi debugging is still recommended on that)

    Of course, the phone needs to be in developer mode with USB debugging enabled.

    To summarize, the process for connecting a device:
    1. Pair bluetooth device (once paired, this often happens automatically)
    2. Enable Bluetooth Tether (Settings->More->Tethering & Portable Hotspot-> Bluetooth Tethering). This has to be done before every session.
    3. For first time pairing, follow directions here https://productforums.google.com/for...us/bivQfyYPPD0, except for when Windows asks if you would like to discover devices on network, say yes to prevent Windows Firewall from giving adb any grief.
    4. The special part is to add the bluetooth device using the "Add a Device" button in Devices and Printers. DO NOT use Win10/8 "Metro" bluetooth dialog for adding the device, as you will likely encounter the "direct access" bug.
    5. Establish network connection
    6. Right click on the Bluetooth symbol on the taskbar and select "Join a Personal Area Network"
    7. Right click on icon of phone to connect to -> Connect using -> Access Point
    8. A shortcut can be created so that the device can be right-clicked from the desktop
    9. Connect phone with USB to PC
    10. Run the batch script "BluetoothAdbCon.bat" (can be done by double clicking on it), and follow its instructions.
    11. Make sure adb is in system path
    12. If it is not, add %USERPROFILE%\AppData\Local\Android\sdk\platform-tools


    Link to folder containing BluetoothAdbCon.bat
    https://drive.google.com/open?id=0B7...jBGRUZiRUxhVHc

    Note: The first time that the app is loaded over the Bluetooth connection, it will take a few minutes to do so (it is much slower than WiFi). After that, changes to code are performed much more quickly. This is due to the Instant Run feature in Android Studio

    Hope that this helps someone. Any questions or problems, please ask so that we can make this guide bulletproof.

  • #2
    Thanks for the great solution!

    To what extent:
    A) is it known if this works on Moto G 3rd generation?
    B) is it known if the old wifi debug tricks from the ZTE still work with the Moto G 3rd Generation?
    C) has anyone tried tethered debugging through a USB hub with any of these controllers?
    Thanks,
    Martin Haeberli
    (de-)Mentor, FTC 7593, TigerBots

    Comment


    • #3
      A) It should work on the Moto G 3rd generation, assuming it allows the "bluetooth tether" setting to be turned on (not disabled by carrier). I have not tested it, as my personal use Moto G 3rd gen does not allow bluetooth tether (it has a Republic Wireless ROM on it). However, with the relatively stock Marshmallow roms that most of the teams use, it should work. (It even worked on the old ZTE speed)

      B) I can confirm that WiFi Direct cannot coexist with Wifi connection on my Moto G 3rd Gen. WiFi adb can be done, just not while the robot is connected to the driver station (which defeats the point). Disconnecting between WiFi Direct and a normal WiFi connection would break the android debug bridge setup.

      C) USB debugging would not work while connected to the robot hub because the Robot Controller phone is in OTG mode, where it is the USB host instead of normal usb client. There cannot be 2 hosts on a USB network.

      Comment


      • #4
        Bendito999,

        Thanks so much for your guidance.

        So, we will be learning a new (Bluetooth) trick!

        Martin Haeberli
        (de-)Mentor, FTC 7593, TigerBots

        Comment


        • #5
          Originally posted by Bendito999 View Post
          Hello everyone,

          7837's sister team 11153 received in their rookie kit of parts a Moto G 2nd gen (Also known as Moto G Titan). When setting up that phone, we realized that the Wifi Direct connection between the Driverstation and the Robot Controller wasn't able to coexist with a connection to a Wifi network for wireless debugging. We figured out a way to establish ADB through Bluetooth instead. It uses a modified version of the batch script Philbot made for wireless ADB connections over Wifi.

          (This is also tested working with the ZTE speed, though WiFi debugging is still recommended on that)

          Of course, the phone needs to be in developer mode with USB debugging enabled.

          To summarize, the process for connecting a device:
          1. Pair bluetooth device (once paired, this often happens automatically)
          2. Enable Bluetooth Tether (Settings->More->Tethering & Portable Hotspot-> Bluetooth Tethering). This has to be done before every session.
          3. For first time pairing, follow directions here https://productforums.google.com/for...us/bivQfyYPPD0, except for when Windows asks if you would like to discover devices on network, say yes to prevent Windows Firewall from giving adb any grief.
          4. The special part is to add the bluetooth device using the "Add a Device" button in Devices and Printers. DO NOT use Win10/8 "Metro" bluetooth dialog for adding the device, as you will likely encounter the "direct access" bug.
          5. Establish network connection
          6. Right click on the Bluetooth symbol on the taskbar and select "Join a Personal Area Network"
          7. Right click on icon of phone to connect to -> Connect using -> Access Point
          8. A shortcut can be created so that the device can be right-clicked from the desktop
          9. Connect phone with USB to PC
          10. Run the batch script "BluetoothAdbCon.bat" (can be done by double clicking on it), and follow its instructions.
          11. Make sure adb is in system path
          12. If it is not, add %USERPROFILE%\AppData\Local\Android\sdk\platform-tools


          Link to folder containing BluetoothAdbCon.bat
          https://drive.google.com/open?id=0B7...jBGRUZiRUxhVHc

          Note: The first time that the app is loaded over the Bluetooth connection, it will take a few minutes to do so (it is much slower than WiFi). After that, changes to code are performed much more quickly. This is due to the Instant Run feature in Android Studio

          Hope that this helps someone. Any questions or problems, please ask so that we can make this guide bulletproof.
          Windows (and Linux) should be able to connect to the robots WiDi network with a lot less work than on the 1.x versions, making bluetooth tethering unnecessary. However, I would not recommend deploying as Debug over the WiDi network (I experinence FTDI issues (i.e. device not found), but I haven't tested the 2.2 code on a robot).

          Also on your batch function, you may want to use the ANDROID_HOME sdk variable to find the Android SDK, assuming the variable is properly set.

          Comment


          • #6
            I hadn't considered adding Windows to the WiFi Direct network, I will try that next time I have the chance (next Wednesday or so).

            Could you provide an example of how to modify the batch script when calling adb (to ensure adb gets called regardless of path)? I don't particularly want the script itself editing the path, and I'm not sure how to access it. I looked on my system and did not see the ANDROID_HOME or ANDROID_HOME_SDK variable, even though I have Android Studio setup and adb working from the system path. I am hesitant to actually hardcode adb paths into the script, such as using "%USERPROFILE%\AppData\Local\Android\sdk\platf orm-tools\adb" instead of "adb", just in case adb or the SDK is really installed somewhere else. Bullet point 12. of the instructions just indicates where it probably is for new users.

            Comment


            • #7
              Update:
              I have a (number of) Moto G 3rd Generation, XT1548. 5.1.1 phones.
              Looks like the Marshmallow 6.0 or later update is not available.
              In any event, also no Bluetooth Tether settings are available.
              And, we use primarily Macs, so WiFi Direct from our development laptops is not an available / attractive option.
              Looking now at alternate phones ...
              Martin Haeberli
              (de-)Mentor, FTC 7593, TigerBots

              Comment


              • #8
                Originally posted by mhaeberli View Post
                Update:
                I have a (number of) Moto G 3rd Generation, XT1548. 5.1.1 phones.
                Looks like the Marshmallow 6.0 or later update is not available.
                In any event, also no Bluetooth Tether settings are available.
                And, we use primarily Macs, so WiFi Direct from our development laptops is not an available / attractive option.
                Looking now at alternate phones ...
                Martin Haeberli
                (de-)Mentor, FTC 7593, TigerBots
                Try this thread, you can install other Marshmallow roms so you do not need to buy new phones.
                http://ftcforum.usfirst.org/showthre...ed-phone/page6

                Comment


                • #9
                  Corban987,
                  It worked out ... thanks ...
                  Martin Haeberli
                  (de-)Mentor, FTC 7593, TigerBots

                  Comment

                  Working...
                  X