From 47384b30fd060ceb44edfef24dd95f0924cb8837 Mon Sep 17 00:00:00 2001 From: Maxime Brunelle Date: Sun, 22 Dec 2024 17:41:22 -0500 Subject: [PATCH 1/3] Fix IC bike SE showing only zeroes The IC bike SE will stop sending notifications if an unsupported Fitness Machine Control Point procedure is used. To prevent it, read the machine fitness features to determine if the Elapsed Time Supported and the Remaining Time Supported bits are set in order to determine if the "Start or Resume" can be used. Also, reduce the connection parameters to 100 instead of 120 to be able to get the notifications which are sent every 500 ms. --- .gitignore | 1 + src/BLE_Client.cpp | 28 +++++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index c4b10095..cb58b594 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ .vscode/launch.json .vscode/ipch .vscode/extensions.json +.idea/ test/tmp_pio_test_transport.cpp data/config.txt include/telegram_token.h diff --git a/src/BLE_Client.cpp b/src/BLE_Client.cpp index 67ef9ded..74f53167 100644 --- a/src/BLE_Client.cpp +++ b/src/BLE_Client.cpp @@ -646,6 +646,31 @@ void SpinBLEClient::postConnect() { } if ((_BLEd.charUUID == FITNESSMACHINEINDOORBIKEDATA_UUID)) { + SS2K_LOG(BLE_CLIENT_LOG_TAG, "Updating Connection Params for: %s", _BLEd.peerAddress.toString().c_str()); + BLEDevice::getServer()->updateConnParams(pClient->getConnId(), 100, 100, 2, 1000); + spinBLEClient.handleBattInfo(pClient, true); + + auto featuresCharacteristic = pClient->getService(FITNESSMACHINESERVICE_UUID)->getCharacteristic(FITNESSMACHINEFEATURE_UUID); + if (featuresCharacteristic == nullptr) { + SS2K_LOG(BLE_CLIENT_LOG_TAG, "Failed to find FTMS features characteristic UUID: %s", FITNESSMACHINEFEATURE_UUID.toString().c_str()); + return; + } + + if (featuresCharacteristic->canRead()) { + auto value = featuresCharacteristic->readValue(); + if (value.size() < sizeof(uint64_t)) { + SS2K_LOG(BLE_CLIENT_LOG_TAG, "Failed to read FTMS features characteristic"); + return; + } + + // We're only interested in the machine fitness features, not the target setting features. + auto features = *reinterpret_cast(value.data()); + if (!(features & FitnessMachineFeatureFlags::Types::ElapsedTimeSupported) || !(features & FitnessMachineFeatureFlags::Types::RemainingTimeSupported)) { + SS2K_LOG(BLE_CLIENT_LOG_TAG, "FTMS Control Point StartOrResume not supported"); + return; + } + } + NimBLERemoteCharacteristic *writeCharacteristic = pClient->getService(FITNESSMACHINESERVICE_UUID)->getCharacteristic(FITNESSMACHINECONTROLPOINT_UUID); if (writeCharacteristic == nullptr) { SS2K_LOG(BLE_CLIENT_LOG_TAG, "Failed to find FTMS control characteristic UUID: %s", FITNESSMACHINECONTROLPOINT_UUID.toString().c_str()); @@ -660,9 +685,6 @@ void SpinBLEClient::postConnect() { SS2K_LOG(BLE_CLIENT_LOG_TAG, "Activated FTMS Training."); } writeCharacteristic->writeValue(FitnessMachineControlPointProcedure::StartOrResume, 1); - SS2K_LOG(BLE_CLIENT_LOG_TAG, "Updating Connection Params for: %s", _BLEd.peerAddress.toString().c_str()); - BLEDevice::getServer()->updateConnParams(pClient->getConnId(), 120, 120, 2, 1000); - spinBLEClient.handleBattInfo(pClient, true); } } } From 2bdd9727a5e175eb6ba6cd9e2c14928a782cc179 Mon Sep 17 00:00:00 2001 From: Anthony Doud Date: Thu, 9 Jan 2025 18:19:51 -0600 Subject: [PATCH 2/3] Tested for issues, and updated changelog.md --- .gitignore | 1 + CHANGELOG.md | 1 + 2 files changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index cb58b594..28192eee 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ SmartSpin_logfile.txt build/CMakeCache.txt *.log .DS_Store +C/Users/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 080ec42d..3b5563ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added ### Changed +- Added checks for IC SE Bike Connection. ### Hardware From d3854c7dd05cb810f73110aafe6943b18d8ca9d4 Mon Sep 17 00:00:00 2001 From: Anthony Doud Date: Thu, 9 Jan 2025 18:55:09 -0600 Subject: [PATCH 3/3] updated main readme.md --- README.md | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index de303e0b..4f4a6e24 100644 --- a/README.md +++ b/README.md @@ -6,23 +6,18 @@ Find the source code here! -> [SS2kConfigApp](https://github.com/doudar/SS2kConfigApp/tree/develop) You can get it from the Apple App Store here: - -
- -
- - Download on the App Store - -
- -
- ss2k banner -
- +
+ +Download on the App Store +
Or for Android devices: -[Companion App on Google Play Store](https://play.google.com/store/apps/details?id=com.smartspin2k.app&pcampaignid=web_share) +
+ +Download on Google Play + +
# About SmartSpin2k is a DIY project that allows you to turn any spin bike into a smart trainer. With SmartSpin2k, you can connect your spin bike to Zwift, TrainerRoad, or other popular training apps. This allows you to control your bike's resistance automatically, track your performance, and compete with other riders online.