iBeacon2Web v1.2

After a really long while, i’ve finally made some changes to iBeacon2Web. This is an update that follows a very minor update where the codes where made swift 2.0 compatible as well as some layout improvements. Nothing really important to note, but the next version of iBeacon2Web would contain changes that would really mark the start of iBeacon2Web being able to address your region detection needs.. mainly geofencing.

While this isn’t something new on iOS, as it already exist within “Find Friends”, there has really been a limited number of really flexible DIY tools for web developers to easily make use of these features on iOS to integrate with their web needs, personal or otherwise.

The addition of Geofencing as part of the region detection also means that there has been some new changes to the query string sent to your web service. Not too much, just a few.

Here are the changes

  • type: ibeacon or geofence
    This is to help to distinguish between the 2 region types. Mainly because iBeacons contains the ability to do Ranging and Geofences do not. So this can help you determine how the web service is to react to such changes
  • major and minor:
    in iBeacon types, major and minor types are what it is, major and minor types. But in GeoFencing, major and minor refers to the boolean state of monitoring “On Entry” and “On Exit” respectively
  • identifier:
    iBeacon identifiers has to be a unique string which you can define. In Geofencing, this is predetermined for you with a combination of the Radius for the Geofence, the Latitude and the Longitude. This should be totally transparent, but if you wish to know these values in the Web Service, just obtain the identifier from the type “geofence” and split the identifier query string into “radius,lat,long“. This then brings us to another important change.
  • label:
    This didn’t use to be a very important field as iBeacons identified themselves with UUIDs. However, with Geofencing, knowing your geofenced region with a human readable name is important. Therefore, when creating a geofence, the label must be unique. This also means that a new key is passed to the Web Service with a key of “label“. You can use this in place of the iBeacon identifier to filter the action to take.

Also take note that Geofences will fire a detection state every time the app is launched just to update the server. Every time there is a possibility that the beacons list has changed, the list would also update, thus causing the Web Service URL to fire. I have not seen a situation where this isn’t helpful especially during configuration and testing. Most of the time, the app sits in the background anyway and the beacon list should be changing too often.

Standard notifications settings still apply to both. So you can allow all notifications in Settings->Privacy, but turn off notifications for individual beacons that you don’t want to be alerted of.

I guess that’s it for v1.2 changes. The new version would be submitted to the App Store soon. And you should be able to get all the above changes once you update the app.

Till next time. enjoy!

 

Evernote Notes Backup: Seagate Wireless Drive

I love having my data with me… even when i am offline. This leads me to really love my LaCie wireless drive by Seagate. In the last couple of months, i have managed to get a few things going on the drive. Namely, the use of the Seagate Satellite Mod and looking into the APIs create by those guys.

As much as i love the refreshing interface compared to what was originally provided by Seagate, i just can’t help exploring what more i can do with the unit. The mod have provided me my files via Bittorrent Sync, and Dropbox computer access via SMB and WebDAV, leaving behind the final mile of what i need. My notes… Evernote.

With that, i am glad to announce that i have successfully written a Python 2.7 based plug-in into the Seagate satellite mod, leveraging the modded platform which can download all your notes into the Wireless Drive. The API integration have finally been accepted by Evernote in their production servers. This means that you can just activate and authorise your Evernote account via OAuth and immediately start syncing your notes.

Head over to GitHub to read the Installation guide (README) and to grab a copy of this to begin using it. I have found it immensely useful for my own and find it comfortable now that i actually have copy of all my notes with me.. i hope you’d find it useful too.

Remote booting a Lacie Fuel With a LightBlue Bean

Things change and move all the time in the software world. Especially when you have to juggle between several people asking for your attention all the time. Not to mention the other interesting gadgets and mods that are being dreamed up everyday.

In my last post, I mentioned that I have managed to reverse engineer the JSON structure and request in my modded LaCie Fuel from http://www.hackseagatesatellite.com. But trouble is that I haven’t gotten much headway in making a proper public facing app from those information yet… Work got in the way.

