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

"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 

Recently uploaded (20)

"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 

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