0
votes

I have detected Peripheral devices using CBCentralManager,

Code i have used is this,

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self.navigationController setNavigationBarHidden: YES animated:NO];

    cbMgr = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
}


- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {


    //NSLog([NSString stringWithFormat:@"%@",[advertisementData description]]);

    NSLog (@"Discovered peripheral: %@", [peripheral name]);
    NSLog (@"Discovered peripheral identifier: %@", [peripheral identifier]);

    NSLog (@"peripheral services before connected: %@", [peripheral services]);
    NSLog (@"Discovered peripheral RSSI: %@", [peripheral RSSI]);
    NSLog (@"\n===============================================");

   // NSLog(@"adversting data %@",[NSString stringWithFormat:@"%@",[advertisementData description]]);
}

-(void)centralManager:(CBCentralManager *)central didRetrievePeripherals:(NSArray *)peripherals{
    NSLog(@"This is it!");
}

- (void)centralManagerDidUpdateState:(CBCentralManager *)central{
    NSString *messtoshow;

    switch (central.state) {
        case CBCentralManagerStateUnknown:
        {
            messtoshow=[NSString stringWithFormat:@"State unknown, update imminent."];
            break;
        }
        case CBCentralManagerStateResetting:
        {
            messtoshow=[NSString stringWithFormat:@"The connection with the system service was momentarily lost, update imminent."];
            break;
        }
        case CBCentralManagerStateUnsupported:
        {
            messtoshow=[NSString stringWithFormat:@"The platform doesn't support Bluetooth Low Energy"];
            break;
        }
        case CBCentralManagerStateUnauthorized:
        {
            messtoshow=[NSString stringWithFormat:@"The app is not authorized to use Bluetooth Low Energy"];
            break;
        }
        case CBCentralManagerStatePoweredOff:
        {
            messtoshow=[NSString stringWithFormat:@"Bluetooth is currently powered off."];
            break;
        }
        case CBCentralManagerStatePoweredOn:
        {
            messtoshow=[NSString stringWithFormat:@"Bluetooth is currently powered on and available to use."];
            [cbMgr scanForPeripheralsWithServices:nil options:nil];
            //[mgr retrieveConnectedPeripherals];

            //--- it works, I Do get in this area!

            break;
        }   

    }
}

Now i want detail like this,
Company ID:
Beacon Type:
Proximity UUID:
Major:
Minor:
Measured Power:

Is it possible to get this detail, I have tried to range beacon using the NSConcreteUUID but it does not return beacon data (as expected)..

1

1 Answers

3
votes

Unfortunately, you cannot read iBeacon info using CoreBluetooth. Apple blocks access to the raw data of iBeacon advertisements using these APIs. You can read full details about this here:

http://developer.radiusnetworks.com/2013/10/21/corebluetooth-doesnt-let-you-see-ibeacons.html

The best you can do to access some of these data is to use the CoreLocation ranging APIs, but you must know the PriximityUUID of the beacon up front to do this. I suspect the reason this has not worked for you may be because you are using the Bluetooth service UUID returned by CoreBluetooth to range for beacons with a given ProximityUUID using CoreLocation. This will not work, because these two UUIDs are actually different.

Again, ranging is the best you can do, but you will not be able to read the companyId, beaconType or measuredPower fields. I am afraid Apple has done a thorough job of blocking access to this info on iOS.