diff options
author | Javier S. Pedro <maemo@javispedro.com> | 2012-08-13 21:31:52 +0200 |
---|---|---|
committer | Javier S. Pedro <maemo@javispedro.com> | 2012-08-13 21:31:52 +0200 |
commit | abdf3b1eaba8151f1b8e862750c38cb7a5411d2a (patch) | |
tree | 69e314d80a332295dd5475fc91f45c2078eaead5 /metawatch/metawatch.cpp | |
parent | 51701e30d710ad016ddf2d306cdd7be122ddf25b (diff) | |
download | sowatch-abdf3b1eaba8151f1b8e862750c38cb7a5411d2a.tar.gz sowatch-abdf3b1eaba8151f1b8e862750c38cb7a5411d2a.zip |
make watchsimulator work again
Diffstat (limited to 'metawatch/metawatch.cpp')
-rw-r--r-- | metawatch/metawatch.cpp | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/metawatch/metawatch.cpp b/metawatch/metawatch.cpp index 6f8edca..6dfdd2f 100644 --- a/metawatch/metawatch.cpp +++ b/metawatch/metawatch.cpp @@ -109,13 +109,14 @@ MetaWatch::MetaWatch(ConfigKey* settings, QObject* parent) : _connectTimer->setSingleShot(true); _connectAlignedTimer->setSingleShot(true); - connect(_connectTimer, SIGNAL(timeout()), SLOT(retryConnect())); - connect(_connectAlignedTimer, SIGNAL(timeout()), SLOT(retryConnect())); + connect(_connectTimer, SIGNAL(timeout()), SLOT(timedReconnect())); + connect(_connectAlignedTimer, SIGNAL(timeout()), SLOT(timedReconnect())); _sendTimer->setInterval(DelayBetweenMessages); connect(_sendTimer, SIGNAL(timeout()), SLOT(timedSend())); - retryConnect(); + // Do an initial connection attempt + _connectTimer->start(100); } MetaWatch::~MetaWatch() @@ -249,7 +250,7 @@ void MetaWatch::displayNotification(Notification *notification) _idleTimer->stop(); } else { _ringTimer->stop(); - setVibrateMode(true, RingLength, RingLength, 2); + // XXX setVibrateMode(true, RingLength, RingLength, 2); _idleTimer->start(); } } @@ -322,6 +323,22 @@ quint16 MetaWatch::calcCrc(const Message& msg) return calcCrc(data, msgSize + 4); } +void MetaWatch::retryConnect() +{ + delete _socket; + _socket = new QBluetoothSocket(QBluetoothSocket::RfcommSocket); + + connect(_socket, SIGNAL(connected()), SLOT(socketConnected())); + connect(_socket, SIGNAL(disconnected()), SLOT(socketDisconnected())); + connect(_socket, SIGNAL(readyRead()), SLOT(socketData())); + connect(_socket, SIGNAL(error(QBluetoothSocket::SocketError)), + SLOT(socketError(QBluetoothSocket::SocketError))); + connect(_socket, SIGNAL(stateChanged(QBluetoothSocket::SocketState)), + SLOT(socketState(QBluetoothSocket::SocketState))); + + _socket->connectToService(_address, 1, QIODevice::ReadWrite | QIODevice::Unbuffered); +} + void MetaWatch::send(const Message &msg) { _toSend.enqueue(msg); @@ -754,20 +771,9 @@ void MetaWatch::socketState(QBluetoothSocket::SocketState error) qDebug() << "socket is in" << error; } -void MetaWatch::retryConnect() +void MetaWatch::timedReconnect() { - delete _socket; - _socket = new QBluetoothSocket(QBluetoothSocket::RfcommSocket); - - connect(_socket, SIGNAL(connected()), SLOT(socketConnected())); - connect(_socket, SIGNAL(disconnected()), SLOT(socketDisconnected())); - connect(_socket, SIGNAL(readyRead()), SLOT(socketData())); - connect(_socket, SIGNAL(error(QBluetoothSocket::SocketError)), - SLOT(socketError(QBluetoothSocket::SocketError))); - connect(_socket, SIGNAL(stateChanged(QBluetoothSocket::SocketState)), - SLOT(socketState(QBluetoothSocket::SocketState))); - - _socket->connectToService(_address, 1, QIODevice::ReadWrite | QIODevice::Unbuffered); + retryConnect(); } void MetaWatch::timedSend() |