summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2008-05-18 13:09:03 +0200
committerGuillaume Seguin <guillaume@segu.in>2008-05-18 13:09:03 +0200
commitcbca2de32d096f2b4f45bdd206a77a437c6c7eeb (patch)
tree754a5827e9130987e1ab7d061e87ac76fd3edd0a
parentce09646ef2fd75047e3355ea1407b1c24a92dbaa (diff)
downloadkuwii-cbca2de32d096f2b4f45bdd206a77a437c6c7eeb.tar.gz
kuwii-cbca2de32d096f2b4f45bdd206a77a437c6c7eeb.tar.bz2
* Disconnect only after 10 timeouts in a row
-rw-r--r--kuwii/wiimote.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/kuwii/wiimote.py b/kuwii/wiimote.py
index c1a09e4..6bcaa1c 100644
--- a/kuwii/wiimote.py
+++ b/kuwii/wiimote.py
@@ -148,13 +148,18 @@ class WiiMote:
self.leds.sync ()
+ timeouts = 0
while self.connected == 1:
try:
msg = self.fdin.recv(23)
+ timeouts = 0
except BluetoothError: # Quit thread when losing connection.
# If self.connected is still true, it's an accidentally
# disconnection, so we have to shutdown the bluetooth link
# clealy
+ timeouts += 1
+ if timeouts < 10:
+ continue
print "Connection timed out, disconnecting."
if self.connected:
self.disconnect()