Skip to content

Commit

Permalink
Added defensive programming
Browse files Browse the repository at this point in the history
  • Loading branch information
JaapvanEkris authored Sep 3, 2024
1 parent 1c76ea1 commit dbe40b0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions app/peripherals/ant/FEPeripheral.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ function createFEPeripheral (antManager) {
0x11, // Page 17
0xFF, // Reserved
0xFF, // Reserved
...Messages.intToLEHexArray(sessionData.distancePerStroke, 1), // Stroke Length in 0.01 m
...Messages.intToLEHexArray((sessionData.distancePerStroke > 0 ? sessionData.distancePerStroke : 0), 1), // Stroke Length in 0.01 m
0x7FFF, // Incline (Not Used)
0x00, // Resistance (DF may be reported if conversion to the % is worked out (value in % with a resolution of 0.5%).
...Messages.intToLEHexArray(feCapabilitiesBitField, 1)
]
if (sessionData.sessionStatus === 'Rowing') {
log.trace(`Page 17 Data Sent. Event=${dataPageCount}. Stroke Length=${sessionData.distancePerStroke}.`)
log.trace(`Hex Stroke Length=0x${sessionData.distancePerStroke.toString(16)}.`)
log.trace(`Hex Stroke Length=0x${sessionData.distancePerStroke > 0 ? sessionData.distancePerStroke.toString(16) : 0}.`)
}
break
case dataPageCount % 8 === 3: // 0x16 - Specific Rower Data (once a second)
Expand All @@ -128,9 +128,9 @@ function createFEPeripheral (antManager) {
0x16, // Page 22
0xFF, // Reserved
0xFF, // Reserved
...Messages.intToLEHexArray(sessionData.accumulatedStrokes, 1), // Stroke Count
...Messages.intToLEHexArray(sessionData.strokeRate, 1), // Cadence / Stroke Rate
...Messages.intToLEHexArray(sessionData.instantaneousPower, 2), // Instant Power (2 bytes)
...Messages.intToLEHexArray((sessionData.accumulatedStrokes > 0 ? sessionData.accumulatedStrokes : 0), 1), // Stroke Count
...Messages.intToLEHexArray((sessionData.strokeRate > 0 ? sessionData.strokeRate : 0), 1), // Cadence / Stroke Rate
...Messages.intToLEHexArray((sessionData.instantaneousPower > 0 ? sessionData.instantaneousPower : 0), 2), // Instant Power (2 bytes)
...Messages.intToLEHexArray((sessionData.fitnessEquipmentState + rowingCapabilitiesBitField), 1)
]
if (sessionData.sessionStatus === 'Rowing') {
Expand All @@ -144,9 +144,9 @@ function createFEPeripheral (antManager) {
channel,
0x10, // Page 16
0x16, // Rowing Machine (22)
...Messages.intToLEHexArray(sessionData.accumulatedTime, 1), // elapsed time
...Messages.intToLEHexArray(sessionData.accumulatedDistance, 1), // distance travelled
...Messages.intToLEHexArray(sessionData.cycleLinearVelocity, 2), // speed in 0.001 m/s
...Messages.intToLEHexArray((sessionData.accumulatedTime > 0 ? sessionData.accumulatedTime : 0), 1), // elapsed time
...Messages.intToLEHexArray((sessionData.accumulatedDistance > 0 ? sessionData.accumulatedDistance : 0), 1), // distance travelled
...Messages.intToLEHexArray((sessionData.cycleLinearVelocity > 0 ? sessionData.cycleLinearVelocity : 0), 2), // speed in 0.001 m/s
0xFF, // heart rate not being sent
...Messages.intToLEHexArray((sessionData.fitnessEquipmentState + feCapabilitiesBitField), 1)
]
Expand Down

0 comments on commit dbe40b0

Please sign in to comment.