【发布时间】:2014-06-15 09:17:53
【问题描述】:
我很困惑。
我使用 CLBeaconRegion 创建了一个 Beacon,并使用 CBPeripheralManager 对其进行宣传:
- (void)startTransmitting:(NSUUID*)uuid major:(NSInteger)major minor:(NSInteger)minor identifier:(NSString*)identifier {
self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid
major:major
minor:minor
identifier:identifier];
self.beaconPeripheralData = [self.beaconRegion peripheralDataWithMeasuredPower:nil];
self.peripheralManager = [[CBPeripheralManager alloc] initWithDelegate:self
queue:nil
options:nil];
}
-(void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral {
if (peripheral.state == CBPeripheralManagerStatePoweredOn) {
NSLog(@"Powered On");
[self.peripheralManager startAdvertising:self.beaconPeripheralData];
} else if (peripheral.state == CBPeripheralManagerStatePoweredOff) {
NSLog(@"Powered Off");
[self.peripheralManager stopAdvertising];
}
}
我能够通过 CBCentralManager 接收 iBeacon:
self.centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
[self.centralManager scanForPeripheralsWithServices:nil options:nil];
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {
[self.peripherals addObject:peripheral];
NSLog(@"New Peripheral found and added... %@", peripheral);
}
这基本上有效。但是发送的和接收的 UUID 是不同的——在我看来应该是一样的。
--> 我做错了什么/理解错了吗??
【问题讨论】:
标签: ios uuid core-bluetooth ibeacon