问题
Does anyone has any knowledge of how to send user weight settings to DataPage 55 for a indoor Smart Trainer?
I want update user weight such that grade simulation can be made more realistic. I have managed to get Grade (data page 51) sent successfully and implementing the same format for User Weight doesn't seem to do anything.
func sendUserConfig(_ peripheral: CBPeripheral, characteristics: CBCharacteristic, userWeight: Double) {
let userWeightKG = (400)
let uWeightLSB = UInt8(Int(userWeightKG) & 0xFF)
let uWeightMSB = UInt8(Int(userWeightKG) >> 8) & 0xFF
print("<><> uWeightLSB:\(uWeightLSB) uWeightMSB:\(uWeightMSB)")
var rawArray = [UInt8]()
rawArray.insert(0xA4, at:0) //Sync
rawArray.insert(0x09, at:1) //Length
rawArray.insert(0x4F, at:2) //Acknowledge message type
rawArray.insert(0x05, at:3) //Channel
rawArray.insert(0x37, at:4) //Page 55
rawArray.insert(uWeightLSB, at:5)
rawArray.insert(uWeightMSB, at:6)
rawArray.insert(0xFF, at:7) // reserved
rawArray.insert(0xFF, at:8) // Bike Wheel Diameter Offset + Bike Weight LSN
rawArray.insert(0xFF, at:9) // Bike Weight MSB (0xFF = default invalid)
rawArray.insert(0xFF, at:10) // Bike Wheel Diameter (0xFF = default invalid)
rawArray.insert(0x00, at:11) // Gear Ratio (0x00 = default invalid)
rawArray.insert(0xFF, at:12) //ChkSum
let data = Data(rawArray)
peripheral.writeValue(data, for: characteristics, type: CBCharacteristicWriteType.withoutResponse)
}
Framing Format for the Message
回答1:
What I was missing was the unit. The user weight data expects a data with units of 0.01kg hence to send
40kg = 40 / 0.01 = 4000
100kg = 100 / 0.01 = 10000
来源:https://stackoverflow.com/questions/65860752/sending-user-weight-to-smart-trainer-via-antfec-over-ble