locked
How do I (WiFi) debug USB device connections? RRS feed

  • Question

  • User378911 posted

    Hi all! I'm developing a Xamarin.Android app for work (on a PL-40L PDA running Android 7.0 (https www.aliexpress.com/item/Caribe-PL-40LAa050-Industrial-mini-portable-nfc-memory-attendance-rfid-android-integrated-with-gps-1d-barcode/32541742965.html), and we need to connect to an Arduino Due. We've settled on having the Due act as USB Host (Arduino-er) (http arduino-er.blogspot.com/2013/03/adk-running-on-arduino-due.html), because we want to charge the PDA, and when I ran the Arduino sketch and the Android app, I got communication to occur. However, while attempting to debug my attempt using WiFi (https docs.microsoft.com/en-us/xamarin/android/get-started/installation/set-up-device-for-development), every time I connect or disconnect the Arduino via USB, debugging in Visual Studio disconnects. I've searched, and the closest I've gotten to a similar issue is unresolved (Stack Overflow) (https stackoverflow.com/questions/20668200/android-adb-over-wifi-still-disconnects-when-usb-cable-is-cycled). In any case, all this is incidental to hooking into the USB accessory attached broadcast (Android.Hardware.Usb.UsbManager.ActionUsbAccessoryAttached). So: * Can anyone help with keeping WiFi debugging going when connecting a USB device? * Alternatively, does anyone know how to reconnect debugging to an Android device when it disconnects like this? * Any tips for getting USB attached hooks working? (I'm happy to ask another question for this one)

    Your help is GREATLY appreciated.

    Wednesday, October 24, 2018 10:29 PM

All replies

  • User364855 posted

    @JonathanJohansen Please check the following link: https://docs.microsoft.com/en-us/xamarin/android/get-started/installation/set-up-device-for-development#connecting-over-wifi

    Friday, October 26, 2018 2:21 AM
  • User378911 posted

    Thanks @BillyLiu, it didn't help, unfortunately. I've resigned myself to it - with a debug text file (I should probably figure out how to use some web thingy to make 'debug' print statements really easy...)

    Monday, October 29, 2018 5:47 AM
  • User342099 posted
    1. Create a text file and copy code below, then rename it as .bat file.
    2. Copy the ip address from your android device wifi in settings, then paste replace in cmd text e.g "adb connect 192.168.1.3:5555" (ip address is "192.168.1.3")
    3. Open .bat file cmd on Windows
    4. Now you can disconnect your android device connected usb cable and check if the device name has appeared in the Visual Studio device listing ~~~ @echo off if %1==payload goto :payload

    :getadmin echo %~nx0: elevating self set vbs=%temp%\getadmin.vbs echo Set UAC = CreateObject^("Shell.Application"^) >> "%vbs%" echo UAC.ShellExecute "%~s0", "payload %~sdp0 %*", "", "runas", 1 >> "%vbs%" "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" goto :eof

    :payload

    ::ENTER YOUR CODE BELOW::
    cd C:\Program Files (x86)\Android\android-sdk\platform-tools adb tcpip 5555 adb connect 192.168.1.3:5555

    ::END OF YOUR CODE::

    echo. echo...Script Complete.... echo.

    pause ~~~

    Monday, June 1, 2020 7:03 AM