mirror of
https://github.com/cagnulein/qdomyos-zwift.git
synced 2026-02-18 00:17:41 +01:00
Compare commits
7 Commits
Mobi-Rower
...
I'm-not-su
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21728f0655 | ||
|
|
40c37d98b3 | ||
|
|
02557bd9ca | ||
|
|
ce9ff3ae65 | ||
|
|
b39d7c0965 | ||
|
|
d5466af2a4 | ||
|
|
09b676d87a |
@@ -1350,6 +1350,7 @@ void bluetooth::deviceDiscovered(const QBluetoothDeviceInfo &device) {
|
||||
(b.name().toUpper().startsWith(QStringLiteral("ANPLUS-"))) || // FTMS
|
||||
b.name().toUpper().startsWith(QStringLiteral("ESANGLINKER"))) &&
|
||||
!horizonTreadmill && filter) {
|
||||
discoveryAgent->stop();
|
||||
this->setLastBluetoothDevice(b);
|
||||
this->stopDiscovery();
|
||||
horizonTreadmill = new horizontreadmill(noWriteResistance, noHeartService);
|
||||
|
||||
@@ -134,6 +134,7 @@ metric bluetoothdevice::elevationGain() { return elevationAcc; }
|
||||
void bluetoothdevice::heartRate(uint8_t heart) { Heart.setValue(heart); }
|
||||
void bluetoothdevice::disconnectBluetooth() {
|
||||
if (m_control) {
|
||||
closing = true;
|
||||
m_control->disconnectFromDevice();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -732,6 +732,8 @@ class bluetoothdevice : public QObject {
|
||||
protected:
|
||||
// useful to understand if a power sensor device for treadmill, it's a real one like the stryd or it's a dumb one like the runpod from Zwift
|
||||
bool powerReceivedFromPowerSensor = false;
|
||||
|
||||
volatile bool closing = false;
|
||||
};
|
||||
|
||||
#endif // BLUETOOTHDEVICE_H
|
||||
|
||||
@@ -2278,12 +2278,26 @@ void horizontreadmill::serviceScanDone(void) {
|
||||
firstStateChanged = 0;
|
||||
auto services_list = m_control->services();
|
||||
|
||||
QBluetoothUuid ftmsService((quint16)0x1826);
|
||||
QBluetoothUuid RSCService((quint16)0x1814);
|
||||
QBluetoothUuid CustomService((quint16)0xFFF0);
|
||||
|
||||
for (const QBluetoothUuid &s : qAsConst(services_list)) {
|
||||
#ifdef Q_OS_WIN
|
||||
if (s == ftmsService || s == RSCService || s == CustomService)
|
||||
#endif
|
||||
{
|
||||
qDebug() << s << "discovering...";
|
||||
gattCommunicationChannelService.append(m_control->createServiceObject(s));
|
||||
connect(gattCommunicationChannelService.constLast(), &QLowEnergyService::stateChanged, this,
|
||||
&horizontreadmill::stateChanged);
|
||||
gattCommunicationChannelService.constLast()->discoverDetails();
|
||||
}
|
||||
#ifdef Q_OS_WIN
|
||||
else {
|
||||
qDebug() << s << "NOT discovering!";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2388,7 +2402,9 @@ void horizontreadmill::deviceDiscovered(const QBluetoothDeviceInfo &device) {
|
||||
connect(m_control, &QLowEnergyController::connected, this, [this]() {
|
||||
Q_UNUSED(this);
|
||||
emit debug(QStringLiteral("Controller connected. Search services..."));
|
||||
#ifndef Q_OS_WIN
|
||||
m_control->discoverServices();
|
||||
#endif
|
||||
});
|
||||
connect(m_control, &QLowEnergyController::disconnected, this, [this]() {
|
||||
Q_UNUSED(this);
|
||||
@@ -2398,10 +2414,19 @@ void horizontreadmill::deviceDiscovered(const QBluetoothDeviceInfo &device) {
|
||||
|
||||
// Connect
|
||||
m_control->connectToDevice();
|
||||
#ifdef Q_OS_WIN
|
||||
QThread::sleep(1);
|
||||
m_control->discoverServices();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
horizontreadmill::~horizontreadmill() {
|
||||
if(connected())
|
||||
m_control->disconnectFromDevice();
|
||||
}
|
||||
|
||||
bool horizontreadmill::connected() {
|
||||
if (!m_control) {
|
||||
|
||||
@@ -2412,8 +2437,8 @@ bool horizontreadmill::connected() {
|
||||
|
||||
void horizontreadmill::controllerStateChanged(QLowEnergyController::ControllerState state) {
|
||||
qDebug() << QStringLiteral("controllerStateChanged") << state;
|
||||
if (state == QLowEnergyController::UnconnectedState && m_control) {
|
||||
qDebug() << QStringLiteral("trying to connect back again...");
|
||||
if (state == QLowEnergyController::UnconnectedState && m_control && !closing) {
|
||||
qDebug() << QStringLiteral("trying to connect back again...") << closing;
|
||||
|
||||
initDone = false;
|
||||
m_control->connectToDevice();
|
||||
|
||||
@@ -38,6 +38,7 @@ class horizontreadmill : public treadmill {
|
||||
Q_OBJECT
|
||||
public:
|
||||
horizontreadmill(bool noWriteResistance, bool noHeartService);
|
||||
~horizontreadmill();
|
||||
bool connected() override;
|
||||
void forceSpeed(double requestSpeed);
|
||||
void forceIncline(double requestIncline);
|
||||
|
||||
@@ -707,6 +707,15 @@ void tacxneo2::serviceScanDone(void) {
|
||||
|
||||
auto services = m_control->services();
|
||||
for (const QBluetoothUuid &s : services) {
|
||||
#ifdef Q_OS_WIN
|
||||
QBluetoothUuid custom = QBluetoothUuid(QStringLiteral("6e40fec1-b5a3-f393-e0a9-e50e24dcca9e"));
|
||||
QBluetoothUuid ftms = QBluetoothUuid((quint16)0x1826);
|
||||
QBluetoothUuid power = QBluetoothUuid((quint16)0x1818);
|
||||
if(s != custom && s != power && s != ftms) {
|
||||
qDebug() << "skipping service";
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
gattCommunicationChannelService.append(m_control->createServiceObject(s));
|
||||
connect(gattCommunicationChannelService.constLast(), &QLowEnergyService::stateChanged, this,
|
||||
&tacxneo2::stateChanged);
|
||||
|
||||
Reference in New Issue
Block a user