Skip to content

Commit 606257a

Browse files
author
root
committed
fix: use 0x31 metrics for Apex WLT8266BM_07E2
1 parent 6543e92 commit 606257a

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/devices/apexbike/apexbike.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
using namespace std::chrono_literals;
1414

1515
bool apexbike::usesWlt8266bmDistanceCounterMetrics(const QString &deviceName) {
16-
return deviceName.startsWith(QStringLiteral("WLT8266BM_"), Qt::CaseInsensitive);
16+
// WLT8266BM_07E2 reports real cadence/distance in 0x31 packets.
17+
// Its 0x30 packet is only a counter and must not be used as distance.
18+
return deviceName.startsWith(QStringLiteral("WLT8266BM_"), Qt::CaseInsensitive) &&
19+
deviceName.compare(QStringLiteral("WLT8266BM_07E2"), Qt::CaseInsensitive) != 0;
1720
}
1821

1922
bool apexbike::isWlt8266bmDistanceCounterMetricsPacket(const QString &deviceName, const QByteArray &newValue) {

tst/Devices/TestApexBikeParser.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ TEST(ApexBikeWlt8266BmRegressionTest, DistanceCounterMetricsAreScopedToBluetooth
1111
EXPECT_TRUE(apexbike::usesWlt8266bmDistanceCounterMetrics(QStringLiteral("wlt8266bm_025b")));
1212
EXPECT_TRUE(apexbike::usesWlt8266bmDistanceCounterMetrics(QStringLiteral("WLT8266BM_0000")));
1313

14+
EXPECT_FALSE(apexbike::usesWlt8266bmDistanceCounterMetrics(QStringLiteral("WLT8266BM_07E2")));
15+
EXPECT_FALSE(apexbike::usesWlt8266bmDistanceCounterMetrics(QStringLiteral("wlt8266bm_07e2")));
1416
EXPECT_FALSE(apexbike::usesWlt8266bmDistanceCounterMetrics(QStringLiteral("WLT8266BM")));
1517
EXPECT_FALSE(apexbike::usesWlt8266bmDistanceCounterMetrics(QStringLiteral("WLT8266BM025B")));
1618
EXPECT_FALSE(apexbike::usesWlt8266bmDistanceCounterMetrics(QStringLiteral("APEX Bike")));

0 commit comments

Comments
 (0)