I am trying to emulate the connection process of a handsfree car system using BlueZ 5.37 on an Ubuntu machine with the NAP profile.
The Ubuntu machine is running the NAP profile, and I can successfully connect client devices and use the Bluetooth tethering functionality.
The issue is, I need to manually reconnect my device each time I boot up the Ubuntu machine. My goal is to have the Ubuntu machine automatically connect to my phone as it comes up. The pairing/trusting process will have already been completed for the device. Thus, just like a handsfree car system, I would only need to go to my Bluetooth settings the first time to pair. Any other time I am nearby when the device boots up, I should automatically be connected.
I am only running the NAP profile, here is my bluetoothctl show command output:
[bluetooth]# show Controller 5C:F3:70:88:D5:E1
Name: BlueZ 5.37
Alias: Test Bluetooth
Class: 0x020000
Powered: yes
Discoverable: no
Pairable: yes
UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
UUID: NAP (00001116-0000-1000-8000-00805f9b34fb)
UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb)
UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb)
Modalias: usb:v1D6Bp0246d0525
Discovering: no
Currently, when I attempt to send the connection request from the Ubuntu side to any client device that is already paired/trusted, I get the following output:
[bluetooth]# connect 00:1A:7D:DA:71:0A
Attempting to connect to 00:1A:7D:DA:71:0A
[CHG] Device 00:1A:7D:DA:71:0A Connected: yes
Failed to connect: org.bluez.Error.NotAvailable
[CHG] Device 00:1A:7D:DA:71:0A Connected: no
The Bluetooth service output is as follows when I initiate a connection from the Ubuntu side:
Sep 28 03:50:20 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/adapter.c:resume_discovery()
Sep 28 03:50:34 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/device.c:connect_profiles() /org/bluez/hci0/dev_00_1A_7D_DA_71_0A (all), client :1.28
Sep 28 03:50:34 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/device.c:connect_profiles() Resolving services for /org/bluez/hci0/dev_00_1A_7D_DA_71_0A
Sep 28 03:50:35 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/adapter.c:connected_callback() hci0 device 00:1A:7D:DA:71:0A connected eir_len 14
Sep 28 03:50:35 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/device.c:search_cb() 00:1A:7D:DA:71:0A: No service update
Sep 28 03:50:35 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/device.c:device_svc_resolved() /org/bluez/hci0/dev_00_1A_7D_DA_71_0A err 0
Sep 28 03:50:35 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/device.c:connect_profiles() /org/bluez/hci0/dev_00_1A_7D_DA_71_0A (all), client :1.28
Sep 28 03:50:39 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/adapter.c:dev_disconnected() Device 00:1A:7D:DA:71:0A disconnected, reason 2
Sep 28 03:50:39 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/adapter.c:adapter_remove_connection()
Sep 28 03:50:39 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/adapter.c:bonding_attempt_complete() hci0 bdaddr 00:1A:7D:DA:71:0A type 0 status 0xe
Sep 28 03:50:39 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/device.c:device_bonding_complete() bonding (nil) status 0x0e
Sep 28 03:50:39 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/device.c:device_bonding_failed() status 14
The logs for a (successful) connection initiated by a client device:
Sep 28 03:50:39 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/adapter.c:resume_discovery()
Sep 28 04:23:11 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/adapter.c:connected_callback() hci0 device A8:96:75:32:09:E9 connected eir_len 5
Sep 28 04:23:11 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/profiles/network/server.c:confirm_event() BNEP: incoming connect from A8:96:75:32:09:E9
Sep 28 04:23:11 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/profiles/network/bnep.c:bnep_getsuppfeat() supported features: 0x1
Sep 28 04:23:11 Aruba8320Bluetooth bluetoothd[6240]: bnep: bridge bt-pan: interface bnep0 added
Is it possible to achieve a seamless reconnection to a paired Bluetooth device using the NAP profile, or is a manual connection required each time from client devices?
If so, where I am going wrong?