3 /// Syncberry library tester
5 // FIXME - add copyright notices
12 #include "blackberry.h"
18 using namespace Syncberry
;
23 << "bbtool - Command line USB Blackberry Test Tool\n\n"
25 << " -l List Blackberry devices\n"
26 << " -p pin Blackberry PIN of device to talk with\n"
27 << " If only one Blackberry plugged in, this flag is optional\n"
31 int main(int argc
, char *argv
[])
33 cout
.sync_with_stdio(true); // leave this on, since libusb uses
34 // stdio for debug messages
39 bool list_only
= false;
41 // process command line options
43 int cmd
= getopt(argc
, argv
, "hlp:");
49 case 'l': // list only
53 case 'p': // Blackberry PIN
54 pin
= strtoul(optarg
, NULL
, 16);
67 int activeDevice
= -1;
68 cout
<< "Blackberry devices found:" << endl
;
69 for( int i
= 0; i
< probe
.GetCount(); i
++ ) {
70 cout
<< probe
.Get(i
) << endl
;
71 if( probe
.Get(i
).m_pin
== pin
)
78 if( activeDevice
== -1 ) {
80 // can we default to single device?
81 if( probe
.GetCount() == 1 )
84 cerr
<< "No device selected" << endl
;
89 cerr
<< "PIN " << setbase(16) << pin
90 << " not found" << endl
;
95 Blackberry
bb(probe
.Get(activeDevice
));
99 catch( Syncberry::SBError
&se
) {
100 std::cerr
<< "SBError caught: " << se
.what() << endl
;
102 catch( Usb::UsbError
&ue
) {
103 std::cerr
<< "UsbError caught: " << ue
.what() << endl
;
105 catch( std::runtime_error
&re
) {
106 std::cerr
<< "std::runtime_error caught: " << re
.what() << endl
;