author | korovkin <korovkin> | 2006-05-14 15:38:20 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-05-14 15:38:20 (UTC) |
commit | 782a34192c2c879a80fd319153a2b2f48ded1c99 (patch) (unidiff) | |
tree | 55f9d66e747876ffa2e87cf30eaafaf33864597a | |
parent | 273ffc42b3f0ce593e0d20874a7f224328416445 (diff) | |
download | opie-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.
-rw-r--r-- | noncore/net/opietooth/applet/bluezapplet.cpp | 31 | ||||
-rw-r--r-- | noncore/net/opietooth/applet/bluezapplet.h | 8 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/device.cc | 5 |
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 | |||
@@ -77,6 +77,7 @@ namespace OpieTooth { | |||
77 | doListDevice = false; | 77 | doListDevice = false; |
78 | isScanning = false; | 78 | isScanning = false; |
79 | m_wasOn = false; | 79 | m_wasOn = false; |
80 | m_sync = false; | ||
80 | 81 | ||
81 | // TODO: determine whether this channel has to be closed at destruction time. | 82 | // TODO: determine whether this channel has to be closed at destruction time. |
82 | QCopChannel* chan = new QCopChannel("QPE/Bluetooth", this ); | 83 | QCopChannel* chan = new QCopChannel("QPE/Bluetooth", this ); |
@@ -87,6 +88,7 @@ namespace OpieTooth { | |||
87 | 88 | ||
88 | BluezApplet::~BluezApplet() { | 89 | BluezApplet::~BluezApplet() { |
89 | if ( btDevice ) { | 90 | if ( btDevice ) { |
91 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); | ||
90 | delete btDevice; | 92 | delete btDevice; |
91 | } | 93 | } |
92 | if ( btManager ) { | 94 | if ( btManager ) { |
@@ -127,7 +129,7 @@ namespace OpieTooth { | |||
127 | btDevice = new Device( "/dev/tts/1", "any", "921600" ); | 129 | btDevice = new Device( "/dev/tts/1", "any", "921600" ); |
128 | break; | 130 | break; |
129 | 131 | ||
130 | #ifndef OPIE120 | 132 | #if OPIE_VERSION >= 102010 |
131 | case Model_MyPal_716: | 133 | case Model_MyPal_716: |
132 | btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" ); | 134 | btDevice = new Device( "/dev/ttyS1", "bcsp", "921600" ); |
133 | break; | 135 | break; |
@@ -137,12 +139,10 @@ namespace OpieTooth { | |||
137 | btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); | 139 | btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); |
138 | break; | 140 | break; |
139 | } | 141 | } |
140 | if (sync) { | 142 | m_sync = sync; |
141 | ::system("/etc/init.d/bluetooth start >/dev/null 2>/dev/null"); | 143 | connect(btDevice, SIGNAL(device(const QString&, bool)), |
142 | } else { | 144 | this, SLOT(slotDevice(const QString&, bool))); |
143 | QCopEnvelope e("QPE/System", "execute(QString)"); | 145 | |
144 | e << QString("/etc/init.d/bluetooth start"); | ||
145 | } | ||
146 | } else { | 146 | } else { |
147 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); | 147 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); |
148 | if ( btManager ) { | 148 | if ( btManager ) { |
@@ -336,6 +336,23 @@ namespace OpieTooth { | |||
336 | p.drawPixmap( 0, 0, bluezDiscoveryOnPixmap ); | 336 | p.drawPixmap( 0, 0, bluezDiscoveryOnPixmap ); |
337 | } | 337 | } |
338 | } | 338 | } |
339 | /** | ||
340 | * Reacts on device up | ||
341 | * @param name device name | ||
342 | * @param up if device was brought up | ||
343 | */ | ||
344 | void BluezApplet::slotDevice(const QString& name, bool up) | ||
345 | { | ||
346 | if (!up) | ||
347 | return; | ||
348 | odebug << name << " is up" << oendl; | ||
349 | if (m_sync) { | ||
350 | ::system("/etc/init.d/bluetooth start >/dev/null 2>/dev/null"); | ||
351 | } else { | ||
352 | QCopEnvelope e("QPE/System", "execute(QString)"); | ||
353 | e << QString("/etc/init.d/bluetooth start"); | ||
354 | } | ||
355 | } | ||
339 | }; | 356 | }; |
340 | 357 | ||
341 | 358 | ||
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 | |||
@@ -70,9 +70,17 @@ public slots: | |||
70 | bool doListDevice; //If I have to list devices after bringing BT up? | 70 | bool doListDevice; //If I have to list devices after bringing BT up? |
71 | bool isScanning; //If I'm scanning devices | 71 | bool isScanning; //If I'm scanning devices |
72 | bool m_wasOn; //If BT was started by menu? | 72 | bool m_wasOn; //If BT was started by menu? |
73 | protected: | ||
74 | bool m_sync; //If we have to bring BT synchronously | ||
73 | 75 | ||
74 | private slots: | 76 | private slots: |
75 | void slotMessage( const QCString& , const QByteArray& ); | 77 | void slotMessage( const QCString& , const QByteArray& ); |
78 | /** | ||
79 | * Reacts on device up | ||
80 | * @param name device name | ||
81 | * @param up if device was brought up | ||
82 | */ | ||
83 | void slotDevice(const QString&, bool); | ||
76 | }; | 84 | }; |
77 | }; | 85 | }; |
78 | 86 | ||
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 | |||
@@ -126,7 +126,8 @@ void Device::slotExited( OProcess* proc) | |||
126 | // FIXME hardcoded to hci0 now :( | 126 | // FIXME hardcoded to hci0 now :( |
127 | m_hci = new OProcess( ); | 127 | m_hci = new OProcess( ); |
128 | *m_hci << "hciconfig"; | 128 | *m_hci << "hciconfig"; |
129 | *m_hci << "hci0 up"; | 129 | *m_hci << "hci0"; |
130 | *m_hci << "up"; | ||
130 | connect(m_hci, SIGNAL( processExited(Opie::Core::OProcess*) ), | 131 | connect(m_hci, SIGNAL( processExited(Opie::Core::OProcess*) ), |
131 | this, SLOT( slotExited(Opie::Core::OProcess* ) ) ); | 132 | this, SLOT( slotExited(Opie::Core::OProcess* ) ) ); |
132 | if(!m_hci->start() ){ | 133 | if(!m_hci->start() ){ |
@@ -151,6 +152,8 @@ void Device::slotExited( OProcess* proc) | |||
151 | if( ret == 0 ){ | 152 | if( ret == 0 ){ |
152 | owarn << "attached really really attached" << oendl; | 153 | owarn << "attached really really attached" << oendl; |
153 | m_attached = true; | 154 | m_attached = true; |
155 | //Wait for a device to be brought up | ||
156 | ::sleep(1); | ||
154 | emit device("hci0", true ); | 157 | emit device("hci0", true ); |
155 | }else{ | 158 | }else{ |
156 | owarn << "failed" << oendl; | 159 | owarn << "failed" << oendl; |