SlideShare a Scribd company logo
1 of 34
Download to read offline
Stefano Zanetti § DevCamp
iBeacons
the new low-powered way of location awareness
DevCamp
Stefano Zanetti
 Apple iOS Developer
Superpartes Innovation Campus & H-Farm	

!
 Co-founder di
# Pragma Mark ― www.pragmamark.org	

!
 [tt] @stezanna

[in] Stefano Zanetti

[fb] stefano.znt 

[email] stefano.zanetti@pragmamark.org
DevCamp
What is a Beacon?
A Bluetooth LE radio, some minor electronic
components and a button cell.
That’s all!
DevCamp
estimote.com radiusnetworks.com kontakt.io
DevCamp
How Beacons could change the world:
1. Your home will automatically react to you.
2. Your phone will give you a tour of museums.
3. Tickets that automatically load as you enter
sporting events.
4. …
DevCamp
Bluetooth LE
DevCamp
a lot of versions…
• first stable version 1.2 (2003)	

• 2.0 + EDR (2004)	

• 2.1 + EDR (2007)	

• 3.0 + HS (2009)	

• 4.0 & 4.0 LE (2010)
DevCamp
ISM 2.4GHz
This is in the globally unlicensed (but not
unregulated) Industrial, Scientific and Medical
(ISM) 2.4 GHz short-range radio frequency band
2400–2483.5 MHz
DevCamp
Mbit/s
0
7,5
15
22,5
30
version
v1.2 v2.o+EDR v3.0+HS v4.0 v4 LE
0,3Mbit/s
24Mbit/s24Mbit/s
3Mbit/s1Mbit/s
Speed
DevCamp
Other differences
classic bluetooth bluetooth low energy
latency 100ms 6ms
total time to
send data
100ms 3ms
peak current
consumption
<30mA <15mA
active slaves! 7
implementation
dependent
profile
standard BT profile
like SPP, DUN, PAN
GATT: Generic
Attribute profile
paring YES NO
DevCamp
Single and Double mode
Classic and low energy BT are not
compatible with each other
Single-mode
devices
Classic OR low
energy radio
Double-mode
devices
Classic AND low
energy radio
DevCamp
Connectionless
Devices do not need to maintain a connection
for useful information to be exchanged quickly
between them
The connectionless model solves these
problems by not defining the state of a
connection, but the state of the device
DevCamp
Stateless
Any client can send any request at any time
and the server will respond to the same
request in exactly the same way, regardless of
which client made the request.
DevCamp
Packet structure
DevCamp
Advertising packet
• Preamble - 1 Byte - fixed 8bit to synchronize bit timing and set
radio’s automatic gain control. 101010101 or 010101010
• Access Address - 4 Bytes - 32 fixed and random bit. 0x8E89BED6
(that in binary is 01101011011111011001000101110001.The preamble
would be 01010101)
• Header - 1 Byte - to describe the contents of packet
• Length - 1 Byte - to describe the payload length
• CRC - 3 Bytes: checksum calculated over PDU
• PDU (Protocol Data Unit) - 37 Bytes
DevCamp
iBeacon
DevCamp
iBeacon is a new technology that
extends Location Services in iOS
iBeacons provide a way to create and
monitor beacons that advertise certain
identifying information using Bluetooth
low energy wireless technology
(ref. iOS 7: Understanding Location Services - Apple)
DevCamp
example of iBeacon PDU
9F436059ADC00201061AFF4C000215B9407F30F5F8466EAFF925556B57FE6D010000FFB6
9F436059ADC0: Beacon’s Bluetooth MAC address
02: Length of the next field
01: Flags field identifier
06: Flags (LE General Discoverable Mode)
1A: Length of the next field
FF: Manufacturer Specific Data field identifier
4C00: Apple’s ID
0215: Two fixed bytes
B9407F30F5F8466EAFF925556B57FE6D: Proximity UUID
0100: Major
00FF: Minor
B6: Measured power
DevCamp
iOS Frameworks
iBeacon
Core
Bluetooth
Core
Location
DevCamp
iOS Classes
CLBeacon
CLLocationManager
CLLocationManagerDelegate
CBPeripheralManager
CBPeripheral
CBCentralManager
CLBeaconRegion
DevCamp
CLBeacon
Identifying the Beacon


    proximityUUID  property


    major  property


    minor  property
!
Determining the Beacon Distance


    proximity  property


    accuracy  property


    rssi  property
