Category Archives: Uncategorized

Physical Web Lightswitch

Physical Web Logo
As I’ve mentioned before I’ve been having a playing a bunch of WeMo kit and also looking at using Bluetooth LE and Physical Web beacons. I’ve been looking at putting the 2 together to solve a problem I’ve been having round the house. (Also one mentioned by somebody [@mattb I’m told by @knolleary], sorry can’t remember who, at this years ThingMonk)

Belkin ship a mobile phone app to control their products but it has a few drawbacks:
Belkin WeMo App

  1. Launching the app takes ages
  2. Vistors need to know what type of lights you own, then they have to install the right app
  3. You have to give visitors access to you Wifi
  4. Once you’ve granted access to the WiFi, Visitors are granted full control of your lights, including when no longer attached to the same network with no way to revoke access

(Having been reminded by @knolleary -> More of these types of problems discussed in @mattb’s Thingmonk talk at this year)

The Physical Web approach deals with the first 2 of these really nicely, a phone will detect the Eddystone beacon and offer a link to the control web page, so no app needed and no need to identify what type of devices you have, you just need to be close enough to it.

The second 2 problems are a little bit more tricky. Due to mitigation of some privacy problems at the moment to get the best out of a Physical Web URL it needs to be publicly accessible, this is because when a device detects a beacon it tries to access the URL in order to pull some summary/meta data to help with presenting it to the user. The problem with this is it exposes the devices IP address to the guys who deployed the beacon, which allows for the possibility of tracking that user. The workaround is that the Physical Web spec says that the URLs should be accessed by a proxy hence shielding the device from the URL, the problem is these proxies are all on the public internet and can only see public sites. But this does mean since it’s on the public internet you don’t need to give guest net access.

All this gets round problem number 3, but means that control for your living room lights needs to be publicly exposed to the internet. Which brings up nicely to problem 4, if it’s on the public internet how do you control who has access, once somebody has used the URL in the beacon it will be in their internet history and they can comeback and mess with your lights from home again.

You can add authentication to the URL, but a careful balance about how long any signed in session lasts will need to be struck as you don’t want to be flapping around in the dark trying to enter a password to turn the lights on. While this is big scary problem there is a potential solution to all that I’ll touch on at the end of this post.

