summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/lib/device.cc
Unidiff
Diffstat (limited to 'noncore/net/opietooth/lib/device.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/device.cc108
1 files changed, 52 insertions, 56 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
@@ -18,29 +18,27 @@ using Opie::Core::OProcess;
18namespace { 18namespace {
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 { 26 owarn << "parsePID: " << (*it).latin1() << oendl;
27 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 { 38 id = (*it).toInt();
40 id = (*it).toInt(); 39 break;
41 break; 40 }
42 }
43 }
44 return id;
45 } 41 }
42 return id;
43 }
46} 44}
@@ -77,9 +75,5 @@ void Device::attach(){
77 if ( ODevice::inst()->modelString() == "HX4700" ) 75 if ( ODevice::inst()->modelString() == "HX4700" )
78 { 76 *m_process << "-S" << "/etc/bluetooth/TIInit_3.2.26.bts" << "/dev/ttyS1" << "texas";
79 *m_process << "-S" << "/etc/bluetooth/TIInit_3.2.26.bts" << "/dev/ttyS1" << "texas";
80 }
81 else 77 else
82 { 78 *m_process << m_device << m_mode << m_speed;
83 *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*) ),
@@ -95,3 +89,3 @@ void Device::attach(){
95 } 89 }
96 }; 90 }
97} 91}
@@ -99,3 +93,5 @@ 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
@@ -104,3 +100,3 @@ void Device::detach(){
104 owarn << "killing" << oendl; 100 owarn << "killing" << oendl;
105 kill(pid, 9); 101 ::kill(pid, 9);
106 } 102 }
@@ -123,23 +119,23 @@ void Device::slotExited( OProcess* proc)
123 if( ret == 0 ){ // attached 119 if( ret == 0 ){ // attached
124 owarn << "attached" << oendl; 120 owarn << "attached" << oendl;
125 owarn << "Output: " << m_output.data() << oendl; 121 owarn << "Output: " << m_output.data() << oendl;
126 pid = parsePid( m_output ); 122 pid = parsePid( m_output );
127 owarn << "Pid = " << pid << oendl; 123 owarn << "Pid = " << pid << oendl;
128 // now hciconfig hci0 up ( determine hciX FIXME) 124 // now hciconfig hci0 up ( determine hciX FIXME)
129 // and call hciconfig hci0 up 125 // and call hciconfig hci0 up
130 // FIXME hardcoded to hci0 now :( 126 // FIXME hardcoded to hci0 now :(
131 m_hci = new OProcess( ); 127 m_hci = new OProcess( );
132 *m_hci << "hciconfig"; 128 *m_hci << "hciconfig";
133 *m_hci << "hci0 up"; 129 *m_hci << "hci0 up";
134 connect(m_hci, SIGNAL( processExited(Opie::Core::OProcess*) ), 130 connect(m_hci, SIGNAL( processExited(Opie::Core::OProcess*) ),
135 this, SLOT( slotExited(Opie::Core::OProcess* ) ) ); 131 this, SLOT( slotExited(Opie::Core::OProcess* ) ) );
136 if(!m_hci->start() ){ 132 if(!m_hci->start() ){
137 owarn << "could not start" << oendl; 133 owarn << "could not start" << oendl;
138 m_attached = false; 134 m_attached = false;
139 emit device("hci0", false ); 135 emit device("hci0", false );
140 } 136 }
141 }else{ 137 }else{
142 owarn << "crass" << oendl; 138 owarn << "crass" << oendl;
143 m_attached = false; 139 m_attached = false;
144 emit device("hci0", false ); 140 emit device("hci0", false );
145 141
@@ -155,9 +151,9 @@ void Device::slotExited( OProcess* proc)
155 if( ret == 0 ){ 151 if( ret == 0 ){
156 owarn << "attached really really attached" << oendl; 152 owarn << "attached really really attached" << oendl;
157 m_attached = true; 153 m_attached = true;
158 emit device("hci0", true ); 154 emit device("hci0", true );
159 }else{ 155 }else{
160 owarn << "failed" << oendl; 156 owarn << "failed" << oendl;
161 emit device("hci0", false ); 157 emit device("hci0", false );
162 m_attached = false; 158 m_attached = false;
163 } 159 }