summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/device.cc35
1 files changed, 32 insertions, 3 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
@@ -1,67 +1,96 @@
#include "device.h"
/* OPIE */
#include <opie2/oprocess.h>
#include <opie2/odebug.h>
+#include <opie2/odevice.h>
+
using namespace Opie::Core;
/* STD */
#include <signal.h>
using namespace OpieTooth;
using Opie::Core::OProcess;
namespace {
- int parsePid( const QCString& par ){
+ int parsePid( const QCString& par )
+ {
int id=0;
QString string( par );
QStringList list = QStringList::split( '\n', string );
- for( QStringList::Iterator it = list.begin(); it != list.end(); ++it ){
+
+ for( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
+ {
owarn << "parsePID: " << (*it).latin1() << oendl;
- if( !(*it).startsWith("CSR") ){
+
+ // FIXME mbhaynie: Surely there is a better way to skip
+ // verbosity (E.g. the TI device configuration
+ // script). Apparently the PID is always on a line by
+ // itself, or is at least the first word of a line. Does
+ // QString have somethine like startsWithRegex("[0-9]+")?
+ if( (*it).startsWith("#") ) continue;
+ if( (*it).startsWith("TI") ) continue;
+ if( (*it).startsWith("Loading") ) continue;
+ if( (*it).startsWith("BTS") ) continue;
+ if( !(*it).startsWith("CSR") )
+ {
id = (*it).toInt();
break;
}
}
return id;
}
}
Device::Device(const QString &device, const QString &mode, const QString &speed )
: QObject(0, "device") {
owarn << "OpieTooth::Device create" << oendl;
m_hci = 0;
m_process = 0;
m_attached = false;
m_device = device;
m_mode = mode;
m_speed = speed;
attach();
}
Device::~Device(){
detach();
}
+
+// FIXME mbhaynie -- If BT is active, and opie is restarted, this
+// applet thinks bt is down, and will fail to start it again. Not
+// sure why.
void Device::attach(){
owarn << "attaching " << m_device.latin1() << " " << m_mode.latin1() << " " << m_speed.latin1() << oendl;
if(m_process == 0 ){
m_output.resize(0);
owarn << "new process to create" << oendl;
m_process = new OProcess();
*m_process << "hciattach";
*m_process << "-p";
+
+ // FIXME -- this is a hack for an odd hciattach interface.
+ if ( ODevice::inst()->modelString() == "HX4700" )
+ {
+ *m_process << "-S" << "/etc/bluetooth/TIInit_3.2.26.bts" << "/dev/ttyS1" << "texas";
+ }
+ else
+ {
*m_process << m_device << m_mode << m_speed;
+ }
connect(m_process, SIGNAL( processExited(Opie::Core::OProcess*) ),
this, SLOT( slotExited(Opie::Core::OProcess* ) ) );
connect(m_process, SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int) ),
this, SLOT(slotStdOut(Opie::Core::OProcess*,char*,int ) ) );
connect(m_process, SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int ) ),
this, SLOT(slotStdErr(Opie::Core::OProcess*,char*,int) ) );
if(!m_process->start(OProcess::NotifyOnExit, OProcess::AllOutput ) ){
owarn << "Could not start" << oendl;
delete m_process;
m_process = 0;
}
};