从 BLE 血糖仪中检索血糖数据 - Swift

问题描述

我正在尝试通过 CoreBluetooth 从 Accucheck Instant 血糖仪获取血糖数据,这是从我的 didUpdateValueFor 特征方法调用方法 -

private func glucoseValue(from characteristic: CBCharacteristic) -> Int {
  guard let characteristicData = characteristic.value else { return -1 }
  let byteArray = [UInt8](characteristicData)

  let firstBitValue = byteArray[0] & 0x01
  if firstBitValue == 0 {
    // glucose Value Format is in the 2nd byte
    return Int(byteArray[1])
  } else {
    // glucose Value Format is in the 2nd and 3rd bytes
    return (Int(byteArray[1]) << 8) + Int(byteArray[2])
  }
}

然而,我没有得到正确的数据,而且我得到的值不正确。 你能帮我解决我做错了什么以及如何正确格式化数据以获得预期结果吗?

这是在我的控制台中为不同的 UUID 打印的内容-

characteristic ====

characteristic ====

characteristic ====

characteristic ====

提前致谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)