SlideShare une entreprise Scribd logo
1  sur  34
Télécharger pour lire hors ligne
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

Contenu connexe

Similaire à 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
 

Similaire à 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
 

Dernier

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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
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
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
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
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
"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
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 

Dernier (20)

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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
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)
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
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
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
"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
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 

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