Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 03 Mar 2003 10:39:18 -0800
From:      Maksim Yevmenkin <myevmenk@exodus.net>
To:        Dustin Boontheekul <dboonthe@math.okstate.edu>
Cc:        freebsd-current@FreeBSD.ORG
Subject:   Re: FreeBSD Bluetooth stuff
Message-ID:  <3E63A156.5000001@exodus.net>
References:  <45258A4365C6B24A9832BFE224837D552B1295@sjdcex01.int.exodus.net> <Pine.BSO.4.53.0303021727210.19641@mail.math.okstate.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
Hello Dustin,

>>1) compile and install hcidump from the snapshot's ports/ directory
> 
> Recompiled and reinstalled.  All went fine.

good

>>2) make sure you have clean setup, i.e.
>>   - run # rc.bluetooth stop <device>
>>   - disconnect the device from the PC
>>   - reset mouse
>>   - connect device back to PC
>>   - run # rc.bluetooth start <device>
>>   - in separate window run # hcidump -x
>>   - run # hccontrol -n <device>hci inquiry
>>   - run # sdptool browse <BD_ADDR_of_your_mouse>
> 
> I followed this sequence.  One thing to note is that the mouse tries it's
> best to conserve power, so it only responds to any initial queries for a
> few seconds after pressing the reset button.  I don't know exactly how
> long, but it's pretty short.  Klausler makes a note of this on his site,
> so it must have caused him a hiccup or two.

hmmm... if your mouse drains batteries so fast for how you long
can you use it?

> Okay, here it is.  Turns out I think my batteries ran out of juice, which
> was causing some of the problems.  I wasn't getting any response at all
> after all sorts of resets so I tried seeing if I could find the keyboard
> and it 'just worked'.  I replaced the batteries and got a response from
> hccontrol inquiry.  Just in case replacing the batteries turned out to
> reset it more than pressing the button I put the old batteries back in and
> still got nothing.  When the batteries 'die' the mouse still lights up
> (it's optical), and apparently the radio connection goes first.  Anyway,
> without further adue here is the hcidump output:

> # hcidump -x

[ inquiry part skipped ]

> < HCI Command: Create Connection(0x01|0x0005) plen 13
>   A8 D6 7E F2 50 00 18 CC 02 00 C3 4B 01
> 
>>HCI Event: Command Status(0x0f) plen 4
>   00 01 05 04
> 
>>HCI Event: Connect Complete(0x03) plen 11
>   00 29 00 A8 D6 7E F2 50 00 01 00

baseband connection is now open

> < HCI Command: Write Link Policy Settings(0x02|0x000d) plen 4
>   29 00 0F 00
> < ACL data: handle 0x0029 flags 0x02 dlen 12
>     L2CAP(s): Connect req: psm 1 scid 0x0040
>>HCI Event: Number of Completed Packets(0x13) plen 5
>   01 29 00 01 00
>>HCI Event: Command Complete(0x0e) plen 6
>   01 0D 08 00 29 00
>>ACL data: handle 0x0029 flags 0x02 dlen 16
>     L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0040 result 1 status 2

this is you PC adjusts link policy settings and request L2CAP
connection on PSM 1 (which is SDP)

>>ACL data: handle 0x0029 flags 0x02 dlen 16
>     L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0040 result 0 status 0
> < ACL data: handle 0x0029 flags 0x02 dlen 12
>     L2CAP(s): Config req: dcid 0x0040 flags 0x0000 clen 0
>>HCI Event: Number of Completed Packets(0x13) plen 5
>   01 29 00 01 00
>>ACL data: handle 0x0029 flags 0x02 dlen 14
>     L2CAP(s): Config rsp: scid 0x0040 flags 0x0000 result 0 clen 0
>>ACL data: handle 0x0029 flags 0x02 dlen 16
>     L2CAP(s): Config req: dcid 0x0040 flags 0x0000 clen 4
>     MTU 48

here your PC tries to configure L2CAP channel (incoming path)
and mouse agrees. after that mouse tries to configure incoming
L2CAP channel and sets incoming MTU to 48 bytes. so far no
problems.

>>HCI Event: QoS Setup Complete(0x0d) plen 21
>   00 29 00 00 01 00 00 00 00 00 00 00 00 F2 2B 00 00 FF FF FF
>   FF

oh! i have never seen any device using this :) your mouse
actually wants to set QoS (Quality Of Service). anyway the
status is 00 - success, so no problem here.

