我们需要从蓝牙设备获取数据到 IOS 设备core_bluetooth.frameworks。我们正在使用. didDisconnectPeripheral 每次都在 didConnectPeripheral 之后调用。我们得到的错误是错误是Error Domain=CBErrorDomain Code=7 "The specified device has disconnected from us." UserInfo={NSLocalizedDescription=The specified device has disconnected from us.}
我们试过的代码是://in ViewDidLoad
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO], CBCentralManagerOptionShowPowerAlertKey, nil];
self.central=[[CBCentralManager alloc] initWithDelegate:self queue:nil options:options];
//self.central=[[CBCentralManager alloc] initWithDelegate:self queue:dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0)];
self.discoveredPeripherals=[NSMutableArray new];
Run Code Online (Sandbox Code Playgroud)
//蓝牙开/关
-(void) centralManagerDidUpdateState:(CBCentralManager *)central {
NSString *stateString = nil;
switch(central.state)
{
case CBCentralManagerStateResetting:
stateString = @"The connection with the system service was momentarily lost, update imminent.";
break;
case CBCentralManagerStateUnsupported:
stateString = @"The …Run Code Online (Sandbox Code Playgroud) core-bluetooth bluetooth-lowenergy cbcentralmanager cbperipheralmanager