summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/lib/device.cc
Unidiff
Diffstat (limited to 'noncore/net/opietooth/lib/device.cc') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/device.cc16
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
@@ -13,39 +13,37 @@ using namespace Opie::Core;
13 13
14 14
15using namespace OpieTooth; 15using namespace OpieTooth;
16 16
17using Opie::Core::OProcess; 17using 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 {
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 }
46} 44}
47 45
48Device::Device(const QString &device, const QString &mode, const QString &speed ) 46Device::Device(const QString &device, const QString &mode, const QString &speed )
49 : QObject(0, "device") { 47 : QObject(0, "device") {
50 48
51 owarn << "OpieTooth::Device create" << oendl; 49 owarn << "OpieTooth::Device create" << oendl;
@@ -66,52 +64,50 @@ Device::~Device(){
66// sure why. 64// sure why.
67void Device::attach(){ 65void Device::attach(){
68 owarn << "attaching " << m_device.latin1() << " " << m_mode.latin1() << " " << m_speed.latin1() << oendl; 66 owarn << "attaching " << m_device.latin1() << " " << m_mode.latin1() << " " << m_speed.latin1() << oendl;
69 if(m_process == 0 ){ 67 if(m_process == 0 ){
70 m_output.resize(0); 68 m_output.resize(0);
71 owarn << "new process to create" << oendl; 69 owarn << "new process to create" << oendl;
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}
98void Device::detach(){ 92void 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}
109bool Device::isLoaded()const{ 105bool Device::isLoaded()const{
110 return m_attached; 106 return m_attached;
111} 107}
112QString Device::devName()const { 108QString Device::devName()const {
113 return QString::fromLatin1("hci0"); 109 return QString::fromLatin1("hci0");
114}; 110};
115void Device::slotExited( OProcess* proc) 111void Device::slotExited( OProcess* proc)
116{ 112{
117 owarn << "prcess exited" << oendl; 113 owarn << "prcess exited" << oendl;