<p>I would like to connect to my EV3 from PC (and then Android) via Bluetooth.
I was able to connect to NXT with <a href="https://github.com/NXT/LEGO-MINDSTORMS-MINDdroid" rel="nofollow noreferrer">LEGO-MINDSTORMS-MINDdroid</a> which uses direct LCP commands but as far as I know the communication language for EV3 is different from that of NXT. </p>

<p>I have installed <a href="http://www.lejos.org/" rel="nofollow noreferrer">lejos</a> 0.9.1-beta on my EV3 and I could communicate with it via USB and WiFi using lejos' HelloWorld example containing <code>BrickFinder.getDefault()</code> for connecting.</p>

<p>I have followed <a href="https://abidmujtaba.blogspot.hu/2014/04/connecting-to-ev3-running-lejos-using.html?showComment=1481277416599#c5803985418525394242" rel="nofollow noreferrer">Abid's tutorial</a> for connecting from Linux. It did not work with Ubuntu 16.04 but it did with Ubuntu 14.04. I could ssh to the brick (I guess because 16.04 uses Bluez 5 while 14.04 and lejos uses Bluez 4). Bluez 4 and 5 seems <a href="http://www.bluez.org/release-of-bluez-5-0/" rel="nofollow noreferrer">incompatible</a>.). However <code>BrickFinder.getDefault()</code> still does not find the brick. (It is not clear whether this function checks Bluetooth at all.)</p>

<p>What should I do to create a Bluetooth connection from Linux (preferably Ubuntu 16.04) and Android? </p>

<p>I would like to avoid low-level bluetooth programming/direct commands as I have no experience with it and I prefer a java solution. Lejos on the brick's side is not a priority.</p>

CC BY-SA 3.0
2016-12-12T16:41:02.453Z
Does this help? http://bricks.stackexchange.com/a/5930/3498
David Lechner
CC BY-SA 3.0
2016-12-13T07:40:30.393Z
@David Lechner I have seen this page but there was no mention of Bluetooth in the source of Peter Mitrano's project. I will check it more thoroughly.
rics
CC BY-SA 3.0
2016-12-14T18:38:58.357Z
The BrickFinder source code is at https://sourceforge.net/p/lejos/ev3/code/ci/master/tree/ev3classes/src/lejos/hardware/BrickFinder.java. It seems the .getDefault() method iterates over all interfaces returned by the Java call NetworkInterface.getNetworkInterfaces(). Once bnep0 is created I would think it would be listed here and the EV3 should consequently become discoverable. Would need to hack this code to test what the problem is.
Abid H. Mujtaba
CC BY-SA 3.0
2016-12-31T10:49:33.550Z
I have found out that socket.receive in BrickFinder.find throws a SocketTimeoutException even if I raise setSoTimeout to MAX_DISCOVERY_TIME from MAX_DISCOVERY_TIME/4. Ping to EV3 from Ubuntu is working. Bluetooth communication from Android to EV3 is also working.
rics
<ev3><programming><bluetooth><lejos>
Bluetooth connection to EV3 from Java on Linux/Android
rics
# Bluetooth connection to EV3 from Java on Linux/Android

(Asked by: username_0 on 2016-12-12)

I would like to connect to my EV3 from PC (and then Android) via Bluetooth.
I was able to connect to NXT with [LEGO-MINDSTORMS-MINDdroid](https://github.com/NXT/LEGO-MINDSTORMS-MINDdroid) which uses direct LCP commands but as far as I know the communication language for EV3 is different from that of NXT.

I have installed [lejos](http://www.lejos.org/) 0.9.1-beta on my EV3 and I could communicate with it via USB and WiFi using lejos' HelloWorld example containing `BrickFinder.getDefault()` for connecting.

I have followed [Abid's tutorial](https://abidmujtaba.blogspot.hu/2014/04/connecting-to-ev3-running-lejos-using.html?showComment=1481277416599#c5803985418525394242) for connecting from Linux. It did not work with Ubuntu 16.04 but it did with Ubuntu 14.04. I could ssh to the brick (I guess because 16.04 uses Bluez 5 while 14.04 and lejos uses Bluez 4). Bluez 4 and 5 seems [incompatible](http://www.bluez.org/release-of-bluez-5-0/).). However `BrickFinder.getDefault()` still does not find the brick. (It is not clear whether this function checks Bluetooth at all.)

What should I do to create a Bluetooth connection from Linux (preferably Ubuntu 16.04) and Android?

I would like to avoid low-level bluetooth programming/direct commands as I have no experience with it and I prefer a java solution. Lejos on the brick's side is not a priority.

**Tags:** ev3, programming, bluetooth, lejos

> **Comments:**
> **username_1**: Does this help? http://bricks.stackexchange.com/a/5930/3498  
> **username_0**: @username_1 I have seen this page but there was no mention of Bluetooth in the source of Peter Mitrano's project. I will check it more thoroughly.  
> **username_2**: The BrickFinder source code is at https://sourceforge.net/p/lejos/ev3/code/ci/master/tree/ev3classes/src/lejos/hardware/BrickFinder.java. It seems the .getDefault() method iterates over all interfaces returned by the Java call NetworkInterface.getNetworkInterfaces(). Once bnep0 is created I would think it would be listed here and the EV3 should consequently become discoverable. Would need to hack this code to test what the problem is.  
> **username_0**: I have found out that socket.receive in BrickFinder.find throws a SocketTimeoutException even if I raise setSoTimeout to MAX_DISCOVERY_TIME from MAX_DISCOVERY_TIME/4. Ping to EV3 from Ubuntu is working. Bluetooth communication from Android to EV3 is also working.  

---

## 0 answers

