gpt4 book ai didi

ios - 从 iHealth 设备(ios - Swift)实时阅读?

转载 作者:行者123 更新时间:2023-11-28 08:58:01 25 4
gpt4 key购买 nike

我想显示来自 iHealth 设备(如 iHealth 应用程序)的实时测量数据。所以我实现了 iHealth-SDK。我可以获得已经存储的用户 prfile 数据。

{
HeightUnit: 0,
WeightUnit: 0,
dateofbirth: xxxxx,
gender: "Male",
height: 180.34,
logo: "https%3a%2f%2fcloud.ihealthlabs.com%2fimages%2fdefault%2fAvatar.png",
nickname: "Senthil kumar",
userid: "yyyyyyy",
weight: 29.483539113316585
}

我实现了 corebuletooth

扣除iHealth

var optionsdic : NSDictionary = NSDictionary(objectsAndKeys: false, CBCentralManagerScanOptionAllowDuplicatesKey)

centralManager!.scanForPeripheralsWithServices(nil, options: optionsdic as [NSObject : AnyObject])

上面的代码调用了它的委托(delegate)方法

     let devID = "12345678-1234-1234-1234-123456789123"

func centralManager(central: CBCentralManager!, didDiscoverPeripheral peripheral: CBPeripheral!, advertisementData: [NSObject : AnyObject]!, RSSI: NSNumber!) {

if peripheral.identifier.UUIDString == devID
{
self.centralManager?.stopScan()
self.myperipheral = peripheral
self.myperipheral?.delegate = self
self.centralManager?.connectPeripheral(peripheral, options: nil)
}
}


func centralManager(central: CBCentralManager!, didConnectPeripheral peripheral: CBPeripheral!) {

if peripheral.identifier.UUIDString == devID
{
if peripheral.state == CBPeripheralState.Connected
{
var uid : CBUUID = CBUUID(string: "FF70")
self.myperipheral = peripheral
self.myperipheral?.delegate = self
self.myperipheral?.discoverServices([CBUUID(string: peripheral.identifier.UUIDString)])
}
}
}

func centralManager(central: CBCentralManager!, didDisconnectPeripheral peripheral: CBPeripheral!, error: NSError!) {
println("Disconnected!== \(error)")
}


func peripheral(peripheral: CBPeripheral!, didDiscoverServices error: NSError!) {

if let servicePeripherals = peripheral.services as? [CBService]
{
for servicePeripheral in servicePeripherals
{
peripheral.discoverCharacteristics([servicePeripheral.UUID], forService: servicePeripheral)
}
}
}



func peripheral(peripheral: CBPeripheral!, didDiscoverCharacteristicsForService service: CBService!, error: NSError!) {

if let charactericsArr = service.characteristics as? [CBCharacteristic]
{
for charactericsx in charactericsArr
{
peripheral.setNotifyValue(true, forCharacteristic: charactericsx)

if charactericsx.UUID.UUIDString == devID{
var parameter = NSInteger(1)
let data = NSData(bytes: &parameter, length: 1)
peripheral.writeValue(data, forCharacteristic: charactericsx, type: CBCharacteristicWriteType.WithResponse)
}

if charactericsx.UUID.UUIDString == "FF70" || charactericsx.UUID.UUIDString == "FF71"{
var parameter = NSInteger(1)
let data = NSData(bytes: &parameter, length: 1)
peripheral.writeValue(data, forCharacteristic: charactericsx, type: CBCharacteristicWriteType.WithResponse)
}
peripheral.readValueForCharacteristic(charactericsx)
}
}

}

func readValueForCharacteristic(Charactersic: CBCharacteristic!){
println("character == \(Charactersic)")
}


func peripheral(peripheral: CBPeripheral!, didUpdateNotificationStateForCharacteristic characteristic: CBCharacteristic!, error: NSError!) {

if ((error) != nil) {
println("Error discovering service: \(error.localizedDescription)")
return;
}

println("description: \(characteristic.description), descriptors: \(characteristic.descriptors), properties: \(characteristic.properties), service :\(characteristic.service), value:\(characteristic.value)")

if (characteristic.isNotifying) {
peripheral.readValueForCharacteristic(characteristic)
}
}

我在 didDiscoverServices 方法中得到空数组 (servicePeripherals)。我想直接在 ios 应用程序和 iHealth 设备之间进行通信。 iHealth 设备读取的所有数据都显示在我的应用程序中。我坚持连接并使用核心蓝牙从 iHealth 设备读取实时数据。请给我建议。

最佳答案

我的办公 table 上刚放了一个无线脉搏血氧仪,我需要链接到 Raspberry Pi 或 Android(或任何东西,真的)在我看来,iHealth API 是云中的存储库。我不认为与 ble 设备的通信在他们的 API 中公开。

如果您像我一样仍在尝试从这些设备获取数据,也许可以通过观察 iPhone 和 ble 设备之间的数据交换来实现,但我不确定。

如果你知道了,请告诉我!!约翰·布罗汉

关于ios - 从 iHealth 设备(ios - Swift)实时阅读?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32564551/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com