diff --git a/app/ble/ftms/IndoorBikeDataCharacteristic.js b/app/ble/ftms/IndoorBikeDataCharacteristic.js index 84d2274..b7cebef 100644 --- a/app/ble/ftms/IndoorBikeDataCharacteristic.js +++ b/app/ble/ftms/IndoorBikeDataCharacteristic.js @@ -58,10 +58,10 @@ export default class IndoorBikeDataCharacteristic extends bleno.Characteristic { if (this._updateValueCallback) { const bufferBuilder = new BufferBuilder() // Field flags as defined in the Bluetooth Documentation - // Instantaneous speed (default), Total Distance (4), Instantaneous Power (6) - // Total / Expended Energy (8), Heart Rate (9), Elapsed Time (11) - // 01010000 - bufferBuilder.writeUInt8(0x50) + // Instantaneous speed (default), Instantaneous Cadence (2), Total Distance (4), + // Instantaneous Power (6), Total / Expended Energy (8), Heart Rate (9), Elapsed Time (11) + // 01010100 + bufferBuilder.writeUInt8(0x54) // 00001011 bufferBuilder.writeUInt8(0x0B) @@ -69,6 +69,8 @@ export default class IndoorBikeDataCharacteristic extends bleno.Characteristic { // for some of the data types // Instantaneous Speed in km/h bufferBuilder.writeUInt16LE(data.speed * 100) + // Instantaneous Cadence in rotations per minute (we use this to communicate the strokes per minute) + bufferBuilder.writeUInt16LE(data.strokesPerMinute * 2) // Total Distance in meters bufferBuilder.writeUInt24LE(data.distanceTotal) // Instantaneous Power in watts diff --git a/app/ble/ftms/IndoorBikeFeatureCharacteristic.js b/app/ble/ftms/IndoorBikeFeatureCharacteristic.js index 4a71512..4c01098 100644 --- a/app/ble/ftms/IndoorBikeFeatureCharacteristic.js +++ b/app/ble/ftms/IndoorBikeFeatureCharacteristic.js @@ -23,13 +23,13 @@ export default class IndoorBikeDataCharacteristic extends bleno.Characteristic { onReadRequest (offset, callback) { // see https://www.bluetooth.com/specifications/specs/fitness-machine-service-1-0 for details // Fitness Machine Features for the IndoorBikeDataCharacteristic - // Total Distance Supported (2), Expended Energy Supported (9), + // Cadence Supported (1), Total Distance Supported (2), Expended Energy Supported (9), // Heart Rate Measurement Supported (10), Elapsed Time Supported (12), Power Measurement Supported (14) - // 00000100 01010110 + // 00000110 01010110 // Target Setting Features for the IndoorBikeDataCharacteristic // none // 0000000 0000000 - const features = [0x04, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] + const features = [0x06, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] log.debug('Features of Indoor Bike requested') callback(this.RESULT_SUCCESS, features.slice(offset, features.length)) } diff --git a/docs/backlog.md b/docs/backlog.md index 29e5b37..19ef719 100644 --- a/docs/backlog.md +++ b/docs/backlog.md @@ -5,7 +5,6 @@ This is the very minimalistic Backlog for further development of this project. ## Soon * monitor battery level of heart rate monitor and show hint if battery is low -* deliver strokes per minute in the simulated FTMS bike as Cadence * add an update script to simplify the migration to new versions * validate FTMS with more training applications and harden implementation (i.e. Holofit and Coxswain) * record a longer rowing session and analyze two encountered problems: 1) rarely the stroke rate doubles for a short duration (might be a problem with stroke detection when measurements are imprecise), 2) in one occasion the measured power jumped to a very high value after a break (40000 watts)