Sending user weight to Smart Trainer via ANT+FEC over BLE

一笑奈何 提交于 2021-02-05 11:31:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!