qtbluetooth: Break read/write loops on bad state

This introduces a state check to only continue to try to read/write from
the bluetooth device while its in a sane state.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Anton Lundin 2015-09-22 23:33:15 +02:00 committed by Dirk Hohndel
parent 8417e84e82
commit 113ab59d81

View file

@ -234,7 +234,7 @@ static int qt_serial_read(serial_t *device, void* data, unsigned int size)
unsigned int nbytes = 0;
int rc;
while(nbytes < size)
while(nbytes < size && device->socket->state() == QBluetoothSocket::ConnectedState)
{
device->socket->waitForReadyRead(device->timeout);
@ -293,7 +293,7 @@ static int qt_serial_write(serial_t *device, const void* data, unsigned int size
unsigned int nbytes = 0;
int rc;
while(nbytes < size)
while(nbytes < size && device->socket->state() == QBluetoothSocket::ConnectedState)
{
device->socket->waitForBytesWritten(device->timeout);