Wake on Lan for iOS Using GCDAsyncUdpSocket

I’ve spent the last couple of weeks working on a new app which runs in the background, and uses cell tower ‘significant change’ functionality to do geofencing. Having got it to work, I’ve now turned my attention to one of the ultimate goals, which is to start sending WoL packets when I enter a CLRegion I’ve defined around the house. [This is actually going to be quite tricky, by virtue of the fact that the regions need to be pretty big, given the sort of accuracy that startMonitoringSignificantLocationChanges provides, but I’ll come back to that another time].

There is a fair amount of example code for WoL, but I couldn’t find anything particularly easy to adapt. What I’ve ended up doing is grafting this C example onto GCDAsyncUdpSocket. It works fine, but there is one annoying side effect, which I haven’t been able to work out yet.

First the code:

//http://shadesfgray.wordpress.com/2010/12/17/wake-on-lan-how-to-tutorial/
    unsigned char tosend[102];
    unsigned char mac[6];
    for(int i = 0; i < 6; i++)
    {
        tosend[i] = 0xff;
    }
    // substitute MAC address: E.g.,
    mac[0] = 0x00;
    mac[1] = 0x2a;
    mac[2] = 0x00;
    mac[3] = 0xfe;
    mac[4] = 0xff;
    mac[5] = 0x33;

for(int i = 1; i <= 16; i++)
    {
        memcpy(&tosend[i * 6], &mac, 6 * sizeof(unsigned char));
    }
    

    NSData *payLoad = [NSData dataWithBytes:tosend length:102];
    GCDAsyncUdpSocket *mysocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
    [mysocket enableBroadcast:YES error:nil]; 
    [mysocket sendData:payLoad toHost:@"192.168.1.255" port:9 withTimeout:-1 tag:0];

So, this works for me insofar as I'm happy enough with broadcasting to the network, with the final quad of the IP set to 255. What I haven't been able to work out is how to send the packet to a single machine. I've written about WoL functionality before - unfortunately the project I mentioned in that post is no longer making the source code available. However, I still have the executable and resorted to WireShark to see if I could fiddle around with the code above to make it play ball:

WireShark

So the .69 example above is from my iPhone, and the .73 is from my MBA, using wol from the command line. To cut a long story short, the full IP is identified as being sufficiently well formed for the WireShark filter to call it WoL, but it won't wake the machine. Final point: all 255s will also wake the machine.

Pin Your Pics 1.1 – New Version Coming Soon

Thanks to some very detailed feedback [cheers Nigel :)] a new version of Pin Your Pics will be appearing on the App Store some time soon. One of the primary pieces of feedback that I had was not being able to do anything with non location data images in the CollectionView was counter intuitive. Now, images without GPS data are labelled meaningfully, and link through to a preview. I also noticed that in the original image preview on the Map [where multiple image data is made available] that the control for the ‘popup’ view wasn’t mutually exclusive: if you browsed to another image around the edge of it in the view underneath, and brought up a second preview, you could never dismiss the original image. I’ve eradicated this with a semi opaque surround to the view so it now fills the screen.

Something else unexpectedly came up since the original release, which I discovered when my wife emailed me a picture from her Android phone. Quite an interesting picture of our cat being rescued by the Fire Brigade but that’s one for another time!

This one is a little – well, inelegant. On the iPhone, if you disable location services for the camera, the image’s EXIF contains no reference to GPS at all, so I have a boolean for this which is set on initial parsing. On my wife’s Android phone, the attributes seem to be there regardless, with values being set or null according to preference. I’ve put a fix in for it.

The Silent Median – App Ratings and the Independent Developer

Having released my second app a couple of weeks ago and started to play with some of the great tools that Apple provides to analyse download patterns, I’ve had something of an epiphany about my personal interactions with the App Store.

My first iPhone was the 3G, which [roughly] coincided with the opening of the platform to third party developers, and the blossoming of the water-cooler ‘have you seen this app?’ conversations. I assiduously rated everything I downloaded.

Now, with those Wild West days well and truly gone, I don’t rate anything. In fact I can’t remember the last app that I rated.

And guess what? When someone from Mexico downloaded my app on the first day it was released and didn’t rate it, the penny dropped with a thud. What did the person think of it?   What did they like? Glaring omissions?

Human nature dictates that most people who bother to review will be at one or other extreme of the normal distribution. While this might average out the scores, a healthy dollop of ‘moderately pleased’ would, I’d argue, help raise visibility. Or to put it another way, the more reviews the better. Provided of course that the app doesn’t suck and get nothing but rubbish reviews, in which case any attempts to raise the profile or visibility  won’t count for much either way.

So: rate those apps. The gaming giants and industry juggernauts can power through without you. The smaller fish, and the downright tiddlers, can’t.

My app on the App Store - new listings in Photo & Video

My app on the App Store - new listings in Photo & Video