Bluetooth Low Energy

This feature is only available on certain products and models (not available with all devices).


Bluetooth Low Energy (BLE) requires GATT software and a BLE peripheral device(such as a sensor broadcasting temperature data) in order to work. The BLE peripheral device should provide services, and then update them as required. The gatttool or libaries may be used to read and write to the BLE peripheral. This requires some prior setup and coding in order to operate.

The example here uses the Texas Instruments Sensortag CC2650, a connectivity kit for IoT sensors to connect to the internet via BLE. (see photo below). Refer to the Texas Instruments website. Go to the bottom of the page for a list of sensors and services. Click on the plus symbol to see the details of each sensor and its handles. The handles are used to control and read the sensor.

You must develop a custom application to read and accept the data from an IoT device.  This code includes the hooks or handles. Your specific approach including desired programming language and related software for this process varies widely based on your application, hardware and software systems.  See Application Development for more information.

For mLinux, one option is to write a C/C++ application and use the BlueZ driver already provided on the device.  Other options include writing a Python application and using the python gattlib library.

NOTE: For mLinux 3.x only, BLE does not work with Bluez 5 on a PC in compatibility mode.  You must use Bluez 4.

BLE Setup and Start

1. Make sure the RS9113 is started with a BLE compatible mode of: 8, 9, 12, or 14. For this example, the choice is 14. If you reboot the system, verify that /etc/default/rs9113 still contains the correct value. NOTE: Once a WiFi connection is established, you cannot scan. Push the black plastic flap as seen here:

Photo of the Texas Instruments Sensortag CC2650 used in this BLE example.

For mLinux 4.x or higher, after step 1, follow these steps:

2.Edit /etc/default/bluetoothd and set BLUETOOTH_ENABLED=1

3.Start the bluetooth daemon:

sudo /etc/init.d/bluetooth start

To stop the bluetooth daemon (don’t do this if you wish to proceed on testing this):

sudo /etc/init.d/bluetooth stop

4. Now use bluetoothctl to find the BLE device.

sudo bluetoothctl
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# scan on
Discovery started
[CHG] Controller 00:23:A7:EA:2E:D3 Discovering: yes

If the BLE device is advertising, you should soon see:

[NEW] Device B0:B4:48:C0:B0:82 CC2650 SensorTag

For mLinux 3.x, after step 1, follow these steps:

2. Put the BLE device in discoverable mode. The green led starts to blink.
3. Enter the following commands:

mtcdt: hciconfig hci0 up
mtcdt: hcitool -i hci0 lescan

    The resulting output displays:

#LE Scan ...
B0:B4:48:C0:B0:82 (unknown)
B0:B4:48:C0:B0:82 CC2650 SensorTag

4. Type <Ctrl-C> to end the scan.

Bring BLE up

To bring BLE up, enter the following command:

mtcdt: hciconfig hci0 up

Bring BLE down

To bring BLE down, enter the following command:

mtcdt: hciconfig hci0 down

BLE Reset

BLE resets automatically upon reboot.

Connect to the Sensor

Now you that you know the address of the BLE device (See BLE Setup and Start), you can connect.

1. To connect to the sensor, enter the following commands:


mtcdt: gatttool -i hci0  -b B0:B4:48:C0:B0:82 --interactive
[         ][B0:B4:48:C0:B0:82][LE]> connect


2. Once you connect, the blinking led stops. Enter the following command: 

[CON][B0:B4:48:C0:B0:82][LE]> primary

 The resulting output displays: 

attr handle: 0x0001, end grp handle: 0x0007 uuid: 00001800-0000-1000-8000-00805f9b34fb
attr handle: 0x0008, end grp handle: 0x000b uuid: 00001801-0000-1000-8000-00805f9b34fb
attr handle: 0x000c, end grp handle: 0x001e uuid: 0000180a-0000-1000-8000-00805f9b34fb
attr handle: 0x001f, end grp handle: 0x0026 uuid: f000aa00-0451-4000-b000-000000000000
attr handle: 0x0027, end grp handle: 0x002e uuid: f000aa20-0451-4000-b000-000000000000
attr handle: 0x002f, end grp handle: 0x0036 uuid: f000aa40-0451-4000-b000-000000000000
attr handle: 0x0037, end grp handle: 0x003e uuid: f000aa80-0451-4000-b000-000000000000
attr handle: 0x003f, end grp handle: 0x0046 uuid: f000aa70-0451-4000-b000-000000000000
attr handle: 0x0047, end grp handle: 0x004b uuid: 0000ffe0-0000-1000-8000-00805f9b34fb
attr handle: 0x004c, end grp handle: 0x0050 uuid: f000aa64-0451-4000-b000-000000000000
attr handle: 0x0051, end grp handle: 0x0058 uuid: f000ac00-0451-4000-b000-000000000000
attr handle: 0x0059, end grp handle: 0x0060 uuid: f000ccc0-0451-4000-b000-000000000000
attr handle: 0x0061, end grp handle: 0xffff uuid: f000ffc0-0451-4000-b000-000000000000

3. To get a list of details of characteristics, use the char-desc command. When using this command , it displays the handle they are at and their UUID:   

[CON][B0:B4:48:C0:B0:82][LE]> char-desc

