Apple Keyboard A1016 Pairing Fails – Troubleshooting Guide

bluemanbluetoothkeyboardsettings

I cannot pair a wireless a1016 Apple keyboard to my Dell XPS laptop which runs Ubuntu 17.10.

I've seen these threads, instructions from them don't help in my case:
Pair Apple Wireless Keyboard 3rd gen with Ubuntu 16.04? and
Apple Wireless Keyboard won't connect in 15.10

I tried via System Settings GUI, where the device is listed as "Not set up". I click on it, then sometimes, after I press a button on the bluetooth keyboard, I get the PIN request window. I type the requested PIN then Enter but then either nothing happens (most often) or the window is refreshed and a new PIN is requested.

I also tried via terminal (bluetoothctl command prompt), tried to trust the device and then connect/pair, without any luck. The error is either ConnectionFailed or AuthenticationTimeout. Tried with blueman package which seems to be a GUI for bluetoothctl. No luck.

Same keyboard pairs flawlessly with iMac, so it's not a hardware issue. Thoughts?

UPD: logs from bluetoothd & hcidump for various types of attempts, maybe that can help

Attempting to connect from bluetoothctl:

Bluetoothd logs:

Apr  4 09:44:35 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:connect_profiles() /org/bluez/hci0/dev_00_0A_95_3B_3B_4D (all), client :1.138
Apr  4 09:44:35 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:connect_profiles() Resolving services for /org/bluez/hci0/dev_00_0A_95_3B_3B_4D
Apr  4 09:44:39 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:pin_code_request_callback() hci0 00:0A:95:3B:3B:4D
Apr  4 09:44:39 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:new_auth() Requesting agent authentication for 00:0A:95:3B:3B:4D
Apr  4 09:44:39 victor-XPS-13-9360 bluetoothd[8782]: src/agent.c:agent_ref() 0x55cc48f0fbb0: ref=2
Apr  4 09:45:07 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:connect_failed_callback() hci0 00:0A:95:3B:3B:4D status 8
Apr  4 09:45:07 victor-XPS-13-9360 bluetoothd[8782]: plugins/policy.c:conn_fail_cb() status 8
Apr  4 09:45:07 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 00:0A:95:3B:3B:4D type 0 status 0x8
Apr  4 09:45:07 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_bonding_complete() bonding (nil) status 0x08
Apr  4 09:45:07 victor-XPS-13-9360 bluetoothd[8782]: src/agent.c:send_cancel_request() Sending Cancel request to :1.469, /org/bluez/agent
Apr  4 09:45:07 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_cancel_authentication() Canceling authentication request for 00:0A:95:3B:3B:4D
Apr  4 09:45:07 victor-XPS-13-9360 bluetoothd[8782]: src/agent.c:agent_unref() 0x55cc48f0fbb0: ref=1
Apr  4 09:45:07 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_bonding_failed() status 8
Apr  4 09:45:07 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:resume_discovery()
Apr  4 09:45:07 victor-XPS-13-9360 bluetoothd[8782]: 00:0A:95:3B:3B:4D: error updating services: Function not implemented (38)
Apr  4 09:45:07 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_svc_resolved() /org/bluez/hci0/dev_00_0A_95_3B_3B_4D err -38

hcidump:

> HCI Event: Command Status (0x0f) plen 4
    Create Connection (0x01|0x0005) status 0x00 ncmd 1
> HCI Event: Connect Complete (0x03) plen 11
    status 0x22 handle 6 bdaddr 00:0A:95:3B:3B:4D type ACL encrypt 0x00
    Error: LMP Response Timeout

Attempting to setup device from KDE bluetooth panel plugin:

bluetoothd logs:

