Skip to contentSkip to conversation

autopair: Don't handle the iCade

PATCH Applied Bastien Nocera 3 participants 4 messages Sep 4, 2017 – Oct 17, 2017 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 autopair: Don't handle the iCade

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(-)
plugins/autopair.c +12 -1
index d44cf539b..a9d2a930a 100644
@@ -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.
Signature · 1 line
2.14.1
#1 lore raw

Hi Bastien,

Quoted 6 lines · 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.

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

Quoted 21 lines
---
 plugins/autopair.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
plugins/autopair.c +2 -1
index d44cf539b..a9d2a930a 100644
@@ -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));

plugins/autopair.c static ssize_t autopair_pincb(struct btd_adapter *adapter, · line 80

Quoted 10 lines
plugins/autopair.c +10 -0
+	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

Quoted 4 lines
plugins/autopair.c +0 -0
 	/* This is a class-based pincode guesser. Ignore devices with an
 	 * unknown class.
 
#2 lore raw
Quoted 7 lines · ERAMOTO Masaya

Hi Bastien,

Quoted 4 lines · 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.

Quoted 6 lines
Quoted 2 lines

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.

Applied
#3 lore raw
In reply to Bastien Nocera

Hi Bastien,

Quoted 30 lines · 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(-)
plugins/autopair.c +5 -1
index d44cf539b..a9d2a930a 100644
@@ -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",

plugins/autopair.c static ssize_t autopair_pincb(struct btd_adapter · line 83

Quoted 10 lines
plugins/autopair.c +7 -0
+		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.

Signature · 2 lines
pozdrawiam
Szymon Janc