> < ACL data: handle 0x0029 flags 0x02 dlen 14
>     L2CAP(s): Config rsp: scid 0x0040 flags 0x0000 result 0 clen 0

and this is your PC agress to use proposed L2CAP configuration.
So L2CAP connection is open and there was no problem.

> < ACL data: handle 0x0029 flags 0x02 dlen 24
>     L2CAP(d): cid 0x40 len 20 [psm 1]
>         SDP SSA Req: tid 0x0 len 0xf
>           pat uuid-16 0x1002 (PubBrwsGrp)
>           max 0xffff
>           aid(s) 0x0000 - 0xffff
>           cont 00
> 
>>HCI Event: Number of Completed Packets(0x13) plen 5
>   01 29 00 01 00
>>HCI Event: Number of Completed Packets(0x13) plen 5
>   01 29 00 01 00

now sdptool sends SDP browse request to your mouse to figure
out which services are available.

>>ACL data: handle 0x0029 flags 0x02 dlen 14
>     L2CAP(d): cid 0x40 len 10 [psm 1]
>         SDP SSA Rsp: tid 0x0 len 0x5
>           cnt 0x2
>  len 0x2 frm->len 0x1 n 0x0
>           cont 00

... and the mouse returns nothing back to us :(

> < ACL data: handle 0x0029 flags 0x02 dlen 12
>     L2CAP(s): Disconn req: dcid 0x0040 scid 0x0040
>>HCI Event: Number of Completed Packets(0x13) plen 5
>   01 29 00 01 00
>>ACL data: handle 0x0029 flags 0x02 dlen 12
>     L2CAP(s): Disconn rsp: dcid 0x0040 scid 0x0040

and at this point sdptool is done and closes the L2CAP
connection.

bottom line: baseband + L2CAP works. you can talk to your
mouse. SDP does not return anything. possible problems:

1) mouse does not fully implement SDP. it is assumed that you have
    to know "magic" PSM for interrupt and control channel on the mouse.

2) SDP interoperability problem

one thing you could try is to ask mouse for the specific service,
rather then for all services. you can do it by

# sdptool search --bdaddr <BD_ADDR> HID

Note: HID is the service you looking for. BD_ADDR is the address
of your mouse.

>>do you have an open baseband connection? inquiry on the local deivce
>>will not show remote devices that already connected to the local device.
>>try to run
>>
>># hccontrol -n <device>hci read_connection_list
>>
> Yes, this shows I have a connection to my mouse.

that explains why moused does not respond to inquiry anymore.

>>you can disconnect baseband connection by hand by typing
>>
>># hccontol -n <device>hci disconnect <connection_handle>
>>
>>BTW you can do
>>
>># hccontrol help
>>
>>and
>>
>># hccontrol help <command>
>>
>>for more information
>>
> These give a lot more help than the man page.

from the hccontrol(8) man page:

command
              One of the supported commands (see below). Special command
              ``help'' can be used to obtain the list of all supported
              commands. To get more information about specific command
              use ``help command''.

> I managed to get 'remote_name_request' to return 'Microsoft Mouse'
> (yippee!), but I just arbitrarily chose <ps_rep_mode> and <ps_mode> as 0.
> I used 'read_clock_offset' to get the clock offset.  What are these 2
> options and how would I properly find them?

well, you have to read Bluetooth spec :) but i can tell you right now
that in this case it is safe to use 0 for all of them :)

Page Scan Mode 0 - is mandatory page scan mode
Clock Offset - it is always safe to set this to 0. If you set it
it *may* speed up page procedure.

perhaps i should change hccontrol(8) so it will use defaults if user
does not provide overrides.

thanks,
max


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3E63A156.5000001>