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