Pairing

Start bluetoothctl and pair an Android phone

In this particular example, we use an Android phone to pair with your mLinux device. Of course, you can use other bluetooth-enabled devices for pairing.

Using bluetoothctl on the device

$ sudo bluetoothctl
[bluetooth] power on
[bluetooth] discoverable on
[bluetooth] pairable on
[bluetooth] agent KeyboardOnly
[bluetooth] default-agent

Enter the following command to show services:

[bluetooth]show

Now the system lists the services on the device.

Controller 00:23:A7:49:43:C1
        Name: MTCDT-LORA-Bluez
        Alias: MTCDT-LORA-Bluez
        Class: 0x00020000
        Powered: yes
        Discoverable: yes
        Pairable: yes
        UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
        UUID: NAP                       (00001116-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
        UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
        UUID: Generic Access Profile    (00001800-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
        Modalias: usb:v1D6Bp0246d052F
        Discovering: no

Initial setup of phone

  1. Go into the bluetooth menu of your phone and this should make your phone discoverable.
  2. Turn scan on the device. You should see the name of the device that was entered in main.conf (assuming you made the device discoverable).

Scan and trust on device

scan on

Wait until you see the following message (for your device):

[NEW] Device DC:74:A8:05:39:77 Test Cell Phone

Now turn scan off and trust the device:

[bluetooth] scan off
Discovery stopped
[bluetooth] trust DC:74:A8:05:39:77
[CHG] Device DC:74:A8:05:39:77 Trusted: yes
Changing DC:74:A8:05:39:77 trust succeeded

Pairing from mLinux device

This operation must be done rapidly due to timeouts on pairing. The pairing must immediately be accepted from the phone. Now pair the device (note the passkey number):

[bluetooth] pair DC:74:A8:05:39:77
Attempting to pair with DC:74:A8:05:39:77
[CHG] Device DC:74:A8:05:39:77 Connected: yes
Request confirmation
[agent] Confirm passkey 021168 (yes/no): yes
[CHG] Device DC:74:A8:05:39:77 Modalias: bluetooth:v0075p0100d0200
[CHG] Device DC:74:A8:05:39:77 UUIDs: 00001105-0000-1000-8000-00805f9b34fb
[CHG] Device DC:74:A8:05:39:77 UUIDs: 0000110a-0000-1000-8000-00805f9b34fb
[CHG] Device DC:74:A8:05:39:77 UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Device DC:74:A8:05:39:77 UUIDs: 00001112-0000-1000-8000-00805f9b34fb
[CHG] Device DC:74:A8:05:39:77 UUIDs: 00001115-0000-1000-8000-00805f9b34fb
[CHG] Device DC:74:A8:05:39:77 UUIDs: 00001116-0000-1000-8000-00805f9b34fb
[CHG] Device DC:74:A8:05:39:77 UUIDs: 0000111f-0000-1000-8000-00805f9b34fb
[CHG] Device DC:74:A8:05:39:77 UUIDs: 0000112f-0000-1000-8000-00805f9b34fb
[CHG] Device DC:74:A8:05:39:77 UUIDs: 00001132-0000-1000-8000-00805f9b34fb
[CHG] Device DC:74:A8:05:39:77 UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Device DC:74:A8:05:39:77 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device DC:74:A8:05:39:77 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device DC:74:A8:05:39:77 ServicesResolved: yes
[CHG] Device DC:74:A8:05:39:77 Paired: yes
Pairing successful
[CHG] Device DC:74:A8:05:39:77 ServicesResolved: no
[CHG] Device DC:74:A8:05:39:77 Connected: no
[bluetooth]

If you have not done discovery for a while, or if the phone is not discoverable, you may see this response:

Device DC:74:A8:05:39:77 not available

Response example on an Android Phone

You should see the same passkey number from the mLinux output displayed on the Android phone (the other connecting device in this example).

Quickly confirm the passkey number to accept the request on the phone OS.

If done in time, you should now see the device listed under Paired Devices (or Bluetooth > My Devices if using iOS)  in the phone OS.