Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/devices/solebike/solebike.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "keepawakehelper.h"
#endif
#include "virtualdevices/virtualbike.h"
#include "homeform.h"
#include "qzsettings.h"
#include <QBluetoothLocalDevice>
#include <QDateTime>
#include <QFile>
Expand Down Expand Up @@ -515,6 +517,25 @@ void solebike::serviceScanDone(void) {
QBluetoothUuid _gattCommunicationChannelServiceId(QStringLiteral("49535343-fe7d-4ae5-8fa9-9fafd205e455"));

gattCommunicationChannelService = m_control->createServiceObject(_gattCommunicationChannelServiceId);

if (!gattCommunicationChannelService) {
// Main Sole service not found, try FTMS service as a fallback to avoid crashes.
QBluetoothUuid ftmsServiceId((quint16)0x1826);
QLowEnergyService *ftmsService = m_control->createServiceObject(ftmsServiceId);
if (ftmsService) {
QSettings settings;
settings.setValue(QZSettings::ftms_bike, bluetoothDevice.name());
qDebug() << "forcing FTMS bike since Sole main service is missing but FTMS service is available";
if (homeform::singleton()) {
homeform::singleton()->setToastRequested("FTMS bike found, restart the app to apply the change");
}
delete ftmsService;
} else {
qDebug() << "Sole main service and FTMS service not found, skipping service init to avoid crash";
}
return;
}

connect(gattCommunicationChannelService, &QLowEnergyService::stateChanged, this, &solebike::stateChanged);
gattCommunicationChannelService->discoverDetails();
}
Expand Down
Loading