The resulting output displays:

handle: 0x0001, uuid: 2800
handle: 0x0002, uuid: 2803
handle: 0x0004, uuid: 2803
handle: 0x0003, uuid: 2a00
handle: 0x0005, uuid: 2a01

4. To read the characterstics that are located at certain handle(s), enter the following command:


[CON][B0:B4:48:C0:B0:82][LE]> char-read-hnd 0x0001
Characteristic value/descriptor: 00 18
[CON][B0:B4:48:C0:B0:82][LE]> char-read-hnd 0x0002
Characteristic value/descriptor: 02 03 00 00 2a

5. You can also write characteristics that are located at certain handle(s): The first write command wakes up (activates) the IR temperature probe on 01. The second write command puts the sensor to sleep on 00. The read commands to simply confirm that the change happened.


[CON][B0:B4:48:C0:B0:82][LE]> char-write-cmd 0x24 01
[CON][B0:B4:48:C0:B0:82][LE]> char-read-hnd 0x24
Characteristic value/descriptor: 01
[CON][B0:B4:48:C0:B0:82][LE]> char-write-cmd 0x24 00
[CON][B0:B4:48:C0:B0:82][LE]> char-read-hnd 0x24
Characteristic value/descriptor: 00

6. Enter the following commands to disconnect and exit. The green LED on the sensor starts blinking again:


[CON][B0:B4:48:C0:B0:82][LE]> disconnect
[   ][B0:B4:48:C0:B0:82][LE]> exit

7. To save energy, turn off the sensor and the green light stops blinking.

Use the device as a server (not yet supported in mLinux 4.x)

You can use the device as a server and send data to your computer.

Note: These instructions were tested on Ubuntu 14.04 and do not work in Ubuntu 16.04.

To use the device as a server:

1. Set the COEX_ MODE of 8  for the rs9113 module (8 changes bluetooth config to a peripheral (slave) mode) in /etc/default/rs9113:


#             8      BT LE MODE /BT   LE   PER   MODE

2. Configure bluetoothd for GATT by entering this command:


mtcdt: grep -in gatt /etc/bluetooth/main.conf
63:# Enable the GATT functionality. Default is false
64: EnableGatt = true

3. To tell the rs9113 module to advertise the device as a BLE device (setup advertising and discovery), enter the following command:

Note: leadv can only be used on the device in this test. If hcitool hci0 leadv is ever run on the PC, the Bluetooth dongle must be removed before gatttool can be run. Otherwise gatttool connect will always fail.


mtcdt: hciconfig hci0 up
mtcdt: hciconfig hci0 noleadv
mtcdt: hcitool -i hci0 cmd 0x08 0x0008 10 02 01 1a 0c ff 18 01 48 45 4c 4c 4f 57 4f 52 4c 44
mtcdt: hciconfig hci0 leadv

4. Check the status by entering this command:


mtcdt: hciconfig

The resulting output displays:


hci0:  Type: BR/EDR  Bus: USB
BD Address: 00:23:A7:49:5C:D9  ACL MTU: 27:10  SCO MTU: 0:0
RX bytes:462 acl:0 sco:0 events:38 errors:0
TX bytes:0 acl:0 sco:0 commands:38 errors:0

5. To find the device, log onto a PC with Linux and BLE and enter the scan command:


pc: sudo hcitool -i hci0 lescan

 The resulting output displays:


LE Scan ...
00:23:A7:49:5C:D9 (unknown)
00:23:A7:49:5C:D9 SimpleBLEPeripheral

 The MAC addresses highlighted in bold from the hciconfig output and the hcitool lescan output should match.

Bring up bluetoothd on the device

The files you need for this procedure are created by building the BlueZ 4 package.

1. Download the package bluez4-plugins_*.ipk onto the device from

2.  Install the plugins:
opkg install bluez4-plugins_*.ipk

3. To start the bluetoothd daemon, enter the following command: 

mtcdt: bluetoothd -n -d

A large of amount of data displays as output. Look for this specific line to confirm that gatt server started.


bluetoothd[5564]: src/attrib-server.c:btd_adapter_gatt_server_start() Start GATT server in hci0

4. This step requires BlueZ 4 already installed. Refer to Bluetooth page for instructions. Log into gatttool on your computer and connect to the device by entering the following commands:


mtcdt: gatttool -i hci0 -b 00:23:A7:49:5C:D9 --interactive
[   ][00:23:A7:49:5C:D9][LE]> connect
[CON][00:23:A7:49:5C:D9][LE]> primary

The following results display:


attr handle: 0x0001, end grp handle: 0x0008 uuid: 00001800-0000-1000-8000-00805f9b34fb
attr handle: 0x0010, end grp handle: 0x0010 uuid: 00001801-0000-1000-8000-00805f9b34fb
[CON][00:23:A7:49:5C:D9][LE]> characteristics 0x0001 0x0008
handle: 0x0004, char properties: 0x02, char value handle: 0x0006, uuid: 00002a00-0000-1000-8000-00805f9b34fb
handle: 0x0007, char properties: 0x02, char value handle: 0x0008, uuid: 00002a01-0000-1000-8000-00805f9b34fb
[CON][00:23:A7:49:5C:D9][LE]> characteristics 0x0010 0x0010