Apr  4 09:46:22 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:remove_temp_devices() /org/bluez/hci0
Apr  4 09:46:22 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_remove() Removing device /org/bluez/hci0/dev_E4_04_12_F1_3D_BB
Apr  4 09:46:22 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:btd_device_unref() Freeing device /org/bluez/hci0/dev_E4_04_12_F1_3D_BB
Apr  4 09:46:22 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_free() 0x55cc48f36280
Apr  4 09:46:22 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_remove() Removing device /org/bluez/hci0/dev_4C_49_E3_C2_E1_A2
Apr  4 09:46:22 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:btd_device_unref() Freeing device /org/bluez/hci0/dev_4C_49_E3_C2_E1_A2
Apr  4 09:46:22 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_free() 0x55cc48f37b50
Apr  4 09:46:42 victor-XPS-13-9360 bluetoothd[8782]: src/agent.c:agent_ref() 0x55cc48f1e590: ref=1
Apr  4 09:46:42 victor-XPS-13-9360 bluetoothd[8782]: src/agent.c:register_agent() agent :1.531
Apr  4 09:46:42 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:start_discovery() sender :1.531
Apr  4 09:46:42 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:update_discovery_filter()
Apr  4 09:46:42 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:discovery_filter_to_mgmt_cp()
Apr  4 09:46:42 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:trigger_start_discovery()
Apr  4 09:46:42 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:cancel_passive_scanning()
Apr  4 09:46:42 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:start_discovery_timeout()
Apr  4 09:46:42 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:start_discovery_timeout() adapter->current_discovery_filter == 0
Apr  4 09:46:43 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:start_discovery_complete() status 0x00
Apr  4 09:46:43 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:discovering_callback() hci0 type 7 discovering 1 method 0
Apr  4 09:46:43 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:device_found_callback() hci0 addr 39:28:52:C3:A3:C8, rssi -68 flags 0x0004 eir_len 31
Apr  4 09:46:43 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:device_found_callback() hci0 addr 5C:49:7D:A2:66:AD, rssi -78 flags 0x0004 eir_len 28
Apr  4 09:46:44 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:device_found_callback() hci0 addr 5C:49:7D:A2:62:C0, rssi -80 flags 0x0000 eir_len 31
Apr  4 09:46:44 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:device_found_callback() hci0 addr 5C:49:7D:A2:66:AD, rssi -79 flags 0x0004 eir_len 28
Apr  4 09:46:44 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:device_found_callback() hci0 addr E4:04:12:F1:3D:BB, rssi -70 flags 0x0000 eir_len 13
Apr  4 09:46:44 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_create() dst E4:04:12:F1:3D:BB
Apr  4 09:46:44 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_new() address E4:04:12:F1:3D:BB
Apr  4 09:46:44 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_new() Creating device /org/bluez/hci0/dev_E4_04_12_F1_3D_BB
Apr  4 09:46:44 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_set_legacy() legacy 0
Apr  4 09:46:44 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_set_rssi_with_delta() rssi -70
Apr  4 09:46:44 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_set_flags() flags 6
Apr  4 09:46:44 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:device_found_callback() hci0 addr 5C:49:7D:A2:62:C0, rssi -79 flags 0x0000 eir_len 31
Apr  4 09:46:44 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:device_found_callback() hci0 addr 39:28:52:C3:A3:C8, rssi -71 flags 0x0004 eir_len 31
Apr  4 09:46:45 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:device_found_callback() hci0 addr 5C:49:7D:A2:66:AD, rssi -78 flags 0x0004 eir_len 28
Apr  4 09:46:45 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:device_found_callback() hci0 addr F4:F5:D8:E5:03:59, rssi -80 flags 0x0004 eir_len 38
Apr  4 09:46:46 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:stop_discovery() sender :1.531
Apr  4 09:46:46 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:stop_discovery_complete() status 0x00
Apr  4 09:46:46 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:trigger_passive_scanning()
Apr  4 09:46:46 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:discovery_remove() owner :1.531
Apr  4 09:46:46 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_set_rssi_with_delta() rssi 0
Apr  4 09:46:46 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:discovering_callback() hci0 type 7 discovering 0 method 0
Apr  4 09:46:46 victor-XPS-13-9360 bluetoothd[8782]: src/agent.c:agent_ref() 0x55cc48f1e590: ref=2
Apr  4 09:46:46 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:bonding_request_new() Requesting bonding for 00:0A:95:3B:3B:4D
Apr  4 09:46:46 victor-XPS-13-9360 bluetoothd[8782]: src/agent.c:agent_ref() 0x55cc48f1e590: ref=3
Apr  4 09:46:46 victor-XPS-13-9360 bluetoothd[8782]: src/agent.c:agent_unref() 0x55cc48f1e590: ref=2
Apr  4 09:46:46 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:suspend_discovery()
Apr  4 09:46:46 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:adapter_bonding_attempt() hci0 bdaddr 00:0A:95:3B:3B:4D type 0 io_cap 0x01
Apr  4 09:46:51 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:connect_failed_callback() hci0 00:0A:95:3B:3B:4D status 4
Apr  4 09:46:51 victor-XPS-13-9360 bluetoothd[8782]: plugins/policy.c:conn_fail_cb() status 4
Apr  4 09:46:51 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 00:0A:95:3B:3B:4D type 0 status 0x4
Apr  4 09:46:51 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_bonding_complete() bonding 0x55cc48f13ef0 status 0x04
Apr  4 09:46:51 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_bonding_failed() status 4
Apr  4 09:46:51 victor-XPS-13-9360 bluetoothd[8782]: src/agent.c:agent_unref() 0x55cc48f1e590: ref=1
Apr  4 09:46:51 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:resume_discovery()
Apr  4 09:46:51 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:pair_device_complete() Connect Failed (0x04)
Apr  4 09:46:51 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 00:0A:95:3B:3B:4D type 0 status 0x4
Apr  4 09:46:51 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_bonding_complete() bonding (nil) status 0x04
Apr  4 09:46:51 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_bonding_failed() status 4
Apr  4 09:46:51 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:resume_discovery()

