0

i have recently purchased the estimote i have seen lots of demo but not able to detect the device.

Here is my code

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.peripheralManager = [[CBPeripheralManager alloc] initWithDelegate:self
                                                                     queue:nil
                                                                   options:nil];


    //Set location managaer delegate
    self.locationManager = [[CLLocationManager alloc] init];
    self.locationManager.delegate = self;


   NSUUID* uuid = [[NSUUID alloc] initWithUUIDString:@"B9407F30-F5F8-466E-AFF9-25556B57FE6D"];

    // Setup a new region with that UUID and same identifier as the broadcasting beacon
    self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@"testRegion"];
    self.beaconRegion.notifyEntryStateOnDisplay = YES;
    self.beaconRegion.notifyOnEntry = YES;
    self.beaconRegion.notifyOnExit = YES;
 [self.locationManager startMonitoringForRegion:self.beaconRegion];
[self.locationManager startRangingBeaconsInRegion:self.beaconRegion];
    // Do any additional setup after loading the view, typically from a nib.
}

// Delegate method returns Region state UNKNOWN!!!

-(void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
{

    switch (state) {
        case CLRegionStateInside:
            currentBeconRegion = (CLBeaconRegion *)region;
            [self.locationManager startRangingBeaconsInRegion:currentBeconRegion];
            NSLog(@"INSIDE the Region");
            break;
        case CLRegionStateOutside:
            NSLog(@"OUTSIDE the Region");
            break;
        case CLRegionStateUnknown:
        default:
            NSLog(@"Region state UNKNOWN!!!");
            [self.locationManager stopRangingBeaconsInRegion:self.beaconRegion];
            break;
    }
}

// Enter Region

    -(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
    //check if we're ranging the correct beacon
    if (![self.beaconRegion isEqual:region]) { return;}

    NSLog(@"didEnterRegion");
    if([region isKindOfClass:[CLBeaconRegion class]])
    {
        currentBeconRegion = (CLBeaconRegion *)region;
        if ([beaconRegion.identifier isEqualToString:@"testRegion"])
        {

            //send local notificaation
            UILocalNotification *notice = [[UILocalNotification alloc] init];
            notice.alertBody = @"Becoan Found!!!";
            notice.alertAction =@"View";
            [[UIApplication sharedApplication] presentLocalNotificationNow:notice];

            //srart raning beacon region
            [self.locationManager startRangingBeaconsInRegion:currentBeconRegion];


        }
    }

}

What i am missing? How can i change ProximityUUID.

Sunny Shah
  • 12,990
  • 9
  • 50
  • 86
  • Wow, you just changed your code entirely haha... Where in your code are you beginning your ranging and/or monitoring? – Lyndsey Scott Jun 02 '14 at 10:52
  • yes because i check the didDetermineState method it always says Region state UNKNOWN!!!. yes i am monitoring. – Sunny Shah Jun 02 '14 at 10:55
  • I'm asking where in your code are you beginning your ranging and/or monitoring. You need to post more code. – Lyndsey Scott Jun 02 '14 at 10:57
  • see the method didDetermineState in this check case CLRegionStateInside: in that i am using startRangingBeaconsInRegion. i dnot know the code for the monitoring. i want to detect the iBeacon is within the region – Sunny Shah Jun 02 '14 at 11:00
  • Your code is getting more and more convoluted with each edit... Why the multiple lines of turning on and off ranging in multiple methods? And also, according to this site http://joris.kluivers.nl/blog/2013/09/27/playing-with-ibeacon/, your UUID is correct (it's the UUID for all Estimote devices) and cannot be changed as of now. – Lyndsey Scott Jun 02 '14 at 13:44

1 Answers1

1

Just add one more line to the bottom of your viewDidLoad method:

 [self.locationManager startMonitoringBeaconsInRegion:self.beacon region];
davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • i have put that line but "didEnterRegion", "didRangeBeacons" "didExitRegion". none of this method calling. only didDetermineState is called with two times first time "Region state UNKNOWN!!!" second time "OUTSIDE the Region" – Sunny Shah Jun 02 '14 at 11:21
  • i have one doubt that about the ProximityUUID that will be same for all the device? – Sunny Shah Jun 02 '14 at 11:22
  • Yes, you transmitter's ProximityUUID must match the one you are using for monitoring (B9407F30-F5F8-466E-AFF9-25556B57FE6D) otherwise you will get results like you describe. You can use tools like iBeacon Locate for Android or ScanBracon for Mac to read iBeacon identifiers without knowing them up front, but iOS does not let you do this. – davidgyoung Jun 02 '14 at 11:45
  • i have estimote device near to my phone. if i use the B9407F30-F5F8-466E-AFF9-25556B57FE6D as ProximityUUID its not detecting. then how can i know the real ProximityUUID. my question is i want to detect that my device is near to the estimote device. i have done the above code. i am not getting the reasult means it may be ProximityUUID problem but i am not able to find how can i find this for the estimote device. Please hepl yar i am really strugging with this – Sunny Shah Jun 02 '14 at 11:50
  • How can i get the ProximityUUID of my estimote device? – Sunny Shah Jun 02 '14 at 12:09
  • As mentioned in my comment above, you can use ScanBeacon if you have a Mac or iBeacon Locate if you have an Android device. These will show you the ProximityUUID of your estimote device. The ProximityUUID you mention above is usually the default, but it is possible somebody has changed it on your unit. It is also possible its battery is dead and it is not transmitting at all -- battery life is only about a month. – davidgyoung Jun 02 '14 at 12:34