Archive for the ‘code’ Category

OpenCellId – collecting data for mobile location-based services

Monday, August 18th, 2008

It is great to see a revived buzz around mobile location based apps and services. There are lots of new services to try. I try loads of them, the most recent was Moot just a few days ago (I love their video which I’ve embedded here – very cute), but there are way more than I can keep up with.

One problem they all share before they get to offer you their variations on useful location-based services is how to figure out where you are in the first place.

GPS is an obvious response, but not everyone has it on their mobile, and even if you do, it has some big problems – it can take a while to get a fix, won’t work indoors, etc.

Good solutions supplement this with other sources of information. Skyhook is getting a lot of attention at the moment for their service – mainly due to it being used in the iPhone. It means that the iPhone (and other devices using Skyhook) can work out where it is using GPS, but if a GPS fix cannot be made (or in the interim time while waiting for one) it can give an approximate location almost instantly using cell-tower triangulation and/or known WiFi access points.

(more…)

Revisiting a Windows GUI for CurrentCost

Monday, July 28th, 2008

tweaking the CurrentCost GUII spent a couple of evenings last month knocking together a quick example of a Windows GUI for the data you get from CurrentCost home electricity use monitors. And then promptly put it to one side and kinda forgot about it.

As a quick recap, I created a Windows app which grabbed the history data from the CurrentCost serial output, and drew a few bar graphs from it – to represent the hours, days, and months data. The app also persisted the history data in the user’s “Application Data” folder, so that older data is kept by the GUI even after it is lost by the CurrentCost meter itself.

I’m thinking about picking it up again, so spent a bit of time idea-storming what I could do with the code. These aren’t all my own ideas – they’re a random collection of ideas and notes taken from discussions with others. I’m posting them here for feedback – new ideas are welcome, as are comments on the usefulness of the stuff I’ve suggested.

(more…)

Improving TwitToday – more Today Screen coding

Wednesday, July 23rd, 2008

Twitter client for Windows MobileApart from adding the ability to initiate an internet connection, my Twitter widget for Windows Mobile Today screens is still virtually the same code as I wrote in a few hours overnight at the Over The Air hackday.

Which isn’t great – as I know there have been a bunch of people waiting for me to make some fixes and add some basic features.

Tonight I had a bit of time to spare, so I finally dug out the code to start making a few improvements:

  • Background worker thread
    Today screen widgets are compiled into DLLs. They aren’t a separate executable, and are run by the Today Screen in the Today screen’s (i.e. explorer.exe’s) flow of execution. When the code tries to post to twitter.com, explorer can’t do anything else until that’s finished.

    That might even be tolerable with most websites, but with twitter – which is known to fall over from time to time! – it means TwitToday could effectively hang your phone for ages until the HTTP post timed-out.

    Not good. Now it does all the HTTP work in a background thread, so you can get on with other stuff while it tries to send your tweet.

  • SIP support
    This was asked for a lot. The Today screen doesn’t include the button to show/hide the on-screen stylus/finger keyboard. So if your mobile doesn’t have a keyboard, TwitToday wasn’t much use.

    I’ve added a setting now that lets you programmatically show the SIP keyboard when you tap on the text box.

If you want to try the new version, you can download it from here. If you want to see how I did it, read on.

(more…)

Fun with MQTT

Friday, July 18th, 2008

I’ve been quiet for the past month or so, as I was keeping my head down to finish a project at work. It’s done now, so now is a good time to crawl back out of my cave and share a bit about what I’ve been up to. This was for a customer who outsourced a software development project to us.

Some quick background: MQTT is a publish/subscribe messaging protocol that IBM products like WebSphere Message Broker can speak.

Our customer wanted an MQTT library written for the real-time embedded firmware that runs on their products. This client library needed to provide the API of the MQTT specification, implemented within the constraints of an embedded platform with significant resource constraints, and only a subset of the standard C OS functions (e.g. no multi-threading, no dynamic memory allocation, no malloc/realloc/calloc, etc.).

(more…)

Our Mashed 08 hack: CurrentCost Live

Monday, June 23rd, 2008

Yesterday was the end of Mashed 08 – the annual London hackday from BBC Backstage.

I saw last week that there was going to be a “social responsibility” category in the hack challenge, and decided that a CurrentCost hack was in order!

Together with Rich, we spent a day trying to hack together a competitive challenge based around CurrentCost, encouraging people to reduce their home electricity usage by making it into a game they can play with their friends.

Here are a few notes based on the presentation I gave at the end.

(more…)

Tweaking the CurrentCost app

Monday, June 16th, 2008

tweaking the CurrentCost GUI

I spent a bit of tonight tweaking last night’s CurrentCost app.

Not a lot to say about it, as it’s more or less the same as it was last night…

(more…)

CurrentCost – getting the history into Windows

Sunday, June 15th, 2008

The CurrentCost meter has been ignored of late as I’ve been a bit busy with other things. Tonight, I started playing with it again.

The plan
The more geeky amongst us have connected the CurrentCost to a server of some sort. By connecting it to something that’s always on, we can collect a history one reading at a time. But what about people without a server? How can they collect history?

As Rich highlighted in his post on the CurrentCost XML output, the CurrentCost meter maintains some running totals in flash memory, and these are included with updates for every reading from the device.

It maintains:

  • totals for each two-hour block for the last day
  • totals for each day for the last 31 days
  • totals for each month for the last 12 months
  • totals for each year for the last 4 years

This means that if you store and aggregate these history totals, you can connect the meter to a computer periodically and still get reasonable CurrentCost readings history.

  • connect at least once every 26 hours to maintain the two-hourly history
  • connect at least once every 31 days to maintain the daily history
  • connect at least once a year to maintain the monthly history
  • connect at least once every four years to maintain the yearly history

Okay, so the two-hourly history might be a bit much, but the others all seem reasonable, even for non-geeks!

So, the plan is to write a simple Windows application that a user could periodically link to a laptop or computer that will collect CurrentCost readings and aggregate them into history data. And ideally then display them in a pretty way

(Not my plan, incidentally, but rather one that I nicked from Andy. Still, if you’re gonna nick ideas, there are worse places to start… 🙂 )

This is what I’ve got so far…

the start of a CurrentCost GUI

(more…)

CurrentCost hacking – starting to identify appliance power usage

Tuesday, June 3rd, 2008

I needed a break from work tonight, so went back to playing with the CurrentCost meter – a chance to try a few new things.

The objective
I want to make a start on identifying how much electricity different things in my house use. To begin, I’m going to start with a very manual user-driven approach:

Subscribe to updates from the CurrentCost meter, and when a significant change in usage occurs, ask me what I’ve just switched on or off, and collect that information to build up a record of how much electricity different devices use.

How?
It’s already quite late, so I just wanted to hack a quick first version together. I decided to write it as a small Java app.

As I’ve mentioned before, I’m publishing the CurrentCost readings to a small broker running on my home server. The plan was to write a Java application that uses MQTT to subscribe to updates from the broker.

Why? Because I’ve not used Java on the Slug before, or with MQTT. (Is that not a good enough reason? 🙂 )

I’ve written it as a command-line app, because it’s a quick way to run it from different devices around the house. (That is, by cheating 🙂 I’m actually running the app on the home server, using PuTTY / PocketPuTTY / SSH etc. to run it from my ThinkPad, PDAs, mobile, EEE PC, etc.).

(more…)