hcidump:

> HCI Event: Command Complete (0x0e) plen 4
    LE Set Random Address (0x08|0x0005) ncmd 1
    status 0x00
> HCI Event: Command Complete (0x0e) plen 4
    LE Set Scan Parameters (0x08|0x000b) ncmd 1
    status 0x00
> HCI Event: Command Complete (0x0e) plen 4
    LE Set Scan Enable (0x08|0x000c) ncmd 1
    status 0x00
> HCI Event: Command Complete (0x0e) plen 4
    LE Set Scan Enable (0x08|0x000c) ncmd 1
    status 0x00
> HCI Event: Command Status (0x0f) plen 4
    Create Connection (0x01|0x0005) status 0x00 ncmd 1
> HCI Event: Connect Complete (0x03) plen 11
    status 0x04 handle 7 bdaddr 00:0A:95:3B:3B:4D type ACL encrypt 0x00
    Error: Page Timeout

Pair from bluetoothctl.

bluetoothd logs:

Apr  4 09:49:05 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:pair_device_complete() Connect Failed (0x04)
Apr  4 09:49:05 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 00:0A:95:3B:3B:4D type 0 status 0x4
Apr  4 09:49:05 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_bonding_complete() bonding (nil) status 0x04
Apr  4 09:49:05 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_bonding_failed() status 4
Apr  4 09:49:05 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:resume_discovery()
Apr  4 09:49:11 victor-XPS-13-9360 bluetoothd[8782]: src/agent.c:agent_ref() 0x55cc48f0fbb0: ref=2
Apr  4 09:49:11 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:bonding_request_new() Requesting bonding for 00:0A:95:3B:3B:4D
Apr  4 09:49:11 victor-XPS-13-9360 bluetoothd[8782]: src/agent.c:agent_ref() 0x55cc48f0fbb0: ref=3
Apr  4 09:49:11 victor-XPS-13-9360 bluetoothd[8782]: src/agent.c:agent_unref() 0x55cc48f0fbb0: ref=2
Apr  4 09:49:11 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:suspend_discovery()
Apr  4 09:49:11 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:adapter_bonding_attempt() hci0 bdaddr 00:0A:95:3B:3B:4D type 0 io_cap 0x04
Apr  4 09:49:13 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:pin_code_request_callback() hci0 00:0A:95:3B:3B:4D
Apr  4 09:49:13 victor-XPS-13-9360 bluetoothd[8782]: plugins/autopair.c:autopair_pincb() device 'Toetsenbord van duckuyk' (00:0A:95:3B:3B:4D) class: 0x2540 vid/pid: 0x0/0x0
Apr  4 09:49:13 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:new_auth() Requesting agent authentication for 00:0A:95:3B:3B:4D
Apr  4 09:49:13 victor-XPS-13-9360 bluetoothd[8782]: src/agent.c:agent_ref() 0x55cc48f0fbb0: ref=3
Apr  4 09:49:13 victor-XPS-13-9360 bluetoothd[8782]: src/agent.c:agent_display_pincode() Calling Agent.DisplayPinCode: name=:1.469, path=/org/bluez/agent, pincode=567546
Apr  4 09:49:13 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:btd_adapter_pincode_reply() hci0 addr 00:0A:95:3B:3B:4D pinlen 6
Apr  4 09:49:13 victor-XPS-13-9360 bluetoothd[8782]: src/agent.c:agent_unref() 0x55cc48f0fbb0: ref=2
Apr  4 09:49:13 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:connect_failed_callback() hci0 00:0A:95:3B:3B:4D status 5
Apr  4 09:49:13 victor-XPS-13-9360 bluetoothd[8782]: plugins/policy.c:conn_fail_cb() status 5
Apr  4 09:49:13 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_cancel_authentication() Canceling authentication request for 00:0A:95:3B:3B:4D
Apr  4 09:49:13 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 00:0A:95:3B:3B:4D type 0 status 0x5
Apr  4 09:49:13 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_bonding_attempt_retry() scheduling retry
Apr  4 09:49:13 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:pair_device_complete() Authentication Failed (0x05)
Apr  4 09:49:13 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 00:0A:95:3B:3B:4D type 0 status 0x5
Apr  4 09:49:16 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_bonding_retry() retrying bonding
Apr  4 09:49:16 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:adapter_bonding_attempt() hci0 bdaddr 00:0A:95:3B:3B:4D type 0 io_cap 0x04
Apr  4 09:49:22 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:connect_failed_callback() hci0 00:0A:95:3B:3B:4D status 4
Apr  4 09:49:22 victor-XPS-13-9360 bluetoothd[8782]: plugins/policy.c:conn_fail_cb() status 4
Apr  4 09:49:22 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 00:0A:95:3B:3B:4D type 0 status 0x4
Apr  4 09:49:22 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_bonding_complete() bonding 0x55cc48f12f20 status 0x04
Apr  4 09:49:22 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_bonding_failed() status 4
Apr  4 09:49:22 victor-XPS-13-9360 bluetoothd[8782]: src/agent.c:agent_unref() 0x55cc48f0fbb0: ref=1
Apr  4 09:49:22 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:resume_discovery()
Apr  4 09:49:22 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:pair_device_complete() Connect Failed (0x04)
Apr  4 09:49:22 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:bonding_attempt_complete() hci0 bdaddr 00:0A:95:3B:3B:4D type 0 status 0x4
Apr  4 09:49:22 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_bonding_complete() bonding (nil) status 0x04
Apr  4 09:49:22 victor-XPS-13-9360 bluetoothd[8782]: src/device.c:device_bonding_failed() status 4
Apr  4 09:49:22 victor-XPS-13-9360 bluetoothd[8782]: src/adapter.c:resume_discovery()

