Diffstat (limited to 'noncore/net/opietooth/lib/device.cc') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opietooth/lib/device.cc | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/noncore/net/opietooth/lib/device.cc b/noncore/net/opietooth/lib/device.cc index 40acbd2..2f04d46 100644 --- a/noncore/net/opietooth/lib/device.cc +++ b/noncore/net/opietooth/lib/device.cc | |||
@@ -19,27 +19,25 @@ namespace { | |||
19 | int parsePid( const QCString& par ) | 19 | int parsePid( const QCString& par ) |
20 | { | 20 | { |
21 | int id=0; | 21 | int id=0; |
22 | QString string( par ); | 22 | QString string( par ); |
23 | QStringList list = QStringList::split( '\n', string ); | 23 | QStringList list = QStringList::split( '\n', string ); |
24 | 24 | ||
25 | for( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 25 | for( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
26 | { | ||
27 | owarn << "parsePID: " << (*it).latin1() << oendl; | 26 | owarn << "parsePID: " << (*it).latin1() << oendl; |
28 | 27 | ||
29 | // FIXME mbhaynie: Surely there is a better way to skip | 28 | // FIXME mbhaynie: Surely there is a better way to skip |
30 | // verbosity (E.g. the TI device configuration | 29 | // verbosity (E.g. the TI device configuration |
31 | // script). Apparently the PID is always on a line by | 30 | // script). Apparently the PID is always on a line by |
32 | // itself, or is at least the first word of a line. Does | 31 | // itself, or is at least the first word of a line. Does |
33 | // QString have somethine like startsWithRegex("[0-9]+")? | 32 | // QString have somethine like startsWithRegex("[0-9]+")? |
34 | if( (*it).startsWith("#") ) continue; | 33 | if( (*it).startsWith("#") ) continue; |
35 | if( (*it).startsWith("TI") ) continue; | 34 | if( (*it).startsWith("TI") ) continue; |
36 | if( (*it).startsWith("Loading") ) continue; | 35 | if( (*it).startsWith("Loading") ) continue; |
37 | if( (*it).startsWith("BTS") ) continue; | 36 | if( (*it).startsWith("BTS") ) continue; |
38 | if( !(*it).startsWith("CSR") ) | 37 | if( !(*it).startsWith("CSR") ) { |
39 | { | ||
40 | id = (*it).toInt(); | 38 | id = (*it).toInt(); |
41 | break; | 39 | break; |
42 | } | 40 | } |
43 | } | 41 | } |
44 | return id; | 42 | return id; |
45 | } | 43 | } |
@@ -72,40 +70,38 @@ void Device::attach(){ | |||
72 | m_process = new OProcess(); | 70 | m_process = new OProcess(); |
73 | *m_process << "hciattach"; | 71 | *m_process << "hciattach"; |
74 | *m_process << "-p"; | 72 | *m_process << "-p"; |
75 | 73 | ||
76 | // FIXME -- this is a hack for an odd hciattach interface. | 74 | // FIXME -- this is a hack for an odd hciattach interface. |
77 | if ( ODevice::inst()->modelString() == "HX4700" ) | 75 | if ( ODevice::inst()->modelString() == "HX4700" ) |
78 | { | ||
79 | *m_process << "-S" << "/etc/bluetooth/TIInit_3.2.26.bts" << "/dev/ttyS1" << "texas"; | 76 | *m_process << "-S" << "/etc/bluetooth/TIInit_3.2.26.bts" << "/dev/ttyS1" << "texas"; |
80 | } | ||
81 | else | 77 | else |
82 | { | ||
83 | *m_process << m_device << m_mode << m_speed; | 78 | *m_process << m_device << m_mode << m_speed; |
84 | } | ||
85 | connect(m_process, SIGNAL( processExited(Opie::Core::OProcess*) ), | 79 | connect(m_process, SIGNAL( processExited(Opie::Core::OProcess*) ), |
86 | this, SLOT( slotExited(Opie::Core::OProcess* ) ) ); | 80 | this, SLOT( slotExited(Opie::Core::OProcess* ) ) ); |
87 | connect(m_process, SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int) ), | 81 | connect(m_process, SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int) ), |
88 | this, SLOT(slotStdOut(Opie::Core::OProcess*,char*,int ) ) ); | 82 | this, SLOT(slotStdOut(Opie::Core::OProcess*,char*,int ) ) ); |
89 | connect(m_process, SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int ) ), | 83 | connect(m_process, SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int ) ), |
90 | this, SLOT(slotStdErr(Opie::Core::OProcess*,char*,int) ) ); | 84 | this, SLOT(slotStdErr(Opie::Core::OProcess*,char*,int) ) ); |
91 | if(!m_process->start(OProcess::NotifyOnExit, OProcess::AllOutput ) ){ | 85 | if(!m_process->start(OProcess::NotifyOnExit, OProcess::AllOutput ) ){ |
92 | owarn << "Could not start" << oendl; | 86 | owarn << "Could not start" << oendl; |
93 | delete m_process; | 87 | delete m_process; |
94 | m_process = 0; | 88 | m_process = 0; |
95 | } | 89 | } |
96 | }; | 90 | } |
97 | } | 91 | } |
98 | void Device::detach(){ | 92 | void Device::detach(){ |
99 | delete m_hci; | 93 | delete m_hci; |
94 | m_hci = 0; | ||
100 | delete m_process; | 95 | delete m_process; |
96 | m_process = 0; | ||
101 | // kill the pid we got | 97 | // kill the pid we got |
102 | if(m_attached ){ | 98 | if(m_attached ){ |
103 | //kill the pid | 99 | //kill the pid |
104 | owarn << "killing" << oendl; | 100 | owarn << "killing" << oendl; |
105 | kill(pid, 9); | 101 | ::kill(pid, 9); |
106 | } | 102 | } |
107 | owarn << "detached" << oendl; | 103 | owarn << "detached" << oendl; |
108 | } | 104 | } |
109 | bool Device::isLoaded()const{ | 105 | bool Device::isLoaded()const{ |
110 | return m_attached; | 106 | return m_attached; |
111 | } | 107 | } |