新QQ交流群:418536818,之前的群已满
1,引入CoreBluetooth.framework库文件
2,实现蓝牙协议,如:
@protocol CBCentralManagerDelegate;
3,导入头文件
#import <CoreBluetooth/CoreBluetooth.h>
@property(nonatomic,strong)CBCentralManager * cbManager;
self.cbManager = [[CBCentralManageralloc]initWithDelegate:selfqueue:nil ];
self.cbManager.delegate =self;
NSDictionary * dic = [NSDictionarydictionaryWithObjectsAndKeys:[NSNumbernumberWithBool:false],CBCentralManagerScanOptionAllowDuplicatesKey,nil];
[self.cbManagerscanForPeripheralsWithServices:niloptions:dic];
#pragma mark-------CBCentralManager代理
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI{
NSLog(@"-----%@ --uu = %@",peripheral.identifier,uu);
NSLog(@"------peripheral = %@,advertisementData = %@,RSSI = %@",peripheral,advertisementData,RSSI);
NSLog(@"---------------------------------------------------------------------");
}