Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning ibeacon

You're reading from  Learning ibeacon

Product type Book
Published in Nov 2014
Publisher
ISBN-13 9781784397128
Pages 196 pages
Edition 1st Edition
Languages
Author (1):
Craig Gilchrist Craig Gilchrist
Profile icon Craig Gilchrist

Table of Contents (16) Chapters

Learning iBeacon
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Welcome to iBeacon Detecting Beacons – Showing an Advert Broadcasting Advertisements – Sending Offers Ranging Beacons – Hunting for Treasure Detecting Beacons in the Background – Location Dating Leaving Regions – Don't Forget Your Stuff Vendor SDKs – Buying and Configuring Beacons Advanced Tutorial – iBeacon Museum iBeacon Security – Understanding the Risks Index

Chapter 6. Leaving Regions – Don't Forget Your Stuff

So far, we have mostly discussed about the triggering functionality when your device enters a region from beacons that are static. However, that's not always going to be the case. Beacons, after all, are tiny Bluetooth devices that can be easily ported around with you.

One of the areas in which iBeacon technology offers an exciting opportunity is home automation. Very inexpensive computing power such as the Raspberry Pi (http://www.raspberrypi.org/) and innovative projects such as Ninja Blocks (https://ninjablocks.com/) are being funded by Kickstarter, which means that there is a growing community of people subscribing to the Internet of Things.

Beacons not only offer an excellent opportunity to trigger functionality based on your proximity to space in the world, but also gives you the ability to trigger notifications and features when items come into your range because beacons don't need to be fixed to bricks and mortar.

I'm sure if you...

Raspberry Pi


Raspberry Pi is a credit-card-sized computer that outputs high-resolution displays via HDMI and includes USB and Ethernet interfaces. It does everything you'd expect a desktop computer to do and also has a hackable circuitry.

The model A retails at $ 25 while B+ retails at $ 35, making it an incredible, hackable, affordable, and most of all, an accessible little device. The Pi has rekindled the hobbyist programmer and led to a whole host of home automation projects. Check out the latest Raspberry Pi home automation projects on the Raspberry Pi Foundation blog (http://bit.ly/pi-ha).

Ninja Blocks


Ninja Blocks started out as a Kickstarter project with the intention of connecting your physical world with the World Wide Web (WWW). The Kickstarter funding smashed its initial crowd-sourcing goals, and has since then shipped thousands of Ninja Blocks devices.

The platform is controlled by simple if this, then that style tasks using effectors and actuators. Both effectors and actuators can be made up in the physical or virtual world, which means you can do things such as post on Twitter when a door sensor is triggered by an opening door or turn on a lava lamp when a file is uploaded to Dropbox.

Find out more about Ninja Blocks on their official website at http://bit.ly/ninja-blocks.

Nest


The Nest project is a learning thermostat that controls your home's central heating system and learns about your habits to ensure that your home is always at the optimum temperature while also saving energy when you're not home.

Nest was recently acquired by Google who maintained its open platform API, allowing us programmers to continue to build solutions to work with it.

Find out more about the Nest API on the nest developer website at http://bit.ly/nestapi.

Phillips Hue


Phillips Hue is a network-enabled lighting system for your home. You swap all the bulbs in your home with Hue LED bulbs and configure the Hue bridge as a control hub for all of the bulbs in your home, giving you a completely personalized colored lighting depending on any factor you choose. You can change your lighting's color to red to match the creepy horror movie in the middle of the movie while your partner has a blue light in the bathroom to enable them to enjoy a nice relaxing bath.

The developer APIs allow you to trigger bulb configurations via HTTP posts, which means that you can automate almost any lighting situation you like using web hooks. You can trigger flashing red lights when there's breaking news on your favorite news channel or light the living room blue when you're mentioned on Twitter.

Find out more about the Hue API at the developer website at http://bit.ly/dev-hue.

Belkin WeMo


The Belkin WeMo switch is a programmable, Wi-Fi-enabled power switch that plugs directly into your power outlet and in which you plug your mains-powered devices into. The Belkin Wi-Fi-enabled WeMo switch lets you turn electronic devices on or off from anywhere. The WeMo switch uses your existing home Wi-Fi network to provide wireless control of TVs, lamps, stereos, heaters, fans, and more.

Find out more about the WeMo API at the developer website at http://bit.ly/devwemo.

iBeacon and home automation


You might be asking yourself where iBeacon fits into all of these amazing projects, and the answer is everywhere! What makes all of these projects so incredibly successful is their open platforms, which means that as an iOS developer with an iPhone or iPad, the world is your oyster.

My team at my company, Eden Agency, likes to play with the Internet of Things. Since we're a team of app developers, we like to get our hands dirty hacking at anything hackable, and this means I've been fortunate enough to get my hands on lots of technologies that are making waves in home automation.

A great middleware piece of hardware is the Ninja Block since it simplifies the interfacing between devices. By using Ninja Blocks, you can automatically wire up Belkin WeMo devices and Phillips Hue devices as actuators for any of your triggers, including web hooks.

By setting up a web hook, you can effectively trigger interactions in your home by doing a simple HTTP post request from your...

Beacon stickers


A number of companies are now developing iBeacon stickers that allow you to flip the idea of beacons being static and you being the variable position to the consideration that things in the real world can move and your device can trigger functionality based on that moving device.

For example, imagine that you want to track every place you've cycled using an iPhone that uses a cycling tracker app. Your app doesn't know the difference between when you're riding a bus, jogging, or cycling, and so would rely on you to tell it when you're cycling, which you are likely to forget at least once.

If you had a very small sticker, such as a beacon, attached to your bicycle, you could automatically start tracking your journey when you're on your bike without having to think about it.

Estimote and Jaalee are the two companies that have streamlined stickers such as beacons for exactly the kind of purpose I just described. Estimote Nearable beacons provide additional functionality including...

Our tutorial


We're going to demonstrate this sticker-type functionality by building an app that lets you add beacon profiles to a local database, and when the beacon is more than two meters away, the app shows a push notification.

Our companion app already includes three beacon profiles for the important things we might forget, which are listed in the following table:

UUID

Major

Minor

C5FAC3DE-33D5-469C-B094-AD527AF3ECCD

1

1

My wallet

2

My keys

3

My dog

The idea behind our app is that we never leave anything important behind. This means that we need to send a notification if the app isn't active and a beacon moves out of range or present an alert if the app is running at the time we lose the beacon.

Ranging beacons in the background

Since all beacons share the same UUID, we can't rely on the locationManager:didExitRegion delegate method because if we've got two out of the three important things with us, then we'll still be in the region and so we might leave something behind and not...

Building our app


Let's get started with building our "important stuff" app. We'll be using core data to store a list of our important stuff, and luckily, Apple has provided a very nice template, which should give us a head start. Consider the following steps:

  1. Fire up Xcode and create a new project. This time, choose Master-Detail Application as your project template and call the project My Important Stuff. Be absolutely sure to check the Use Core Data option as this tutorial heavily relies on it.

  2. We're going to need CoreLocation; so, add that to the linked frameworks and libraries as we've done in previous chapters.

Beginning the app with a database schema

Let's start with the database required to support the app. We'll need to store all of our beacons within the local database so that our location manager knows what's missing. We'll also need to remove any of the default entities that the template has created so that we don't cloud up our nice clean code. Consider the following steps:

  1. Open up...

Testing your app


Test your app using the companion OS X app provided. Add a wallet, keys, and dog to your collection as shown in the Location updates enabled in background modes figure and then turn the beacon profiles on and off in the companion app to test the notifications. Remember to wait for 5 minutes before receiving your notifications.

Summary


In this chapter, we learned about the amazing potential of iBeacons in home automation and also that beacons need not be fixed in the world. It's just possible for the beacon to be movable than the mobile user! Our tutorial showed us how to utilize background modes to range beacons in the background and also how to show local notifications when the app is in the background.

In the next chapter, we'll be discussing purchasing beacons from well-known manufacturers and their SDKs. We'll also be hacking Estimote beacons, which will require hardware beacons to complete the tutorial.

lock icon The rest of the chapter is locked
You have been reading a chapter from
Learning ibeacon
Published in: Nov 2014 Publisher: ISBN-13: 9781784397128
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}