我正在开发一款应用程序,我必须从Mio-Fuse等BLE设备中获取燃烧卡路里。
我可以从Apple Watch的Health工具包中获取数据,但是当涉及到BLE可穿戴任何API时,我无法追踪服务ID或特征ID。所以请帮助我。
提前致谢
答案 0 :(得分:1)
您需要发布代码才能获得帮助。 首先查找您的设备 - 代码是obj c但您应该可以轻松地相应地更改swift
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];
}
}
一旦连接,您将获得特征