* [Bluez-devel] Reset card
@ 2005-08-17 19:16 Joshua Wright
2005-08-19 9:23 ` Ronny L Nilsson
0 siblings, 1 reply; 8+ messages in thread
From: Joshua Wright @ 2005-08-17 19:16 UTC (permalink / raw)
To: bluez-devel
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I'd like to programatically reset my CSR USB dongle after running
"bdaddr" from bluez-utils, but I haven't found a way to do that (short
of manually removing and inserting the dongle).
I tried "hciconfig hci0 reset", but this does not reflect the changes
from the bdaddr utility, even after hciconfig down/up. I also tried
"hcitool -i hci0 cmd 0x03 0x0003" (OGF_HOST_CTL, OCF_RESET), but had the
same results with "hciconfig hci0 reset".
I even tried to detach the device manually with libusb and usb_reset()
and usb_detach_kernel_driver_np(). The former causes BlueZ to become
intermittent with the USB dongle until I run a "hciconfig hci0 reset",
but still no BD_ADDR change until I manually remove and reinsert the
card. The latter causes the system to ignore the USB dongle until I
manually remove and re-insert.
Any suggestions? Many 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
iD8DBQFDA40LTS8i9jZYpL8RAjYoAKCITpoODWDNaJSgCQNbz7UqRk8tuQCfRR2R
H1Dboc+GfktjC33pzhXxG0s=
=knrV
-----END PGP SIGNATURE-----
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Bluez-devel] Reset card
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
0 siblings, 1 reply; 8+ messages in thread
From: Ronny L Nilsson @ 2005-08-19 9:23 UTC (permalink / raw)
To: bluez-devel
> I'd like to programatically reset my CSR USB dongle after running
> "bdaddr" from bluez-utils, but I haven't found a way to do that
> (short of manually removing and inserting the dongle).
Hi
This MAY perhaps be possible using a CSR proprietary BCCMD reset
command. There is no support for it (yet) in BlueZ though since it's
not widely asked for (what I know of).
Regards
/Ronny
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Bluez-devel] Reset card
2005-08-19 9:23 ` Ronny L Nilsson
@ 2005-08-19 9:28 ` Simon Vogl
2005-08-19 14:49 ` Marcel Holtmann
0 siblings, 1 reply; 8+ messages in thread
From: Simon Vogl @ 2005-08-19 9:28 UTC (permalink / raw)
To: bluez-devel
there's a little reset utility on my page, as I needed this as well:
http://www.soft.uni-linz.ac.at/_wiki/tiki-index.php?page=3DProjectBluezHa=
ndsfree
Look at the end of the page and use at your own risk :)
Simon
Ronny L Nilsson wrote:
>>I'd like to programatically reset my CSR USB dongle after running
>>"bdaddr" from bluez-utils, but I haven't found a way to do that
>>(short of manually removing and inserting the dongle).
>=20
>=20
> Hi
> This MAY perhaps be possible using a CSR proprietary BCCMD reset=20
> command. There is no support for it (yet) in BlueZ though since it's=20
> not widely asked for (what I know of).
>=20
> Regards
> /Ronny
>=20
>=20
>=20
>=20
>=20
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Pract=
ices
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing &=
QA
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5=
sf
> _______________________________________________
> Bluez-devel mailing list
> Bluez-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/bluez-devel
--=20
_______________________________________________________________________
Dr. Simon Vogl
ARC Seibersdorf research GmbH
Research Studios Austria, Studio Pervasive Computing Applications
Altenberger Stra=DFe 69, A-4040 Linz, Austria
Tel: +43 732 2468-8517, Fax: +43 732 2468-8426
mailto: simon.vogl@researchstudio.at
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Bluez-devel] Reset card
2005-08-19 9:28 ` Simon Vogl
@ 2005-08-19 14:49 ` Marcel Holtmann
2005-08-19 16:21 ` Joshua Wright
0 siblings, 1 reply; 8+ messages in thread
From: Marcel Holtmann @ 2005-08-19 14:49 UTC (permalink / raw)
To: bluez-devel
Hi Simon,
> there's a little reset utility on my page, as I needed this as well:
> http://www.soft.uni-linz.ac.at/_wiki/tiki-index.php?page=ProjectBluezHandsfree
> Look at the end of the page and use at your own risk :)
feel free to send me a patch for the bccmd tool that I can include into
the bluez-utils distribution.
Regards
Marcel
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Bluez-devel] Reset card
2005-08-19 14:49 ` Marcel Holtmann
@ 2005-08-19 16:21 ` Joshua Wright
2005-08-21 14:03 ` Marcel Holtmann
0 siblings, 1 reply; 8+ messages in thread
From: Joshua Wright @ 2005-08-19 16:21 UTC (permalink / raw)
To: bluez-devel
[-- 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);
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Bluez-devel] Reset card
2005-08-19 16:21 ` Joshua Wright
@ 2005-08-21 14:03 ` Marcel Holtmann
2005-08-22 19:20 ` Joshua Wright
0 siblings, 1 reply; 8+ messages in thread
From: Marcel Holtmann @ 2005-08-21 14:03 UTC (permalink / raw)
To: bluez-devel
Hi Joshua,
> > 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.
I modified it a little bit to make it more generic, but it is in the CVS
now. Feel free to test it. Do I get also a patch for bccmd for a reset
command and a patch for decoding this command in hcidump?
Regards
Marcel
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Bluez-devel] Reset card
2005-08-21 14:03 ` Marcel Holtmann
@ 2005-08-22 19:20 ` Joshua Wright
2005-08-22 20:42 ` Marcel Holtmann
0 siblings, 1 reply; 8+ messages in thread
From: Joshua Wright @ 2005-08-22 19:20 UTC (permalink / raw)
To: bluez-devel
[-- Attachment #1: Type: text/plain, Size: 1107 bytes --]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Marcel Holtmann wrote:
> I modified it a little bit to make it more generic, but it is in the CVS
> now. Feel free to test it. Do I get also a patch for bccmd for a reset
> command and a patch for decoding this command in hcidump?
Why, yes! Attached is a patch to add decoding for hcidump, and a few
extras for bccmd. I added "disabletx", "enabletx" and "rand", as well
as "coldreset" to bccmd.
Note that coldreset will be decoded in hcidump properly, but hcidump
dies shortly afterward when it isn't getting a response from the card
during reset.
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
iD8DBQFDCiV3TS8i9jZYpL8RAusWAKC6bYjtEyvQDTvzulJNWdH2h6gyyQCeNtrI
L+FfgUfB+pCBKi8ZWfCYKDY=
=XBJy
-----END PGP SIGNATURE-----
[-- Attachment #2: bccmd-extras.diff --]
[-- Type: text/plain, Size: 3921 bytes --]
diff -ru bluez-utils-2.19/tools/bccmd.c bluez-utils-2.19-jlw/tools/bccmd.c
--- bluez-utils-2.19/tools/bccmd.c 2005-07-03 19:12:08.000000000 -0400
+++ bluez-utils-2.19-jlw/tools/bccmd.c 2005-08-22 14:42:31.000000000 -0400
@@ -129,16 +129,53 @@
return 0;
}
+static int cmd_disabletx(int dd, int argc, char *argv[])
+{
+ return csr_write_varid_uint16(dd, 0, CSR_VARID_DISABLE_TX, 0, 0);
+}
+
+static int cmd_enabletx(int dd, int argc, char *argv[])
+{
+ return csr_write_varid_uint16(dd, 0, CSR_VARID_ENABLE_TX, 0, 0);
+}
+
+static int cmd_coldreset(int dd, int argc, char *argv[])
+{
+ return csr_write_varid_uint16(dd, 0, CSR_VARID_COLD_RESET, 0, 0);
+}
+
+static int cmd_rand(int dd, int argc, char *argv[])
+{
+ uint16_t error = 0;
+ int err;
+
+ err = csr_read_varid_uint16(dd, 5, CSR_VARID_RAND, &error);
+ if (err < 0) {
+ errno = -err;
+ return -1;
+ }
+
+ printf("Random number: 0x%02x (%d)\n", error, error);
+
+ return 0;
+}
+
+
+
static struct {
char *str;
int (*func)(int dd, int argc, char **argv);
char *arg;
char *doc;
} commands[] = {
- { "keylen", cmd_keylen, "<handle>", "Get current crypt key length" },
- { "clock", cmd_clock, "", "Get local Bluetooth clock" },
- { "panicarg", cmd_panicarg, "", "Get panic code argument" },
- { "faultarg", cmd_faultarg, "", "Get fault code argument" },
+ { "keylen", cmd_keylen, "<handle>", "Get current crypt key length" },
+ { "clock", cmd_clock, "", "Get local Bluetooth clock" },
+ { "panicarg", cmd_panicarg, "", "Get panic code argument" },
+ { "faultarg", cmd_faultarg, "", "Get fault code argument" },
+ { "coldreset", cmd_coldreset, "", "Perform cold reset" },
+ { "disabletx", cmd_disabletx, "", "Disable TX on the device" },
+ { "enabletx", cmd_enabletx, "", "Enable TX on the device" },
+ { "rand", cmd_rand, "", "Obtain a random number" },
{ NULL },
};
diff -ru bluez-utils-2.19/tools/csr.c bluez-utils-2.19-jlw/tools/csr.c
--- bluez-utils-2.19/tools/csr.c 2005-07-18 20:12:37.000000000 -0400
+++ bluez-utils-2.19-jlw/tools/csr.c 2005-08-22 14:41:47.000000000 -0400
@@ -668,3 +668,53 @@
return 0;
}
+
+
+int csr_write_varid_uint16(int dd, uint16_t seqnum, uint16_t varid, uint16_t value, int chkresp)
+{
+ unsigned char cmd[] = { 0x02, 0x00,
+ 0x09, 0x00,
+ seqnum & 0xff, seqnum >> 8,
+ varid & 0xff, varid >> 8,
+ 0x00, 0x00, // status
+ 0x00, 0x00, // payload
+ 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);
+
+ /* Only check for a response if the BCCMD warrants it. Reset does not. */
+ if (chkresp) {
+ if (hci_send_req(dd, &rq, 2000) < 0)
+ return -1;
+
+ if (rp[0] != 0xc2) {
+ errno = EIO;
+ return -1;
+ }
+
+ if ((rp[9] + (rp[10] << 8)) != 0) {
+ errno = ENXIO;
+ return -1;
+ }
+ } else {
+ hci_send_req(dd, &rq, 2000);
+ }
+
+ return 0;
+}
diff -ru bluez-utils-2.19/tools/csr.h bluez-utils-2.19-jlw/tools/csr.h
--- bluez-utils-2.19/tools/csr.h 2005-07-03 17:19:51.000000000 -0400
+++ bluez-utils-2.19-jlw/tools/csr.h 2005-08-22 14:37:26.000000000 -0400
@@ -81,3 +81,4 @@
int csr_read_pskey_complex(int dd, uint16_t seqnum, uint16_t pskey, uint8_t *value, uint16_t length);
int csr_read_pskey_uint16(int dd, uint16_t seqnum, uint16_t pskey, uint16_t *value);
int csr_write_pskey_uint16(int dd, uint16_t seqnum, uint16_t pskey, uint16_t value);
+int csr_write_varid_uint16(int dd, uint16_t seqnum, uint16_t varid, uint16_t value, int chkresp);
[-- Attachment #3: hcidump-bccmd-extras.diff --]
[-- Type: text/plain, Size: 974 bytes --]
Only in bluez-hcidump-1.24-jlw/: Makefile
Only in bluez-hcidump-1.24-jlw/: config.h
Only in bluez-hcidump-1.24-jlw/: config.log
Only in bluez-hcidump-1.24-jlw/: config.status
Only in bluez-hcidump-1.24-jlw/parser: .csr.c.swp
Only in bluez-hcidump-1.24-jlw/parser: Makefile
diff -ru bluez-hcidump-1.24/parser/csr.c bluez-hcidump-1.24-jlw/parser/csr.c
--- bluez-hcidump-1.24/parser/csr.c 2005-07-03 17:19:51.000000000 -0400
+++ bluez-hcidump-1.24-jlw/parser/csr.c 2005-08-22 15:05:24.000000000 -0400
@@ -214,6 +214,15 @@
case 0x3008:
handle_length_dump(level + 1, "CRYPT_KEY_LENGTH", frm);
break;
+ case 0x4001:
+ uint16_dump(level + 1, "COLD_RESET", frm);
+ break;
+ case 0x4007:
+ uint16_dump(level + 1, "ENABLE_TX", frm);
+ break;
+ case 0x4008:
+ uint16_dump(level + 1, "DISABLE_TX", frm);
+ break;
case 0x481c:
uint16_dump(level + 1, "MAP_SCO_PCM", frm);
break;
Only in bluez-hcidump-1.24-jlw/src: Makefile
Only in bluez-hcidump-1.24-jlw/: stamp-h1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Bluez-devel] Reset card
2005-08-22 19:20 ` Joshua Wright
@ 2005-08-22 20:42 ` Marcel Holtmann
0 siblings, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2005-08-22 20:42 UTC (permalink / raw)
To: bluez-devel
Hi Josh,
> > I modified it a little bit to make it more generic, but it is in the CVS
> > now. Feel free to test it. Do I get also a patch for bccmd for a reset
> > command and a patch for decoding this command in hcidump?
>
> Why, yes! Attached is a patch to add decoding for hcidump, and a few
> extras for bccmd. I added "disabletx", "enabletx" and "rand", as well
> as "coldreset" to bccmd.
>
> Note that coldreset will be decoded in hcidump properly, but hcidump
> dies shortly afterward when it isn't getting a response from the card
> during reset.
thanks for the patch, but always keep the coding style in mind and
follow it.
The coldreset, disabletx and enabletx commands are valueless and so you
must handle them like this.
I fixed that and added also the missing BCCMD variables to hcidump.
Regards
Marcel
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2005-08-22 20:42 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2005-08-21 14:03 ` Marcel Holtmann
2005-08-22 19:20 ` Joshua Wright
2005-08-22 20:42 ` Marcel Holtmann
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).