From: Joshua Wright <jwright@hasborg.com>
To: bluez-devel@lists.sourceforge.net
Subject: Re: [Bluez-devel] Reset card
Date: Fri, 19 Aug 2005 12:21:13 -0400 [thread overview]
Message-ID: <430606F9.3060906@hasborg.com> (raw)
In-Reply-To: <1124462989.6398.8.camel@notepaq>
[-- Attachment #1: Type: text/plain, Size: 912 bytes --]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Marcel Holtmann wrote:
> feel free to send me a patch for the bccmd tool that I can include
> into the bluez-utils distribution.
Thanks to all who replied. Simon's code was exactly what was needed,
and the CSR BCCMD documentation was very helpful.
Attached is a patch to automatically reset CSR cards after changing the
BD_ADDR with the bdaddr utility.
Thanks,
- -Josh
- --
- -Joshua Wright
jwright@hasborg.com
2005-2006 pgpkey: http://802.11ninja.net/pgpkey.htm
fingerprint: F00E 7A42 8375 0C55 964F E5A4 4D2F 22F6 3658 A4BF
Today I stumbled across the world's largest hotspot. The SSID is "linksys".
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFDBgb4TS8i9jZYpL8RAqOoAKCPXtduODADCFt6bOt2xofhVEG6oQCg8Bx6
2zYqq5VehC3FpOhPYwyiFgE=
=9B88
-----END PGP SIGNATURE-----
[-- Attachment #2: bdaddr-csr-reset.diff --]
[-- Type: text/plain, Size: 1621 bytes --]
--- bdaddr.c 2005-05-09 14:33:24.000000000 -0400
+++ bdaddr-jlw.c 2005-08-19 12:15:03.000000000 -0400
@@ -103,6 +103,40 @@
}
#endif
+static int csr_cold_reset(int dd)
+{
+ unsigned char cmd[] = { 0x02, 0x00, /* message type */
+ 0x09, 0x00, /* message length */
+ 0x00, 0x00, /* seqno for pairing response */
+ 0x01, 0x40, /* varid for cold reset */
+ 0x00, 0x00, /* status */
+ /* payload follows, must be at least at least
+ 4 uint16s in length accordind to BCCMD */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+ unsigned char cp[254], rp[254];
+ struct hci_request rq;
+
+ memset(&cp, 0, sizeof(cp));
+ cp[0] = 0xc2;
+ memcpy(cp + 1, cmd, sizeof(cmd));
+
+ memset(&rq, 0, sizeof(rq));
+ rq.ogf = OGF_VENDOR_CMD;
+ rq.ocf = 0x00;
+ rq.event = EVT_VENDOR;
+ rq.cparam = cp;
+ rq.clen = sizeof(cmd) + 1;
+ rq.rparam = rp;
+ rq.rlen = sizeof(rp);
+
+ if (hci_send_req(dd, &rq, 2000) < 0)
+ return -1;
+
+ return 0;
+}
+
+
static int csr_write_bd_addr(int dd, bdaddr_t *bdaddr)
{
unsigned char cmd[] = { 0x02, 0x00, 0x0c, 0x00, 0x11, 0x47, 0x03, 0x70,
@@ -291,7 +325,16 @@
exit(1);
}
- printf("Address changed - Reset device now\n");
+ if (ver.manufacturer == 10) { /* CSR devices */
+ if (csr_cold_reset(dd) != 0) {
+ fprintf(stderr, "Error resetting card, remove and insert manually.\n");
+ exit(1);
+ } else {
+ printf("Address changed - card reset successfully\n");
+ }
+ } else { /* non-CSR devices */
+ printf("Address changed - Reset device now\n");
+ }
//ioctl(dd, HCIDEVRESET, dev);
//ioctl(dd, HCIDEVDOWN, dev);
next prev parent reply other threads:[~2005-08-19 16:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-17 19:16 [Bluez-devel] Reset card Joshua Wright
2005-08-19 9:23 ` Ronny L Nilsson
2005-08-19 9:28 ` Simon Vogl
2005-08-19 14:49 ` Marcel Holtmann
2005-08-19 16:21 ` Joshua Wright [this message]
2005-08-21 14:03 ` Marcel Holtmann
2005-08-22 19:20 ` Joshua Wright
2005-08-22 20:42 ` Marcel Holtmann
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=430606F9.3060906@hasborg.com \
--to=jwright@hasborg.com \
--cc=bluez-devel@lists.sourceforge.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.