Compare commits

...

1 Commits

Author SHA1 Message Date
Roberto Viola
160daeb19d fixed iOS resistance forced when FTMS was on without a central connected 2021-07-08 20:24:19 +02:00
5 changed files with 19 additions and 11 deletions

View File

@@ -16,7 +16,7 @@ public:
void virtualbike_zwift_ios();
double virtualbike_getCurrentSlope();
double virtualbike_getPowerRequested();
void virtualbike_updateFTMS(unsigned short normalizeSpeed, unsigned char currentResistance, unsigned short currentCadence, unsigned short currentWatt);
bool virtualbike_updateFTMS(unsigned short normalizeSpeed, unsigned char currentResistance, unsigned short currentCadence, unsigned short currentWatt);
};
#endif // LOCKSCREEN_H

View File

@@ -81,9 +81,10 @@ double lockscreen::virtualbike_getPowerRequested()
return 0;
}
void lockscreen::virtualbike_updateFTMS(UInt16 normalizeSpeed, UInt8 currentResistance, UInt16 currentCadence, UInt16 currentWatt)
bool lockscreen::virtualbike_updateFTMS(UInt16 normalizeSpeed, UInt8 currentResistance, UInt16 currentCadence, UInt16 currentWatt)
{
if(_virtualbike_zwift != nil)
[_virtualbike_zwift updateFTMSWithNormalizeSpeed:normalizeSpeed currentCadence:currentCadence currentResistance:currentResistance currentWatt:currentWatt];
return [_virtualbike_zwift updateFTMSWithNormalizeSpeed:normalizeSpeed currentCadence:currentCadence currentResistance:currentResistance currentWatt:currentWatt];
return false;
}
#endif

View File

@@ -31,12 +31,14 @@ let TrainingStatusUuid = CBUUID(string: "0x2AD3");
return peripheralManager.PowerRequested;
}
@objc public func updateFTMS(normalizeSpeed: UInt16, currentCadence: UInt16, currentResistance: UInt8, currentWatt: UInt16)
@objc public func updateFTMS(normalizeSpeed: UInt16, currentCadence: UInt16, currentResistance: UInt8, currentWatt: UInt16) -> Bool
{
peripheralManager.NormalizeSpeed = normalizeSpeed
peripheralManager.CurrentCadence = currentCadence
peripheralManager.CurrentResistance = currentResistance
peripheralManager.CurrentWatt = currentWatt
return peripheralManager.connected;
}
}
@@ -62,6 +64,7 @@ class BLEPeripheralManagerZwift: NSObject, CBPeripheralManagerDelegate {
public var CurrentWatt: UInt16! = 0
public var serviceToggle: Bool = false
public var connected: Bool = false
private var notificationTimer: Timer! = nil
//var delegate: BLEPeripheralManagerDelegate?
@@ -181,6 +184,7 @@ class BLEPeripheralManagerZwift: NSObject, CBPeripheralManagerDelegate {
var high : UInt16 = (((UInt16)(requests.first!.value![2])) << 8);
self.PowerRequested = (Double)((UInt16)(requests.first!.value![1]) + high);
}
self.connected = true;
self.peripheralManager.respond(to: requests.first!, withResult: .success)
print("Responded successfully to a read request")
}
@@ -195,6 +199,7 @@ class BLEPeripheralManagerZwift: NSObject, CBPeripheralManagerDelegate {
}
func peripheralManager(_ peripheral: CBPeripheralManager, central: CBCentral, didSubscribeTo characteristic: CBCharacteristic) {
self.connected = true;
print("Successfully subscribed")
updateSubscribers();
self.startSendingDataToSubscribers()
@@ -202,6 +207,7 @@ class BLEPeripheralManagerZwift: NSObject, CBPeripheralManagerDelegate {
func peripheralManager(_ peripheral: CBPeripheralManager, central: CBCentral, didUnsubscribeFrom characteristic: CBCharacteristic) {
//self.notificationTimer.invalidate()
self.connected = false;
print("Successfully unsubscribed")
}

View File

@@ -496,5 +496,5 @@ ios {
QMAKE_TARGET_BUNDLE_PREFIX = org.cagnulein
}
VERSION = 2.6.60
VERSION = 2.7.0

View File

@@ -629,12 +629,13 @@ void virtualbike::bikeProvider()
#ifndef IO_UNDER_QT
if(h)
{
h->virtualbike_updateFTMS(normalizeSpeed, (char)Bike->currentResistance().value(), (uint16_t)Bike->currentCadence().value() * 2, (uint16_t)Bike->wattsMetric().value());
h->virtualbike_setHeartRate(Bike->currentHeart().value());
if(!erg_mode)
slopeChanged(h->virtualbike_getCurrentSlope());
else
powerChanged(h->virtualbike_getPowerRequested());
if(h->virtualbike_updateFTMS(normalizeSpeed, (char)Bike->currentResistance().value(), (uint16_t)Bike->currentCadence().value() * 2, (uint16_t)Bike->wattsMetric().value())) {
h->virtualbike_setHeartRate(Bike->currentHeart().value());
if(!erg_mode)
slopeChanged(h->virtualbike_getCurrentSlope());
else
powerChanged(h->virtualbike_getPowerRequested());
}
return;
}
#endif