EV3 is equipped with Bluetooth. It has been designed to communicate with other Bluetooth devices, especially smartphones, which can be used to control EV3 when running the right software. LeJOS takes this concept to the next level.
An EV3 running LeJOS implements a Bluetooth Personal Area Network (PAN) by acting as a Group Ad-hoc Network (GN) controller. This means that EV3 acts as a server on a Bluetooth-based network, allowing other devices, for example, a computer, to act as a PANU (PAN client) and connect to the network. Once established, the PAN behaves like any other network, most importantly, allowing transparent SSH access.
The first step is to prepare your computer. The Linux machine must have either Bluetooth built in or a Bluetooth USB dongle attached. Make sure that Bluetooth is enabled and visible to other devices, using whichever graphical means are used to control it. To confirm that Bluetooth is active and running, run hciconfig -a
. Here is some sample output obtained by running this command:
hci0: Type: BR/EDR Bus: USB BD Address: 00:16:CF:FE:03:A0 ACL MTU: 1017:8 SCO MTU: 64:8 UP RUNNING PSCAN ISCAN RX bytes:301012 acl:2298 sco:0 events:460 errors:0 TX bytes:94808 acl:966 sco:0 commands:67 errors:0 Features: 0xff 0xff 0x8d 0xfe 0x9b 0xfd 0x00 0x80 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH HOLD SNIFF PARK Link mode: SLAVE ACCEPT Name: 'laptop-0' Class: 0x6e010c Service Classes: Networking, Rendering, Capturing, Audio, Telephony Device Class: Computer, Laptop HCI Version: 2.0 (0x3) Revision: 0x20da LMP Version: 2.0 (0x3) Subversion: 0x4182 Manufacturer: Broadcom Corporation (15)
The output should have Networking
in the Service Classes
section and Computer
in the Device Class
section.
EV3 running LeJOS requires almost no configuration. Just make sure it is turned on; navigate to the Bluetooth menu and ensure that it says Visibility on (and the iPhone/iPad/iPod option is disabled). This indicates that EV3 is acting as a PAN server and is ready to accept clients.
EV3 is running as a visible Bluetooth server, and the computer has Bluetooth activated. We make sure that EV3 is visible to the computer by running the hcitool
scan on the latter. The response should look as follows:
Scanning … 00:16:53:40:E9:7D EV3
We are interested in the Bluetooth address of EV3 (the 12 hexadecimal numbers interspersed with colons). To connect to EV3 as a PANU (Bluetooth client), we use the pand
utility (on Debian/Ubuntu, it is available in the bluez-compat
package and can be installed by running sudo apt-get install bluez-compat
). To establish the connection, run the following command (as root):
sudo pand –-connect <BT ADDR> -n
Replace <BT ADDR>
with the Bluetooth address of EV3. We are looking for the line bnep0
connected in the output to confirm that the connection was successful.
The PAN connection has been established, but we need to run a network interface over it, mainly
Bluetooth Network Encapsulation Protocol (BNEP). Since EV3 has an IP address of 10.0.1.1
on both the Ethernet and BNEP, we choose an IP address of 10.0.1.2
for our computer and start the BNEP network interface by running the following (as root):
ifconfig bnep0 10.0.1.2
To confirm that the interface is up, run ifconfig
and look for an output similar to the following:
bnep0 Link encap:Ethernet HWaddr 84:a6:c8:9b:ce:58 inet addr:10.0.1.2 Bcast:10.255.255.255 Mask:255.0.0.0 inet6 addr: fe80::86a6:c8ff:fe9b:ce58/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:670 errors:0 dropped:0 overruns:0 frame:0 TX packets:7 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:30820 (30.8 KB) TX bytes:428 (428.0 B)
To verify that the computer is now connected to EV3, run ping -c1 10.0.1.1
and look for the following:
PING 10.0.1.1 (10.0.1.1) 56(84) bytes of data. 64 bytes from 10.0.1.1: icmp_req=1 ttl=64 time=46.3 ms --- 10.0.1.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 46.340/46.340/46.340/0.000 ms
With the connection established and EV3 having the same IP address as on the usb0
interface discussed earlier, you can SSH into EV3 over Bluetooth by issuing ssh ev3
(or ssh [email protected]
if you haven't set up ssh config
yet).
Finally, to disconnect the computer from EV3's PAN, run pand -K
as the root.
3.145.131.238