Skip to content

Commit 31269cf

Browse files
authored
Merge branch 'develop' into Joroto-X2
2 parents f0aefbd + 705b7d2 commit 31269cf

File tree

4 files changed

+37
-17
lines changed

4 files changed

+37
-17
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
.vscode/launch.json
44
.vscode/ipch
55
.vscode/extensions.json
6+
.idea/
67
test/tmp_pio_test_transport.cpp
78
data/config.txt
89
include/telegram_token.h
@@ -15,3 +16,4 @@ build/CMakeCache.txt
1516
.DS_Store
1617
.aider*
1718
.env
19+
C/Users/

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
### Changed
13+
- Added checks for IC SE Bike Connection.
1314

1415
### Hardware
1516

README.md

+9-14
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,18 @@
66
Find the source code here! -> [SS2kConfigApp](https://github.com/doudar/SS2kConfigApp/tree/develop)
77

88
You can get it from the Apple App Store here:
9-
10-
<div style="display: flex; justify-content: center; flex-wrap: wrap;">
11-
12-
<div style="flex: 1; min-width: 250px; text-align: center; margin-right: 20px;">
13-
<a href="https://apps.apple.com/us/app/smartspin2k-companion-app/id6477836948?itsct=apps_box_badge&amp;itscg=30200">
14-
<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;">
15-
</a>
16-
</div>
17-
18-
<div style="flex: 1; min-width: 230px; text-align: center;">
19-
<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;">
20-
</div>
21-
9+
<div style="display: flex; flex-wrap: wrap;">
10+
<a href="https://apps.apple.com/us/app/smartspin2k-companion-app/id6477836948?itscg=30200&itsct=apps_box_badge&mttnsubad=6477836948" style="display: inline-block;">
11+
<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;" />
12+
</a>
2213
</div>
2314

2415
Or for Android devices:
25-
[Companion App on Google Play Store](https://play.google.com/store/apps/details?id=com.smartspin2k.app&pcampaignid=web_share)
16+
<div style="display: flex; flex-wrap: wrap;">
17+
<a href="https://play.google.com/store/apps/details?id=com.smartspin2k.app">
18+
<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;" />
19+
</a>
20+
</div>
2621

2722
# About
2823
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.

src/BLE_Client.cpp

+25-3
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,31 @@ void SpinBLEClient::postConnect() {
646646
}
647647

648648
if ((_BLEd.charUUID == FITNESSMACHINEINDOORBIKEDATA_UUID)) {
649+
SS2K_LOG(BLE_CLIENT_LOG_TAG, "Updating Connection Params for: %s", _BLEd.peerAddress.toString().c_str());
650+
BLEDevice::getServer()->updateConnParams(pClient->getConnId(), 100, 100, 2, 1000);
651+
spinBLEClient.handleBattInfo(pClient, true);
652+
653+
auto featuresCharacteristic = pClient->getService(FITNESSMACHINESERVICE_UUID)->getCharacteristic(FITNESSMACHINEFEATURE_UUID);
654+
if (featuresCharacteristic == nullptr) {
655+
SS2K_LOG(BLE_CLIENT_LOG_TAG, "Failed to find FTMS features characteristic UUID: %s", FITNESSMACHINEFEATURE_UUID.toString().c_str());
656+
return;
657+
}
658+
659+
if (featuresCharacteristic->canRead()) {
660+
auto value = featuresCharacteristic->readValue();
661+
if (value.size() < sizeof(uint64_t)) {
662+
SS2K_LOG(BLE_CLIENT_LOG_TAG, "Failed to read FTMS features characteristic");
663+
return;
664+
}
665+
666+
// We're only interested in the machine fitness features, not the target setting features.
667+
auto features = *reinterpret_cast<const uint32_t *>(value.data());
668+
if (!(features & FitnessMachineFeatureFlags::Types::ElapsedTimeSupported) || !(features & FitnessMachineFeatureFlags::Types::RemainingTimeSupported)) {
669+
SS2K_LOG(BLE_CLIENT_LOG_TAG, "FTMS Control Point StartOrResume not supported");
670+
return;
671+
}
672+
}
673+
649674
NimBLERemoteCharacteristic *writeCharacteristic = pClient->getService(FITNESSMACHINESERVICE_UUID)->getCharacteristic(FITNESSMACHINECONTROLPOINT_UUID);
650675
if (writeCharacteristic == nullptr) {
651676
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() {
660685
SS2K_LOG(BLE_CLIENT_LOG_TAG, "Activated FTMS Training.");
661686
}
662687
writeCharacteristic->writeValue(FitnessMachineControlPointProcedure::StartOrResume, 1);
663-
SS2K_LOG(BLE_CLIENT_LOG_TAG, "Updating Connection Params for: %s", _BLEd.peerAddress.toString().c_str());
664-
BLEDevice::getServer()->updateConnParams(pClient->getConnId(), 120, 120, 2, 1000);
665-
spinBLEClient.handleBattInfo(pClient, true);
666688
}
667689
}
668690
}

0 commit comments

Comments
 (0)