It is through work that I realized that in the course of using my Fuel, especially in the plane, I have had to reach into my bag in the overhead compartment or under the seat in front of me to turn the unit on/off. Wouldn’t it be nice to have some way to trigger the boot up of the Lacie Fuel using some kinda of Bluetooth or wifi connection?

Enter the LightBlue Bean (https://punchthrough.com/bean).

Its a fancy little Bluetooth v4 board I discovered that has a variety of sensors and uses an Arduino for hardware interfacing and control. I have had some experience with Arduino in the past and this gave the perfect low power wireless interface for an iOS app to talk to it. All that was needed is a simple circuit to create a transistor based relay that is controlled by one of the digital pins from the Bean to trigger the switch on the Fuel and wala! A Bluetooth capable Fuel that can be toggled on/off within the range of my iPhone/iPad’s Bluetooth.

With some testing and prototyping, I have managed to create a circuit that would do the above and posted the code up on github (https://github.com/sulph68/lightblue-bean-lacie-power). The code commit contains the iOS app, written in Swift and Obj-C bridging for the LightBlue bean SDK, the Arduino code and the circuit diagram with the parts and components that I have used to create the working circuit.

The iOS app has the ability to perform a short and long press of the LaCie power button, blink the LED on the Bean, and provides some information so that I would know when I might need to change the onboard CR2302 battery.

The Arduino code tries to sleep as much as possible so as to use as little power as possible. It would only wake up when the bean is connected to via the iOS app.

I hope the code and circuit would provide some use to others in the same situation as I am and bring an additional level of use to the LaCie Fuel… Or maybe even the Seagate Wireless!

Reverse engineered!

It took me a while to get it done, but ever since i got my hands on a LaCie Fuel and applied the mod from http://hackseagatesatellite.com, i finally managed to finish understanding their JSON.

it might take a while longer but i might just be able to get a iOS Native app out of this…

Triggering Web Services from iOS… WebSet

WebSet is a application that helps to interface the iOS button and switch controls to any provided URL as a query string. This provides a way to easily create DIY web services that can be controlled by an iOS application.

To use this app, you have to ensure that the web service you are trying to connect to accepts the right format of a query string and response with a valid JSON. Simply add a web end-point with the relevant information, providing sample information if your end-point doesn’t require it. When adding the URL, test it and a sample of the URL that will be transmitted will be shown. Be sure that the URL connects successfully as you will not be able to change it once its added!

A setting will start off being disabled and you would have to enable it. The label colors grey, black, orange, green and red displays the web state as disabled, enabled, transmitted, responded and error respectively.\n\nIn order to read the state of the switch, it is required that one of the JSON keys returned contains “state” 1 or 0.

A sample looks like

{ “state” : 1 }

To refresh the state of the controls, drag the list view down to refresh.

We encourage all URLs to be in HTTPS for security reasons.

One month in…. Using iBeacon2Web

Its been a month since I wrote and started using iBeacon2Web. I must say it makes implementing detection and integration of iBeacons easier.

To start, I would need to describe what I am using the technology for. It’s mainly for 2 purposes.

  1. To track the location of some of my belongings and take certain actions
  2. to automate certain actions based on the state of my physical presence based on the location of my phone.

Based on this, I do have the following capabilities in my home.

  • A web server running on the post 2011 Mac mini, and
  • an iPhone 5 that is placed in a required location with iBeacon2web installed
  • my mobile phone with iBeacon2Web installed

The purpose of the web server is to be able to run scripts that would serve as the end point of ibeacon2web and the iPhone 5 is to serve as the iOS device that would detect the beacons with ibeacon2web installed. A simple web endpoint is created filtering only the allowed deviceUUID to execute that script. This prevent unauthorized devices from being able to connect to my web endpoint. This UUID is generated on application install of ibeacon2web and can be obtained by looking at the help page. The CGI and a simple perl script is able to then record the state of the detected beacon and store it on the web server.

The process flow can be summarized to be:-

Beacon comes into range -> iPhone detects Beacon -> iBeacon2Web sends the URL to the defined end point -> End point filters the DeviceUUID -> CGI records the state into a simple DB

Once that was done, the web server simply takes over. As the web server is running on a Mac, it was trivial to use launchd as the mechanism to trigger server based actions based on changes in state. This trigger in launchd is then used to run scripts, for example, to turn my Belkin WeMo switches on or off. It can also generate a simple status report of the location of all my devices that has a beacon attached to it. For example, the location of my bicycles or bags.

The process summary is:-

DB state file changes -> launchd detects changes -> launchd runs a script -> script reads the DB and performs logic operations on the state and proximity of the beacons -> scrept performs other intended actions

Remember that each belonging is associated to a specific beacon and thus defines the “region” and the UUID of the item tagged with the beacon. I used a reverse dotted notation to help differentiate between my belongings and to build groups of the items. E.g. sulph.wheels.foldingbike vs Sulph.wheels.roadbike. The above works great for being able to discover if my belongings have been moved out of the house or have been returned. However, there is another angle to the use of iBeacon2web in which we are able to trigger specific actions in specific locations. For example, when you walk into a room.

When using iBeacon2web for specific region detection, the beacon is placed specifically in the area of interest, such as a room. We then make use of the “Near” and “Immediate” proximities to trigger an action. In this case, ibeacon2web is installed on my personal mobile phone (as opposed to a house phone in the earlier part of the post). The resulting endpoint for the web service remains the same and the CGI scripts would only trigger actions based on the right deviceUUID a as well as the right proximity states. I have used this to successfully turn screens on or off, or sending commands to other web services such as those on my Raspberry Pi for specific instructions to be carried out (such as telling me the weather).

Irrespective of whether the beacon is placed on my belongings or in a specific location, the mechanism is the same. The state of beacon detection gets recorded into a web server via ibeacon2web and a web CGI takes over in triggering the intended action.

This fulfills the goal of iBeacon2Web where, as long as you can script it on the server, you can make beacons work for you. This opens up a entire range of possibilities for web developers to be able to make use of this budding new technology and enhances their web services without having to resort to developing an iOS app just for a very specific use.

Hopefully this has made it much easier for other web developers to also leverage this technology and create something awesom too.

Till next time.

iBeacon2Web – for the web developers who want to use iBeacons

iBeacon2Web is a simple beacon region and ranging application. It translates the detected information from a iBeacon and provides it to a given URL as a query string. This allows a large number of potential DIY applications to be built on top of iBeacon technology.

To use this app, simply add a beacon with the relevant information and provide the web service URL to call. A sample of the URL that will be transmitted will be shown. Be sure to test the URL before you add the beacon as you will not be able to change it once its added!

If you wish to only detect for a beacon but NOT send the information to any URL, just enter https://do.not.send.url as the connecting URL instead.

Take note that for the URL to be succesfully connected, it needs to return a valid JSON file.

We encourage all URLs to be in HTTPS for security reasons.

The information passed to the query string includes
– beacon UUID
– identifier
– major number
– minor number
– proximity (Immediate, Near, Far, Entered, Exited)
– deviceUUID (generated upon install for web service to filter if its a valid device)

*Note that this app does not work well on an iPhone4S as the settings interface will not scroll on the smaller screen. The beacon capability on the phone is also not as good as those made after the iPhone 4S

A sample region query string looks like this
deviceUUID=A34408A9-6660-4F47-9BF5-19D3D870222C&identifier=living.room&proximity=[Entered|Exited]

A sample ranging query string looks like this
deviceUUID=A34408A9-6660-4F47-9BF5-19D3D870222C&proximity=[Immediate|Near|Far]&uuid=CA97BBE1-E862-1801-A170-001C4DB8BC13&minor=1&identifier=living.room&major=1

Sample use cases of this app is as follows
1) Roving App, Static Beacon: for the web developer to have an app detect a beacon and send a call to a URL to display or take custom actions
2) Roving Beacon, Static App: for a old device to be placed in a static location and for a beacon to enter, exit a region. The app then contacts a web server to report on the beacon’s approximate location region