Bluetoothctl connects and disconnects repeatedly

24,887

try these steps;

  • put the keyboard into pair mode (k380 you would hold the bt key you want to assign the device too)
  • at pi console, run bluetoothctl
  • type power on
  • type agent on
  • type pair 0C:4D:12:11:01:E4
  • type the pair code into the keyboard as prompted
  • type connect 0C:4D:12:11:01:E4
  • type trust 0C:4D:12:11:01:E4
  • type agent off
  • type quit

hopefully you should have a bt keyboard connected. you may have to do additional work to ensure the BT will power on and pair on restart of the device.

you require to enable the agent so that keyboard can do the pair code thingy. some keyboards may vary.

hope this helps.

Share:
24,887

Related videos on Youtube

Jacolack
Author by

Jacolack

Updated on September 18, 2022

Comments

  • Jacolack
    Jacolack over 1 year

    I am using a Raspberry Pi Zero with a Iot pHat and was able to ssh into the Pi using a USB cable using this tutorial. I then set up my home WiFi with the pHat. Then I powered up the Pi with a separate power source. I could then ssh into the Pi wirelessly through my home network.

    Finally to my question. I would like to connect the Pi to a wireless keyboard. I am trying to use the bluetoothctl tool to connect it. When running scan on, the Pi recognizes the keyboard, but when pairing, it won't pair. Here is the terminal session:

    [CHG] Device 0C:4D:12:11:01:E4 Name: Bluetooth Keyboard
    [CHG] Device 0C:4D:12:11:01:E4 Alias: Bluetooth Keyboard
    [bluetooth]# pair 0C:4D:12:11:01:E4
    Attempting to pair with 0C:4D:12:11:01:E4
    [CHG] Device 0C:4D:12:11:01:E4 Connected: yes
    [CHG] Device 0C:4D:12:11:01:E4 Connected: no
    [CHG] Device 0C:4D:12:11:01:E4 Connected: yes
    [CHG] Device 0C:4D:12:11:01:E4 Connected: no
    [CHG] Device 0C:4D:12:11:01:E4 Connected: yes
    [CHG] Device 0C:4D:12:11:01:E4 Connected: no
    [CHG] Device 0C:4D:12:11:01:E4 Connected: yes
    Failed to pair: org.bluez.Error.AuthenticationFailed
    [CHG] Device 0C:4D:12:11:01:E4 Connected: no
    

    As you can see it seems like it connects and disconnects repeatedly.

    • neoedmund
      neoedmund over 2 years
      try remove first, then connect.
  • jimjamslam
    jimjamslam almost 7 years
    Doesn't work for me. The first time I set Bluetooth up, my phone connected using these steps without any problem. But as soon as I restarted the Pi, my phone refused to connect—and it looks like it misreads my Pi's device class too. No idea what's going on :/
  • jimjamslam
    jimjamslam almost 7 years
    [bluetooth]# connect XX:XX:XX:XX:XX:XX Attempting to connect to XX:XX:XX:XX:XX:XX Failed to connect: org.bluez.Error.Failed [CHG] Device XX:XX:XX:XX:XX:XX Connected: yes [CHG] Device XX:XX:XX:XX:XX:XX Connected: no [CHG] Device XX:XX:XX:XX:XX:XX Connected: yes [CHG] Device XX:XX:XX:XX:XX:XX Connected: no
  • Rodislav Moldovan
    Rodislav Moldovan over 3 years
    If connection fails after trusting - connect again to pi and it'll work.
  • new2cpp
    new2cpp about 3 years
    @rensa I have a similiar issue. It resloved after pactl load-module module-bluetooth-discover, which may need askubuntu.com/a/1121417/669610
  • ManuelSchneid3r
    ManuelSchneid3r over 2 years
    Did not work for me either
  • dgeske
    dgeske over 2 years
    This command may help troubleshoot the reason for the disconnect: $ sudo btmon -w pair.bts