Titanium and Estimotes :: Getting Started

The topic of iBeacons has begun to come up within the Titanium community and with the release of iOS 7 (and with Titanium SDK 3.2x due out shortly) it seemed like a subject worthy of discussion.  Some parameters for our discussions though.  We will be using Estimotes and iOS for the time being.

Understanding The Technology

Before we get into any code, it is important that we understand a bit about the underlying technology. At its very basic definition, an iBeacon is simply a Bluetooth transmitter.  But as we geek out a little bit, we will begin to see that it is so much more.  Originally, the use of Bluetooth was a complex, ornery process.  On one side we would have a device, say a cell phone, and on the other we had a Bluetooth headset.  The user would perform a complex series of steps nearly as complicated as the Konami Code in order to achieve that transcendent state known as: pairing.

Along comes Bluetooth Core Specification 4.0, and with it Bluetooth Low Energy (BLE).  The health and sports markets were the first to test the waters with heart monitors, glucose meters, and cadence monitors for cycling and running. Because of the costs at the time for each Bluetooth accessory, it makes sense that healthcare and wellness had the first ‘cool toys’.

But there was another Bluetooth profile, that as the costs dropped, began to emerge.  This particular profile, the Proximity Profile (PXP), allows a device to detect whether another device is nearby.  The device uses the RSSI (signal strength) of the radio receiver to determine how close another device is.  The signal, while fairly accurate, can be affected by environmental conditions and barriers.

So our first possible use case is to identify if a device is nearby.  This makes the marketing folks in the retail world all giddy, because now a user could opt-in to receive location based advertising!

But what if we were to add a second signal to the mix?  If the distance between two signals are known, we can determine that a device is in one of two locations.  Add a third signal, and we can trilaterate the position of a device. This allows for indoor location services similar to what can be done outdoors with GPS.

estimote-triangulation

Finding Hardware to Play With

The iPhone 4s and 3rd generation iPad are the first devices that support the underlying Bluetooth technology required for iBeacon support.  For those on the android side, the Samsung Galaxy line starting with the S3 have had this support.

Now, you could use your iPhone or iPad as a beacon, but what fun would that be?  Stand along Beacons are not cheap, but they won’t break your budget either. A quick google search for ‘ble beacons’ will return a good number of suppliers.

First App

Beacon Details

Each beacon has a unique id that is made up of three parts.  There is the UUID proper, a major number, and a minor number.  Estimotes all come with the same UUID (B9407F30-F5F8-466E-AFF9-25556B57FE6D).  If you haven’t already done so, I’d recommend you download the Estimote Virtual Beacon. Tap the green Beacons area. Selecting a beacon will bring up some details about it. Now, I don’t want to alarm anyone, but in order to isolate your emoticons, and to determine which one is which, some physical exertion may be required!  I had to carry 2 of mine at a time to the far end of the house in order to be sure I knew which ones were which.  You can also color code them within the app here as well. Now, take a note of the major and minor numbers of your Estimotes. These will be important as we progress through the series.

We will be using Joe Beuckman’s TiBeacons module (Github: Source. Download: TiBeacons .4) Now Joe has a demonstration app on Github that you can download and run.  Remember, you will have to run it on a device, as the simulator isn’t supported.

This section of code in the index.js sets up a beacon for ranging:

Estimote Range

It is a general match for all uuids that match, in this case, estimotes.

 

In the next edition, we will work with proximity.

Stephen Feather a founding partner of Feather Direct, a mobile design firm in the Atlanta, GA area. He worked directly with communications companies such as Netscape, Microsoft, and Oracle in the early days of the Internet. In 1996 he authored JavaScript by Example, one of the first publications on the then-new scripting language. He volunteers time to assist and train a new generation of app developers through online forums and local user groups.


Comments