1

メイン キューのCBCenteralManagerinを初期化します。viewdidload初めて更新状態メソッドが呼び出され、Bluetooth デバイスのスキャンが開始されますが、didDiscoverPeripheral:デリゲート メソッドは呼び出されません。

コードは次のとおりです。

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.CM = [[CBCentralManager alloc]initWithDelegate:self queue:nil];
}

-(void)centralManagerDidUpdateState:(CBCentralManager *)central{

    if (central.state == CBCentralManagerStatePoweredOn) {

        [self.CM scanForPeripheralsWithServices:nil options:nil];

    }
}

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

}
-(void)centralManager:(CBCentralManager *)central didRetrieveConnectedPeripherals:(NSArray *)peripherals{

}
-(void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error{

}
-(void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error{

}
-(void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral{

}
4

0 に答える 0