2005-08-17 19:16:27

by Joshua Wright

[permalink] [raw]
Subject: [Bluez-devel] Reset card

-----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
[email protected]

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
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel


2005-08-22 20:42:09

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-devel] Reset card

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
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2005-08-22 19:20:25

by Joshua Wright

[permalink] [raw]
Subject: Re: [Bluez-devel] Reset card

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


Attachments:
bccmd-extras.diff (3.83 kB)
hcidump-bccmd-extras.diff (974.00 B)
Download all attachments

2005-08-21 14:03:06

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-devel] Reset card

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
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2005-08-19 16:21:13

by Joshua Wright

[permalink] [raw]
Subject: Re: [Bluez-devel] Reset card

--- 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);


Attachments:
bdaddr-csr-reset.diff (1.58 kB)

2005-08-19 14:49:49

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-devel] Reset card

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
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2005-08-19 09:28:30

by Simon Vogl

[permalink] [raw]
Subject: Re: [Bluez-devel] Reset card

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
> [email protected]
> 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: [email protected]



-------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2005-08-19 09:23:42

by Ronny L Nilsson

[permalink] [raw]
Subject: Re: [Bluez-devel] Reset card


> 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel