# [SOLVED] [bluetooth] Mouse not reconnecting automatically

## diloo

Hi all,

I'm trying to make my mighty mouse work and I have one big issue. After going idle, or after disconnectiong (by switching it off) the mouse I am not able to get it connected again. My goal is to use the input interface of hcid and not the deprecated (but well described) hidd tool. I'm running the 2.6.30 kernel and using bluez-{libs|utils} 3.36.

The connection of my mouse is OK when using the verbose method described there : http://wiki.bluez.org/wiki/HOWTO/InputDevices.

So I have my mouse registred by the input interface of hcid but now, when I try to reconnect it after idle (by pressing on button) nothing appears in the logs and the mouse does not work...

Here is the dbus-monitor --system output when I try to reconnect

```

signal sender=org.freedesktop.DBus -> dest=:1.32 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired

   string ":1.32"

signal sender=:1.0 -> dest=(null destination) path=/org/bluez/hci0; interface=org.bluez.Adapter; member=RemoteDeviceConnected

   string "00:1E:52:CF:20:15"

signal sender=:1.0 -> dest=(null destination) path=/org/bluez/hci0; interface=org.bluez.Adapter; member=RemoteNameUpdated

   string "00:1E:52:CF:20:15"

   string "Souris de quentin"

signal sender=:1.1 -> dest=(null destination) path=/org/freedesktop/Hal/Manager; interface=org.freedesktop.Hal.Manager; member=DeviceAdded

   string "/org/freedesktop/Hal/devices/bluetooth_acl_1e52cf2015"

signal sender=:1.0 -> dest=(null destination) path=/org/bluez/hci0; interface=org.bluez.Adapter; member=RemoteDeviceDisconnected

   string "00:1E:52:CF:20:15"

signal sender=:1.1 -> dest=(null destination) path=/org/freedesktop/Hal/Manager; interface=org.freedesktop.Hal.Manager; member=DeviceRemoved

   string "/org/freedesktop/Hal/devices/bluetooth_acl_1e52cf2015"

```

Here is the hcidump -V of what's happening when I press a button of my mouse (when it has gone idle) :

