tag:airfy.svbtle.com,2014:/feedairfy Inc.2014-07-15T05:14:08-07:00airfy Inc.https://airfy.svbtle.comteam@airfy.comSvbtle.comtag:airfy.svbtle.com,2014:Post/what-ble-means-for-the-iot-maker-community2014-07-15T05:14:08-07:002014-07-15T05:14:08-07:00What Bluetooth Low Energy means for the IoT maker community<h2 id="connecting-your-microcontrollers-to-the-inter_2">Connecting your microcontrollers to the internet <a class="head_anchor" href="#connecting-your-microcontrollers-to-the-inter_2">#</a>
</h2>
<p>There are alot of wireless standards aiming at lower-than-wifi power, zigbee, zwave, enotion to name a bunch,<br>
but none of them have wide consumers application, making it difficult for us hackers and makers to play with them.</p>
<p>Like me, Bluetooth Low Energy came out of Nokia, an important innovator in mobile wireless technology.<br>
It was renamed from Wibree to Bluetooth 4.0 when it was handed over to the Bluetooth Special Interest Group (SIG),<br>
which enabled it to follow in the footsteps of the popular bluetooth standard, despite being a totally different thing.</p>
<p>Designed from the ground up for super low battery consumption, it has successfuly made the bridge between<br>
high end mobile phones and super low power gadgets. For us IoT folks, this means we have an enormously powerful<br>
technology that enables us to connect our tiny gadgets to powerful consumer devices without any sort of middleman,<br>
no cables, no expensive power hungry wifi controllers.</p>
<h2 id="look-ma-no-cables_2">Look ma,… no cables <a class="head_anchor" href="#look-ma-no-cables_2">#</a>
</h2>
<p>My company airfy inc today launched its first smart home product on kickstarter that is aiming to be a consumer<br>
ready product. But hackers never forget where they came from, so we made the whole thing as open as it can possibly get.</p>
<p>It’s a personal pleasure to announce that the entirety of our mobile app is open source and the hardware is<br>
practically screaming for you to hack it. The open source realtime OS RIOT is being ported to it, although<br>
you could probably run freertos as well (no really, RIOT is awesome, you want this).</p>
<p>We’ll also give you GPIOS, a ton of them. And SPI and I2C and you know what, we’re even giving you a powerrail<br>
so you can glue sensors and stuff directly into the box and have them run off the internal batteries. I just<br>
built a soil sensor for my plants that give me updates about their moist. The whole thing, … no wires.</p>
<h2 id="end-to-end-ipv6_2">End to end ipv6 <a class="head_anchor" href="#end-to-end-ipv6_2">#</a>
</h2>
<p>At airfy, we are commited to the Internet of Things, and we litterally mean Internet. Like, real internet<br>
reachable ip addresses for every single thing you build. Ping your moist sensor from your friends house, because you can.<br>
BLE isn’t there yet, but we’re heading the right way, mowing down all the barricades for you.</p>
<h2 id="how-low-is-low-power_2">How low is low power <a class="head_anchor" href="#how-low-is-low-power_2">#</a>
</h2>
<p>Our product is a cortex-m0, ‘nough said. The performance versus power consumption of arm is unmatched, while BLE<br>
is its connecting companion with a datastream at full burst consuming as low as 300 microamps. That’s right, micro.<br>
And standby, oh my, don’t get me started, like… below a microamp. It’s so good that the thing lasts years.</p>
<h2 id="hackin39-there-slowly_2">Hackin’ there slowly <a class="head_anchor" href="#hackin39-there-slowly_2">#</a>
</h2>
<p>We’re going to get there, with your support. The Kickstarter campaign is our first consumer product, but also<br>
the beginning of my teams journey to bring IP connectivity to makers all over the world.</p>
<p><a href="https://www.kickstarter.com/projects/261147844/436145065">https://www.kickstarter.com/projects/261147844/436145065</a></p>
tag:airfy.svbtle.com,2014:Post/clone-a-beacon-ibeacon-and-the-proof-of-location-issue2014-07-10T08:24:56-07:002014-07-10T08:24:56-07:00Clone-a-beacon: iBeacon and the proof of location issue<p>In <a href="http://airfy.svbtle.com/building-ibeacon-applications-on-android">our previous issue, I covered the basics of using iBeacons in iOS and Android apps</a>, today I want to show some privacy and security issues, as well as how to clone and fake beacons such as Estimote, Shopkick, and how to get location based app rewards without ever leaving your desk.</p>
<p>Remember, iBeacons are really just numbers attached to distances. So to figure out if a user is near a shop, we’d simply check for their distance to an id that is known to be installed in that shop. Beacons really have no way of sending or receiving content, other than the hardcoded three part identifier, you will have to do the mapping in your app.</p>
<p>There’s usually two approaches this:</p>
<ul>
<li>hardcoding major/minor values to specific places or actions in your app</li>
<li>calling an external beacon fleet platform / CMS to obtain the relevant content</li>
</ul>
<p>While the former is simpler, it has the rather obvious disadvantage of you having to update the app for every beacon rollout or content change. External fleet management platforms usually give you an easy to integrate api. On top of being able to change the content dynamically, fleet management apis also have tools for large scale deployment, such as brand shops with thousands of beacons.</p>
<p>What none of them can do of course, is change the way iBeacons interact on the low level, which is what i want to write about next. If we recall the previous posts, iBeacons are basically broadcasting bluetooth low energy announcements. Every device in the vicinity of a beacon receives the identical frame “i am beacon nr. 123” and calculates the distance.<br>
The actual content, such as “This is my secret corner.” is in your app, and not part of the broadcast. </p>
<p>Beacon privacy/security is never about receiving content not intended for you. It is about:</p>
<ul>
<li>correlation tracking</li>
<li>false proof of location</li>
</ul>
<p>The first is a privacy issue, in that beacons are continuously broadcasting unique information that is easy to track and correlate to other private information. This really becomes an issue when a user is carrying a beacon, but it may also be a minor concern to restaurant chains and industrial applications who prefer to not give tracking abilities to the whole world. There have been suggested workarounds to this issue, and even implemented by some manufacturers. Typically, they would simply swap the major/minor every now and then to disrupt mass analysis of beacon data. A CMS/fleet management platform would know when the ids are swapped and simply re-map the correct content to the new ids.</p>
<p>The second issue, false prove of location, is about the fact that iBeacons are really really simple devices. Literally all you need to make one is a laptop or an iPhone. This together with the privacy problem also means it is easy to trick reward systems that rely on you being somewhere. Like “get a free coffee if you enter our shop 100 times”. Let me show you how, by just entering one of such hypothetical shops, a hundred times, without moving from my desk.</p>
<p>On my Android phone, I install the free app “iBeacon locate” by Radius Networks, and hit the “Locate iBeacons” to start scanning for beacons. Let’s say i’m sitting at my favorite store which uses Estimote beacons for rewards, so I get 3 entries in the scanner.</p>
<table>
<thead>
<tr>
<th>uuid</th>
<th>major</th>
<th>minor</th>
</tr>
</thead>
<tbody>
<tr>
<td>B9407F30-F5F8-466E-AFF9-25556B57FE6D</td>
<td>12</td>
<td>23</td>
</tr>
<tr>
<td>B9407F30-F5F8-466E-AFF9-25556B57FE6D</td>
<td>223</td>
<td>12</td>
</tr>
<tr>
<td>B9407F30-F5F8-466E-AFF9-25556B57FE6D</td>
<td>75</td>
<td>83</td>
</tr>
</tbody>
</table>
<p>These are 3 distinct devices. Probably the vendor installed them in different areas of the shop. One of them is for getting rewards in their app. I could track it down and steal it, but that’s sort of lame. Instead i’ll just clone it. For that, i’ll need an iphone with the same app from radius (androids can scan, iphones can transmit, weird isnt it), or i’ll just use my linux laptop:</p>
<pre><code class="prettyprint">sudo hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 B9 40 7F 30 F5 F8 46 6E AF F9 25 55 6B 57 FE 6D 00 0C 00 17 C5 00
</code></pre>
<p>I’ll not bother you with the details of bluetooth low energy, but let me break this down just a little bit:</p>
<table>
<thead>
<tr>
<th>Segment</th>
<th>What does it mean?</th>
</tr>
</thead>
<tbody>
<tr>
<td><code class="prettyprint">sudo hcitool -i hci0 cmd 0x08 0x0008 1E</code></td>
<td>Send announcements</td>
</tr>
<tr>
<td><code class="prettyprint">02 01 1A</code></td>
<td>I’m a non connectable device</td>
</tr>
<tr>
<td><code class="prettyprint">1A FF 4C 00</code></td>
<td>Apple-specific announcement</td>
</tr>
<tr>
<td><code class="prettyprint">02 15</code></td>
<td>iBeacon type</td>
</tr>
<tr>
<td><code class="prettyprint">B9407F30-F5F8-466E-AFF9-25556B57FE6D</code></td>
<td>Estimote</td>
</tr>
<tr>
<td><code class="prettyprint">00 0C</code></td>
<td>Major number 12</td>
</tr>
<tr>
<td><code class="prettyprint">00 17</code></td>
<td>Minor number 23</td>
</tr>
<tr>
<td><code class="prettyprint">c5</code></td>
<td>TX power</td>
</tr>
</tbody>
</table>
<p>Ok so i cloned the beacon using two simple steps. Now i can leave the store, and continue earning points at home by entering and existing the region, which is… turn the beacon on and off while my phone sits there doing nothing.</p>
<p>Cloning prevention is hard to implement, as there is no connection happening between client and device that would allow the device to uniquely identify each mobile phone, or the other way round. Apple ‘prevents’ cloning by disallowing developers to specify a wildcard as the uuid, so you just can’t scan for other beacons. However, all you need is an android phone.</p>
<p>At <a href="http://airfy.com">airfy</a>, what we’re doing to counter this is making our beacons dual-channel. That is, our beacon is both an iBeacon, and a different proprietary implementation that has security implemented. While you can still clone the iBeacon ids, you won’t get any rewards in apps that use our proprietary security extension. At the same time we can be apple certified and our beacons can do fancy stuff like wake up apps from background. </p>
tag:airfy.svbtle.com,2014:Post/building-ibeacon-applications-on-android2014-07-08T00:09:58-07:002014-07-08T00:09:58-07:00Building iBeacon applications on Android<p><em>This post is part of the series on working with beacons and mobile devices and was written by our CTO, <a href="http://github.com/aep">Arvid E. Picciani (aep)</a>. Arvid is an ex-Nokia engineer, IoT pioneer, and self-proclaimed embedded devices hacker.</em></p>
<p>Apple’s iBeacons are really Bluetooth in the core. Bluetooth Low Energy came out of Nokia, an important innovator in mobile wireless technology. It was renamed from Wibree to Bluetooth 4.0 when it was handed over to the Bluetooth Special Interest Group (SIG). It was designed from the ground up for super low battery consumption and succeeded. The major competitor Near Field Communication (NFC) uses even less power (zero), at a shorter range (centimeters), but is not available in popular devices like the iPhone.</p>
<p>On top of Bluetooth Low Energy, there are several alternative approaches to build proximity applications, such as Qualcomm’s Gimbal or Samsung’s Flybell. Each of them adds features or implements them differently. We currently assert that they will not receive the benefits of some iOS features, such as waking an app up near a beacon. In this post, i’d like to explain Apple’s configuration a little bit in details, which is a pre-requirement to understanding how to use them on Android.</p>
<p>Android brings Bluetooth Low Energy support with version 4.3. Unlike iOS, Android does not treat beacons in any special way and does not offer any core libraries. As an application developer, rather than fighting the OS API, you have to be aware of how beacons actually work, and implement most of the framework yourself.</p>
<p>iBeacons emit Bluetooth non-connectable announcement frames at a frequency of about 100-400ms with static content. You would fetch the first type of frame and parse its Manufacturing Specific Data field.</p>
<p>To get started with beacons on Android, you’d need an Android phone that supports Bluetooth 4.0 (Nexus 4, 5) and the Android developer environment ready setup. If you do not have a hardware beacon available, an iPhone will do as well. Download the “iBeacon Locate” app from the App Store and enable it to broadcast a beacon. If you do not have an iPhone, a Linux laptop with a Bluetooth 4.0 internal or USB stick will work as well. Basically just run:</p>
<pre><code class="prettyprint">sudo hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 BE EF BE EF BE EF BE EF BE EF BE EF DE AD F0 0D 00 00 00 00 C5 00
</code></pre>
<p>Getting started with your app is either really hard (implement your own Bluetooth scanner daemon and so on) or really easy thanks to the friendly folks at RadiusNetworks who give us a library that already does that for us.<br>
<a href="https://github.com/RadiusNetworks/android-ibeacon-service">You can get it at their GitHub</a></p>
<p>It implements most of the hard parts and makes it available in a similar fashion to the iOS API, which I explained in the previous series.</p>
<ul>
<li>IBeaconManager is an android Service that can be bound to your app</li>
<li>IBeaconConsumer is the callback interface you implement</li>
</ul>
<p>Start with binding the service:</p>
<pre><code class="prettyprint">private IBeaconManager iBeaconManager = IBeaconManager.getInstanceForApplication(this);
protected void onCreate(Bundle savedInstanceState) {
// ...
iBeaconManager.bind(this);
}
</code></pre>
<p>…and then start ranging beacons with a RangeNotifier</p>
<pre><code class="prettyprint">public void onIBeaconServiceConnect() {
iBeaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection iBeacons, Region region) {
Log.i(TAG, "I see Bacon "+iBeacons.iterator().next().getAccuracy()+
" meters away!”);
}
});
try {
iBeaconManager.startRangingBeaconsInRegion(new
Region("beefbeef-beef-beef-beef-beefdeadf00d" , null, null, null));
} catch (RemoteException e) { }
}
</code></pre>
<p>Android has its own set of quirk, that the library works around for you. But you should keep in mind that bound Android services may get killed when your UI is no longer visible, so build your application accordingly.</p>
<p>The same physical restrictions as on iPhones, also apply on Android. Bluetooth Low Energy and WiFi share the same frequency, and sometimes the same antenna. Unlike on iOS, where WiFi always takes priority and sometimes disables Bluetooth scanning, on Android it is the opposite. When continuously scanning for beacon frames, the users internet connection may be impaired.</p>
tag:airfy.svbtle.com,2014:Post/battery-friendly-indoor-positioning-with-ibeacon2014-07-03T00:46:05-07:002014-07-03T00:46:05-07:00Battery friendly indoor positioning with iBeacon<p><em>This post is the first of the series on working with beacons and mobile devices and was written by our CTO, <a href="http://github.com/aep">Arvid E. Picciani (aep)</a>. Arvid is an ex-Nokia engineer, IoT pioneer, and self-proclaimed embedded devices hacker.</em></p>
<p>Indoor positioning and proximity tracking have become universally available thanks to apples iBeacon profile. It allows any compatible mobile device track its location indoor, using tiny battery powered “beacons”. All much much less battery hungry than GPS. </p>
<p>If you remember the painful pairing process of classical Bluetooth, iBeacons are not like that. In fact, iBeacons don’t connect to devices at all. The communication is one way, in that the iBeacon only continuously broadcasts its unique device id together with the strength of its own signal. The device then calculates the distance by matching its own perceived signal strength to the one advertised by the device. All that the mobile phone really knows is that:</p>
<blockquote class="short">
<p>“There is an iBeacon with id X at Y meters distance”</p>
</blockquote>
<p>It is up to the individual application developer to figure out what to do with that information. Common use cases include showing the user location based advertising, such as “You are near our special offer, if you actually put down your phone for a second, you would see it”. Another cool use case is location based gamified rewards. “Get a free coffee if you visit all or 3 stores in the city”. For that, you will a way to match the devices major and minor numbers to something that has meaning in your application. “Number 06:03 is Tanja’s corner shop”</p>
<p>Bluetooth 4.0 Low Energy, also called Bluetooth Smart, is not backwards compatible with classic Bluetooth and requires Android 4.3 or iOS7 and later, as well as hardware support in the mobile phone, available in e.g. the iPhone 5s, iPhone 6, or the Google Nexus 4 and 5.</p>
<p>In the first part of my series on iBeacons, I will cover the basics of getting started with iOS.</p>
<p>If you don’t have an iOS, don’t despair, there will be love for Android later on!</p>
<h1 id="getting-started_1">Getting started <a class="head_anchor" href="#getting-started_1">#</a>
</h1>
<p>Since you are working on iOS, you will need, well, an iPhone, and a Mac. </p>
<p>If you don’t have a beacon hardware yet (<a href="http://airfy.com/beacon/">my company is launching one soon!</a>), that is fine, since <a href="https://github.com/mttrb/BeaconOSX">your Mac can emulate one using this handy tool</a></p>
<p>Because beacons are tiny location guides, iOS7 restricts availability to the geolocation classes. It requires 3 essential components:</p>
<ul>
<li>
<code class="prettyprint">CLLocationManager</code>, the iOS core api for geolocation</li>
<li>
<code class="prettyprint">CLBeaconRegion</code>, declaring a physical region using iBeacons</li>
<li>
<code class="prettyprint">CLLocationManagerDelegate</code>, receiving location updates in your application</li>
</ul>
<p>Telling the iOS core geolocation API to use beacons for location monitoring is as easy as declaring a ClBeaconRegion, which has to be restricted to one specific iBeacon vendor uuid. For this example, we’ll just use something funny. Note that you’ll have to enter the same uuid in OSXBeacon, or it won’t work.</p>
<pre><code class="prettyprint">NSString * const kBeaconUUID = @”beefbeef-beef-beef-beef-beefdeadf00d”
NSString * const identifier = @”com.myapp.example1"
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:kBeaconUUID];
CLBeaconRegion *beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:proximityUUID identifier:identifier];
</code></pre>
<p>There are two different methods available for getting changes to a <code class="prettyprint">CLBeaconRegion</code>. </p>
<h1 id="monitoring-and-ranging_1">Monitoring and Ranging <a class="head_anchor" href="#monitoring-and-ranging_1">#</a>
</h1>
<p>Monitoring is more battery friendly, giving you events when a user has exited or entered a region, it is supposed to work while your app is in the background. As of iOS7, it does not. The other interface is ranging, giving you periodic updates about all the beacons in a region. For maximum responsiveness, enable both.</p>
<pre><code class="prettyprint">locationManager = [CLLocationManager new];
locationManager.delegate = self;
locationManager startMonitoringForRegion: beaconRegion
locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
self.locationManager startMonitoringForRegion:self.region
locationManager startRangingBeaconsInRegion:beaconRegion
locationManager startUpdatingLocation
</code></pre>
<p>Note the counter-intuitive use of <code class="prettyprint">startUpdatingLocation</code>, which is actually intended to receive GPS coordinates. We set desiredAccuracy to the lowest and most battery friendly resolution, which disables GPS and uses cell towers to locate the device instead. Your delegate will now receive periodic updates of beacons in range:</p>
<pre><code class="prettyprint">(void)locationManager:CLLocationManager *)manager
</code></pre>
<p> didRangeBeacons:(NSArray *)beacons<br>
inRegion:(CLBeaconRegion *)region</p>
<p>When a beacon is within a region (i.e. visible) iOS knows 3 different proximity ranges: <code class="prettyprint">CLProximityImmediate</code>, <code class="prettyprint">CLProximityNear</code> and <code class="prettyprint">CLProximityFar</code>. It does calculate these ranges for you, and smoothes out transitions. For maximum responsiveness in for example smart home applications, we find that that <code class="prettyprint">CLProximityImmediate</code> works best, but your use case might be different.</p>
<p><code class="prettyprint">CLProximityUnknown</code> is a side effect on a caveat you should be aware of when using beacons in location applications: Bluetooth Low Energy and WiFi share the same frequency band, and sometimes even the same antenna. While transmitting data through WiFi, beacon signals are unavailable, and iOS may mark the proximity of the beacon as “unknown”.</p>
<p>When your application is in the background, beacon ranging may be unavailable as well, unless you have <code class="prettyprint">UiBackgroundModes = location</code> capabilities. Even then, iOS may decide to lower the update frequency dramatically after the user appears to be not using the phone any longer.</p>
<p>When they power the device again, you can receive an instantaneous update when setting <code class="prettyprint">region.notifyEntryStateOnDisplay = YES;</code> </p>
<p>Occasionally, iOS decides the user is no longer moving, and stops location updates anyway, which can be countered with <code class="prettyprint">locationManager.pausesLocationUpdatesAutomatically = NO;</code></p>
<h2 id="summary_2">Summary <a class="head_anchor" href="#summary_2">#</a>
</h2>
<p>iOS makes it real simple to get kickin’ with iBeacons by providing us the necessary low level tools to deal with them in their geo API. Unfortunately they also built in some caveats when it comes to using them in responsive applications, like actual indoor location guidance. Apple appears to be committed to making it work seamlessly throughout the next updates.</p>
<p>In our next post of the series, we will go in deeper and cover how to build stuff with beacons on Android, which is a much different experience.</p>