hcidump:

> HCI Event: Command Status (0x0f) plen 4
    LE Create Connection (0x08|0x000d) status 0x00 ncmd 1
> HCI Event: Command Status (0x0f) plen 4
    LE Read Remote Used Features (0x08|0x0016) status 0x00 ncmd 1
> HCI Event: Command Status (0x0f) plen 4
    Disconnect (0x01|0x0006) status 0x00 ncmd 1
> HCI Event: Disconn Complete (0x05) plen 4
    status 0x00 handle 7 reason 0x16
    Reason: Connection Terminated by Local Host
> HCI Event: Command Status (0x0f) plen 4
    Create Connection (0x01|0x0005) status 0x00 ncmd 1
> HCI Event: Connect Complete (0x03) plen 11
    status 0x04 handle 8 bdaddr 00:0A:95:3B:3B:4D type ACL encrypt 0x00
    Error: Page Timeout
> HCI Event: Command Status (0x0f) plen 4

Best Answer

I don't have a Dell XPS nor am I using Ubuntu, but I have paired the Apple Wireless Keyboard model A1016 with a bluetooth dongle on Debian 9.9 (stretch) using bluetoothctl.

  1. Turn off keyboard. Keyboard will work with rechargeables, but better to use fresh batteries.

  2. Run bluetoothctl. Enter the following commands.

power on

agent KeyboardOnly

default-agent

pairable on

  1. Turn on the keyboard. Its light will pulse 2x, pause, pulse 2x, pause, and repeat.

  2. Enter the following commands in bluetoothctl.

scan on

  1. Wait for the "Apple Wireless Keyboard" to show up. Note the MAC address. Let's say it is 00:0A:95:33:33:33.

  2. Enter the following command into bluetoothctl.

connect 00:0A:95:33:33:33

  1. On the keyboard, blindly type 12345678 and hit the return key.

  2. A message prompt in bluetoothctl will appear.

[agent] Enter PIN code:

Type 12345678 and hit the enter key into this prompt in bluetoothctl.

  1. bluetoothctl should show messages saying the keyboard is paired. (xxxxxx may be unique to you)
[CHG] Device 00:0A:95:33:33:33 Paired: yes
[CHG] Device 00:0A:95:33:33:33 Connected: yes
[CHG] Device 00:0A:95:33:33:33 Modalias: usb:xxxxxxxxxxxx
[CHG] Device 00:0A:95:33:33:33 UUIDs: xxxxxxxxxxx
[CHG] Device 00:0A:95:33:33:33 UUIDs: xxxxxxxxxxx
[CHG] Device 00:0A:95:33:33:33 ServicesResolved: yes
Connection successful
  1. Enter the following commands into bluetoothctl to stop the pairing process:

scan off

pairable off

  1. Confirm the keyboard is in the list of paired devices in bluetoothctl:

paired-devices

Related Question