```

> HCI Event: Connect Request (0x04) plen 10

    bdaddr 00:1E:52:CF:20:15 class 0x002580 type ACL

< HCI Command: Accept Connection Request (0x01|0x0009) plen 7

    bdaddr 00:1E:52:CF:20:15 role 0x00

    Role: Master

> HCI Event: Command Status (0x0f) plen 4

    Accept Connection Request (0x01|0x0009) status 0x00 ncmd 1

> HCI Event: Role Change (0x12) plen 8

    status 0x00 bdaddr 00:1E:52:CF:20:15 role 0x00

    Role: Master

> HCI Event: Connect Complete (0x03) plen 11

    status 0x00 handle 46 bdaddr 00:1E:52:CF:20:15 type ACL encrypt 0x00

< HCI Command: Read Remote Supported Features (0x01|0x001b) plen 2

    handle 46

> HCI Event: Page Scan Repetition Mode Change (0x20) plen 7

    bdaddr 00:1E:52:CF:20:15 mode 1

> HCI Event: Command Status (0x0f) plen 4

    Read Remote Supported Features (0x01|0x001b) status 0x00 ncmd 1

< HCI Command: Remote Name Request (0x01|0x0019) plen 10

    bdaddr 00:1E:52:CF:20:15 mode 2 clkoffset 0x0000

> HCI Event: Command Status (0x0f) plen 4

    Remote Name Request (0x01|0x0019) status 0x00 ncmd 1

> HCI Event: Read Remote Supported Features (0x0b) plen 11

    status 0x00 handle 46

    Features: 0xbc 0x02 0x04 0x38 0x08 0x00 0x00 0x00

> ACL data: handle 46 flags 0x02 dlen 12

    L2CAP(s): Connect req: psm 17 scid 0x0042

< ACL data: handle 46 flags 0x02 dlen 16

    L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0042 result 1 status 0

      Connection pending - No futher information available

< ACL data: handle 46 flags 0x02 dlen 10

    L2CAP(s): Info req: type 2

> ACL data: handle 46 flags 0x02 dlen 16

    L2CAP(s): Info rsp: type 2 result 0

      Extended feature mask 0x0004

        Bi-directional QoS

< ACL data: handle 46 flags 0x02 dlen 16

    L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0042 result 0 status 0

      Connection successful

> HCI Event: Remote Name Req Complete (0x07) plen 255

    status 0x00 bdaddr 00:1E:52:CF:20:15 name 'Souris de diloo'

> HCI Event: Number of Completed Packets (0x13) plen 5

    handle 46 packets 1

> HCI Event: Number of Completed Packets (0x13) plen 5

    handle 46 packets 1

> HCI Event: Number of Completed Packets (0x13) plen 5

    handle 46 packets 1

> ACL data: handle 46 flags 0x02 dlen 16

    L2CAP(s): Config req: dcid 0x0040 flags 0x00 clen 4

      MTU 185 

< ACL data: handle 46 flags 0x02 dlen 18

    L2CAP(s): Config rsp: scid 0x0042 flags 0x00 result 0 clen 4

      MTU 185 

< ACL data: handle 46 flags 0x02 dlen 12

    L2CAP(s): Config req: dcid 0x0042 flags 0x00 clen 0

> HCI Event: Number of Completed Packets (0x13) plen 5

    handle 46 packets 1

> HCI Event: Number of Completed Packets (0x13) plen 5

    handle 46 packets 1

> ACL data: handle 46 flags 0x02 dlen 18

    L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 0 clen 4

      MTU 185 

> ACL data: handle 46 flags 0x02 dlen 12

    L2CAP(s): Connect req: psm 19 scid 0x0043

< ACL data: handle 46 flags 0x02 dlen 16

    L2CAP(s): Connect rsp: dcid 0x0041 scid 0x0043 result 0 status 0

      Connection successful

> HCI Event: Number of Completed Packets (0x13) plen 5

    handle 46 packets 1

> ACL data: handle 46 flags 0x02 dlen 16

    L2CAP(s): Config req: dcid 0x0041 flags 0x00 clen 4

      MTU 185 

< ACL data: handle 46 flags 0x02 dlen 18

    L2CAP(s): Config rsp: scid 0x0043 flags 0x00 result 0 clen 4

      MTU 185 

< ACL data: handle 46 flags 0x02 dlen 12

    L2CAP(s): Config req: dcid 0x0043 flags 0x00 clen 0

> HCI Event: Number of Completed Packets (0x13) plen 5

    handle 46 packets 1

> HCI Event: Number of Completed Packets (0x13) plen 5

    handle 46 packets 1

> ACL data: handle 46 flags 0x02 dlen 18

    L2CAP(s): Config rsp: scid 0x0041 flags 0x00 result 0 clen 4

      MTU 185 

< ACL data: handle 46 flags 0x02 dlen 12

    L2CAP(s): Disconn req: dcid 0x0042 scid 0x0040

< ACL data: handle 46 flags 0x02 dlen 12

    L2CAP(s): Disconn req: dcid 0x0043 scid 0x0041

> HCI Event: Number of Completed Packets (0x13) plen 5

    handle 46 packets 1

> ACL data: handle 46 flags 0x02 dlen 12

    L2CAP(s): Disconn rsp: dcid 0x0042 scid 0x0040

> HCI Event: QoS Setup Complete (0x0d) plen 21

    status 0x00 handle 46 flags 0

    Service type: 1

    Token rate: 0

    Peak bandwith: 0

    Latency: 12500

    Delay variation: -1

> HCI Event: Number of Completed Packets (0x13) plen 5

    handle 46 packets 1

> ACL data: handle 46 flags 0x02 dlen 12

    L2CAP(s): Disconn rsp: dcid 0x0043 scid 0x0041

> HCI Event: Mode Change (0x14) plen 6

    status 0x00 handle 46 mode 0x02 interval 20

    Mode: Sniff

< HCI Command: Disconnect (0x01|0x0006) plen 3

    handle 46 reason 0x13

    Reason: Remote User Terminated Connection

> HCI Event: Command Status (0x0f) plen 4

    Disconnect (0x01|0x0006) status 0x00 ncmd 1

> HCI Event: Disconn Complete (0x05) plen 4

    status 0x00 handle 46 reason 0x16

    Reason: Connection Terminated by Local Host

```

So, as you can see somewhere near the end of the listing we can see that the local stack is sending a "Disconn req", and this is what I can't understand.

The communication is well established but then closed for an unknown reason.

Thanks for your help !

----------

## diloo

Ok,

after tons of googling/testing I finally found an answer to this issue.

I had to set my device as a trusted one :

dbus-send --print-reply --system --type=method_call --dest=org.bluez /org/bluez/service_input org.bluez.Service.SetTrusted string:XX:XX:XX:XX:XX:XX

I think a little error message from hcid (bluez) would be nice in order not to search the source of the problem during hours !

----------