There is one other problem, URLs broadcast via Eddystone beacons have to be less than 18 bytes long which is pretty short, while there are some encoding tricks for common start and end sections (e.g. ‘http://www.’ & ‘.com’) that reduce these sections to just 1 byte, that still doesn’t leave room for much more. You need to use a URL shortner to do anything major.

Trying things out

While thinking about all this I decided to spin up a little project (on github) to have a play. I took the core code from my Node-RED WeMo node and wrapped it up in a little web app along with the bleno and eddystone-beacon npm modules. I could have done this using Node-RED but I wanted to be able to support control via straight BLE as well.

The code uses discovery to find the configured light bulb or group of bulbs

wemo.start();

if (!wemo.get(deviceID)) {
  wemo.on('discovered', function(d){
    if (d === deviceID) {
      device = wemo.get(d);
      console.log("found light");
    }
  });
} else {
  device = wemo.get(deviceID);
  console.log("found light");
}

It then starts up an express js webserver and creates 2 routes, 1 to toggle on/off and one to set the brightness

app.post('/toggle/:on', function(req, res){
  console.log("toggle " + req.params.on);
  if (req.params.on === 'on') {
    wemo.setStatus(device,'10006',1);
  } else {
    wemo.setStatus(device,'10006',0);
  }
  res.send();
});

app.post('/dim/:range', function(req,res){
  console.log("dim " + req.params.range);
  wemo.setStatus(device,'10006,10008','1,' + req.params.range);
  res.send();
});

It also sets up a directory to load static content out of. Once that is all setup then it sets up the Eddystone beacon

eddystone.advertiseUrl(config.shortURL, {name: config.name});

Enabling Physical Web on You Phone

If you want to have a play yourselves there are a couple of approaches to enable Physical Web discovery on your phone. The first is a mobile app built by the physicalweb.org guys, it’s available for both Android and iOS. When you launch this app it will seek out any Eddystone beacons in range and display a list along with a summary

Recently Google announced that they were rolling Physical web capability into the their Chrome Web browser. At the moment it is only available in the beta release. You can down it on Android here and the this link has instructions for iOS. I have not tried iOS instructions as I don’t have a suitable device.

Once it’s been installed these instructions explain how to enable it.

Now we have a beacon and some way to detect it what does it look like

Discovered beacons

The Physical Web app has detected 2 beacons (actually they are both the same beacon, using both BLE and mDNS to broadcast the URL). Both beacon are on my private network at the moment so the proxy could not load any of the meta data to enrich the listing, it could also not find my private URL shortener http://s.loc. If I click on one of the beacons then it will take me to a page to control the light. At the moment the interface is purely functional.

Light interface

This is working nicely enough for now, but it needs to be made to look a bit nicer and could do with presenting what brightness level the bulb is currently set to.

Direct device communication

I mentioned earlier there was a possible solution for the public network access requirement and authentication. There is a working group developing a specification to allow web pages to interact with local BLE devices. The Web Bluetooth API Specification is not yet finished but an early version is baked into Chrome (you can enable it via these instructions). This is something I intend to play with because it solves the whole public facing site problem and how to stop guests keeping remote access to your lights. It doesn’t matter that you can download the control page if you still need to be physically close to the beacon to connect via BLE to control the lights.

I’ve added 2 BLE GATT characteristics to the beacon (1 for on/off and 1 for dimming) and when I get another couple of free hours I’m going to improve the webpage served up from the beacon to include this support. Once this works I can move the page to my public site and use a public URL shortener which should mean all the meta data will load properly.

All this also means that with the right cache headers the page only needs to be downloaded once and can then loaded directly from the on device cache in the future.

Random gifts

A couple of weeks ago I got back into the office on Monday morning after a long weekend off to find a message from the office’s Goods Inwards department saying there had been a package delivered for me on Friday. I was expecting a few things for various projects so I set off down through the tunnels under Hursley to see which bits had arrived.

On arrival I found a plain cardboard box held together with tape claiming it had been damaged in transit (no obvious signs of damage on the box) marked with my name, work address and desk phone number but no indication of where it had come from. Once opened it revealed a boxed pair of Sennheiser Momentum on ear headphones and a delivery note.

None of the projects I’m working on at the moment need a set of headphones and I’d not ordered any for myself, as my usual set of Philips O’Neill Headphones are still in great shape and spend most of the working day on my head.

A quick ask round the office didn’t turn up anybody who knew anything about them. The delivery note didn’t help as it only showed 1 set of headphones and the delivery details, nothing about where they had come from. It was as if it should have been printed on headed note paper. So having drawn a blank as to where they may have come from I threw out a tweet to see if anybody would own up to sending them:

This didn’t get any joy, so I was at a little bit of a loss with what to do with them. A bit of googling round seamed to imply that if something is unsolicited then it should be considered a gift. Having said I decided to leave them in the box for a couple of weeks just in case somebody came looking for them.

Now some 2 weeks later and nobody has come to demand their new headphones so I’ve decided the least I can review them. I’ll use them next week in the office and write up my impressions.

EDIT:
It appears somebody has come looking for them a whole month after they arrived. They caught me in a moment of weakness and I agreed to send them back (they did try to sell them to me when I mentioned they had now been used and I had to point out that it would be illegal to request payment…)

Tracks2Miles 1.1.16

I pushed a new update to the market at the weekend.

It should hopefully fix a problem where Tracks2Miles would complain it could not access My Tracks data even when sharing was allowed. This looks to be down to a change in the My Tracks API with the My Tracks 1.1.15.

I’ve also tweaked the “Like” handling a little to only work for posts that are videos or pictures as this seams to be the only type of posts this works.

Recently a college has been having a look at the code to see if there are some things he wants to add. Hopefully I should have something from him soon.

Matterbox

Looks like I was one of the lucky few to get allocated one of this round of Matterboxes.

Mattterbox

Matterbox are an offshoot from the Royal Mail that ships cardboard boxes with samples from different companies to people in the hope that they will try the samples and spread the word (looks like they’ve achieved their goal with me this time). There have been 2 previous boxes, a pilot and the first edition, I got a copy of the first edition last year. I really like the concept of Matterbox, it’s nice to see the Royal Mail branching out and looking for new ways to make use of it’s network in these days of email and declining post.

This time round it was an all Cabury affair, based around their Spots v Stripes campaign. The concept is to encourage a sense of competition in the run up to the 2012 Olympics by creating 2 virtual teams that can compete against each other to score points. The competition can take nearly any form that has 2 opposing teams.

As part of the campaign Cabury ran a competition to create games that could be used, and this release of Matterbox contains the 2 winning entries and a Spots v Stripes chocolate bar.

Egg-a-thon

Egg-a-thon comprises of 4 small platic eggs, a dice and the board (the box), players start with both their eggs in the start zone, then take it in turn to roll the dice. If a player rolls a 6 they get to use the 6 and get another go, if they roll a 1 they loose their turn. The player can move their eggs forward, backward, left or right and move them in such a way as to obstruct their opponent, the score rolled on the dice between eggs. The winner is the first player to get both eggs to the finish line.

Flick Racer

In this box there are 8 numbered counters and a stick of chalk. You use the chalk to draw a racetrack and then between 2 and 8 players take it in turns to flick their cars round the track. If there are only 2 players then each player has 4 cars, 4 players each get 2 cars. If the counters end up out side the lines of the track drawn in chalk then place the counter back on track and turn it over, if you crash in to one of the other players counters, both are turned over. If a players counter is upside down when it gets round to their turn, then all they can do is to turn it the right way up.

The idea is you play the games and then register your scores for one of the two teams, I’ll take them to the office tomorrow and see if anybody wants to play.

Eightbar

I got added as an author for the Eightbar blog today.

Eightbar is a group of techie/creative people working in and around IBM’s Hursley Park Lab in the UK. We have regular technical community meetings, well more like a cup of tea and a chat really, about all kinds of cool stuff. One of the things we talked about is that although there are lots of cool people and projects going on in Hursley, we never really let anyone know about them. So, we decided to try and record some of the stuff that goes on here in an unofficial blog: eightbar.

The plan is to give a bit of a UK flavour to it all, but talk about the technology coming out of the lab, things people are playing with, but also some of the fun side. Hursley’s a very unusual place (compared to most technology sites), so we want to get that across. Anyway, hopefully lots of different people who work in and around Hursley will contribute.

The name Eightbar comes from the IBM logo which uses letters made up of 8 horizontal bars.

I posted my first article today about Andy Piper’s new AR.Drone that he brought to the office on Tuesday.

New Toy

I’ve finally got round to getting a smart phone. I have never been sold on the whole iPhone clut craze and I’ve already got a work blackberry that I despise so the choices where really between an Android or Windows Mobile device.

Given the hackability of Android pretty much sealed the deal, but I was torn between a Sony Ericsson Xperia X10 and a HTC Desire.

Sony Erricson – Xperia X10

Sony Xperia X10 front
Image CC licensed by louisvolant on Flickr

My last few phones have all been from Sony Ericsson, I’ve had the following:

  • T68i
  • K700
  • K750
  • w850
  • W880i
  • C905

I’ve been very happy with these phones over the years (with the exception of the C905’s lack of functional Google Maps, but that was down to O2’s “custom” firmware) so getting another SE was definitely a possibility but after getting hold one and having a bit of a play with the Timescape layer that SE have added on top of Android I decided it wasn’t for me.

HTC – Desire

HTC Desire 4
Image CC licensed by louisvolant on Flickr

HTC built the first Android phone the G1 and also the recent Nexus One for Google so they have a decent amount of experience with Android. The Desire shares most of the components of the Nexus One with major differences being cosmetic, the 4 buttons on the front are physical rather than an extension of the touch screen and the track ball in an optical sensor on the Desire.

I am quite taken with the Sense interface that HTC have layered on top of 2.1 Android “Eclaire”, but I’m hoping to have a play with a colleges Desire which is running a plain build of Android 2.2 “Froyo” shortly to see if it’s worth waiting for the Sense skinned version of Android 2.2 which is rumoured to arriving in 3Q, or to root the phone and install a custom image.

Apps

I’ve been taking it easy with apps so far and I’ve not found one I want to pay for just yet but the following free ones have been getting a reasonable amount of use.

  • Simple Last.fm Scrobbler – A scrobbler for the Android built in music player
  • UK Traffic Checker – A very cool app written by Dale Lane that check the route between 2 places for traffic problems
  • Bump – A neat way to send photos and vcards between 2 phones
  • Layar Reality Browser- A AR viewer

Development

So now I have my cool new phone I suppose it would be rude to not make use of it’s open development platform. I’ve downloaded the latest version of the SDK and the Eclipse plugin. I’m working my way through a couple of the tutorials before coming up with a project.