Sunday 15 April 2012

Llamas near fields

I've managed to borrow a phone with NFC support from my real-life job and I've been toying with it over the weekend. The Llama at the end of this blog post now has NFC support. You can place your phone near an NFC tag and get it to do stuff! Consider this a very early implementation. I'll never be able to use this in the real world, so you should let me know how it performs.

To use it, you add the 'NFC tag detected' condition to an event. Llama will then tell you that you need to place your phone over an NFC tag, such as your Oyster card if your a Londoner like me. You can then give the tag a friendly name. Then add other conditions and actions as normal.

The NFC tag detected condition is a trigger only. At all other times it will evaluate to false. This is because Android doesn't tell Llama when a tag disappears, only when it is first seen. It may be possible to periodically attempt to write to a tag to detect its presence, but I haven't had a chance to implement that yet.


  • Llama can now detect NFC tags!

This is a very early build that I haven't been able to test much, so you really really should export your Llama data before installing it. I've tested it in the emulator running Froyo (which lacks the NFC APIs) and it didn't crash, but who knows.


Sunday 8 April 2012

The Llamaloc format

I've not got as far as I wanted to with the LlamaTrail reader. Someone emailed me asking about how the .llamaloc format works, so here's a brief description. I've also attached my proof-of-concept, no where near fit for human consumption app that reads them. Unfortunately, it's a Windows app written in C# rather than an Android app written in Java. Android apps are hard and fiddly to write and Java is a pig of a language, so a Windows C# app was the quickest way to check that Llama was logging stuff correctly.

The Llamaloc file format is a continuous stream of timestamped information. Each file is a separate day, so the timestamps are only the time of that day. Following the timestamp is a byte identifying the type of data that follows. After that is the data itself, whose length varies depending on the type of data. There are 3 types of data so far: Llama start, Llama shutdown and a cell change. Eventually, there will be wifi network and Bluetooth changes.

[1-byte datatype ID][4-byte milliseconds since midnight][datatype payload]

  • Datatype 0: Llama start
    • Payload length: 0
  • Datatype 1: Llama shutdown
    • Payload length: 0
  • Datatype 2: Cell change
    • Payload length: 8 bytes
    • [4-byte Cell Id][2-byte MCC][2-byte MNC]

You'll also need to open the Llama_Areas.txt. This is a geeky-human readable format, rather than binary. Each line represents an area, which is stored as a pipe-separated list. The first item in the list is the Area's name. All subsequent items on the line are the beacons (cells, wifi networks, etc). If a beacon starts with something non-numeric, then it isn't a cell*, and you should ignore it for now (it could be W=WiFi-name, M=WiFi-mac, B=Bluetooth or P=Map-point). The cells are colon-separated as CellId:MCC:MNC.

If you want to play with the app, you need to mount your phone's SD card and point the Llama Trail Reader at your Llama folder on your SD card. If you have a shiny new Galaxy Nexus, it doesn't have proper mass-storage support... I don't think Windows assigns it a drive letter. You'll have to copy the Llama folder to somewhere (e.g. your Desktop) and then point Llama Trail Reader at the copy.

As I mentioned, the app and the code is pretty horrible. If you can figure something out from it then great! Do post about it in a comment or email me. You may use the Llama Trail Reader code and app as you wish and at your own risk, but you may not sell anything derived from it. If you do, I'll get angry, but probably won't sue you because lawyers are boring and expensive. However, one day I may study law so watch out. If you want to release a free app with a donate button, then that's fine. If you have any questions or are unclear about anything, then email me.

Download Llama Trail Reader EXE and source

* - Llama was originally never meant to support anything other than cells.

Gmail Label Speaker Resurrection

Google has recently published an official Gmail API for labels, after beefing up Gmail's security about a year ago. This means that Llama's neglected, dim-witted cousin Gmail Label Speaker now works again. Whoopie!!!


Download from Google Market Android Play thing

Boring market release

I've released a new Llama to roam free on the Market, or Google Play as its now called. I still can't get used to calling it that. There's not much exciting going on in this release. It's mostly the previous blog posts version, with a few different things.

One email I get all the time, and probably the most common "OMFG teh rubbish 1-star" comment, is about uninstalling Llama. When you activate Llama as a Device Administrator, you won't be able to uninstall Llama without first deactivating it as a Device Administrator. To the detriment of my sanity, Android doesn't even tell you this. It just says 'uninstall unsuccessful'.

The device admin settings can be found in the Location and Security settings on Android, but as per usual, other manufacturers will move all of the settings about. Llama now has a bigger warning before you enable it as a Device Administrator. Hopefully people will remember to untick it before uninstalling Llama, rather than emailing me ;)

The other change since the last blog post is a way to immediately accept a confirmable event from the notification that appears, which saves me one click when my Bluetooth headset connects :) hooray for laziness!


  • Big fat warning about disabling Llama as a device admin BEFORE uninstalling (when using screen off/lock password actions)
  • Instant event confirmation from notification
  • Updated German and Slovenian translations
Download from the market Google Play