From owner-freebsd-bluetooth@FreeBSD.ORG Sat Mar 21 14:46:21 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 063B7E4D for ; Sat, 21 Mar 2015 14:46:21 +0000 (UTC) Received: from mail-we0-x22a.google.com (mail-we0-x22a.google.com [IPv6:2a00:1450:400c:c03::22a]) (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 7B764E2A for ; Sat, 21 Mar 2015 14:46:20 +0000 (UTC) Received: by wetk59 with SMTP id k59so103230513wet.3 for ; Sat, 21 Mar 2015 07:46:19 -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=9MC3YVWEUZT572mGbnVQ8ONEQHAOkerHy2flavBX3CA=; b=mnqMPm7mlKtH8lTHEtb4/Z6IQmFicKp+Y9GqPK3ITBthSUHvhx2d7ZKPdt8KOBiwHV bRdHbf6MfGV3BTZHkmCe0vEfgk2AQjyINwGbVzkoN/6x4kDCulp9EyQN/FHEGsWITntT kqeezNEWZf1UBkbP58NvKZTUeOtOuWr0AT5ick9/4p0nmi80lMvsyHmH7ydkDbLppxIb tVR8cwjCP5fC//No3+Jwknazw7McutSZtt3dw2Pkb8xNuZF4tPm2dHS7VswQqZpyzHPN wir7uh8bXTTrn98b4S6yeZzq0Vv/AXktcGrumdIrLHAWP2RVo3D9IKlIKg36zPr04DBQ 7gWA== MIME-Version: 1.0 X-Received: by 10.194.187.46 with SMTP id fp14mr83530702wjc.86.1426949179079; Sat, 21 Mar 2015 07:46:19 -0700 (PDT) Received: by 10.27.214.136 with HTTP; Sat, 21 Mar 2015 07:46:18 -0700 (PDT) In-Reply-To: References: <0AD7A2F7-37BE-4F6A-9FD6-F6C81B2CAF36@gmail.com> Date: Sat, 21 Mar 2015 07:46:18 -0700 Message-ID: Subject: Re: register HID with SDP error From: Waitman Gobble To: Maksim Yevmenkin 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: Sat, 21 Mar 2015 14:46:21 -0000 On Thu, Mar 19, 2015 at 1:24 PM, Maksim Yevmenkin wrote: >> Hi, >> >> It's not for production use, but if someone comes across this post in >> the future maybe save a few minutes when tinkering and >> troubleshooting. >> >> I changed the Makefile so it will 'more easily' build as a standalone >> outside /usr/src >> I added the syslog line around ln 324 in server.c - just wanted to see >> that data was coming in. >> >> do { >> len = read(fd, &data, to_read); >> syslog(LOG_ERR,"%s",data.b); >> } while (len < 0 && errno == EINTR); > > ok, thanks. > > so, yes, please check your hid report format. > > this it the input report you should be using (this is taken from your > hid descriptor) > > Input id=1 size=8 count=6 page=Keyboard > usage=Reserved_(no_event_indicated), logical range 0..255 > > so, it means that on-the-wire packet should be 10 bytes > > byte 0: 0xA1 -- bluetooth header > byte 1: 0x01 -- hid report id > byte 2: 0xXX -- bitmask for modifier key pressed, i.e. ctrl, shift, alt, etc. > byte 3: 0x00 -- padding > byte 4: 0xXX -- key code pressed #1 > byte 5: 0xXX -- key code pressed #2 > byte 6: 0xXX -- key code pressed #3 > byte 7: 0xXX -- key code pressed #4 > byte 8: 0xXX -- key code pressed #5 > byte 9: 0xXX -- key code pressed #6 > > hid repot should tell which keys (scan codes 1..6) are pressed > currently, and, which modifier keys are pressed currently (byte 2). if > no keys are pressed currently, then, 0x00 should be used. host should > keep track of which keys were pressed previously, and, effectively > build a press/release logic itself. meaning if hid report N had key > code K, and, hid report N+1 did not have key code K, then it means > that key code K was pressed and subsequently released. > > here is another example that my be easier to understand. suppose we > start with no keys pressed. hid report will look like > > byte 0: 0xA1 > byte 1: 0x01 > byte 2: 0x00 > byte 3: 0x00 > byte 4: 0x00 > byte 5: 0x00 > byte 6: 0x00 > byte 7: 0x00 > byte 8: 0x00 > byte 9: 0x00 > > now, suppose key 'a' was pressed and then released. two hid reports > will go out, i.e. > > byte 0: 0xA1 > byte 1: 0x01 > byte 2: 0x00 > byte 3: 0x00 > byte 4: key code for 'a' key > byte 5: 0x00 > byte 6: 0x00 > byte 7: 0x00 > byte 8: 0x00 > byte 9: 0x00 > > followed by > > byte 0: 0xA1 > byte 1: 0x01 > byte 2: 0x00 > byte 3: 0x00 > byte 4: 0x00 > byte 5: 0x00 > byte 6: 0x00 > byte 7: 0x00 > byte 8: 0x00 > byte 9: 0x00 > > meaning key 'a' was released and no other keys were pressed. > > i hope it makes sense to you. > > thanks, > max Yes, thank you Max, that helps alot. One question, where is "Class" set? I believe this is causing me trouble # hccontrol -n ubt0hci inquiry Inquiry result, num_responses=1 Inquiry result #0 BD_ADDR: 00:1b:dc:06:94:d3 Page Scan Rep. Mode: 0x1 Page Scan Period Mode: 0x2 Page Scan Mode: 00 Class: ff:01:0c Clock offset: 0x2658 Inquiry complete. Status: No error [00] "Class: ff:01:0c" If I understand correctly, this is advertising this machine as a "computer" (actually the "C" is a laptop even though this machine isn't actually a laptop) right? So at the moment I'm announcing (through sdpd) that this is a computer with an 'available' 1124 HID interface. I'm guessing this is why it shows up on other machines as a "computer". I think what I really want to do is advertise the class to be something like 0x540, which I think I understand to be in the peripheral / keyboard class. Thank you, -- Waitman Gobble Los Altos California USA 510-830-7975