Kickr Fixups for WF Api 3.0beta08

.. still has a 20sec connection issue
.. no longer crashes on BTLE reset
This commit is contained in:
Mark Liversedge
2013-03-16 21:48:10 +00:00
parent 3155940155
commit 4df7af1f09
2 changed files with 15 additions and 15 deletions

View File

@@ -147,6 +147,8 @@ void Kickr::run()
// only get busy if we're actually connected
if (WFApi::getInstance()->isConnected(sd)) {
connectionloops = 0;
// We ALWAYS set load for each loop. This is because
// even though the device reports as connected we need
// to wait before it really is. So we just keep on
@@ -172,6 +174,19 @@ void Kickr::run()
currentslope = slope;
currentmode = mode;
}
// get telemetry
if (WFApi::getInstance()->hasData(sd)) {
pvars.lock();
WFApi::getInstance()->getRealtimeData(sd, &rt);
// set speed from wheelRpm and configured wheelsize
double x = rt.getWheelRpm();
if (devConf) rt.setSpeed(x * (devConf->wheelSize/1000) * 60 / 1000);
else rt.setSpeed(x * 2.10 * 60 / 1000);
pvars.unlock();
}
} else {
// 100ms in each loop, 30secs is 300 loops
if (++connectionloops > 300) {
@@ -179,18 +194,6 @@ void Kickr::run()
quit(-1);
}
}
if (WFApi::getInstance()->hasData(sd)) {
pvars.lock();
WFApi::getInstance()->getRealtimeData(sd, &rt);
// set speed from wheelRpm and configured wheelsize
double x = rt.getWheelRpm();
if (devConf) rt.setSpeed(x * (devConf->wheelSize/1000) * 60 / 1000);
else rt.setSpeed(x * 2.10 * 60 / 1000);
pvars.unlock();
}
// lets not hog cpu
msleep(100);
}

View File

@@ -134,9 +134,6 @@ static inline NSString* fromQString(const QString &string)
// connect and disconnect a device
-(WFSensorConnection *)connectDevice: (NSString *)uuid
{
// it takes far too long!
[[WFHardwareConnector sharedConnector] disableFirmwareCheck];
// just in case there is a discovery in action, lets cancel it...
[[WFHardwareConnector sharedConnector] cancelDiscoveryOnNetwork:WF_NETWORKTYPE_BTLE];