Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Mar 2015 11:14:43 -0700
From:      Waitman Gobble <gobble.wa@gmail.com>
To:        Maksim Yevmenkin <maksim.yevmenkin@gmail.com>
Cc:        "freebsd-bluetooth@freebsd.org" <freebsd-bluetooth@freebsd.org>, Iain Hibbert <plunky@ogmig.net>
Subject:   Re: register HID with SDP error
Message-ID:  <CAFuo_fxGgWYp5x=xWbFogj8F8ZMULFQw_HOWZiJ42=vDO7tXnQ@mail.gmail.com>
In-Reply-To: <CAFPOs6rJ_SaKjmXrbr%2Bpa9BoVL2HtjkzoyBo015BFK1QB9ZVsQ@mail.gmail.com>
References:  <CAFuo_fy9xRU2T3GUPY8116yZCUd8sL9pBQ9ixXnMwO56niJFog@mail.gmail.com> <CAFuo_fzdmB79qdoH8P5EcO_ZZoa=_id6h=eqFBXvP_a%2B3WMkLw@mail.gmail.com> <CAFuo_fzB3A5L3vivH7Z80OEoBtVEHftEYE4LUkhnrkguzL5GDA@mail.gmail.com> <CAFuo_fzrk%2BWLXivZrnTsGQD%2BS7mq%2BUSXB7Mn6%2BJT=y64JakGSw@mail.gmail.com> <CAFPOs6q3iVcNthF=S--UgTm=5wA0HM6coqB7AcmCKb=55OWdTQ@mail.gmail.com> <CAFuo_fxgBVKxmzbJs%2B-XDz%2Bu4tb2_i3eYXSa-oiOoU%2BQD6ApwQ@mail.gmail.com> <CAFPOs6r_D7bcGCMP_bP%2BQtZgKt7Oj5jRJ2v872RODekn%2B6xv1Q@mail.gmail.com> <CAFuo_fwPuaD4bYwfZou0RBswZsTmdtVZA1B2GqUdo3ZJJiWRQg@mail.gmail.com> <0AD7A2F7-37BE-4F6A-9FD6-F6C81B2CAF36@gmail.com> <CAFuo_fye5RWNtjsutHa%2BbXL0AYHYRpJxW-b=48o0iMwX227wdA@mail.gmail.com> <alpine.NEB.2.11.1503170658130.4414@galant.ogmig.net> <CAFuo_fx47uRC-eKD_KtsSsrMCQZauyHyCOgRxGbtp_WEZ49o_Q@mail.gmail.com> <CAFPOs6rYXOFPk5_nqXivToUvGRjXDMS=XL60RyKbMQm7nP8wFg@mail.gmail.com> <CAFuo_fw5-YtH_sj3Ft52hpfXEP8QCkweptJzT0eUSos9DoBZ%2BA@mail.gmail.com> <CAFuo_fzSMNvwewpkKxcLr9aHyTcwaVgcreLtexSo=FNzNhC6og@mail.gmail.com> <CAFPOs6rJ_SaKjmXrbr%2Bpa9BoVL2HtjkzoyBo015BFK1QB9ZVsQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Mar 18, 2015 at 10:06 AM, Maksim Yevmenkin
<maksim.yevmenkin@gmail.com> wrote:
> Hello,
>
> [...]
>
>> I think I'm getting close, I finally have a good scan with bthidcontrol
>>
>> Note that bthidcontrol doesn't seem to connect after sdpd is restarted
>> on the server, unless I do sdpcontrol browse first.
>
> hmm... i'm sorry, i do not follow. both bthidcontrol(8) and
> sdpcontrol(8) are using exactly the same way to obtain sdp records. it
> should not make any difference.
>
>
>> #sdpcontrol -a 00:1b:dc:06:94:d3 browse
>
> [...]
>
>> # bthidcontrol -a 00:1b:dc:06:94:d3 query
>
> [...]
>
> this looks better to me.
>
>> latest version at https://github.com/waitman/sdpd/blob/master/hid.c
>
> thanks! i will take a look. few minor nits: attribute list must be
> sorted. when generating protocol descriptor list and additional
> protocol descriptor list, you may re-use one function, i.e. additional
> protocol descriptor list is just a protocol descriptor list wrapped
> into a sequence. you hardwired lots of hid related things. while its
> ok for testing, i feel like it should be moved to parameters so
> clients can set those up as needed.
>
>> I didn't see a "bool(8)" defined in sdp.h, I was thinking maybe it was
>> the same as UINT8 but then I noticed Iain's post that showed a
>> 'bool(8)' as 0x28 instead of 0x08, thank you.
>
> huh? from /usr/include/sdp.h
>
> /* Unsigned integer */
> #define SDP_DATA_UINT8                                  0x08
>
> /* Boolean */
> #define SDP_DATA_BOOL                                   0x28
>
> thanks,
> max

Max,

I'm wrong on both accounts, I'm not sure why I missed the 0x28
definition before and I'm also not sure why yesterday it seemed that
bthidcontrol was not connecting without first doing spdcontrol. But
it's working today. Sorry about my mistake.


I'm working on the hid code. It opens the l2cap control and interrupt
sockets then waits for client connect. When the client connects it
sends the key codes.

very simply,

struct sockaddr_l2cap l2addr, cli_addr;

controlsock = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BLUETOOTH_PROTO_L2CAP);
bind(controlsock, (struct sockaddr *) &l2addr, sizeof(l2addr));

intrsock = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BLUETOOTH_PROTO_L2CAP);
bind(intrsock, (struct sockaddr *) &l2addr, sizeof(l2addr));


clilen = sizeof(cli_addr);
newsockfd = accept(controlsock, (struct sockaddr *) &cli_addr,
&clilen); //blocks until client connect

then loop while reading chars from FIFO:

evkeyb->btcode = 0xA1;
evkeyb->rep_id = REPORTID_KEYBD;
evkeyb->key[0] = retkey(sfifo[i]); //translate to key code
send ( newsockfd, evkeyb,sizeof(struct hidrep_keyb_t),MSG_NOSIGNAL );


The client is connecting (seen in btsockstat)
# btsockstat
Active raw HCI sockets
Socket   PCB      Flags  Recv-Q Send-Q Local address
fffff8003a505000 fffff8011a6bd180 000003      0      0 *
fffff801554418b8 fffff80004765780 000002      0      0 *
Active L2CAP sockets
PCB      Recv-Q Send-Q Local address/PSM       Foreign address   CID   State
fffff8000d2d7100      0      0 00:1b:dc:06:94:d3/19
00:10:60:af:5b:af 157   CLOSED
fffff8000d0a4600      0      0 00:1b:dc:06:94:d3/17
00:10:60:af:5b:af 156   OPEN
fffff8000d2d6000      0      0 *                /19    *
  0     LISTEN
fffff8000d0a7500      0      0 *                /17    *
  0     LISTEN
fffff801a19b8c00      0      0 *                /1     *
  0     LISTEN


# ./hid_sppd
control socket created
interrupt socket created
waiting for connect
waiting for fifo.. press Control-C to exit.
sent data 38 "key 0"
sent data 29 "key 1"
sent data 30 "key 2"
sent data 31 "key 3"
sent data 32 "key 4"
...

...and it's reading the fifo buffer and sending the keys through the
clientfd, but nothing useful is happening on client.. So I think I'm
either doing this wrong, or my SDP record is still incorrect.

Thank you,



-- 
Waitman Gobble
Los Altos California USA
510-830-7975



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFuo_fxGgWYp5x=xWbFogj8F8ZMULFQw_HOWZiJ42=vDO7tXnQ>