ios蓝牙 未测试

2016-01-07  本文已影响0人  j了个p

- (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);

}

上一篇下一篇

猜你喜欢

热点阅读