summaryrefslogtreecommitdiff
authorkorovkin <korovkin>2006-05-14 15:38:20 (UTC)
committer korovkin <korovkin>2006-05-14 15:38:20 (UTC)
commit782a34192c2c879a80fd319153a2b2f48ded1c99 (patch) (side-by-side diff)
tree55f9d66e747876ffa2e87cf30eaafaf33864597a
parent273ffc42b3f0ce593e0d20874a7f224328416445 (diff)
downloadopie-782a34192c2c879a80fd319153a2b2f48ded1c99.zip
opie-782a34192c2c879a80fd319153a2b2f48ded1c99.tar.gz
opie-782a34192c2c879a80fd319153a2b2f48ded1c99.tar.bz2
Script must be started after device is started up.
We should wait for 1 second after device is brought up. Fixed an error in hcicongig hci0 up.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opietooth/applet/bluezapplet.cpp31
-rw-r--r--noncore/net/opietooth/applet/bluezapplet.h8
-rw-r--r--noncore/net/opietooth/lib/device.cc5
3 files changed, 36 insertions, 8 deletions
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp
index f7774f0..127b0af 100644
--- a/noncore/net/opietooth/applet/bluezapplet.cpp
+++ b/noncore/net/opietooth/applet/bluezapplet.cpp
@@ -76,8 +76,9 @@ namespace OpieTooth {
bluezDiscoveryActive = false;
doListDevice = false;
isScanning = false;
m_wasOn = false;
+ m_sync = false;
// TODO: determine whether this channel has to be closed at destruction time.
QCopChannel* chan = new QCopChannel("QPE/Bluetooth", this );
connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ),
@@ -86,8 +87,9 @@ namespace OpieTooth {
}
BluezApplet::~BluezApplet() {
if ( btDevice ) {
+ ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null");
delete btDevice;
}
if ( btManager ) {
delete btManager;
@@ -126,9 +128,9 @@ namespace OpieTooth {
case Model_iPAQ_H5xxx:
btDevice = new Device( "/dev/tts/1", "any", "921600" );
break;
-#ifndef OPIE120
+#if OPIE_VERSION >= 102010
case Model_MyPal_716:
btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" );
break;
#endif
@@ -136,14 +138,12 @@ namespace OpieTooth {
default:
btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" );
break;
}
- if (sync) {
- ::system("/etc/init.d/bluetooth start >/dev/null 2>/dev/null");
- } else {
- QCopEnvelope e("QPE/System", "execute(QString)");
- e << QString("/etc/init.d/bluetooth start");
- }
+ m_sync = sync;
+ connect(btDevice, SIGNAL(device(const QString&, bool)),
+ this, SLOT(slotDevice(const QString&, bool)));
+
} else {
::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null");
if ( btManager ) {
delete btManager;
@@ -335,8 +335,25 @@ namespace OpieTooth {
if (bluezDiscoveryActive) {
p.drawPixmap( 0, 0, bluezDiscoveryOnPixmap );
}
}
+ /**
+ * Reacts on device up
+ * @param name device name
+ * @param up if device was brought up
+ */
+ void BluezApplet::slotDevice(const QString& name, bool up)
+ {
+ if (!up)
+ return;
+ odebug << name << " is up" << oendl;
+ if (m_sync) {
+ ::system("/etc/init.d/bluetooth start >/dev/null 2>/dev/null");
+ } else {
+ QCopEnvelope e("QPE/System", "execute(QString)");
+ e << QString("/etc/init.d/bluetooth start");
+ }
+ }
};
EXPORT_OPIE_APPLET_v1( OpieTooth::BluezApplet )
diff --git a/noncore/net/opietooth/applet/bluezapplet.h b/noncore/net/opietooth/applet/bluezapplet.h
index 1937934..b79ed5b 100644
--- a/noncore/net/opietooth/applet/bluezapplet.h
+++ b/noncore/net/opietooth/applet/bluezapplet.h
@@ -69,11 +69,19 @@ public slots:
bool bluezDiscoveryActive;
bool doListDevice; //If I have to list devices after bringing BT up?
bool isScanning; //If I'm scanning devices
bool m_wasOn; //If BT was started by menu?
+ protected:
+ bool m_sync; //If we have to bring BT synchronously
private slots:
void slotMessage( const QCString& , const QByteArray& );
+ /**
+ * Reacts on device up
+ * @param name device name
+ * @param up if device was brought up
+ */
+ void slotDevice(const QString&, bool);
};
};
diff --git a/noncore/net/opietooth/lib/device.cc b/noncore/net/opietooth/lib/device.cc
index 2f04d46..88d4cf9 100644
--- a/noncore/net/opietooth/lib/device.cc
+++ b/noncore/net/opietooth/lib/device.cc
@@ -125,9 +125,10 @@ void Device::slotExited( OProcess* proc)
// and call hciconfig hci0 up
// FIXME hardcoded to hci0 now :(
m_hci = new OProcess( );
*m_hci << "hciconfig";
- *m_hci << "hci0 up";
+ *m_hci << "hci0";
+ *m_hci << "up";
connect(m_hci, SIGNAL( processExited(Opie::Core::OProcess*) ),
this, SLOT( slotExited(Opie::Core::OProcess* ) ) );
if(!m_hci->start() ){
owarn << "could not start" << oendl;
@@ -150,8 +151,10 @@ void Device::slotExited( OProcess* proc)
int ret = m_hci->exitStatus();
if( ret == 0 ){
owarn << "attached really really attached" << oendl;
m_attached = true;
+ //Wait for a device to be brought up
+ ::sleep(1);
emit device("hci0", true );
}else{
owarn << "failed" << oendl;
emit device("hci0", false );