我们试图将蓝牙设备的数据读取到 iphone。我们流过这个
https://github.com/paulw11/BTBackground。我们得到了设备名称和设备 uuid 编号和连接也很好。但我们未能获取数据。请指导我们
-(void) centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral {
self.connectedPeripheral=peripheral;
NSLog(@"Connected to %@(%@)",peripheral.name,peripheral.identifier.UUIDString);
peripheral.delegate=self;
NSLog(@"DeviceInfoUUID %@",_deviceInfoUUID);
[peripheral discoverServices:@[self.deviceInfoUUID]];
//we tried this also
// [peripheral discoverServices:nil];
}
#pragma mark - CBPeripheralManager delegate methods
-(void) peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error {
NSLog(@"peripheral.services %@",peripheral.services);
for (CBService *service in peripheral.services) {
NSLog(@"Discovered service %@",service.description);
if ([service.UUID isEqual:self.deviceInfoUUID]) {
[peripheral discoverCharacteristics:nil forService:service];
}
}
}
请指导我们代码有什么问题。我们是新的