Introducing Rooster: the easy to use Wake on LAN app for the Apple TV

Up until late last year, we’ve been using a third-hand iMac (vintage 2009) as our “television set”. Mostly the unit was used to show YouTube to our then two year old son. One nice thing about YouTube compared to aerial television is control – you can mostly control which show that gets displayed. This is quite useful for our young toddler who seems to enjoy watching the same shows over and over again. At the time, he’s pretty fond of everything related to buses, trains, and planets.

One day, the iMac made a loud “crack” and tripped the apartment’s power breaker with it. After having restored electricity back on, the iMac won’t turn on. So I guessed that’s the end of its useful life, and ordered a 40-inch TV and a refurbished Apple TV (tip for buying Apple hardware: if you can find what you need in the refurbished store, go for it).

The Apple TV continues the role of playing YouTube videos and occasionally some videos stored on the home network drive (NAS; Network-Attached Storage. There’s also a tennis game that I sometimes play for mild exercise, a “quick news” app from Reuters, and also playing music via a Bluetooth speaker set.

Rooster at home TV screenshot

I’ve been keeping the network drive on a power schedule. That is having the drive online only during the times we’re likely going to use it, either for the Apple TV or for computer backups. One reason is to save some electricity, since it’s a NAS with two server-grade hard drives. The other reason is that the drive’s temperatures goes to 60°C during light loads — I’m rather worried it may overheat with prolonged uptime. Indoor temperatures here in Singapore typically ranges 29—31°C, hence that may contribute the drive’s rather high temperatures. The unit does have an “automatic drive sleep” mode — but it doesn’t seem to have any effect since there’s always some kind of background activity happening even when no one is accessing the drive.

WD MyCloud EX2 Power Schedule

At times I need to access the drive out-of-schedule (the drive is scheduled to be offline at the time I need it). For this, I’ve been relying on a small Python script that sends Wake-on-LAN signals run by the Pythonista app from my iPhone. The setup was pretty workable for me, but seems impractical for my wife when she needed to juggle a toddler, the Apple TV remote, and an iPhone at the same time. That’s the glimpse of the “maybe an app could solve this”.

I’ve searched the tvOS App Store for “wake on LAN” and similar keywords. Got one, but that app was pretty hard to configure and use. First, it requires me to enter MAC address manually into the app — yeah, sure I already know the NAS’ MAC address from having to use a Python script to do this, but non-techies would probably find this requirement impossible. Second, the app doesn’t seem to check whether a device was waken up successfully. The thing is, there’s a significant boot-up time the NAS needs, about one minute or so, and constantly telling my media player app to refresh to check whether the NAS became online was un-fun.

That’s when I decided to build a Wake-on-LAN app for the Apple TV. I needed to start learning the Swift programming language anyway and this is a fresh start to do an app that’s small enough to complete in a short time but complex enough to be useful. But in retrospect I under-estimated the effort needed to complete this app. It took almost six months to complete – from the first code commit in late January 2017 until launch in early June 2017.

One of the main challenge to have a better app — and one of the main differentiator over the competition — is finding the MAC address automatically (that is, the identification number of the device’s network chip). This requires scanning the network. Some other network tools do this by enumerating the IP address of the local network. In effect, they try to count every possible IP address and try to query whether something responds at that address. Of course this could take a long time. Even on a small home network with only 253 possible network devices attached, this process could take a minute or two to complete.

For this I’ve decied to use Bonjour to scan the network. This is Apple’s method for network devices to find one another in a local network. Since I’m writing an Apple TV app, it’s probably safe to assume that other devices to be used in conjunction with the Apple TV would be friendly to Apple protocols hence advertise itself via Bonjour. For example, my NAS is a WD MyBook Live EX2 — not made by Apple — that advertises its services via Bonjour and others such that the Apple TV would be able to see it in the local network.

The other challenge is that tvOS doesn’t have a persistent storage. The operating system reserves the right to remove files when the application is not running as part of storage conservation effort. Apple’s recommendation is to store data in the user’s iCloud account — which is then moved in or out from the device as needed. However it doesn’t really make sense to associate data about nearby network devices inside the user’s iCloud account. An Apple TV is mostly stationary – it doesn’t get moved between networks very often. Moreover it is also a shared device; it is typically used by a number of iCloud accounts logged in. If the Wake-on-LAN data is pegged to an iCloud account, it would need to be re-configured for every account in the device — making it impractical.

But there’s one place that gets persisted on the Apple TV device, that is the user defaults a.k.a. preferences. Sure it can only store small amounts of data. However most likely the app’s users only has one device to wake up anyway — or three, maybe five. But not hundreds — that’s a data center and using an Apple TV to wake up servers in such facilities is unimaginable. As an additional precaution to ensure that the user defaults area is sufficient, I made the app compress the registered devices data before it gets stored there. Compressed, this configuration amounts to only a few hundred bytes typically — much shorter than this article.

Rooster for Apple TV

Then I made the app. Designing software for the Apple TV is different from user interface design for the iPhone or the Mac. First, although the screen is much bigger, the information density is really less than a smartphone screen. Mainly because the screen is typically about five meters away from the user. Second, typing is a big no-no — an even bigger no than designing a smartphone application because the on-screen keyboard on the Apple TV is really awkward to use due to no touch screen. For the benefit of readers who doesn’t have an Apple TV, typing on the on-screen keyboard using the TV remote is like doing typing on a software keyboard using a trackpad. Nevertheless, the Apple TV does supports bluetooth keyboards and using the virtual keyboard of an iOS device. But apps shouldn’t mandate users to go this route.

That’s one of the big reason of needing to auto-detect network devices. It’s not just relieving users from finding their devices’ MAC addresses but also saving them the pain of typing it into via the TV Remote — dictating these would even be a more arduous task.

Some interesting stuff that I found while developing the app is that iOS devices tend to randomize their MAC addresses. That is, at different times they show up with different ethernet addresses. Interesting trivia, but I feel that it doesn’t make the app less useful — there are better ways to wake up iOS devices than through the network (e.g. “Hey, Siri!”). However the app works perfectly with the WD MyCloud EX2 drive that we’re using to serve media to the Apple TV.

So that’s all for now. Check out the Rooster app’s product info page for further information. Until next time.


Get articles like this sent to your inbox as soon as they are published.

* indicates required

Unsubscribe any time and we won't share your details with third parties.

Tags: , , , , ,

%d bloggers like this: