From 1ff5069d80c35f887f5cc807c5343f7d87921c3e Mon Sep 17 00:00:00 2001 From: Roberto Viola Date: Sat, 27 Jul 2024 15:27:05 +0200 Subject: [PATCH 1/5] it pairs but it doesn't steer --- src/ios/BLEPeripheralManager.swift | 5 +++ src/ios/virtualbike_zwift.swift | 55 ++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/src/ios/BLEPeripheralManager.swift b/src/ios/BLEPeripheralManager.swift index bd3d438e5..9119a05e5 100644 --- a/src/ios/BLEPeripheralManager.swift +++ b/src/ios/BLEPeripheralManager.swift @@ -27,6 +27,11 @@ let PowerFeatureCharacteristicUUID = CBUUID(string: "0x2A65") let PowerSensorLocationCharacteristicUUID = CBUUID(string: "0x2A5D") let PowerMeasurementCharacteristicUUID = CBUUID(string: "0x2A63") +let SterzoServiceUUID = CBUUID(string: "347b0001-7635-408b-8918-8ff3949ce592") +let SterzoWriteUUID = CBUUID(string: "347b0031-7635-408b-8918-8ff3949ce592") +let SterzoNotifyUUID = CBUUID(string: "347b0030-7635-408b-8918-8ff3949ce592") + + @objc public class virtualbike_ios_swift: NSObject { private var peripheralManager: BLEPeripheralManager! diff --git a/src/ios/virtualbike_zwift.swift b/src/ios/virtualbike_zwift.swift index b943a6e43..2af97a6e3 100644 --- a/src/ios/virtualbike_zwift.swift +++ b/src/ios/virtualbike_zwift.swift @@ -97,6 +97,10 @@ class BLEPeripheralManagerZwift: NSObject, CBPeripheralManagerDelegate { private var PowerFeatureCharacteristic: CBMutableCharacteristic! private var PowerSensorLocationCharacteristic: CBMutableCharacteristic! private var PowerMeasurementCharacteristic: CBMutableCharacteristic! + + private var SterzoService: CBMutableService! + private var SterzoWriteCharacteristic: CBMutableCharacteristic! + private var SterzoNotifyCharacteristic: CBMutableCharacteristic! public var LastFTMSMessageReceived: Data? @@ -254,6 +258,26 @@ class BLEPeripheralManagerZwift: NSObject, CBPeripheralManagerDelegate { PowerMeasurementCharacteristic] self.peripheralManager.add(PowerService) + // Sterzo + self.SterzoService = CBMutableService(type: SterzoServiceUUID, primary: true) + + let SterzoWriteProperties: CBCharacteristicProperties = [.write] + let SterzoWritePermissions: CBAttributePermissions = [.writeable] + self.SterzoWriteCharacteristic = CBMutableCharacteristic(type: SterzoWriteUUID, + properties: SterzoWriteProperties, value: nil, + permissions: SterzoWritePermissions) + + let SterzoNotifyProperties: CBCharacteristicProperties = [.notify] + let SterzoNotifyPermissions: CBAttributePermissions = [] + self.SterzoNotifyCharacteristic = CBMutableCharacteristic(type: SterzoNotifyUUID, + properties: SterzoNotifyProperties, + value: nil, + permissions: SterzoNotifyPermissions) + + + SterzoService.characteristics = [SterzoWriteCharacteristic, + SterzoNotifyCharacteristic] + self.peripheralManager.add(SterzoService) default: print("Peripheral manager is down") @@ -323,7 +347,11 @@ class BLEPeripheralManagerZwift: NSObject, CBPeripheralManagerDelegate { let responseData = Data(bytes: &response, count: 3) self.peripheralManager.updateValue(responseData, for: self.FitnessMachineControlPointCharacteristic, onSubscribedCentrals: nil) - } + } else if requests.first!.characteristic == self.SterzoWriteCharacteristic { + self.peripheralManager.respond(to: requests.first!, withResult: .success) + print("Responded successfully to a write request") + } + } func peripheralManager(_ peripheral: CBPeripheralManager, didReceiveRead request: CBATTRequest) { @@ -466,6 +494,12 @@ class BLEPeripheralManagerZwift: NSObject, CBPeripheralManagerDelegate { let heartRateData = Data(bytes: &heartRateBPM, count: MemoryLayout.size(ofValue: heartRateBPM)) return heartRateData } + + func float32ToUInt8Array(_ value: Float32) -> [UInt8] { + let bytes = withUnsafeBytes(of: value) { Array($0) } + return bytes.reversed() + } + func calculateIndoorBike() -> Data { let flags0:UInt8 = 0x64 @@ -477,13 +511,28 @@ class BLEPeripheralManagerZwift: NSObject, CBPeripheralManagerDelegate { return indoorBikeData } + static var angle: Float32 = 0 + @objc func updateSubscribers() { - if(self.serviceToggle == 3 || garmin_bluetooth_compatibility) + if(self.serviceToggle == 4) { + + /*if(BLEPeripheralManagerZwift.angle < 45) { + BLEPeripheralManagerZwift.angle = BLEPeripheralManagerZwift.angle + 1; + } else {*/ + BLEPeripheralManagerZwift.angle = -45; + //} + print("Angle \(BLEPeripheralManagerZwift.angle)") + let sterzoData = Data(bytes: float32ToUInt8Array(BLEPeripheralManagerZwift.angle), count: 4) + let ok = self.peripheralManager.updateValue(sterzoData, for: self.SterzoNotifyCharacteristic, onSubscribedCentrals: nil) + if(ok) { + self.serviceToggle = 0 + } + } else if(self.serviceToggle == 3 || garmin_bluetooth_compatibility) { let powerData = self.calculatePower() let ok = self.peripheralManager.updateValue(powerData, for: self.PowerMeasurementCharacteristic, onSubscribedCentrals: nil) if(ok) { - self.serviceToggle = 0 + self.serviceToggle = self.serviceToggle + 1 } } else if(self.serviceToggle == 2) { let cadenceData = self.calculateCadence() From fdf1e68986adfdaa96e16d87aad68d5f3614e307 Mon Sep 17 00:00:00 2001 From: Roberto Viola Date: Sat, 27 Jul 2024 15:51:27 +0200 Subject: [PATCH 2/5] seems to work! --- src/ios/virtualbike_zwift.swift | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/ios/virtualbike_zwift.swift b/src/ios/virtualbike_zwift.swift index 2af97a6e3..c4dacc8cb 100644 --- a/src/ios/virtualbike_zwift.swift +++ b/src/ios/virtualbike_zwift.swift @@ -511,17 +511,23 @@ class BLEPeripheralManagerZwift: NSObject, CBPeripheralManagerDelegate { return indoorBikeData } - static var angle: Float32 = 0 + static var angle: Float32 = 10 + static var angleCount: Int = 0 @objc func updateSubscribers() { if(self.serviceToggle == 4) { - - /*if(BLEPeripheralManagerZwift.angle < 45) { - BLEPeripheralManagerZwift.angle = BLEPeripheralManagerZwift.angle + 1; - } else {*/ - BLEPeripheralManagerZwift.angle = -45; - //} + BLEPeripheralManagerZwift.angleCount = BLEPeripheralManagerZwift.angleCount + 1 + if(BLEPeripheralManagerZwift.angleCount > 5) { + BLEPeripheralManagerZwift.angleCount = 0 + if(BLEPeripheralManagerZwift.angle < 0) { + BLEPeripheralManagerZwift.angle = 30 + } else { + BLEPeripheralManagerZwift.angle = -30; + } + } else { + BLEPeripheralManagerZwift.angle = BLEPeripheralManagerZwift.angle + 3.3; + } print("Angle \(BLEPeripheralManagerZwift.angle)") let sterzoData = Data(bytes: float32ToUInt8Array(BLEPeripheralManagerZwift.angle), count: 4) let ok = self.peripheralManager.updateValue(sterzoData, for: self.SterzoNotifyCharacteristic, onSubscribedCentrals: nil) From b09e704ee990276502b0da157a2d6dedc8b3f991 Mon Sep 17 00:00:00 2001 From: Roberto Viola Date: Sat, 27 Jul 2024 16:49:41 +0200 Subject: [PATCH 3/5] i can't understand yet the angle that zwift wants --- src/ios/virtualbike_zwift.swift | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ios/virtualbike_zwift.swift b/src/ios/virtualbike_zwift.swift index c4dacc8cb..6aac69a68 100644 --- a/src/ios/virtualbike_zwift.swift +++ b/src/ios/virtualbike_zwift.swift @@ -513,20 +513,27 @@ class BLEPeripheralManagerZwift: NSObject, CBPeripheralManagerDelegate { static var angle: Float32 = 10 static var angleCount: Int = 0 + static var angleToogle: Bool = false @objc func updateSubscribers() { if(self.serviceToggle == 4) { BLEPeripheralManagerZwift.angleCount = BLEPeripheralManagerZwift.angleCount + 1 - if(BLEPeripheralManagerZwift.angleCount > 5) { + if(BLEPeripheralManagerZwift.angleCount > 10) { BLEPeripheralManagerZwift.angleCount = 0 - if(BLEPeripheralManagerZwift.angle < 0) { + if(BLEPeripheralManagerZwift.angleToogle) { BLEPeripheralManagerZwift.angle = 30 + BLEPeripheralManagerZwift.angleToogle = false } else { BLEPeripheralManagerZwift.angle = -30; + BLEPeripheralManagerZwift.angleToogle = true } } else { - BLEPeripheralManagerZwift.angle = BLEPeripheralManagerZwift.angle + 3.3; + if(!BLEPeripheralManagerZwift.angleToogle) { + BLEPeripheralManagerZwift.angle = BLEPeripheralManagerZwift.angle - 3.3; + } else { + BLEPeripheralManagerZwift.angle = BLEPeripheralManagerZwift.angle + 3.3; + } } print("Angle \(BLEPeripheralManagerZwift.angle)") let sterzoData = Data(bytes: float32ToUInt8Array(BLEPeripheralManagerZwift.angle), count: 4) From e66db6bb8dcfbe47b2683c88c70c275d17cdd8d9 Mon Sep 17 00:00:00 2001 From: Roberto Viola Date: Wed, 31 Jul 2024 16:21:37 +0200 Subject: [PATCH 4/5] adding android zwift ride protocol --- .../zwiftridecontroller.proto | 114 ++++++++++++++++++ src/virtualdevices/virtualbike.cpp | 51 +++++++- src/virtualdevices/virtualbike.h | 2 + 3 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 src/devices/zwiftridecontroller/zwiftridecontroller.proto diff --git a/src/devices/zwiftridecontroller/zwiftridecontroller.proto b/src/devices/zwiftridecontroller/zwiftridecontroller.proto new file mode 100644 index 000000000..31e0cfb3e --- /dev/null +++ b/src/devices/zwiftridecontroller/zwiftridecontroller.proto @@ -0,0 +1,114 @@ +syntax = "proto2"; + +package org.cagnulen.qdomyoszwift; + +//---------------- Zwift Play messages +enum PlayButtonStatus { +ON = 0; +OFF = 1; +} +// The command code prepending this message is 0x07 +message PlayKeyPadStatus { +optional PlayButtonStatus RightPad = 1; +optional PlayButtonStatus Button_Y_Up = 2; +optional PlayButtonStatus Button_Z_Left = 3; +optional PlayButtonStatus Button_A_Right = 4; +optional PlayButtonStatus Button_B_Down = 5; +optional PlayButtonStatus Button_On = 6; +optional PlayButtonStatus Button_Shift = 7; +optional sint32 Analog_LR = 8; +optional sint32 Analog_UD = 9; +} + +message PlayCommandParameters { +optional uint32 param1 = 1; +optional uint32 param2 = 2; +optional uint32 HapticPattern = 3; +} + +message PlayCommandContents { +optional PlayCommandParameters CommandParameters = 1; +} + +// The command code prepending this message is 0x12 +// This is sent to the control point to configure and make the controller vibrate +message PlayCommand { +optional PlayCommandContents CommandContents = 2; +} + +// The command code prepending this message is 0x19 +// This is sent periodically when there are no button presses +message Idle { +optional uint32 Unknown2 = 2; +} + +//----------------- Zwift Ride messages +enum RideButtonMask { +LEFT_BTN = 0x00001; +UP_BTN = 0x00002; +RIGHT_BTN = 0x00004; +DOWN_BTN = 0x00008; +A_BTN = 0x00010; +B_BTN = 0x00020; +Y_BTN = 0x00040; + +Z_BTN = 0x00100; +SHFT_UP_L_BTN = 0x00200; +SHFT_DN_L_BTN = 0x00400; +POWERUP_L_BTN = 0x00800; +ONOFF_L_BTN = 0x01000; +SHFT_UP_R_BTN = 0x02000; +SHFT_DN_R_BTN = 0x04000; + +POWERUP_R_BTN = 0x10000; +ONOFF_R_BTN = 0x20000; +} + +enum RideAnalogLocation { +LEFT = 0; +RIGHT = 1; +UP = 2; +DOWN = 3; +} + +message RideAnalogKeyPress { +optional RideAnalogLocation Location = 1; +optional sint32 AnalogValue = 2; +} + +message RideAnalogKeyGroup { +repeated RideAnalogKeyPress GroupStatus = 1; +} + +// The command code prepending this message is 0x23 +message RideKeyPadStatus { +optional uint32 ButtonMap = 1; +optional RideAnalogKeyGroup AnalogButtons = 2; +} + +//------------------ Zwift Click messages +// The command code prepending this message is 0x37 +message ClickKeyPadStatus { +optional PlayButtonStatus Button_Plus = 1; +optional PlayButtonStatus Button_Minus = 2; +} + +//------------------ Device Information requested after connection +// The command code prepending this message is 0x3c +message DeviceInformationContent { +repeated uint32 Unknown1 = 2; +optional string DeviceName = 3; +optional string SerialNumber = 6; +optional string HardwareVersion = 7; +optional uint32 Unknown2 = 9; +optional uint32 Unknown3 = 10; +} + +message SubContent { +optional DeviceInformationContent Content = 1; +} + +message DeviceInformation { +optional uint32 Unknown1 = 1; +optional SubContent SubContent = 2; +} \ No newline at end of file diff --git a/src/virtualdevices/virtualbike.cpp b/src/virtualdevices/virtualbike.cpp index 5e7e0d463..2116136d3 100644 --- a/src/virtualdevices/virtualbike.cpp +++ b/src/virtualdevices/virtualbike.cpp @@ -381,6 +381,39 @@ virtualbike::virtualbike(bluetoothdevice *t, bool noWriteResistance, bool noHear serviceDataChanged.addCharacteristic(charData); } + // zwift ride controller + if(1) { + QBluetoothUuid _syncRxChar(QStringLiteral("00000003-19CA-4651-86E5-FA29DCDD09D1")); + QBluetoothUuid _syncTxChar(QStringLiteral("00000004-19CA-4651-86E5-FA29DCDD09D1")); + QBluetoothUuid _asyncChar(QStringLiteral("00000002-19CA-4651-86E5-FA29DCDD09D1")); + + QLowEnergyCharacteristicData charDataASyncChar; + charDataASyncChar.setUuid(_asyncChar); + charDataASyncChar.setValue(QByteArray(2, 0)); + charDataASyncChar.setProperties(QLowEnergyCharacteristic::Notify); + const QLowEnergyDescriptorData clientConfigAsyncChar(QBluetoothUuid::ClientCharacteristicConfiguration, + QByteArray(2, 0)); + charDataASyncChar.addDescriptor(clientConfigAsyncChar); + + QLowEnergyCharacteristicData charDataSyncTxChar; + charDataASyncChar.setUuid(_syncTxChar); + charDataASyncChar.setValue(QByteArray(1, 0)); + charDataASyncChar.setProperties(QLowEnergyCharacteristic::Indicate); + const QLowEnergyDescriptorData clientConfigSyncTxChar(QBluetoothUuid::ClientCharacteristicConfiguration, + QByteArray(1, 0)); + charDataASyncChar.addDescriptor(clientConfigAsyncChar); + + QLowEnergyCharacteristicData charDataSyncRxChar; + charDataASyncChar.setUuid(_syncRxChar); + charDataASyncChar.setProperties(QLowEnergyCharacteristic::Write | QLowEnergyCharacteristic::WriteNoResponse); + + serviceDataZwiftController.setType(QLowEnergyServiceData::ServiceTypePrimary); + serviceDataZwiftController.setUuid(QBluetoothUuid(QStringLiteral("00000001-19ca-4651-86e5-fa29dcdd09d1"))); + serviceDataZwiftController.addCharacteristic(charDataASyncChar); + serviceDataZwiftController.addCharacteristic(charDataSyncTxChar); + serviceDataZwiftController.addCharacteristic(charDataSyncRxChar); + } + //! [Start Advertising] leController = QLowEnergyController::createPeripheral(); Q_ASSERT(leController); @@ -411,6 +444,13 @@ virtualbike::virtualbike(bluetoothdevice *t, bool noWriteResistance, bool noHear if (!this->noHeartService || heart_only) { serviceHR = leController->addService(serviceDataHR); + QThread::msleep(100); + } + + // zwift ride + if(1) { + serviceZwiftController = leController->addService(serviceDataZwiftController); + QThread::msleep(100); } if (!echelon && !ifit) { @@ -984,8 +1024,17 @@ void virtualbike::reconnect() { if (battery) serviceBattery = leController->addService(serviceDataBattery); - if (!this->noHeartService || heart_only) + if (!this->noHeartService || heart_only) { serviceHR = leController->addService(serviceDataHR); + QThread::msleep(100); + } + + // zwift ride + if(1) { + serviceZwiftController = leController->addService(serviceDataZwiftController); + QThread::msleep(100); + } + #endif QLowEnergyAdvertisingParameters pars; diff --git a/src/virtualdevices/virtualbike.h b/src/virtualdevices/virtualbike.h index 3d9402e7e..e4853f11f 100644 --- a/src/virtualdevices/virtualbike.h +++ b/src/virtualdevices/virtualbike.h @@ -50,6 +50,7 @@ class virtualbike : public virtualdevice { QLowEnergyService *serviceFIT = nullptr; QLowEnergyService *service = nullptr; QLowEnergyService *serviceChanged = nullptr; + QLowEnergyService *serviceZwiftController = nullptr; QLowEnergyAdvertisingData advertisingData; QLowEnergyServiceData serviceDataHR; QLowEnergyServiceData serviceDataBattery; @@ -57,6 +58,7 @@ class virtualbike : public virtualdevice { QLowEnergyServiceData serviceData; QLowEnergyServiceData serviceDataChanged; QLowEnergyServiceData serviceEchelon; + QLowEnergyServiceData serviceDataZwiftController; QTimer bikeTimer; bluetoothdevice *Bike; CharacteristicWriteProcessor2AD9 *writeP2AD9 = 0; From 91989a138bf83cab7fdc2450bb5dcb14295e333d Mon Sep 17 00:00:00 2001 From: Roberto Viola Date: Wed, 31 Jul 2024 16:30:37 +0200 Subject: [PATCH 5/5] Revert "adding android zwift ride protocol" This reverts commit e66db6bb8dcfbe47b2683c88c70c275d17cdd8d9. --- .../zwiftridecontroller.proto | 114 ------------------ src/virtualdevices/virtualbike.cpp | 51 +------- src/virtualdevices/virtualbike.h | 2 - 3 files changed, 1 insertion(+), 166 deletions(-) delete mode 100644 src/devices/zwiftridecontroller/zwiftridecontroller.proto diff --git a/src/devices/zwiftridecontroller/zwiftridecontroller.proto b/src/devices/zwiftridecontroller/zwiftridecontroller.proto deleted file mode 100644 index 31e0cfb3e..000000000 --- a/src/devices/zwiftridecontroller/zwiftridecontroller.proto +++ /dev/null @@ -1,114 +0,0 @@ -syntax = "proto2"; - -package org.cagnulen.qdomyoszwift; - -//---------------- Zwift Play messages -enum PlayButtonStatus { -ON = 0; -OFF = 1; -} -// The command code prepending this message is 0x07 -message PlayKeyPadStatus { -optional PlayButtonStatus RightPad = 1; -optional PlayButtonStatus Button_Y_Up = 2; -optional PlayButtonStatus Button_Z_Left = 3; -optional PlayButtonStatus Button_A_Right = 4; -optional PlayButtonStatus Button_B_Down = 5; -optional PlayButtonStatus Button_On = 6; -optional PlayButtonStatus Button_Shift = 7; -optional sint32 Analog_LR = 8; -optional sint32 Analog_UD = 9; -} - -message PlayCommandParameters { -optional uint32 param1 = 1; -optional uint32 param2 = 2; -optional uint32 HapticPattern = 3; -} - -message PlayCommandContents { -optional PlayCommandParameters CommandParameters = 1; -} - -// The command code prepending this message is 0x12 -// This is sent to the control point to configure and make the controller vibrate -message PlayCommand { -optional PlayCommandContents CommandContents = 2; -} - -// The command code prepending this message is 0x19 -// This is sent periodically when there are no button presses -message Idle { -optional uint32 Unknown2 = 2; -} - -//----------------- Zwift Ride messages -enum RideButtonMask { -LEFT_BTN = 0x00001; -UP_BTN = 0x00002; -RIGHT_BTN = 0x00004; -DOWN_BTN = 0x00008; -A_BTN = 0x00010; -B_BTN = 0x00020; -Y_BTN = 0x00040; - -Z_BTN = 0x00100; -SHFT_UP_L_BTN = 0x00200; -SHFT_DN_L_BTN = 0x00400; -POWERUP_L_BTN = 0x00800; -ONOFF_L_BTN = 0x01000; -SHFT_UP_R_BTN = 0x02000; -SHFT_DN_R_BTN = 0x04000; - -POWERUP_R_BTN = 0x10000; -ONOFF_R_BTN = 0x20000; -} - -enum RideAnalogLocation { -LEFT = 0; -RIGHT = 1; -UP = 2; -DOWN = 3; -} - -message RideAnalogKeyPress { -optional RideAnalogLocation Location = 1; -optional sint32 AnalogValue = 2; -} - -message RideAnalogKeyGroup { -repeated RideAnalogKeyPress GroupStatus = 1; -} - -// The command code prepending this message is 0x23 -message RideKeyPadStatus { -optional uint32 ButtonMap = 1; -optional RideAnalogKeyGroup AnalogButtons = 2; -} - -//------------------ Zwift Click messages -// The command code prepending this message is 0x37 -message ClickKeyPadStatus { -optional PlayButtonStatus Button_Plus = 1; -optional PlayButtonStatus Button_Minus = 2; -} - -//------------------ Device Information requested after connection -// The command code prepending this message is 0x3c -message DeviceInformationContent { -repeated uint32 Unknown1 = 2; -optional string DeviceName = 3; -optional string SerialNumber = 6; -optional string HardwareVersion = 7; -optional uint32 Unknown2 = 9; -optional uint32 Unknown3 = 10; -} - -message SubContent { -optional DeviceInformationContent Content = 1; -} - -message DeviceInformation { -optional uint32 Unknown1 = 1; -optional SubContent SubContent = 2; -} \ No newline at end of file diff --git a/src/virtualdevices/virtualbike.cpp b/src/virtualdevices/virtualbike.cpp index a7342877b..ef7a65370 100644 --- a/src/virtualdevices/virtualbike.cpp +++ b/src/virtualdevices/virtualbike.cpp @@ -381,39 +381,6 @@ virtualbike::virtualbike(bluetoothdevice *t, bool noWriteResistance, bool noHear serviceDataChanged.addCharacteristic(charData); } - // zwift ride controller - if(1) { - QBluetoothUuid _syncRxChar(QStringLiteral("00000003-19CA-4651-86E5-FA29DCDD09D1")); - QBluetoothUuid _syncTxChar(QStringLiteral("00000004-19CA-4651-86E5-FA29DCDD09D1")); - QBluetoothUuid _asyncChar(QStringLiteral("00000002-19CA-4651-86E5-FA29DCDD09D1")); - - QLowEnergyCharacteristicData charDataASyncChar; - charDataASyncChar.setUuid(_asyncChar); - charDataASyncChar.setValue(QByteArray(2, 0)); - charDataASyncChar.setProperties(QLowEnergyCharacteristic::Notify); - const QLowEnergyDescriptorData clientConfigAsyncChar(QBluetoothUuid::ClientCharacteristicConfiguration, - QByteArray(2, 0)); - charDataASyncChar.addDescriptor(clientConfigAsyncChar); - - QLowEnergyCharacteristicData charDataSyncTxChar; - charDataASyncChar.setUuid(_syncTxChar); - charDataASyncChar.setValue(QByteArray(1, 0)); - charDataASyncChar.setProperties(QLowEnergyCharacteristic::Indicate); - const QLowEnergyDescriptorData clientConfigSyncTxChar(QBluetoothUuid::ClientCharacteristicConfiguration, - QByteArray(1, 0)); - charDataASyncChar.addDescriptor(clientConfigAsyncChar); - - QLowEnergyCharacteristicData charDataSyncRxChar; - charDataASyncChar.setUuid(_syncRxChar); - charDataASyncChar.setProperties(QLowEnergyCharacteristic::Write | QLowEnergyCharacteristic::WriteNoResponse); - - serviceDataZwiftController.setType(QLowEnergyServiceData::ServiceTypePrimary); - serviceDataZwiftController.setUuid(QBluetoothUuid(QStringLiteral("00000001-19ca-4651-86e5-fa29dcdd09d1"))); - serviceDataZwiftController.addCharacteristic(charDataASyncChar); - serviceDataZwiftController.addCharacteristic(charDataSyncTxChar); - serviceDataZwiftController.addCharacteristic(charDataSyncRxChar); - } - //! [Start Advertising] leController = QLowEnergyController::createPeripheral(); Q_ASSERT(leController); @@ -446,13 +413,6 @@ virtualbike::virtualbike(bluetoothdevice *t, bool noWriteResistance, bool noHear if (!this->noHeartService || heart_only) { serviceHR = leController->addService(serviceDataHR); - QThread::msleep(100); - } - - // zwift ride - if(1) { - serviceZwiftController = leController->addService(serviceDataZwiftController); - QThread::msleep(100); } if (!echelon && !ifit) { @@ -1070,17 +1030,8 @@ void virtualbike::reconnect() { if (battery) serviceBattery = leController->addService(serviceDataBattery); - if (!this->noHeartService || heart_only) { + if (!this->noHeartService || heart_only) serviceHR = leController->addService(serviceDataHR); - QThread::msleep(100); - } - - // zwift ride - if(1) { - serviceZwiftController = leController->addService(serviceDataZwiftController); - QThread::msleep(100); - } - #endif QLowEnergyAdvertisingParameters pars; diff --git a/src/virtualdevices/virtualbike.h b/src/virtualdevices/virtualbike.h index 2e41b765e..05fc1f90b 100644 --- a/src/virtualdevices/virtualbike.h +++ b/src/virtualdevices/virtualbike.h @@ -50,7 +50,6 @@ class virtualbike : public virtualdevice { QLowEnergyService *serviceFIT = nullptr; QLowEnergyService *service = nullptr; QLowEnergyService *serviceChanged = nullptr; - QLowEnergyService *serviceZwiftController = nullptr; QLowEnergyAdvertisingData advertisingData; QLowEnergyServiceData serviceDataHR; QLowEnergyServiceData serviceDataBattery; @@ -58,7 +57,6 @@ class virtualbike : public virtualdevice { QLowEnergyServiceData serviceData; QLowEnergyServiceData serviceDataChanged; QLowEnergyServiceData serviceEchelon; - QLowEnergyServiceData serviceDataZwiftController; QTimer bikeTimer; bluetoothdevice *Bike; CharacteristicWriteProcessor2AD9 *writeP2AD9 = 0;