In the words of the old Star Wars Joke - "Luke I know what you are getting for Christmas..."
Hickmat 100000QA3T Visits (7546)
I have felt your presents....
A while back I spotted that Presence Insights (PI) was available on Bluemix and I thought it would be cool to play around with it once I had some spare time and more importantly some Beacons.
A couple of months back I managed to address the lack of any Beacons by picking up 4 of these (iBeacon Module Bluetooth 4.0 BLE Support Near-field Positioning Sensor Wireless) from eBay which left me with the issue of finding some time to have a "play".
As luck would have it that opportunity cropped up a couple of weeks back and coincided with me thinking about what I could do for my Christmas lights in the office this year. I was thinking about using PI to detect me approaching my desk and using that information to control the lights and may be even scroll a festive message across a set of LED matrices I have wired up to an Adruino but then a customer use case came in. I won't go into the details of the use case but at a high level it was simply around detecting a customer arriving and notifying employees of the customers presence. So pretty much use case 101 for PI
Armed with an opportunity to show something I set about thinking how I could pull something together. This led to me creating the following high level solution:
Given I was fairly confident in my ability to get NodeRED to do what I needed, I initially focused on the PI area. The supporting documentation was simple to follow and I started off by doing the following:
With the location structure defined in PI, I next set up a pair of subscriptions so I could get PI to call out to NodeRED when a device entered or exited any zone defined for my organisation. From the NodeRED end this was just a case of creating a pair of HTTP Input nodes and ensuring the registered Web Hook in the PI subscription aligned with the configuration of the related input node. Initially I just set the NodeRED flow to dump the received payload to Debug and perform and HTTP response back to PI (failure to do this causes lots of timeout errors to be logged in PI).
So I had the basic plumbing and configuration in place so I next set about building the mobile applications I needed. As PI provides both an iOS and Android SDK (and I like a challenge) I decided to build an app on each platform. The main challenge I hit here was my lack of skills and experience in doing development on either of these platforms but with lots of Googling, the clarity of the PI docs and support from
With the app working and the events being spat out into NodeRED I started to look at the last part of my solution i.e. the NodeRED flow and the supporting Docker based broker. To accelerate things I simple re-used and existing Mosquitto Docker build from Github. All I did to this was tweak the exposed ports and upload it to my Bluemix account - job done. Next I created the following flow in NodeRED to handle the inbound events.
The payload from PI is a nicely formatted JSON message with lots of great info in it so processing it with NodeRED was a breeze. In the above you'll spot that I have a switch on what the type of customer and then a 2nd switch which i cunningly didn't name The first switch is related to the "Device Type" passed to PI by the app when it connects to PI and registers its self. For a customer device I decided to register them with a "Device Type" of "External" and for employees "Internal". The switch in my flow simply checked the devi
The final step was to create a WebUI which could use WebSockets to connect to the Mosquitto broker running in Docker on Bluemix and provide notifications when events happened. Again via the power of the Web I pulled down some sample code created by one of my IBM colleagues from Github and hacked it to meet my needs. I then pushed this code to an AlterUI sub folder under my NodeRED public folder. In this way I could access the WebUI via the NodeRED base route.
With all this plumbed together I was ready to test and as I expected it all worked. As I simulated a customer moving from zone to zone by switching power on my beacons the event data flowed correctly to the WebUI and the correct "Enter" events were send via SMS to my phone. This was enough to demonstrate the capability but as usual I have plans to tinker a bit more. A couple of ideas I'm thinking about are:
Anyway those are for another day when I get some time.