ev3dev icon indicating copy to clipboard operation
ev3dev copied to clipboard

Connecting with Bluetooth on Windows 10 through VS Code

Open physcrowley opened this issue 4 years ago • 0 comments

I have had many issues reliably connecting my EV3 brick with the ev3dev device browser extension even when a Bluetooth connection between the EV3 brick and my Windows 10 machine is properly established. However, I seem to have found a simple solution and I want to see if it will work for others.

Typical problem cycle

Configuration : Windows 10, "ev3micropythonv200" / kernel 4.14.117-ev3dev-2.3.5-ev3 / brickman v0.10.3

I would follow the standard pairing and connecting protocol for Bluetooth on Windows and establish a connection. The network status would be "Connected" and an IP address would duly appear at the top of the EV3 brick's screen. I could establish an SSH connection from the PowerShell terminal using ssh [email protected], and the same IP address as appears on the brick would be echoed to the terminal when the connection was made.

But if I tried to connect the "ev3dev (Bluetooth)" device using Visual Studio Code's ev3dev Device Browser extension, the attempt would always timeout with an error using some standard IP address instead of the actual Bluetooth connection's IP address.

Attempted solutions

  1. Pre-emptive solution -> use a USB connection. I want to avoid this, as it seems unnecessary if there is an established Bluetooth connection and only odd VS Code extension behaviour. It sometimes solved the issue, but I never figured out a surefire way of using it (again weird VS Code extension behaviour), so I've abandoned it as a "correction" for the Bluetooth connection.
  2. The first attempted solution targeting only Bluetooth was to change the "Additional Devices" setting in the settings.json file (not the one in the project directory but VS Code's settings), and manually change the IP address to the one I saw on the EV3 brick. This did not work : I still got the same timeout error using the same, old IP address.
    • I should have restarted VS Code then attempted the connection : this would have given me the same effective result as attempt number 2. I have tested it and it works.
  3. The second attempted solution was to "connect to another device" which I called "ev3dev (Bluetooth manual)" and simply enter the correct IP address at the following prompt. This worked immediately. The only problem is that I would have to create a new device each time I reboot the EV3 brick as the IP addresses seem to reset dynamically with each new connection. Then I'd have a long, annoying list of similarly named devices to navigate, with each "device" only being useful once.

My recommended solution

I think the manual editing of the VS Code setting for ev3dev's Additional devices is the most effective workaround.

Make sure to have an established Bluetooth connection with the EV3 brick before starting the steps below.

  1. Go into VS Code's settings : type Ctrl + , to bring up the Settings UI.
  2. Search "ev3" and click on "ev3dev browser configuration" under the Extensions section of settings.
  3. Edit the "Additional Devices" setting by opening the settings.json file and changing the IP address of the device "ev3dev (Bluetooth)" to the IP address appearing on the EV3 brick. Save the changes if they are not saved automatically.
  4. Close and relaunch VS Code.
  5. Use the ev3dev device browser to connect to "ev3dev (Bluetooth)"

May your connection circle forever be 🟢 !

Does this work for you?

Did I miss something that I should have been doing differently? Can the extension correct this behaviour by automatically updating to the current IP address of [email protected] without having to do this manually?

I would love to know if there is a simpler way, but this works reliably enough for me at the moment.

physcrowley avatar Jun 30 '21 03:06 physcrowley