Linux bluetooth development
 help / color / mirror / Atom feed
From: David Herrmann <dh.herrmann@googlemail.com>
To: linux-bluetooth@vger.kernel.org
Cc: hadess@hadess.net, marcel@holtmann.org,
	David Herrmann <dh.herrmann@googlemail.com>
Subject: [PATCH 3/3] Support hardcoded Nintendo Wii Remote pins
Date: Sat,  2 Apr 2011 21:51:03 +0200	[thread overview]
Message-ID: <1301773863-16297-4-git-send-email-dh.herrmann@googlemail.com> (raw)
In-Reply-To: <1301773863-16297-1-git-send-email-dh.herrmann@googlemail.com>

The Nintendo Wii Remote requires the destination bluetooth address
as pincode. This changes the pin handling by skipping the agent
module and sending an hardcoded pin if the target device is a
Nintendo Wii Remote.
---
 src/event.c |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/src/event.c b/src/event.c
index 91343d4..ec05e95 100644
--- a/src/event.c
+++ b/src/event.c
@@ -129,6 +129,24 @@ fail:
 	error("Sending PIN code reply failed: %s (%d)", strerror(-err), -err);
 }
 
+static int get_pin(bdaddr_t *sba, bdaddr_t *dba, char *pinbuf)
+{
+	uint16_t vendor, product;
+	char src_addr[18], dst_addr[18];
+
+	ba2str(sba, src_addr);
+	ba2str(dba, dst_addr);
+	if (0 == read_device_id(src_addr, dst_addr, NULL, &vendor, &product, NULL)) {
+		/* Nintendo Wii Remote uses destination address as PIN */
+		if (vendor == 0x057e && product == 0x0306) {
+			memcpy(pinbuf, dba, 6);
+			return 6;
+		}
+	}
+
+	return read_pin_code(sba, dba, pinbuf);
+}
+
 int btd_event_request_pin(bdaddr_t *sba, bdaddr_t *dba)
 {
 	struct btd_adapter *adapter;
@@ -140,7 +158,7 @@ int btd_event_request_pin(bdaddr_t *sba, bdaddr_t *dba)
 		return -ENODEV;
 
 	memset(pin, 0, sizeof(pin));
-	pinlen = read_pin_code(sba, dba, pin);
+	pinlen = get_pin(sba, dba, pin);
 	if (pinlen > 0) {
 		btd_adapter_pincode_reply(adapter, dba, pin, pinlen);
 		return 0;
-- 
1.7.4.2

  parent reply	other threads:[~2011-04-02 19:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-02 19:51 [PATCH 0/3] Support binary pin codes David Herrmann
2011-04-02 19:51 ` [PATCH 1/3] Add length argument to hci pincode reply David Herrmann
2011-04-02 19:51 ` [PATCH 2/3] Make adapter API accept binary pincodes David Herrmann
2011-04-02 19:51 ` David Herrmann [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-04-06 10:04 [PATCH 3/3] Support hardcoded Nintendo Wii Remote pins Daniele Forsi
2011-04-06 10:55 ` David Herrmann
2011-04-06 14:05   ` Daniele Forsi
2011-04-06 14:31     ` Bastien Nocera
2011-04-06 17:55       ` David Herrmann
2011-04-06 18:05         ` Bastien Nocera

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=1301773863-16297-4-git-send-email-dh.herrmann@googlemail.com \
    --to=dh.herrmann@googlemail.com \
    --cc=hadess@hadess.net \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.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