Add extra logs for custom serial Bluetooth implementation

This patch increases the verbosity level for QtBluetooth API
and add some extra logs for custom serial Bluetooth open method.

The scope of this patch is only for testing.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Claudiu Olteanu 2015-07-06 17:11:02 +03:00 committed by Dirk Hohndel
parent 198cc41959
commit 14e071e8d8
2 changed files with 8 additions and 1 deletions

View file

@ -15,6 +15,7 @@
#include <QStringList> #include <QStringList>
#include <QApplication> #include <QApplication>
#include <QLoggingCategory>
#include <git2.h> #include <git2.h>
QTranslator *qtTranslator, *ssrfTranslator; QTranslator *qtTranslator, *ssrfTranslator;
@ -23,7 +24,7 @@ int main(int argc, char **argv)
{ {
int i; int i;
bool no_filenames = true; bool no_filenames = true;
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
QApplication *application = new QApplication(argc, argv); QApplication *application = new QApplication(argc, argv);
QStringList files; QStringList files;
QStringList importedFiles; QStringList importedFiles;

View file

@ -4,6 +4,7 @@
#include <QtBluetooth/QBluetoothSocket> #include <QtBluetooth/QBluetoothSocket>
#include <QEventLoop> #include <QEventLoop>
#include <QTimer> #include <QTimer>
#include <QDebug>
#include <libdivecomputer/custom_serial.h> #include <libdivecomputer/custom_serial.h>
@ -57,16 +58,19 @@ static int qt_serial_open(serial_t **out, dc_context_t *context, const char* dev
if (serial_port->socket->state() == QBluetoothSocket::ConnectingState) { if (serial_port->socket->state() == QBluetoothSocket::ConnectingState) {
// It seems that the connection on channel 1 took more than expected. Wait another 15 seconds // It seems that the connection on channel 1 took more than expected. Wait another 15 seconds
qDebug() << "The connection on RFCOMM channel number 1 took more than expected. Wait another 15 seconds.";
timer.start(3 * msec); timer.start(3 * msec);
loop.exec(); loop.exec();
} else if (serial_port->socket->state() == QBluetoothSocket::UnconnectedState) { } else if (serial_port->socket->state() == QBluetoothSocket::UnconnectedState) {
// Try to connect on channel number 5. Maybe this is a Shearwater Petrel2 device. // Try to connect on channel number 5. Maybe this is a Shearwater Petrel2 device.
qDebug() << "Connection on channel 1 failed. Trying on channel number 5.";
serial_port->socket->connectToService(remoteDeviceAddress, 5); serial_port->socket->connectToService(remoteDeviceAddress, 5);
timer.start(msec); timer.start(msec);
loop.exec(); loop.exec();
if (serial_port->socket->state() == QBluetoothSocket::ConnectingState) { if (serial_port->socket->state() == QBluetoothSocket::ConnectingState) {
// It seems that the connection on channel 5 took more than expected. Wait another 15 seconds // It seems that the connection on channel 5 took more than expected. Wait another 15 seconds
qDebug() << "The connection on RFCOMM channel number 5 took more than expected. Wait another 15 seconds.";
timer.start(3 * msec); timer.start(3 * msec);
loop.exec(); loop.exec();
} }
@ -77,6 +81,8 @@ static int qt_serial_open(serial_t **out, dc_context_t *context, const char* dev
// Get the latest error and try to match it with one from libdivecomputer // Get the latest error and try to match it with one from libdivecomputer
QBluetoothSocket::SocketError err = serial_port->socket->error(); QBluetoothSocket::SocketError err = serial_port->socket->error();
qDebug() << "Failed to connect to device " << devaddr << ". Device state " << serial_port->socket->state() << ". Error: " << err;
switch(err) { switch(err) {
case QBluetoothSocket::HostNotFoundError: case QBluetoothSocket::HostNotFoundError:
case QBluetoothSocket::ServiceNotFoundError: case QBluetoothSocket::ServiceNotFoundError: