Skip to content

Commit

Permalink
Merge pull request #610 from madxime/bugs/fix-ic-se-bike-showing-zeroes
Browse files Browse the repository at this point in the history
Fix IC bike SE showing only zeroes
  • Loading branch information
doudar authored Jan 10, 2025
2 parents 1c120d4 + d3854c7 commit 705b7d2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -13,3 +14,4 @@ SmartSpin_logfile.txt
build/CMakeCache.txt
*.log
.DS_Store
C/Users/
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
23 changes: 9 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

<div style="display: flex; justify-content: center; flex-wrap: wrap;">

<div style="flex: 1; min-width: 250px; text-align: center; margin-right: 20px;">
<a href="https://apps.apple.com/us/app/smartspin2k-companion-app/id6477836948?itsct=apps_box_badge&amp;itscg=30200">
<img src="https://tools.applemediaservices.com/api/badges/download-on-the-app-store/black/en-us?size=250x83&amp;releaseDate=1711584000" alt="Download on the App Store" style="border-radius: 13px; width: 250px; height: 83px; margin-top: 10px;">
</a>
</div>

<div style="flex: 1; min-width: 230px; text-align: center;">
<img src="https://is1-ssl.mzstatic.com/image/thumb/PurpleSource221/v4/8c/f9/c5/8cf9c58e-9471-c012-d974-469f03794167/9b8c3d21-edf7-44d0-a8cc-651944b28ca4_Apple_iPhone_Xs_Max_Screenshot_1.png/230x0w.webp" alt="ss2k banner" style="height: 400px; width: auto;">
</div>

<div style="display: flex; flex-wrap: wrap;">
<a href="https://apps.apple.com/us/app/smartspin2k-companion-app/id6477836948?itscg=30200&itsct=apps_box_badge&mttnsubad=6477836948" style="display: inline-block;">
<img src="https://toolbox.marketingtools.apple.com/api/v2/badges/download-on-the-app-store/black/en-us?releaseDate=1711584000" alt="Download on the App Store" style="width: 176px; height: 82px; vertical-align: middle; object-fit: contain;" />
</a>
</div>

Or for Android devices:
[Companion App on Google Play Store](https://play.google.com/store/apps/details?id=com.smartspin2k.app&pcampaignid=web_share)
<div style="display: flex; flex-wrap: wrap;">
<a href="https://play.google.com/store/apps/details?id=com.smartspin2k.app">
<img src="https://play.google.com/intl/en_us/badges/static/images/badges/en_badge_web_generic.png" alt="Download on Google Play" style="height: 82px; vertical-align: middle; object-fit: contain;" />
</a>
</div>

# 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.
Expand Down
28 changes: 25 additions & 3 deletions src/BLE_Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const uint32_t *>(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());
Expand All @@ -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);
}
}
}
Expand Down

0 comments on commit 705b7d2

Please sign in to comment.