From owner-freebsd-bluetooth@FreeBSD.ORG Wed Mar 18 18:48:35 2015 Return-Path: Delivered-To: freebsd-bluetooth@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3C5298C0 for ; Wed, 18 Mar 2015 18:48:35 +0000 (UTC) Received: from mail-ig0-x234.google.com (mail-ig0-x234.google.com [IPv6:2607:f8b0:4001:c05::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E5D0C80A for ; Wed, 18 Mar 2015 18:48:34 +0000 (UTC) Received: by igcau2 with SMTP id au2so1109582igc.1 for ; Wed, 18 Mar 2015 11:48:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=0soVcngmuXuz/ocxBkESybasoPpL1ZKn3nUDL7bdqUQ=; b=ZafSlidprcXf4pmtLEMyHV2L1JtMvTidH9mMOVd3If4hgSQJMbgJUpgUArYyNoXMDq jc8+ywlwN0Ly83e7fuTdZ7qeBMy9LjcNmMgL4N3XvGtuW9idj8cXGQrdXTKXlu9GVrJ/ WUA2Yr5YQMcT5AQXkQW1lagbmWuCENL4P/igffU+/GXQOOCwz9jUXgB0+SznXsCvzo7J QXdAk7xAB0I9JTuRzBOROAzlH0mfk/7UYqDfYHFV7VcysMZ22ZU5yRDdBsbuvNh65pfy nEf67qd3BOYCWmlGHMLIieKmzAgL18/a8yGS516vabFObIndWrK8MA/qSQvPqd1+3c1n z2Gg== MIME-Version: 1.0 X-Received: by 10.107.7.141 with SMTP id g13mr96877400ioi.52.1426704514416; Wed, 18 Mar 2015 11:48:34 -0700 (PDT) Received: by 10.36.66.74 with HTTP; Wed, 18 Mar 2015 11:48:34 -0700 (PDT) In-Reply-To: References: <0AD7A2F7-37BE-4F6A-9FD6-F6C81B2CAF36@gmail.com> Date: Wed, 18 Mar 2015 11:48:34 -0700 Message-ID: Subject: Re: register HID with SDP error From: Maksim Yevmenkin To: Waitman Gobble Content-Type: text/plain; charset=UTF-8 Cc: "freebsd-bluetooth@freebsd.org" , Iain Hibbert X-BeenThere: freebsd-bluetooth@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Using Bluetooth in FreeBSD environments List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2015 18:48:35 -0000 [...] > 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 ok... are you also accepting connection on interrupt channel? please recall, i've mentioned that buetooth hid is modeled after usb hid. there are two channels: control and interrupt. > 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 ); hmm.... i don't think its quite correct. all the hid reports should be sent on the interrupt channel (just like usb hid device uses interrupt transfer endpoint to send its reports back to host). if i'm reading your code correctly, newsockfd is an accepted connection on the control socket. i presume you have constructed correct hid report sequence to send too (as per hid descriptor you have given out to remote host via sdp). [...] > # ./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. well, if remote host has connected then, presumably, it has found everything that it needed from sdp. so, i would guess that your sdp records are probably correct. i suspect that you need to sort out your hid reports format and send them via interrupt channel, not control. you also might want to take a look at USBHID(3), specifically hid_set_data(). you can use bthidd(8) code as an example of what host *might* be doing and how host *might* expect data. in fact, you can probably use bthidd(8) to test your virtual hid device. one thing to keep in mind is the initial "handshake" setup. when hid device is "unknown" to host, host must initiate connection to the device first. later, host must respect value of reconnect_initiate attribute, and, if its set, host must wait for hid device to re-connect. this way, say, keyboard may put itself to sleep, and, wake up and reconnect when user presses a button. thanks, max