TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Jul 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Joel Stewart.
Depends on: | |
SwiftySensors | ~> 0.3 |
Signals | ~> 4.0 |
This Swifty Sensor plugin adds Services and Characteristics for Kinetic Sensors (inRide and Smart Control). It uses the Objective C Kinetic SDK (included) to serialize and deserialize the messages coming from the Kinetic sensors. An API key is required (create a free API key after you create an account at the Kinetic Dev Portal).
Copy all of the swift files in the Sources
directory into you project. Also copy the Headers and Libraries directories. Include the appropriate lib for your project (libKineticSDKCocoa.a for macOS). You may need to add some includes to the header files in your Bridging Header (and create one if you don’t have one).
This library is not compatible with Swift Package Manager yet. It relies upon Kinetic’s Objective C SDK library and Objective C libs are not supported in the SPM yet.
When setting up your SensorManager, simply add the Kinetic Services to the scan list.
import SwiftySensors
import SwiftySensorsKinetic
// Launch the Kinetic SDK with your API Key
KineticSDK.launch("INSERT API KEY HERE")
// Customize what services you want to scan for
SensorManager.instance.setServicesToScanFor([
CyclingPowerService.self,
...
InRide2Service.self,
SmartControlService.self
])
The Kinetic inRide2 behaves a lot like a CyclingPowerService with some additional data and functionality (such as calibration).
The Kinetic Smart Control Service provides methods to control the Trainer:
// ERG Mode
let targetWatts: UInt16 = 150
smartControlService.setResistanceErg(targetWatts)
// Simulation Mode
let weight: Float = 85 // kgs
let rollingResistance: Float = 0.004 // asphault
let windResistance: Float = 0.6 // typical human
let grade: Float = 5 // ugh
let windSpeed: Float = 3 // meters / second headwind (negative for tail)
smartControlService.setSimulationMode(weight, rollingResistance: rollingResistance, windResistance: windResistance, grade: grade, windSpeed: windSpeed)
// Static Brake
let brakePercent: Float = 0.5 // 0 to 1
smartControlService.setResistanceBrake(brakePercent)
// Fluid Mode
let fluidMode: UInt8 = 2
smartControlService.setResistanceFluid(fluidMode)
None.
Example iOS App needs calibration demo.