lunedì 7 luglio 2014

Beacon su IOS


A seguito delle prove effettuate in questo post ed in questo post (usando in entrambi i casi un telefono Moto G con Android e librerie Radius) mi sono convertito ad IOS ed ho ripetuto l'esperienza usando un IPhone 4S con le medesime antenne usate in precedenza e le API di IOS



non ho ancora capito bene il motivo ma sembra che il segnale risulta nettamente piu' stabile su IOS che su Android (hardware o software???)


da notare che al contrario di Android su IOS vengono segnalati come valori negativi le fallite acquisizioni

il codice impiegato per misurare il segnale e' riportato in seguito (ripreso da questo link dall'esempio Art Gallery)

#import "ViewController.h"

#define ESTIMOTE_PROXIMITY_UUID [[NSUUID alloc] initWithUUIDString:@"4506F9C7-00F9-C206-C12C-C2F9C702D3C3"]

int oldminor;

@interface ViewController ()
@property (nonatomic, strong) NSMutableArray *beacons;
@property (nonatomic, strong) NSArray *paintings;
@property (nonatomic, strong) CLLocationManager *locationManager;
@property (nonatomic, strong) CLBeaconRegion *beaconRegion;


@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
_beacons = [[NSMutableArray alloc] init];
    
    _locationManager = [[CLLocationManager alloc] init];
    _locationManager.delegate = self;
    
    _beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:ESTIMOTE_PROXIMITY_UUID
                                                       identifier:@"lucainnoc.Ibeareader"];
}



- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewDidAppear:(BOOL)animated
{
    [_locationManager startRangingBeaconsInRegion:_beaconRegion];
}

- (void)viewDidDisappear:(BOOL)animated
{
    [_locationManager stopRangingBeaconsInRegion:_beaconRegion];
}

- (void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region
{
    if (beacons.count) {
        
        CLBeacon *closestBeacon;
        
        for (CLBeacon *beacon in beacons) {
         
            NSLog([NSString stringWithFormat:@"%f", beacon.accuracy]);
            
           
        }

    }
    
}



@end

Nessun commento:

Posta un commento

Sigaretta Elettronica

Avevo visto qualche tempo fa un documentario sulla RAI Svizzera sul carico inquinante delle sigarette elettroniche monouso Ne ho trovata una...