Enabling Bluetooth in Ref-OS-IoT

You can find useful Bluetooth® documentation at these links:

Ref-OS-IoT uses a standard command line client bluetoothctl. It can run in two modes:

  • In command mode, commands are entered as arguments to the bluetoothctl command.
  • Interactive mode is started by typing bluetoothctl without arguments. The prompt will change to bluetoothctl> to indicate it is waiting for user commands.

You can enter the bluetoothctl command directly. Enter help to view all available commands. To exit from the bluetoothctl interactive shell, enter quit.

By default Bluetooth® is disabled via rfkill in Ref-OS-IoT.  Unblock Bluetooth® as follows:

root@intel-5xx-64:/# rfkill list
0: hci0: bluetooth
        Soft blocked: yes
        Hard blocked: no
1: phy0: wlan
        Soft blocked: yes
        Hard blocked: no
root@intel-5xx-64:/# rfkill unblock bluetooth
root@intel-5xx-64:/# rfkill list
0: hci0: bluetooth
        Soft blocked: no
        Hard blocked: no
1: phy0: wlan
        Soft blocked: yes
        Hard blocked: no


Now Bluetooth can be used. Ref-OS-IoT provides the widely used bluetoothctl tool to manage and control Bluetooth devices.

root@intel-5xx-64:/# bluetoothctl
[NEW] Controller 00:C2:C6:CC:D1:9C intel-5xx-64 [default]

Type help at the prompt to know the full command list. Once the rfkill has unblocked Bluetooth, the Bluetooth device is powered on.

[bluetooth]# show
Controller 00:C2:C6:CC:D1:9C
        Name: intel-5xx-64
        Alias: intel-5xx-64
        Class: 0x0c0110
        Powered: yes
        Discoverable: no
        Pairable: yes
        UUID: Headset AG                (00001112-0000-1000-8000-00805f9b34fb)
        UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
        UUID: Generic Access Profile    (00001800-0000-1000-8000-00805f9b34fb)
        UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
        UUID: Audio Sink                (0000110b-0000-1000-8000-00805f9b34fb)
        UUID: Audio Source              (0000110a-0000-1000-8000-00805f9b34fb)
        Modalias: usb:v1D6Bp0246d052B
        Discovering: no

bluetoothctl can be used to set the device discoverable and to start scanning for new devices.

[bluetooth]# scan on
Discovery started
[CHG] Controller 00:C2:C6:CC:D1:9C Discovering: yes
[NEW] Device A8:1B:5A:B4:77:49 OPPO R7f
[bluetooth]# discoverable on
Changing discoverable on succeeded
[CHG] Controller 00:C2:C6:CC:D1:9C Discoverable: yes

To see the list of available devices.

[bluetooth]# devices
Device 00:1D:DF:5F:A3:2E PHILIPS SBT75
Device A8:1B:5A:B4:77:49 OPPO R7f

To pair to another device which has been discovered during scanning. Use the command pair <device id>.

[bluetooth]# pair A8:1B:5A:B4:77:49
Attempting to pair with A8:1B:5A:B4:77:49
[CHG] Device A8:1B:5A:B4:77:49 Connected: yes
[CHG] Device 00:1D:DF:5F:A3:2E Connected:yes
[CHG] Controller 00:C2:C6:CC:D1:9C Discoverable: no
[CHG] Device 00:1D:DF:5F:A3:2E Connected: no
[OPPO R7f]#

The same device id can be used to connect too. Use the command connect <device id>.

For more complete information about compiler optimizations, see our Optimization Notice.