Veethree D7 SDK
Loading...
Searching...
No Matches
Bluetooth Basics

< Bluetooth

Official Linux Bluetooth protocol stack- BlueZ supports Bluetooth communication on the D7. BlueZ includes tools like bluetoothctl, btmgmt, hciconfig, btmon, sdptool, rfcomm, obexctl, etc.

Note: This document provides basic usage commands. Although Arch Linux is not used on the D7, ArchWiki Bluetooth provides more details on BlueZ usage and troubleshooting.

Basic commands

To get started with using Bluetooth on the D7, run the following commands on the shell.

Set up

  • Check if BlueZ daemon (bluetoothd) is running:

    $ systemctl status bluetooth
    # Start service if not running
    $ systemctl start bluetooth
  • Get Bluetooth adapter status and configuration information:

    $ hciconfig
  • Power on Bluetooth: If powered on, the command hciconfig should show UP RUNNING and BD Address should not be empty. If the device status is DOWN, Bluetooth adapter is powered off, to power on:

    $ hciconfig hci0 up

    Or using bluetoothctl:

    $ bluetoothctl
    [bluetooth]# power on
    [bluetooth]# quit
  • Get more information like device name, profile UUIDs, public MAC etc:

    $ bluetoothctl show

Pair and unpair devices

bluetoothctl interactive command line tool is used to scan and pair Bluetooth devices. To pair with a remote device, start the interactive tool using bluetoothctl

Initiate pairing

To initiate a pairing request:

  1. Start the interactive tool and register an agent to handle PIN codes, passkey confirmations, or authorization prompts when pairing:

    $ bluetoothctl
    [bluetooth]# agent on
  2. Scan for devices:

    [bluetooth]# scan on

    Scanning is required to initiate a pairing request to another device. To pair a remote device, its public MAC address should be on D7's scan/cache list

  3. List scanned devices

    [bluetooth]# devices

    Verify your remote device's MAC address is present in the list

  4. Initiate pairing with your remote device using its MAC

    [bluetooth]# pair <MAC>

    If the device requires authorization or PIN requests, registered agent will handle it and show required prompts. If the authentication is successful, devices will be paired.

  5. BlueZ keeps scanning for devices until a predefined timeout period. To manually stop scanning run
    [bluetooth]# pair <MAC>

Accept pairing requests

To accept a pairing request from a remote device,

  1. Start the interactive command line tool and register the agent

    $ bluetoothctl
    [bluetooth]# agent on
    [bluetooth]# discoverable on
  2. Make the device device discoverable

    [bluetooth]# discoverable on

    When a remote device initiates pairing, the registered agent will show authentication prompts as required. If the authentication is successful, devices will be paired.

Verify and Unpair

  • List all available devices

    [bluetooth]# devices

    Add a filter to list paired devices

    [bluetooth]# devices Paired
  • Get information from a paired device

    [bluetooth]# info <MAC>
  • Unpair

    [bluetooth]# remove <MAC>

GUI example

QML Bluetooth application included in ~/d7-sdk/examples/gui/qml-bluetooth/ provides an equivalent GUI app to enable bluetooth, scan/pair and make device discoverable.