Home / Ramblings / EV3 Bricks: BLE or Blah?

EV3 Bricks: BLE or Blah?

A little while back, the Lejos forums were getting reports that some of the newly purchased bricks were having issues with Bluetooth connections.  Andy Shaw, one of the main developers of this project, determined that the main cause was a newly updated Bluetooth chipset in this brick.  Unlike its predecessor, this chipset is BT 4.0 capable.  That means that, at least in theory, the brick is BLE (Bluetooth Low Energy) capable.

For whatever reason, the LEGO MINDSTORMS hardware team decided to NOT increment the hardware revision number of these new brick, which makes identifying them extremely tricky.  The only way to do it is to gain console access to the brick, which is not trivial for non-Linux savvy users.  A command line utility has to be run and the output checked.  The tool in question is hciconfig, a tool to configure BT devices.  The output of this command, when run on an “old” brick, gives us the following:

Screenshot at 07-38-35

On a new brick, the output is quite different:

Screenshot at 07-39-14

As you can see, the first output tells us that the chipsets supports Bluetooth 2.1, the second output tells us that BT 4.0 is supported.

The LEGO firmware cannot tell the difference between the two due to the fact that the new chipset is a complete drop-in replacement for its predecessor, the only difference is the version number of the chipset firmware file version number.

I’ve created a small LMS assembler based program that will allow you to check your brick’s BT chipset, using the hciconfig command, without requiring console access.  It’s been precompiled for you, but if you’d like, you can see the code below.  As you can see, it’s pretty harmless.  You can download the precompiled version here: [LINK].  Just download it to your brick and run it from the screen.  A simple message will be displayed on your screen for 5 seconds, telling you whether or not you have a BLE capable chipset.  I have only tested this with LEGO firmware versions 1.06 and 1.07, as I don’t have the source code for firmwares versions 1.08 and 1.09.

Keep in mind that having the BLE capable chipset doesn’t really allow you to do anything special with the current LEGO firmware.  Perhaps in the future, LEGO will leverage this new capability, who knows.

/* Xander Soldaat (2016)
 * Copyright (C) 2016 Xander Soldaat
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

define NO_BLE_MSG 'No BLE chipset found'
define YES_BLE_MSG 'BLE chipset found'

vmthread MAIN
 DATA32 waitTimer
 DATA32 exitCode
 DATA16 fileHandle
 DATA32 fileSize
 DATA8 flag
 DATAS fileContent 32
 DATAS uiMessage 32

 // This runs the hciconfig, which retrieves all of the BT hardware related info
 SYSTEM('(hciconfig -a | grep -q "Version: 4.0" && echo "1" || echo "0") > /tmp/output.rtf', exitCode)

 // Open the file and read the first byte, which will be a '1' or '0' (ASCII)
 FILE(OPEN_READ, '/tmp/output.rtf', fileHandle, fileSize)
 FILE(READ_TEXT, fileHandle, DEL_NONE, 1, fileContent)
 FILE(CLOSE, fileHandle)
 // Compare the string and jump to the appropriate messsage initialisation
 STRINGS(COMPARE, fileContent, '1', flag)
 JR_TRUE(flag, HasBLE)
 JR_FALSE(flag, NoBLE)

// No BLE chipset found, this is an older generation brick

// A BLE capable chipset was found, this is a newer generation brick

// Put a little message on the screen and exit after 5 seconds
 UI_DRAW(TEXT,FG_COLOR, 0, 60, uiMessage)



About Xander

Xander Soldaat is a Software Engineer and former Infrastructure Architect. He loves building and programming robots. He recently had the opportunity to turn his robotics hobby into his profession and has started working for Robomatter, the makers of ROBOTC and Robot Virtual Words.