linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bastien Nocera <hadess@hadess.net>
To: linux-bluetooth@vger.kernel.org
Cc: Bastien Nocera <hadess@hadess.net>
Subject: [PATCH] autopair: Add more common PIN codes for audio devices
Date: Fri,  3 Nov 2017 11:55:42 +0100	[thread overview]
Message-ID: <20171103105542.1271-1-hadess@hadess.net> (raw)

PIN codes "1111", and "1234" are fairly common PIN codes used for audio
devices such as speakers and headsets. This replaces similar quirks
already present in gnome-bluetooth's PIN database.
---
 plugins/autopair.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/plugins/autopair.c b/plugins/autopair.c
index 6980b0a64..70e19930e 100644
--- a/plugins/autopair.c
+++ b/plugins/autopair.c
@@ -92,10 +92,20 @@ static ssize_t autopair_pincb(struct btd_adapter *adapter,
 		case 0x06:		/* Headphones */
 		case 0x07:		/* Portable Audio */
 		case 0x0a:		/* HiFi Audio Device */
-			if (attempt > 1)
-				return 0;
-			memcpy(pinbuf, "0000", 4);
-			return 4;
+			{
+				const char *pincodes[] = {
+					"0000",
+					"1234",
+					"1111"
+				};
+				const char *pincode;
+
+				if (attempt > G_N_ELEMENTS(pincodes))
+					return 0;
+				pincode = pincodes[attempt - 1];
+				memcpy(pinbuf, pincode, strlen(pincode));
+				return strlen(pincode);
+			}
 		}
 		break;
 
-- 
2.14.3


                 reply	other threads:[~2017-11-03 10:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171103105542.1271-1-hadess@hadess.net \
    --to=hadess@hadess.net \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).