DevCamp
CLBeaconRegion
Initializing the Beacon Region
!! – initWithProximityUUID:identifier:
!! – initWithProximityUUID:major:identifier:
!! – initWithProximityUUID:major:minor:identifier:
Accessing the Beacon Attributes


    proximityUUID  property


    major  property


    minor  property
Delivering Beacon Notifications


    notifyEntryStateOnDisplay  property
Getting Beacon Advertisement Data
!! – peripheralDataWithMeasuredPower:
DevCamp
Code
DevCamp
iDevice as an iBeacon
self.manager = [[CBPeripheralManager alloc] initWithDelegate:self queue:nil];
!
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@“666972D4-9BE7-4E7D-
A1D4-973E1285BE19"];
!
CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:uuid
major:1234
minor:12
identifier:@“My region”];
!
[self.manager startAdvertising:[region peripheralDataWithMeasuredPower:nil]];
!
[self.manager stopAdvertising];
DevCamp
Monitoring & Ranging
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@“666972D4-9BE7-4E7D-
A1D4-973E1285BE19"];
!
CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:uuid
identifier:@“My region”];
!
self.manager = [[CLLocationManager alloc] init];
self.manager.delegate = self;
[self.manager startMonitoringForRegion:region];
[self.manager requestStateForRegion:region];
DevCamp
- (void)locationManager:(CLLocationManager *)manager didDetermineState:
(CLRegionState)state forRegion:(CLRegion *)region
{
if (state == CLRegionStateInside)
{
NSLog(@“INSIDE REGION");
[manager startRangingBeaconsInRegion:(CLBeaconRegion *)region];
}
}
!
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion
*)region
{
NSLog(@“ENTER REGION");
[manager startRangingBeaconsInRegion:(CLBeaconRegion *)region];
}
!
- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region
{
NSLog(@“EXIT REGION");
[manager stopRangingBeaconsInRegion:(CLBeaconRegion *)region];
}
DevCamp
- (void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray
*)beacons inRegion:(CLBeaconRegion *)region
{
for (CLBeacon *beacon in beacons)
{
NSLog(@"%@ %@ %@ %zd %f",
beacon.major,
beacon.minor,
@[@"Unknown", @"Immediate", @"Near", @"Far"][beacon.proximity],
beacon.rssi,
beacon.accuracy);
}
}
DevCamp
Background mode
DevCamp
Background region monitoring
If a region boundary is crossed while an app isn’t running, that app
is relaunched into the background to handle the event.
In iOS, regions associated with your app are tracked at all times,
including when the app isn’t running.
Similarly, if the app is suspended when the event occurs, it’s woken
up and given a short amount of time (around 10 seconds) to handle
the event.
When necessary, an app can request more background execution
time using the beginBackgroundTaskWithExpirationHandler:
method of the UIApplication class.
DevCamp
but…
Region monitoring in background takes very long time to notify the
region change (up to 15min).
there is a little trick:
Set the notifyEntryStateOnDisplay toYES
the location manager sends beacon notifications when the user turns
on the display and the device is already inside the region.These
notifications are sent even if your app is not running.
DevCamp
Limitations
1. Signal interference
2. Very small data packets
3. Easy to sniff advertising packets
4. Easy to clone a beacon
DevCamp
Internet & Books
http://developer.radiusnetworks.com
http://estimote.com
https://www.bluetooth.org/en-us/specification/adopted-specifications
“Bluetooth Low Energy:The Developer's Handbook” (Heydon, Robin)
DevCamp
Link
!
facebook.com/pragmamark	

facebook.com/groups/pragmamark	



@pragmamarkorg	

!
!
http://pragmamark.org
DevCamp
NSLog(@”Thank you!”);
stefano.zanetti@pragmamark.org

More Related Content

Similar to iBeacons - the new low-powered way of location awareness

IWAN Lab Guide
IWAN Lab GuideIWAN Lab Guide
IWAN Lab Guidejww330015
 
The Software Developers Guide to Prototyping Wearable Devices
The Software Developers Guide to Prototyping Wearable DevicesThe Software Developers Guide to Prototyping Wearable Devices
The Software Developers Guide to Prototyping Wearable DevicesTechWell
 
Indoor Wireless Localization - Zigbee
Indoor Wireless Localization - ZigbeeIndoor Wireless Localization - Zigbee
Indoor Wireless Localization - ZigbeeAlex Salim
 
How to Connect SystemVerilog with Octave
How to Connect SystemVerilog with OctaveHow to Connect SystemVerilog with Octave
How to Connect SystemVerilog with OctaveAmiq Consulting
 
R07_Senegacnik_CBO.pdf
R07_Senegacnik_CBO.pdfR07_Senegacnik_CBO.pdf
R07_Senegacnik_CBO.pdfcookie1969
 
Security Monitoring with eBPF
Security Monitoring with eBPFSecurity Monitoring with eBPF
Security Monitoring with eBPFAlex Maestretti
 
Netw 208 Success Begins / snaptutorial.com
Netw 208  Success Begins / snaptutorial.comNetw 208  Success Begins / snaptutorial.com
Netw 208 Success Begins / snaptutorial.comWilliamsTaylor65
 
[1C2]webrtc 개발, 현재와 미래
[1C2]webrtc 개발, 현재와 미래[1C2]webrtc 개발, 현재와 미래
[1C2]webrtc 개발, 현재와 미래NAVER D2
 
Athens IoT meetup #7 - Create the Internet of your Things - Laurent Ellerbach...
Athens IoT meetup #7 - Create the Internet of your Things - Laurent Ellerbach...Athens IoT meetup #7 - Create the Internet of your Things - Laurent Ellerbach...
Athens IoT meetup #7 - Create the Internet of your Things - Laurent Ellerbach...Athens IoT Meetup
 
Web Template Mechanisms in SOC Verification - DVCon.pdf
Web Template Mechanisms in SOC Verification - DVCon.pdfWeb Template Mechanisms in SOC Verification - DVCon.pdf
Web Template Mechanisms in SOC Verification - DVCon.pdfSamHoney6
 
Introduction to WebRTC
Introduction to WebRTCIntroduction to WebRTC
Introduction to WebRTCPatrick Cason
 
Using Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systemsUsing Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systemsSerge Stinckwich
 
OpenStack API's and WSGI
OpenStack API's and WSGIOpenStack API's and WSGI
OpenStack API's and WSGIMike Pittaro
 
The Ring programming language version 1.6 book - Part 7 of 189
The Ring programming language version 1.6 book - Part 7 of 189The Ring programming language version 1.6 book - Part 7 of 189
The Ring programming language version 1.6 book - Part 7 of 189Mahmoud Samir Fayed
 
Sunspot Final
Sunspot FinalSunspot Final
Sunspot Finalpauldeng
 
Score (smart contract for icon)
Score (smart contract for icon) Score (smart contract for icon)
Score (smart contract for icon) Doyun Hwang
 
Introducing the Sun SPOTs
Introducing the Sun SPOTsIntroducing the Sun SPOTs
Introducing the Sun SPOTsStefano Sanna
 

Similar to iBeacons - the new low-powered way of location awareness (20)

IWAN Lab Guide
IWAN Lab GuideIWAN Lab Guide
IWAN Lab Guide
 
The Software Developers Guide to Prototyping Wearable Devices
The Software Developers Guide to Prototyping Wearable DevicesThe Software Developers Guide to Prototyping Wearable Devices
The Software Developers Guide to Prototyping Wearable Devices
 
Indoor Wireless Localization - Zigbee
Indoor Wireless Localization - ZigbeeIndoor Wireless Localization - Zigbee
Indoor Wireless Localization - Zigbee
 
How to Connect SystemVerilog with Octave
How to Connect SystemVerilog with OctaveHow to Connect SystemVerilog with Octave
How to Connect SystemVerilog with Octave
 
R07_Senegacnik_CBO.pdf
R07_Senegacnik_CBO.pdfR07_Senegacnik_CBO.pdf
R07_Senegacnik_CBO.pdf
 
Security Monitoring with eBPF
Security Monitoring with eBPFSecurity Monitoring with eBPF
Security Monitoring with eBPF
 
Netw 208 Success Begins / snaptutorial.com
Netw 208  Success Begins / snaptutorial.comNetw 208  Success Begins / snaptutorial.com
Netw 208 Success Begins / snaptutorial.com
 
[1C2]webrtc 개발, 현재와 미래
[1C2]webrtc 개발, 현재와 미래[1C2]webrtc 개발, 현재와 미래
[1C2]webrtc 개발, 현재와 미래
 
Athens IoT meetup #7 - Create the Internet of your Things - Laurent Ellerbach...
Athens IoT meetup #7 - Create the Internet of your Things - Laurent Ellerbach...Athens IoT meetup #7 - Create the Internet of your Things - Laurent Ellerbach...
Athens IoT meetup #7 - Create the Internet of your Things - Laurent Ellerbach...
 
Web Template Mechanisms in SOC Verification - DVCon.pdf
Web Template Mechanisms in SOC Verification - DVCon.pdfWeb Template Mechanisms in SOC Verification - DVCon.pdf
Web Template Mechanisms in SOC Verification - DVCon.pdf
 
Introduction to WebRTC
Introduction to WebRTCIntroduction to WebRTC
Introduction to WebRTC
 
Using Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systemsUsing Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systems
 
OpenStack API's and WSGI
OpenStack API's and WSGIOpenStack API's and WSGI
OpenStack API's and WSGI
 
MattsonTutorialSC14.pdf
MattsonTutorialSC14.pdfMattsonTutorialSC14.pdf
MattsonTutorialSC14.pdf
 
The Ring programming language version 1.6 book - Part 7 of 189
The Ring programming language version 1.6 book - Part 7 of 189The Ring programming language version 1.6 book - Part 7 of 189
The Ring programming language version 1.6 book - Part 7 of 189
 
Sunspot Final
Sunspot FinalSunspot Final
Sunspot Final
 
Node.js - As a networking tool
Node.js - As a networking toolNode.js - As a networking tool
Node.js - As a networking tool
 
Using iBeacons in Titanium
Using iBeacons in TitaniumUsing iBeacons in Titanium
Using iBeacons in Titanium
 
Score (smart contract for icon)
Score (smart contract for icon) Score (smart contract for icon)
Score (smart contract for icon)
 
Introducing the Sun SPOTs
Introducing the Sun SPOTsIntroducing the Sun SPOTs
Introducing the Sun SPOTs
 

Recently uploaded

Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfFIDO Alliance
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024Stephanie Beckett
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfFIDO Alliance
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?Mark Billinghurst
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe中 央社
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...marcuskenyatta275
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...panagenda
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxDavid Michel
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftshyamraj55
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...CzechDreamin
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireExakis Nelite
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...FIDO Alliance
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimaginedpanagenda
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty SecureFemke de Vroome
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityScyllaDB
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyJohn Staveley
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Julian Hyde
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101vincent683379
 

Recently uploaded (20)

Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 

iBeacons - the new low-powered way of location awareness

  • 1. Stefano Zanetti § DevCamp iBeacons the new low-powered way of location awareness
  • 2. DevCamp Stefano Zanetti  Apple iOS Developer Superpartes Innovation Campus & H-Farm !  Co-founder di # Pragma Mark ― www.pragmamark.org !  [tt] @stezanna
 [in] Stefano Zanetti
 [fb] stefano.znt 
 [email] stefano.zanetti@pragmamark.org
  • 3. DevCamp What is a Beacon? A Bluetooth LE radio, some minor electronic components and a button cell. That’s all!
  • 5. DevCamp How Beacons could change the world: 1. Your home will automatically react to you. 2. Your phone will give you a tour of museums. 3. Tickets that automatically load as you enter sporting events. 4. …
  • 7. DevCamp a lot of versions… • first stable version 1.2 (2003) • 2.0 + EDR (2004) • 2.1 + EDR (2007) • 3.0 + HS (2009) • 4.0 & 4.0 LE (2010)
  • 8. DevCamp ISM 2.4GHz This is in the globally unlicensed (but not unregulated) Industrial, Scientific and Medical (ISM) 2.4 GHz short-range radio frequency band 2400–2483.5 MHz
  • 9. DevCamp Mbit/s 0 7,5 15 22,5 30 version v1.2 v2.o+EDR v3.0+HS v4.0 v4 LE 0,3Mbit/s 24Mbit/s24Mbit/s 3Mbit/s1Mbit/s Speed
  • 10. DevCamp Other differences classic bluetooth bluetooth low energy latency 100ms 6ms total time to send data 100ms 3ms peak current consumption <30mA <15mA active slaves! 7 implementation dependent profile standard BT profile like SPP, DUN, PAN GATT: Generic Attribute profile paring YES NO
  • 11. DevCamp Single and Double mode Classic and low energy BT are not compatible with each other Single-mode devices Classic OR low energy radio Double-mode devices Classic AND low energy radio
  • 12. DevCamp Connectionless Devices do not need to maintain a connection for useful information to be exchanged quickly between them The connectionless model solves these problems by not defining the state of a connection, but the state of the device
  • 13. DevCamp Stateless Any client can send any request at any time and the server will respond to the same request in exactly the same way, regardless of which client made the request.
  • 15. DevCamp Advertising packet • Preamble - 1 Byte - fixed 8bit to synchronize bit timing and set radio’s automatic gain control. 101010101 or 010101010 • Access Address - 4 Bytes - 32 fixed and random bit. 0x8E89BED6 (that in binary is 01101011011111011001000101110001.The preamble would be 01010101) • Header - 1 Byte - to describe the contents of packet • Length - 1 Byte - to describe the payload length • CRC - 3 Bytes: checksum calculated over PDU • PDU (Protocol Data Unit) - 37 Bytes
  • 17. DevCamp iBeacon is a new technology that extends Location Services in iOS iBeacons provide a way to create and monitor beacons that advertise certain identifying information using Bluetooth low energy wireless technology (ref. iOS 7: Understanding Location Services - Apple)
  • 18. DevCamp example of iBeacon PDU 9F436059ADC00201061AFF4C000215B9407F30F5F8466EAFF925556B57FE6D010000FFB6 9F436059ADC0: Beacon’s Bluetooth MAC address 02: Length of the next field 01: Flags field identifier 06: Flags (LE General Discoverable Mode) 1A: Length of the next field FF: Manufacturer Specific Data field identifier 4C00: Apple’s ID 0215: Two fixed bytes B9407F30F5F8466EAFF925556B57FE6D: Proximity UUID 0100: Major 00FF: Minor B6: Measured power
  • 21. DevCamp CLBeacon Identifying the Beacon    proximityUUID  property    major  property    minor  property ! Determining the Beacon Distance    proximity  property    accuracy  property    rssi  property
  • 22. DevCamp CLBeaconRegion Initializing the Beacon Region !! – initWithProximityUUID:identifier: !! – initWithProximityUUID:major:identifier: !! – initWithProximityUUID:major:minor:identifier: Accessing the Beacon Attributes    proximityUUID  property    major  property    minor  property Delivering Beacon Notifications    notifyEntryStateOnDisplay  property Getting Beacon Advertisement Data !! – peripheralDataWithMeasuredPower:
  • 24. DevCamp iDevice as an iBeacon self.manager = [[CBPeripheralManager alloc] initWithDelegate:self queue:nil]; ! NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@“666972D4-9BE7-4E7D- A1D4-973E1285BE19"]; ! CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:uuid major:1234 minor:12 identifier:@“My region”]; ! [self.manager startAdvertising:[region peripheralDataWithMeasuredPower:nil]]; ! [self.manager stopAdvertising];
  • 25. DevCamp Monitoring & Ranging NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@“666972D4-9BE7-4E7D- A1D4-973E1285BE19"]; ! CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@“My region”]; ! self.manager = [[CLLocationManager alloc] init]; self.manager.delegate = self; [self.manager startMonitoringForRegion:region]; [self.manager requestStateForRegion:region];
  • 26. DevCamp - (void)locationManager:(CLLocationManager *)manager didDetermineState: (CLRegionState)state forRegion:(CLRegion *)region { if (state == CLRegionStateInside) { NSLog(@“INSIDE REGION"); [manager startRangingBeaconsInRegion:(CLBeaconRegion *)region]; } } ! - (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region { NSLog(@“ENTER REGION"); [manager startRangingBeaconsInRegion:(CLBeaconRegion *)region]; } ! - (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region { NSLog(@“EXIT REGION"); [manager stopRangingBeaconsInRegion:(CLBeaconRegion *)region]; }
  • 27. DevCamp - (void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region { for (CLBeacon *beacon in beacons) { NSLog(@"%@ %@ %@ %zd %f", beacon.major, beacon.minor, @[@"Unknown", @"Immediate", @"Near", @"Far"][beacon.proximity], beacon.rssi, beacon.accuracy); } }
  • 29. DevCamp Background region monitoring If a region boundary is crossed while an app isn’t running, that app is relaunched into the background to handle the event. In iOS, regions associated with your app are tracked at all times, including when the app isn’t running. Similarly, if the app is suspended when the event occurs, it’s woken up and given a short amount of time (around 10 seconds) to handle the event. When necessary, an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler: method of the UIApplication class.
  • 30. DevCamp but… Region monitoring in background takes very long time to notify the region change (up to 15min). there is a little trick: Set the notifyEntryStateOnDisplay toYES the location manager sends beacon notifications when the user turns on the display and the device is already inside the region.These notifications are sent even if your app is not running.
  • 31. DevCamp Limitations 1. Signal interference 2. Very small data packets 3. Easy to sniff advertising packets 4. Easy to clone a beacon