Reduced minimum password retry level from 6 to 3
[barry/pauldeden.git] / tools / breset.cc
blob8eb8afefee53b71fc26b09254061dd6c9bbd1e62
1 ///
2 /// \file breset.cc
3 /// Attempt to reset all connected Blackberry devices via software
4 ///
5 /// This file is part of the Barry project:
6 ///
7 /// http://www.netdirect.ca/software/packages/barry/index.php
8 /// http://sourceforge.net/projects/barry
9 ///
10 /// Compile with the following command (needs libusb):
11 ///
12 /// g++ -o breset breset.cc -lusb
13 ///
16 Copyright (C) 2007-2008, Net Direct Inc. (http://www.netdirect.ca/)
18 This program is free software; you can redistribute it and/or modify
19 it under the terms of the GNU General Public License as published by
20 the Free Software Foundation; either version 2 of the License, or
21 (at your option) any later version.
23 This program is distributed in the hope that it will be useful,
24 but WITHOUT ANY WARRANTY; without even the implied warranty of
25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 See the GNU General Public License in the COPYING file at the
28 root directory of this project for more details.
31 #include <usb.h>
32 #include <stdio.h>
33 #include <unistd.h>
35 #define VENDOR_RIM 0x0fca
36 #define PRODUCT_RIM_BLACKBERRY 0x0001
37 #define PRODUCT_RIM_PEARL_DUAL 0x0004
38 #define PRODUCT_RIM_PEARL_8120 0x8004
39 #define PRODUCT_RIM_PEARL 0x0006
41 #define BLACKBERRY_INTERFACE 0
42 #define BLACKBERRY_CONFIGURATION 1
44 bool reset(struct usb_device *dev)
46 usb_dev_handle *handle = usb_open(dev);
47 if( !handle )
48 return false;
50 bool ret = usb_reset(handle) < 0;
51 usb_close(handle);
52 return ret;
55 int main()
57 struct usb_bus *busses;
59 usb_init();
60 usb_find_busses();
61 usb_find_devices();
62 busses = usb_get_busses();
64 printf("Scanning for Blackberry devices...\n");
65 int found = 0;
67 struct usb_bus *bus;
68 for( bus = busses; bus; bus = bus->next ) {
69 struct usb_device *dev;
71 for (dev = bus->devices; dev; dev = dev->next) {
72 // Is this a blackberry?
73 if( dev->descriptor.idVendor == VENDOR_RIM &&
74 (dev->descriptor.idProduct == PRODUCT_RIM_BLACKBERRY ||
75 dev->descriptor.idProduct == PRODUCT_RIM_PEARL ||
76 dev->descriptor.idProduct == PRODUCT_RIM_PEARL_8120 ||
77 dev->descriptor.idProduct == PRODUCT_RIM_PEARL_DUAL ) ) {
78 printf("Found...");
79 printf("attempting to reset.\n");
80 if( reset(dev) )
81 found++;
82 else
83 printf("Can't reset device on bus %s, devnum %u\n", bus->dirname, (unsigned int) dev->devnum);
88 printf("%d device%s reset.\n", found, found > 1 ? "s" : "");