mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-14 00:28:42 +00:00
Add support for BTLE power sensors
This commit is contained in:
@@ -53,6 +53,9 @@ public:
|
||||
void setBPM(float x) {
|
||||
telemetry.setHr(x);
|
||||
}
|
||||
void setWatts(double watts) {
|
||||
telemetry.setWatts(watts);
|
||||
}
|
||||
|
||||
private slots:
|
||||
void addDevice(const QBluetoothDeviceInfo&);
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
#include "BT40Controller.h"
|
||||
|
||||
QList<QBluetoothUuid> BT40Device::supportedServiceUuids = QList<QBluetoothUuid>()
|
||||
<< QBluetoothUuid(QBluetoothUuid::HeartRate);
|
||||
<< QBluetoothUuid(QBluetoothUuid::HeartRate)
|
||||
<< QBluetoothUuid(QBluetoothUuid::CyclingPower);
|
||||
|
||||
BT40Device::BT40Device(QObject *parent, QBluetoothDeviceInfo devinfo) : parent(parent), m_currentDevice(devinfo)
|
||||
|
||||
@@ -102,6 +103,10 @@ void BT40Device::serviceStateChanged(QLowEnergyService::ServiceState s)
|
||||
characteristic = service->characteristic(
|
||||
QBluetoothUuid(QBluetoothUuid::HeartRateMeasurement));
|
||||
}
|
||||
else if (service->serviceUuid() == QBluetoothUuid(QBluetoothUuid::CyclingPower)) {
|
||||
characteristic = service->characteristic(
|
||||
QBluetoothUuid(QBluetoothUuid::CyclingPowerMeasurement));
|
||||
}
|
||||
if (characteristic.isValid()) {
|
||||
const QLowEnergyDescriptor notificationDesc = characteristic.descriptor(
|
||||
QBluetoothUuid::ClientCharacteristicConfiguration);
|
||||
@@ -136,6 +141,14 @@ void BT40Device::updateValue(const QLowEnergyCharacteristic &c,
|
||||
}
|
||||
dynamic_cast<BT40Controller*>(parent)->setBPM(hr);
|
||||
}
|
||||
else if (c.uuid() == QBluetoothUuid(QBluetoothUuid::CyclingPowerMeasurement)) {
|
||||
quint16 flags;
|
||||
ds >> flags;
|
||||
qint16 tmp_pwr;
|
||||
ds >> tmp_pwr;
|
||||
double power = (double) tmp_pwr;
|
||||
dynamic_cast<BT40Controller*>(parent)->setWatts(power);
|
||||
}
|
||||
}
|
||||
|
||||
void BT40Device::serviceError(QLowEnergyService::ServiceError e)
|
||||
|
||||
Reference in New Issue
Block a user