summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/device.cc55
1 files changed, 42 insertions, 13 deletions
diff --git a/noncore/net/opietooth/lib/device.cc b/noncore/net/opietooth/lib/device.cc
index eea1178..40acbd2 100644
--- a/noncore/net/opietooth/lib/device.cc
+++ b/noncore/net/opietooth/lib/device.cc
@@ -4,6 +4,8 @@
4/* OPIE */ 4/* OPIE */
5#include <opie2/oprocess.h> 5#include <opie2/oprocess.h>
6#include <opie2/odebug.h> 6#include <opie2/odebug.h>
7#include <opie2/odevice.h>
8
7using namespace Opie::Core; 9using namespace Opie::Core;
8 10
9/* STD */ 11/* STD */
@@ -14,19 +16,33 @@ using namespace OpieTooth;
14 16
15using Opie::Core::OProcess; 17using Opie::Core::OProcess;
16namespace { 18namespace {
17 int parsePid( const QCString& par ){ 19 int parsePid( const QCString& par )
18 int id=0; 20 {
19 QString string( par ); 21 int id=0;
20 QStringList list = QStringList::split( '\n', string ); 22 QString string( par );
21 for( QStringList::Iterator it = list.begin(); it != list.end(); ++it ){ 23 QStringList list = QStringList::split( '\n', string );
22 owarn << "parsePID: " << (*it).latin1() << oendl; 24
23 if( !(*it).startsWith("CSR") ){ 25 for( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
24 id = (*it).toInt(); 26 {
25 break; 27 owarn << "parsePID: " << (*it).latin1() << oendl;
26 } 28
29 // FIXME mbhaynie: Surely there is a better way to skip
30 // verbosity (E.g. the TI device configuration
31 // script). Apparently the PID is always on a line by
32 // itself, or is at least the first word of a line. Does
33 // QString have somethine like startsWithRegex("[0-9]+")?
34 if( (*it).startsWith("#") ) continue;
35 if( (*it).startsWith("TI") ) continue;
36 if( (*it).startsWith("Loading") ) continue;
37 if( (*it).startsWith("BTS") ) continue;
38 if( !(*it).startsWith("CSR") )
39 {
40 id = (*it).toInt();
41 break;
42 }
43 }
44 return id;
27 } 45 }
28 return id;
29 }
30} 46}
31 47
32Device::Device(const QString &device, const QString &mode, const QString &speed ) 48Device::Device(const QString &device, const QString &mode, const QString &speed )
@@ -44,6 +60,10 @@ Device::Device(const QString &device, const QString &mode, const QString &speed
44Device::~Device(){ 60Device::~Device(){
45 detach(); 61 detach();
46} 62}
63
64// FIXME mbhaynie -- If BT is active, and opie is restarted, this
65// applet thinks bt is down, and will fail to start it again. Not
66// sure why.
47void Device::attach(){ 67void Device::attach(){
48 owarn << "attaching " << m_device.latin1() << " " << m_mode.latin1() << " " << m_speed.latin1() << oendl; 68 owarn << "attaching " << m_device.latin1() << " " << m_mode.latin1() << " " << m_speed.latin1() << oendl;
49 if(m_process == 0 ){ 69 if(m_process == 0 ){
@@ -52,7 +72,16 @@ void Device::attach(){
52 m_process = new OProcess(); 72 m_process = new OProcess();
53 *m_process << "hciattach"; 73 *m_process << "hciattach";
54 *m_process << "-p"; 74 *m_process << "-p";
55 *m_process << m_device << m_mode << m_speed; 75
76 // FIXME -- this is a hack for an odd hciattach interface.
77 if ( ODevice::inst()->modelString() == "HX4700" )
78 {
79 *m_process << "-S" << "/etc/bluetooth/TIInit_3.2.26.bts" << "/dev/ttyS1" << "texas";
80 }
81 else
82 {
83 *m_process << m_device << m_mode << m_speed;
84 }
56 connect(m_process, SIGNAL( processExited(Opie::Core::OProcess*) ), 85 connect(m_process, SIGNAL( processExited(Opie::Core::OProcess*) ),
57 this, SLOT( slotExited(Opie::Core::OProcess* ) ) ); 86 this, SLOT( slotExited(Opie::Core::OProcess* ) ) );
58 connect(m_process, SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int) ), 87 connect(m_process, SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int) ),