linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] autopair: Don't handle the iCade
@ 2013-12-09 17:08 Bastien Nocera
  0 siblings, 0 replies; 5+ messages in thread
From: Bastien Nocera @ 2013-12-09 17:08 UTC (permalink / raw)
  To: linux-bluetooth


We can't easily enter digits other than 1 through 4 (inclusive)
so leave it up to the agent to figure out a good passcode
for the iCade.

Note that we can not use the VID/PID of the device, as it is not
yet known at that point.
---
 plugins/autopair.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/plugins/autopair.c b/plugins/autopair.c
index 8c98c12..5d2f6f7 100644
--- a/plugins/autopair.c
+++ b/plugins/autopair.c
@@ -57,13 +57,23 @@ static ssize_t autopair_pincb(struct btd_adapter *adapter,
 {
 	char addr[18];
 	char pinstr[7];
+	char name[25];
 	uint32_t class;
 
 	ba2str(device_get_address(device), addr);
 
 	class = btd_device_get_class(device);
 
-	DBG("device %s 0x%x", addr, class);
+	device_get_name(device, name, sizeof(name));
+	name[sizeof(name) - 1] = 0;
+
+	DBG("device %s (%s) 0x%x", addr, name, class);
+
+	g_message ("vendor 0x%X product: 0x%X", btd_device_get_vendor (device), btd_device_get_product (device));
+
+	/* The iCade shouldn't use random PINs like normal keyboards */
+	if (name != NULL && strstr(name, "iCade") != NULL)
+		return 0;
 
 	/* This is a class-based pincode guesser. Ignore devices with an
 	 * unknown class.
-- 
1.8.4.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] autopair: Don't handle the iCade
@ 2017-09-04 17:54 Bastien Nocera
  2017-09-07  7:46 ` ERAMOTO Masaya
  2017-10-17  9:53 ` Szymon Janc
  0 siblings, 2 replies; 5+ messages in thread
From: Bastien Nocera @ 2017-09-04 17:54 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Bastien Nocera

We can't easily enter digits other than 1 through 4 (inclusive)
so leave it up to the agent to figure out a good passcode
for the iCade.

Note that we can not use the VID/PID of the device, as it is not
yet known at that point.
---
 plugins/autopair.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/plugins/autopair.c b/plugins/autopair.c
index d44cf539b..a9d2a930a 100644
--- a/plugins/autopair.c
+++ b/plugins/autopair.c
@@ -60,13 +60,24 @@ static ssize_t autopair_pincb(struct btd_adapter *adapter,
 {
 	char addr[18];
 	char pinstr[7];
+	char name[25];
 	uint32_t class;
 
 	ba2str(device_get_address(device), addr);
 
 	class = btd_device_get_class(device);
 
-	DBG("device %s 0x%x", addr, class);
+	device_get_name(device, name, sizeof(name));
+	name[sizeof(name) - 1] = 0;
+
+	DBG("device '%s' (%s) class: 0x%x vid/pid: 0x%X/0x%X",
+		name, addr, class,
+		btd_device_get_vendor (device),
+		btd_device_get_product (device));
+
+	/* The iCade shouldn't use random PINs like normal keyboards */
+	if (name != NULL && strstr(name, "iCade") != NULL)
+		return 0;
 
 	/* This is a class-based pincode guesser. Ignore devices with an
 	 * unknown class.
-- 
2.14.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] autopair: Don't handle the iCade
  2017-09-04 17:54 Bastien Nocera
@ 2017-09-07  7:46 ` ERAMOTO Masaya
  2017-09-07 12:05   ` Bastien Nocera
  2017-10-17  9:53 ` Szymon Janc
  1 sibling, 1 reply; 5+ messages in thread
From: ERAMOTO Masaya @ 2017-09-07  7:46 UTC (permalink / raw)
  To: Bastien Nocera, linux-bluetooth

Hi Bastien,

On 09/05/2017 02:54 AM, Bastien Nocera wrote:
> We can't easily enter digits other than 1 through 4 (inclusive)
> so leave it up to the agent to figure out a good passcode
> for the iCade.
> 
> Note that we can not use the VID/PID of the device, as it is not
> yet known at that point.

Does not the device class of iCade include its unique value or a value 
for similar devices?

> ---
>  plugins/autopair.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/plugins/autopair.c b/plugins/autopair.c
> index d44cf539b..a9d2a930a 100644
> --- a/plugins/autopair.c
> +++ b/plugins/autopair.c
> @@ -60,13 +60,24 @@ static ssize_t autopair_pincb(struct btd_adapter *adapter,
>  {
>  	char addr[18];
>  	char pinstr[7];
> +	char name[25];
>  	uint32_t class;
>  
>  	ba2str(device_get_address(device), addr);
>  
>  	class = btd_device_get_class(device);
>  
> -	DBG("device %s 0x%x", addr, class);
> +	device_get_name(device, name, sizeof(name));
> +	name[sizeof(name) - 1] = 0;
> +
> +	DBG("device '%s' (%s) class: 0x%x vid/pid: 0x%X/0x%X",
> +		name, addr, class,
> +		btd_device_get_vendor (device),
> +		btd_device_get_product (device));
> +
> +	/* The iCade shouldn't use random PINs like normal keyboards */
> +	if (name != NULL && strstr(name, "iCade") != NULL)
> +		return 0;

If there is not a value identified as iCade in the device class, 
I think that it is better to use simply device->name instead of 
copying since the full device name is used.


Regards,
Eramoto

>  
>  	/* This is a class-based pincode guesser. Ignore devices with an
>  	 * unknown class.
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] autopair: Don't handle the iCade
  2017-09-07  7:46 ` ERAMOTO Masaya
@ 2017-09-07 12:05   ` Bastien Nocera
  0 siblings, 0 replies; 5+ messages in thread
From: Bastien Nocera @ 2017-09-07 12:05 UTC (permalink / raw)
  To: ERAMOTO Masaya, linux-bluetooth

On Thu, 2017-09-07 at 16:46 +0900, ERAMOTO Masaya wrote:
> Hi Bastien,
> 
> On 09/05/2017 02:54 AM, Bastien Nocera wrote:
> > We can't easily enter digits other than 1 through 4 (inclusive)
> > so leave it up to the agent to figure out a good passcode
> > for the iCade.
> > 
> > Note that we can not use the VID/PID of the device, as it is not
> > yet known at that point.
> 
> Does not the device class of iCade include its unique value or a
> value 
> for similar devices?

No, the iCade is configured as a keyboard so it can be paired with
Apple iOS devices which only recognise keyboards. Each keypress and key
release is a separate keyboard key press/release.

In mainline Linux, you can find the hid-icade driver that'll take care
of transforming those key presses and key releases into joypad events:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/hid/hid-icade.c

As we don't want the autopair keyboard to generate impossible to "type"
numbers, we need to do this somewhere else. It's done in gnome-
bluetooth's pairing agent as the device was deemed too niche to have
this handled in bluez. We still need the quirk however.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] autopair: Don't handle the iCade
  2017-09-04 17:54 Bastien Nocera
  2017-09-07  7:46 ` ERAMOTO Masaya
@ 2017-10-17  9:53 ` Szymon Janc
  1 sibling, 0 replies; 5+ messages in thread
From: Szymon Janc @ 2017-10-17  9:53 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-bluetooth

Hi Bastien,

On Monday, 4 September 2017 19:54:46 CEST Bastien Nocera wrote:
> We can't easily enter digits other than 1 through 4 (inclusive)
> so leave it up to the agent to figure out a good passcode
> for the iCade.
> 
> Note that we can not use the VID/PID of the device, as it is not
> yet known at that point.
> ---
>  plugins/autopair.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/plugins/autopair.c b/plugins/autopair.c
> index d44cf539b..a9d2a930a 100644
> --- a/plugins/autopair.c
> +++ b/plugins/autopair.c
> @@ -60,13 +60,24 @@ static ssize_t autopair_pincb(struct btd_adapter
> *adapter, {
>  	char addr[18];
>  	char pinstr[7];
> +	char name[25];
>  	uint32_t class;
> 
>  	ba2str(device_get_address(device), addr);
> 
>  	class = btd_device_get_class(device);
> 
> -	DBG("device %s 0x%x", addr, class);
> +	device_get_name(device, name, sizeof(name));
> +	name[sizeof(name) - 1] = 0;
> +
> +	DBG("device '%s' (%s) class: 0x%x vid/pid: 0x%X/0x%X",
> +		name, addr, class,
> +		btd_device_get_vendor (device),
> +		btd_device_get_product (device));
> +
> +	/* The iCade shouldn't use random PINs like normal keyboards */
> +	if (name != NULL && strstr(name, "iCade") != NULL)
> +		return 0;
> 
>  	/* This is a class-based pincode guesser. Ignore devices with an
>  	 * unknown class.

Applied, thanks.

-- 
pozdrawiam
Szymon Janc

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-10-17  9:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-09 17:08 [PATCH] autopair: Don't handle the iCade Bastien Nocera
  -- strict thread matches above, loose matches on Subject: below --
2017-09-04 17:54 Bastien Nocera
2017-09-07  7:46 ` ERAMOTO Masaya
2017-09-07 12:05   ` Bastien Nocera
2017-10-17  9:53 ` Szymon Janc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).