From owner-freebsd-bluetooth@FreeBSD.ORG Wed Apr 22 18:26: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 A871F4E5 for ; Wed, 22 Apr 2015 18:26:21 +0000 (UTC) Received: from mail-ig0-x22f.google.com (mail-ig0-x22f.google.com [IPv6:2607:f8b0:4001:c05::22f]) (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 71ABA1301 for ; Wed, 22 Apr 2015 18:26:21 +0000 (UTC) Received: by iget9 with SMTP id t9so623098ige.1 for ; Wed, 22 Apr 2015 11:26:20 -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=vX8/P67RCyaFz1nxaBw5maiUcpBZLN7U3LVlaeSeeug=; b=rVTF/x0oWWTdXiIGYdi9e0gGkNKy9h6QTeyDqdyAfR2REAmcxkh27ar9yLQ0NoEvFi rlGYUD7485vBAdEpjA3vJ4+R+wE62vw/ZTs/V0s6G0rmqBmsSHyuCt3iEsrVF+Ku7k6W h241xUCdyvXaMX9Vdlq1VXLca4likLKt3nSYmeFGSZGllzel7B+mOrdbIsGSPx5S5sX/ Fxy3RpIo2AQrk2ZNmwRFpDI9gPuEiHwW8rbYHXeiOLEQ8D/KHKJ+mlGj7myAxopO4r85 SfdQXe7pIVbJNiP2yRKm+Mu7jm1VUyuUOOs7wVS5Sjz2XJwVRAGQpTzRib3z/0ZI33h2 x4Tg== MIME-Version: 1.0 X-Received: by 10.43.63.76 with SMTP id xd12mr11563592icb.11.1429727180895; Wed, 22 Apr 2015 11:26:20 -0700 (PDT) Received: by 10.36.66.17 with HTTP; Wed, 22 Apr 2015 11:26:20 -0700 (PDT) In-Reply-To: References: Date: Wed, 22 Apr 2015 11:26:20 -0700 Message-ID: Subject: Re: question about bthidd client.c From: Maksim Yevmenkin To: Waitman Gobble Cc: "freebsd-bluetooth@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-bluetooth@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Using Bluetooth in FreeBSD environments List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Apr 2015 18:26:21 -0000 On Wed, Apr 22, 2015 at 11:17 AM, Maksim Yevmenkin wrote: >>>> I notice that if bthidd is running, and bluetooth is not active, or >>>> the configured host is out of range, the client_rescan() function >>>> generates new vkbd devices every 20 seconds or so. I believe this will >>>> eventually lock up the machine. >>>> >>> >>> may be... usually devices will reconnect, i.e. reconnect_initiate >>> would be 1. however, this is a known problem. for whatever reason >>> "cloned" devices are not completely going away when closed. similar >>> problem exists with other "cloned" devices. its not bthidd or >>> bluetooth code specific. >> >> Thanks for the reply. Is there a better way to decide if a device is >> 'connectable'? It looks like a chicken-and-egg kind of problem, since > > device tells host who is supposed to initiate reconnect (in sdp > attribute). normally, devices will initiate reconnect. host should not > be required to constantly "poll". there is no easy way to know if > device is "connectable". inquiry may tell you if device is in range > but only if device is in "discoverable" mode. most devices will only > go into discoverable mode during pairing. > >> the connect routine uses the established vkbd device. I am thinking >> that attempting to connect to the device on psm 1 is a way to verify >> that the host is connectable in the first place, before creating a new >> vkbd. Or, maybe the new vkbd can be destroyed on failure... but maybe >> this would cause other problems. > > there should not be any problem. cloned device is created on open() > and should be destroyed on close(). the simplest solution to this problem is to add a configuration parameter that specifies vkbd unit number for each entry. this way, the same device (i.e. keyboard) will always use the same vkbd. no more endless cloning. thanks, max