0
我很困惑。iBeacons发送和接收UUID
我创建使用CLBeaconRegion和广告它与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是不同的 - 在我看来应该是相同的。
- >我做错了什么/明白错误?
谢谢你的回答!这些现在很清楚。 – Marco