ios蓝牙 未测试

- (void)viewDidLoad {

[superviewDidLoad];

self.MyCertralManager=[[CBCentralManageralloc]initWithDelegate:selfqueue:nil];

// Do any additional setup after loading the view, typically from a nib.

}

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

switch(central.state) {

caseCBCentralManagerStateUnknown:

break;

caseCBCentralManagerStateUnsupported:

NSLog(@"1");

break;

caseCBCentralManagerStateUnauthorized:

break;

caseCBCentralManagerStatePoweredOff:

NSLog(@"2");

break;

caseCBCentralManagerStateResetting:

break;

caseCBCentralManagerStatePoweredOn:

NSLog(@"3");

[self.MyCertralManagerscanForPeripheralsWithServices:niloptions:nil];

[self.myActivityIndicatorstartAnimating];

break;

default:

break;

}

}

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

[self.myActivityIndicatorstopAnimating];

NSLog(@"the name%@",peripheral.name);

}

你可能感兴趣的:(ios蓝牙 未测试)