Last active
August 29, 2015 14:18
-
-
Save don/029f5694fbf374db1502 to your computer and use it in GitHub Desktop.
Code for ETE 2015 presentation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
locationManager = [[CLLocationManager alloc] init]; | |
locationManager.delegate = self; | |
NSUUID *uuid = [[NSUUID alloc] | |
initWithUUIDString:@"01122334-4556-6778-899A-ABBCCDDEEFF0"]; | |
CLBeaconRegion *region = [[CLBeaconRegion alloc] | |
initWithProximityUUID:uuid identifier:@"iBeacon"]; | |
region.notifyOnEntry = TRUE; | |
region.notifyOnExit = TRUE; | |
region.notifyEntryStateOnDisplay = TRUE; | |
[locationManager requestAlwaysAuthorization]; | |
[locationManager startMonitoringForRegion:region]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)locationManager:(CLLocationManager *)manager | |
didDetermineState:(CLRegionState)state | |
forRegion:(CLRegion *)region | |
{ | |
if(state == CLRegionStateInside) | |
{ | |
CLBeaconRegion *beaconRegion = (CLBeaconRegion *)region; | |
[locationManager startRangingBeaconsInRegion:beaconRegion]; | |
} | |
else if(state == CLRegionStateOutside) | |
{ | |
CLBeaconRegion *beaconRegion = (CLBeaconRegion *)region; | |
[locationManager stopRangingBeaconsInRegion:beaconRegion]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)locationManager:(CLLocationManager *)manager | |
didRangeBeacons:(NSArray *)beacons | |
inRegion:(CLBeaconRegion *)region | |
{ | |
CLBeacon *beacon = [beacons firstObject]; | |
switch (beacon.proximity) { | |
case CLProximityImmediate: | |
[[self rangeLabel] setText:@"Immediate"]; | |
break; | |
case CLProximityNear: | |
[[self rangeLabel] setText:@"Near"]; | |
break; | |
case CLProximityFar: | |
[[self rangeLabel] setText:@"Far"]; | |
break; | |
case CLProximityUnknown: | |
[[self rangeLabel] setText:@"Unknown"]; | |
break; | |
default: | |
[[self rangeLabel] setText:@"Error"]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Robosmart", | |
"id": "78:C5:E5:9A:15:AA", | |
"advertising": {}, | |
"rssi": -65, | |
"services": [ | |
"1800", "1801", "180a", | |
"f000ffc0-0451-4000-b000-000000000000", | |
"ff10", "ff20", "ff40" | |
], | |
"characteristics": [ | |
{ | |
"service": "ff10", | |
"characteristic": "ff11", | |
"properties": [ | |
"Read", "Write" | |
] | |
}, | |
{ | |
"service": "ff10", | |
"characteristic": "ff12", | |
"properties": [ | |
"Read", "Write" | |
] | |
}, | |
{ | |
"service": "ff10", | |
"characteristic": "ff16", | |
"properties": [ | |
"Read" | |
] | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
00 // http://www. | |
70 // p | |
68 // h | |
69 // i | |
6c // l | |
6c // l | |
79 // y | |
65 // e | |
64 // t | |
65 // e | |
00 // .com/ | |
72 // r | |
2f // / | |
61 // a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment