Introduction to iBeacon - Meetupfiles.meetup.com/12356572/Introduction to iBeacon.pdf · What is...
Transcript of Introduction to iBeacon - Meetupfiles.meetup.com/12356572/Introduction to iBeacon.pdf · What is...
Introduction to iBeaconTM
Robb Sabolovic !
04/24/2014 Redmond, WA Xcoders Meeting
!!
iBeaconTM is Apple trademark covering location and proximity detection technology.
Agenda
Introduction to iBeaconTM Technology!
iBeaconTM HW and Communication understanding!
iBeaconTM application use cases open discussion.!
iOS 7.0+ CoreLocation iBeaconTM integration!
Questions / Demos
What is iBeacon
iBeaconTM is the Apple Trademark for an indoor positioning system that Apple Inc. calls "a new class of low-powered, low-cost transmitters that can notify nearby iOS 7 devices of their presence."
What is behind iBeaconBluetooth Low Energy (part of the new Bluetooth 4.0 or Bluetooth Smart standard) make iBeacon possible. !!Any device supporting Bluetooth 4.0 and beyond can be an iBeacon transmitter. However since iBeacon uses uni-directional non-connected advertisement packet transmission, extremely simple very low cost and low power devices can also be an iBeacon broadcasting device.
GATT = Generic Attribute Profile!ATT = Attribute Profile!L2CAP = Logic Link Control and Adaptation Protocol
iBeacon Broadcast EventsDuring one broadcast event, the message is be sent on three different Bluetooth low energy dedicated advertisement channels 37(2.402GHz), 38(2.426GHz) and 39(2.480GHz).
!Broadcast Interval is targeted at 100ms.!Delay is a pseudorandom delay up to 10ms !Device sleeps (<1uA) between the events.
iBeacon Packet Content
TX Power 2’s complement of !
measured TX power @1meter
0x8E89BED6
Preamble (1 byte)
Access Address (4 bytes)
PDU (2-39 bytes)
CRC (3 bytes)
Header (2 bytes)
MAC Address (6 bytes)
Data (up to 31 bytes)
iBeacon!Prefix!
(9 bytes)Proximity UUID
(16 bytes)Major
(2 bytes)Minor
(2 bytes)TX Power (2 bytes)
iBeacon Prefix (Fixed) 02 01 06 1A FF 4C 00 02 15
3276
8 va
lues
3276
8 va
lues
iBeacon RangingOne of the keys to iBeacon is the ability to range a device. It is this ranging that enables location based user interaction. !!!!!!!Immediate = few cm !Near = few meters !Far = ~10m !Unknown = Out to ~70m
Immediate
Near
Far
Unknown
Bluetooth Smart Beacon InteractionsGiven that we now know our proximity to a given point we can now offer something in relation to this point!!Not only “this is where you are” but also “this is what you can do” !
The relative proximity to a beacon can trigger:!• Open an app and/or perform a specific action within an app!• Push specific content to a user who opt-in
Phones as Smart BeaconsListening for beacons can enable twist to our concepts Still within micro-locationing / interaction !
Trigger actions based on your vicinity • Turn on/off lights • Lock/open computers • Pre-payment of tickets / merchandise • Etc. !
Beacon scanners can • Keep track of phones in vicinity
Use Case - Retail
Consumer!• Special promotions • Personal messages!• Recommendations!• Automatic check-in
Retailer!• Monitoring shopping behavior!• Advertisement!• Simplify payment handling!• Data collection
Use Case - Retail
Cloud service!• Beacon management!• Access information on user!• Push segmented information!• Security / Beacon validation
CoreLocation iBeacon Integration
Overview The Core Location framework lets you determine the current location or heading associated with a device. The framework uses the available hardware to determine the user’s position and heading. You use the classes and protocols in this framework to configure and schedule the delivery of location and heading events. You can also use it to define geographic regions and monitor when the user crosses the boundaries of those regions. In iOS, you can also define a region around a Bluetooth beacon. !Class References!CLBeacon!CLBeaconRegion!CLCircularRegion!CLGeocoder!CLHeading!CLLocation!CLLocationManager!CLPlacemark!CLRegion
CLBeaconRegionOverview A CLBeaconRegion object defines a type of region that is based on the device’s proximity to a Bluetooth beacon, as opposed to a geographic location. A beacon region looks for devices whose identifying information matches the information you provide. When that device comes in range, the region triggers the delivery of an appropriate notification. !Specifying a Beacon’s Identity You identify beacons using a combination of three values: The proximityUUID property contains the identifier that you use to identify your company’s beacons. You typically generate only one UUID for your company’s beacons but can generate more as needed. You generate this value using the uuidgen command-line tool. !The major property contains a value that can be used to group related sets of beacons. For example, a department store might assign the same major value for all of the beacons on the same floor. !The minor property specifies the individual beacon within a group. For example, for a group of beacons on the same floor of a department store, this value might be assigned to a beacon in a particular section
CLBeaconOverview The CLBeacon class represents a beacon that was encountered during region monitoring. You do not create instances of this class directly. The location manager object reports encountered beacons to its associated delegate object. You can use the information in a beacon object to identify which beacon was encountered. The identity of a beacon is defined by its proximityUUID, major, and minor properties. These values are coded into the beacon itself. !!Tasks Identifying the Beacon ! proximityUUID property!! major property!! minor property!!Determining the Beacon Distance ! proximity property!! accuracy property!! rssi property
CLLocationManagerOverview The CLLocationManager class defines the interface for configuring the delivery of location- and heading-related events to your application. You use an instance of this class to establish the parameters that determine when location and heading events should be delivered and to start and stop the actual delivery of those events. You can also use a location manager object to retrieve the most recent location and heading data. A location manager object provides support for the following location-related activities:!! •! Tracking large or small changes in the user’s current location with a configurable degree of
accuracy.!! •! Reporting heading changes from the onboard compass. (iOS only)! ! •! Monitoring distinct regions of interest and generating location events when the user enters or
leaves those regions.!! •! Deferring the delivery of location updates while the app is in the background. (iOS 6 and
later only)!! •! Reporting the range to nearby beacons.! Some location services require the presence of specific hardware on the given device. For example, heading information is available only for devices that contain a hardware compass. This class defines several methods that you can use to determine which services are currently available.
iBeaconSimple Xcode Example Demo … Linked Frameworks
CoreLocation and CoreBluetooth Frameworks are necessary for running an iBeacon application
iBeaconSimple Xcode Example Demo … ViewController.h
!#import <UIKit/UIKit.h> #import <CoreLocation/CoreLocation.h> #import <CoreBluetooth/CoreBluetooth.h> #import <AudioToolbox/AudioToolbox.h> !@interface ViewController : UIViewController <CLLocationManagerDelegate> !@property (strong, nonatomic) CLLocationManager *locationManager; @property (strong, nonatomic) CLBeaconRegion *beaconRegion; !@property (weak, nonatomic) IBOutlet UILabel *stateLabel; @property (weak, nonatomic) IBOutlet UILabel *majorLabel; @property (weak, nonatomic) IBOutlet UILabel *minorLabel; @property (weak, nonatomic) IBOutlet UILabel *rssiLabel; @property (weak, nonatomic) IBOutlet UILabel *distanceLabel; @property (weak, nonatomic) IBOutlet UILabel *proximityLabel; !@end
iBeaconSimple Xcode Example Demo … ViewController.m
!#import "ViewController.h" !@interface ViewController () !@end !@implementation ViewController !- (void)viewDidLoad { [super viewDidLoad]; // Initialize our location manager and set ourselves as delegate self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; // Create UUID with the same UUID as Broadcasting Device NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"E2C56DB5-DFFB-48D2-B060-D0F5A7101234"]; NSUInteger mymajor = 1; // Set Region to cover only one Major value within the defined UUID space self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID: uuid major: mymajor identifier: @"myregion"]; [self.locationManager startMonitoringForRegion:self.beaconRegion]; } !!- (void)locationManager:(CLLocationManager*)manager didEnterRegion:(CLRegion*)region { // Start Ranging of UUID based Region [self.locationManager startRangingBeaconsInRegion:self.beaconRegion]; } !. . .
iBeaconSimple Xcode Example Demo … ViewController.m Continued
!. . . !-(void)locationManager:(CLLocationManager*)manager didRangeBeacons:(NSArray*)beacons inRegion:(CLBeaconRegion*)region { CLBeacon *beacon = [[CLBeacon alloc] init]; beacon = [beacons lastObject]; self.stateLabel.text = @"Beacon found!"; self.majorLabel.text = [NSString stringWithFormat:@"MAJOR: %@", beacon.major]; self.minorLabel.text = [NSString stringWithFormat:@"MINOR: %@", beacon.minor]; self.rssiLabel.text = [NSString stringWithFormat:@"RSSI: %li", (long)beacon.rssi]; self.distanceLabel.text = [NSString stringWithFormat:@"DISTANCE: %f meters", (double)beacon.accuracy]; if (beacon.proximity == CLProximityUnknown) { self.proximityLabel.text = @"Proximity: Unknown"; self.majorLabel.text = @"Major:"; self.minorLabel.text = @"Minor:"; self.rssiLabel.text = @"RSSI:"; self.distanceLabel.text = @"Distance:"; } else if (beacon.proximity == CLProximityImmediate) { AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); self.proximityLabel.text = @"Proximity: Immediate"; } else if (beacon.proximity == CLProximityNear) { self.proximityLabel.text = @"Proximity: Near"; } else if (beacon.proximity == CLProximityFar) { self.proximityLabel.text = @"Proximity: Far"; } }
iBeaconSimple Xcode Example Demo … ViewController.m Continued
!. . . !
-(void)locationManager:(CLLocationManager*)manager didExitRegion:(CLRegion*)region { // Stop Ranging of beaconRegion … Region based detection still active [self.locationManager stopRangingBeaconsInRegion:self.beaconRegion]; // Clear out values when Beacon is gone self.stateLabel.text = @"Beacon gone!"; self.majorLabel.text = @"Major:"; self.minorLabel.text = @"Minor:"; self.proximityLabel.text = @" "; self.rssiLabel.text = @"RSSI:"; self.distanceLabel.text = @"Distance:"; } !- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } !@end
Thanks for your participation
Reference Links: !
www.ti.com TI Low-cost Broadcaster Reference Design
TI SensorTag Hardware !
CoreLocation Framework (developer.apple.com) AirLocate Demo Code (developer.apple.com)
!