From 4df7af1f09af74f0d658c4ed14353cfa5c598ba5 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Sat, 16 Mar 2013 21:48:10 +0000 Subject: [PATCH] Kickr Fixups for WF Api 3.0beta08 .. still has a 20sec connection issue .. no longer crashes on BTLE reset --- src/Kickr.cpp | 27 +++++++++++++++------------ src/WFApi.mm | 3 --- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Kickr.cpp b/src/Kickr.cpp index 93958f5c5..2b1cb68bc 100644 --- a/src/Kickr.cpp +++ b/src/Kickr.cpp @@ -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); } diff --git a/src/WFApi.mm b/src/WFApi.mm index 523bb36c6..fb412e4bd 100644 --- a/src/WFApi.mm +++ b/src/WFApi.mm @@ -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];