ios - 从开放式 BLE 设备获取燃烧卡路里

标签 ios swift3 bluetooth bluetooth-lowenergy

<分区>


想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post .

关闭 5 年前

我正在开发一个应用程序,我必须在其中从 Mio-Fuse 等 BLE 设备获取燃烧的卡路里。

我能够从Apple Watch的健康套件中获取数据,但是当涉及到没有任何API的BLE可穿戴设备时,我无法追踪服务ID或特征ID。所以请帮助我。

提前致谢

最佳答案

您需要发布代码才能获得帮助。 首先查找您的设备 - 代码是 obj c,但您应该可以轻松地进行相应更改以实现快速

  if (central.state == CBCentralManagerStatePoweredOn) {
    [_centralManager scanForPeripheralsWithServices:@[[CBUUID UUIDWithString:@"0x180A"]] options:@{CBCentralManagerScanOptionAllowDuplicatesKey : @YES}];
    NSLog(@"Start scanning");
}

如果成功,则寻找这样的特征

 - (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {

for (CBService *service in peripheral.services) {
    NSLog(@"Discovered service1: %@", service.UUID);
    [peripheral discoverCharacteristics:nil forService:service];
}
if (_discoveredPeripheral != peripheral) {
    // Save a local copy of the peripheral, so CoreBluetooth doesn't get rid of it
    _discoveredPeripheral = peripheral;

    // And connect
    NSLog(@"Connecting to peripheral %@", peripheral);
    [_centralManager connectPeripheral:peripheral options:nil];
}
}

一旦连接,您将获得特征

关于ios - 从开放式 BLE 设备获取燃烧卡路里,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45795437/

上一篇:android - 如何在不使用 native 代码的情况下要求用户在 NativeScript 上启用蓝牙

下一篇:ios - UILabel 下划线文本,高字符低于基线

相关文章:

ios - swift 变量前的下划线 "_"是什么意思?

swift - 如何使用自定义模型类按部分字母顺序对 tableView 中的数据进行排序?

delphi - Mac OS X 上 Lazarus/FreePascal 上的蓝牙

ios - Objective-c 蓝牙说它已连接但 CBCentralManager 没有发现它

ios - iOS 8 中带有 native 预测的自定义键盘

ios - 在对 tableView 约束进行动画处理时,TableViewCells 最初的大小错误

ios - 如果我将使用Swift 3再次运行该应用程序,则该图像在文档目录中不存在

ios - 下载并使用大量头像

ios - 如何跨 View Controller 访问蓝牙数据?在 xcode 中

ios - NSURLSession 忽略 NSURLSessionConfiguration 缓存策略