Find the answer to your Linux question:
Results 1 to 4 of 4
I can connect my bluetooth keyboard manually just fine - and it works like a charm. My problem is that i can't get it to connect during boot. Archlinux / ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux User ImNeat's Avatar
    Join Date
    Feb 2006
    Location
    N. America
    Posts
    392

    Enable bluetooth keyboard at boot


    I can connect my bluetooth keyboard manually just fine - and it works like a charm. My problem is that i can't get it to connect during boot.

    Archlinux / Fluxbox / Dell Inspiron 1420N / Logitech BT Keyboard

    What I did to configure the bt keyboard:
    -installed bluez-utils
    -added my keyboard's name/mac to file '/etc/bluetooth/hcid.conf'
    -enabled laptop's bluetooth device with command 'hciconfig hci0 up'
    -connected the device using the command 'hidd --search'

    What I've done to try and get the keyboard to connect during boot:
    -added the command 'hciconfig hci0 up' to file '/etc/rc.local' so the laptop's bt device is enabled
    -added 'hcid' and 'hidd' to modules array in file '/etc/rc.conf'
    -added 'bluetooth' to daemons arrary in file '/etc/rc.conf'
    -added ' HIDD_ENABLE="true" ' to file '/etc/rc.d/bluetooth'
    -added ' HIDD_OPTIONS="--connect <keyboard mac>" ' to file 'etc/rc.d/bluetooth'
    -added 'HIDD_ENABLED=1' to file /etc/default/bluetooth'
    -added ' HIDD_OPTIONS="--master --connect <keyboard mac> --server" ' to file '/etc/default/bluetooth'

    Nothing seems to work. The keyboard never connects at boot. Anyone know what I need to do to get this working?

    Very many thanks in advance.
    10" Sony Vaio SRX99P 850MHz P3-M 256MB RAM 20GB HD : ArchLinux
    14" Dell Inspiron 1420N 2GHz Core2Duo 2GB RAM 160GB HD : Xubuntu

  2. #2
    Linux User ImNeat's Avatar
    Join Date
    Feb 2006
    Location
    N. America
    Posts
    392
    Well, I think I have the boot thing figured out. I pretty much started from scratch, clearing out everything I did before. I then changed the '/etc/bluetooth/hcid.conf' to:
    Code:
    # HCI daemon configuration file.
    
    # HCId options
    options {
            # Automatically initialize new devices
            autoinit yes;
    
            # Security Manager mode
            #   none - Security manager disabled
            #   auto - Use local PIN for incoming connections
            #   user - Always ask user for a PIN
            #
            security user;
    
            # Pairing mode
            #   none  - Pairing disabled
            #   multi - Allow pairing with already paired devices
            #   once  - Pair once and deny successive attempts
            pairing multi;
    
            # Default PIN code for incoming connections
            #passkey "0000";
    
            # D-Bus PIN helper
            #dbus_pin_helper;
    }
    
    # Default settings for HCI devices
    device {
            # Local device name
            #   &#37;d - device id
            #   %h - host name
            name "inspiron (%d)";
    
            # Local device class
            class 0x000100;
    
            # Default packet type
            pkt_type DH1,DM1,HV1;
    
            # Inquiry and Page scan
            iscan enable; pscan enable;
    
            # Default link mode
            #   none   - no specific policy
            #   accept - always accept incoming connections
            #   master - become master on incoming connections,
            #            deny role switch on outgoing connections
            lm master;
    
            # Default link policy
        #   none    - no specific policy
            #   rswitch - allow role switch
            #   hold    - allow hold mode
            #   sniff   - allow sniff mode
            #   park    - allow park mode
            lp rswitch,hold,sniff,park;
    }
    I changed my '/etc/rc.local' to
    Code:
    #!/bin/bash
    #
    # /etc/rc.local: Local multi-user startup script.
    #
    hciconfig hci0 up &
    sleep 1
    hidd --connect 00:07:61:C4:98:21
    and I click the pairing button on my keyboard when the laptop is starting up and the local commands initiate.

    The keyboard now works at boot and can be used to log in!

    I have found another problem though: after a few minutes of inactivity the keyboard goes to sleep - this deactivates the pairing - and I need to repair them with the hidd --connect command. Sigh.

    Any ideas? How do I keep them paired through sleep, or re-pair them without having to type a command?

    Thanks!
    10" Sony Vaio SRX99P 850MHz P3-M 256MB RAM 20GB HD : ArchLinux
    14" Dell Inspiron 1420N 2GHz Core2Duo 2GB RAM 160GB HD : Xubuntu

  3. #3
    Linux User ImNeat's Avatar
    Join Date
    Feb 2006
    Location
    N. America
    Posts
    392
    ok... I've made some strides I'll document here.

    I was on the wrong path before. I shouldn't have duct taped my system by adding those commands to /etc/rc.local

    Instead, I needed to add dbus and bluetooth to daemons in /etc/rc.conf. That enabled the hci0 device and started the hcid/hidd daemons.

    Next, all the howtos on this are generally for Debian-based systems, hence why they have people alter /etc/default/bluetooth in order to keep the device paired. Arch doesn't follow this mold - instead the actual daemon should be altered, e.g. changes are made directly to /etc/rc.d/bluetooth.

    I added HIDD_ENABLE="true" and HIDD_OPTIONS="--master --connect 00:00:00:00:00:00 --server" to /etc/rc.d/bluetooth.

    Now everything is together as it should be, conformed to arch. I just need to wait around to see if the keyboard auto-pairs correctly now. *fingers crossed*

    For further reference: here are my files with noted items bolded

    /etc/rc.d/bluetooth
    Code:
    #!/bin/sh
    #
    # Start/stop the Bluetooth daemons
    #
    
    . /etc/rc.conf
    . /etc/rc.d/functions
    
    DAEMON_NAME="hcid"
    HID2HCI_NAME="hid2hci"
    SDPD_NAME="sdpd"
    HIDD_NAME="hidd"
    RFCOMM_NAME="rfcomm"
    PAND_NAME="pand"
    DUND_NAME="dund"
    
    DAEMON_EXEC="/usr/sbin/hcid"
    HID2HCI_EXEC="/usr/sbin/hid2hci"
    SDPD_EXEC="/usr/sbin/sdpd"
    HIDD_EXEC="/usr/bin/hidd"
    RFCOMM_EXEC="/usr/bin/rfcomm"
    PAND_EXEC="/usr/bin/pand"
    DUND_EXEC="/usr/bin/dund"
    
    DAEMON_ENABLE="true"
    HID2HCI_ENABLE="false"
    SDPD_ENABLE="false"
    HIDD_ENABLE="true"
    RFCOMM_ENABLE="false"
    DUND_ENABLE="false"
    PAND_ENABLE="false"
    
    DAEMON_CONFIG="/etc/bluetooth/hcid.conf"
    RFCOMM_CONFIG="/etc/bluetooth/rfcomm.conf"
    
    HIDD_OPTIONS="--master --connect XX:XX:XX:XX:XX:XX <- your MAC here> --server"
    DUND_OPTIONS="--listen --persist"
    PAND_OPTIONS=""
    
    [ -f /etc/conf.d/bluetooth ] && . /etc/conf.d/bluetooth
    
    case "$1" in
      start)
        stat_busy "Starting bluetooth subsystem:"
        if [ "$DAEMON_ENABLE" = "true" -a -x "$DAEMON_EXEC" -a -f "$DAEMON_CONFIG" ] ; then
          stat_append " $DAEMON_NAME"
          if [ "$SDPD_ENABLE" = "true" ]; then
            $DAEMON_EXEC -f $DAEMON_CONFIG
          else
            $DAEMON_EXEC -s -f $DAEMON_CONFIG
          fi
        fi
    ..........removed for length........
        stat_append " $HIDD_NAME"
        killall $HIDD_NAME >/dev/null 2>&1
    
        stat_append " $SDPD_NAME"
        killall $SDPD_NAME >/dev/null 2>&1
    
        stat_append " $DAEMON_NAME"
        killall $DAEMON_NAME >/dev/null 2>&1
    
        rm_daemon bluetooth
        stat_done
        ;;
      restart)
        $0 stop
        sleep 1
        $0 start
        ;;
      *)
        echo "usage: $0 {start|stop|restart}"
    esac
    exit 0
    /etc/bluetooth/hcid.conf
    Code:
    #
    # HCI daemon configuration file.
    #
    
    # HCId options
    options {
            # Automatically initialize new devices
            autoinit yes;
    
            # Security Manager mode
            #   none - Security manager disabled
            #   auto - Use local PIN for incoming connections
            #   user - Always ask user for a PIN
            #
            security auto;
    
            # Pairing mode
            #   none  - Pairing disabled
            #   multi - Allow pairing with already paired devices
            #   once  - Pair once and deny successive attempts
            pairing multi;
    
            # Default PIN code for incoming connections
            #passkey "0000";
    
            # D-Bus PIN helper
            #dbus_pin_helper;
    }
    
    # Default settings for HCI devices
    device {
            # Local device name
            #   &#37;d - device id
            #   %h - host name
            name "%h-%d";
    
            # Local device class
            class 0x000100;
    
            # Default packet type
            #pkt_type DH1,DM1,HV1;
    
            # Inquiry and Page scan
            iscan enable; pscan enable;
            discovto 0;
    
            # Default link mode
            #   none   - no specific policy
            #   accept - always accept incoming connections
            #   master - become master on incoming connections,
            #            deny role switch on outgoing connections
            lm accept;
    
            # Default link policy
            #   none    - no specific policy
            #   rswitch - allow role switch
            #   hold    - allow hold mode
            #   sniff   - allow sniff mode
            #   park    - allow park mode
            lp rswitch,hold,sniff,park;
    }
    
    device XX:XX:XX:XX:XX:XX {
    name "DEVICE NAME";
    auth enable;
    encrypt enable;
    }
    /etc/rc.conf
    Code:
    #
    # /etc/rc.conf - Main Configuration for Arch Linux
    #
    
    # -----------------------------------------------------------------------
    # LOCALIZATION
    # -----------------------------------------------------------------------
    #
    # LOCALE: available languages can be listed with the 'locale -a' command
    # HARDWARECLOCK: set to "UTC" or "localtime"
    # USEDIRECTISA: use direct I/O requests instead of /dev/rtc for hwclock
    # TIMEZONE: timezones are found in /usr/share/zoneinfo
    # KEYMAP: keymaps are found in /usr/share/kbd/keymaps
    # CONSOLEFONT: found in /usr/share/kbd/consolefonts (only needed for non-US)
    # CONSOLEMAP: found in /usr/share/kbd/consoletrans
    # USECOLOR: use ANSI color sequences in startup messages
    #
    LOCALE="en_US.utf8"
    HARDWARECLOCK="localtime"
    USEDIRECTISA="yes"
    TIMEZONE="Canada/Pacific"
    KEYMAP="us"
    CONSOLEFONT=
    CONSOLEMAP=
    USECOLOR="yes"
    
    # -----------------------------------------------------------------------
    # HARDWARE
    # -----------------------------------------------------------------------
    #
    # MOD_AUTOLOAD: Allow autoloading of modules at boot and when needed
    # MOD_BLACKLIST: Prevent udev from loading these modules
    # MODULES: Modules to load at boot-up. Prefix with a ! to blacklist.
    #
    # NOTE: Use of 'MOD_BLACKLIST' is deprecated. Please use ! in the MODULES array.
    #
    MOD_AUTOLOAD="yes"
    #MOD_BLACKLIST=() #deprecated
    MODULES=(tg3 !iwl3945 ipw3945 snd-mixer-oss snd-pcm-oss snd-hwdep snd-page-alloc snd-pcm snd-timer snd snd-hda-intel soundcore)
    ..........removed for length........
    
    # -----------------------------------------------------------------------
    # DAEMONS
    # -----------------------------------------------------------------------
    #
    # Daemons to start at boot-up (in this order)
    #   - prefix a daemon with a ! to disable it
    #   - prefix a daemon with a @ to start it up in the background
    #
    DAEMONS=(syslog-ng netfs crond ipw3945d autofs dbus bluetooth)
    10" Sony Vaio SRX99P 850MHz P3-M 256MB RAM 20GB HD : ArchLinux
    14" Dell Inspiron 1420N 2GHz Core2Duo 2GB RAM 160GB HD : Xubuntu

  4. $spacer_open
    $spacer_close
  5. #4
    Linux User ImNeat's Avatar
    Join Date
    Feb 2006
    Location
    N. America
    Posts
    392
    Everything is working perfectly. After having the computer and keyboard off all night, I just turned them both on and booted the computer. I was able to log in using the keyboard without doing anything.

    The pacakges I installed were:
    bluez-libs
    bluez-utils
    bluez-gnome & gnome-bluetooth (one of these helps with hid2hci)
    10" Sony Vaio SRX99P 850MHz P3-M 256MB RAM 20GB HD : ArchLinux
    14" Dell Inspiron 1420N 2GHz Core2Duo 2GB RAM 160GB HD : Xubuntu

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •