• youtube
  • linkedin
  • google

Archives for : February2013

Dropping Dropbox + Hardware Hacking

Recently, I purchased some very cheap mobile routers for a project idea. That project didn’t work out, so I needed something do with them. Fortunately, I had another problem which needed to be solved, and this gave me a good excuse to do a little hardware hacking! Now I can get all the information that I need and maybe after I´m done, I can get some new info on the heroes in overwatch.

SO… Dropbox and I are breaking up. Well, cutting back at least. Also, I met someone new. Here’s the “why”, the “who”, and the “how”.


The cloud is becoming unavoidable. I’ve been using Dropbox for a while now, and it’s a wonderful service. When they announced that you could get free, bonus storage for enabling automatic photo uploads, no data recovery issues, I jumped at the opportunity.

For a while, it was great. I’d take a picture from my phone, Dropbox would upload it automatically, my desktop and laptop would download it automatically… all was right with the world.

And then it wasn’t.

What happened? Well, I ran out of space while I was in the Philippines. I took SOOO many pictures while I was there, and it didn’t take long to eat up the rest of my 5 or 6gb. To make matters worse, the camera on my phone will only save photos to the internal storage, which kept running out of space – so I had to keep moving images manually to the SD card. So I had some pictures on the SD card, some on the internal storage, some in my Dropbox, and some moved out of my Dropbox and into a plain folder on my laptop to make room for new photos.

STILL WORSE: Dropbox RENAMES YOUR PICTURES when automatically uploaded from your camera. So while I was trying to combine all of the photos from all of these places, many of them were duplicates but with different filenames. ARGH!

Eventually, I sorted all of it out – but it was a pain. Wouldn’t have been an issue if I had more space though.. so I started shopping. Google Drive,, Amazon S3, etc, etc. None of them fit all of my needs (linux client, android client, automatic photo uploads), and none of them had enough space. I thought about separating my files – pictures on Dropbox, documents on Google Drive, code on… but that sounded messy. Besides, even if I moved all of the non-photos from Dropbox, it still wasn’t enough room.


Would I bite the bullet and drop money on this? Would I have to switch back to traditional backup methods? Negative. Enter: OwnCloud.

It’s open source, which means – if you have a computer, you can host your own file server, available anywhere you have an Internet connection. It’s also extensible with it’s plugin API. Great! But does it have a Linux client? YES! Alright, but does it have an Android client? YES! Does it support auto-photo-uploads? YES! Even the Android client is open source ($1 in the Google Play store… or FREE if you download the source and build the .apk yourself!).

I heard about this project when they first started, but it was quite lacking. It’s come a long way, and not a moment to soon.


Naturally, my instinct was to load the code on – unfortunately, it requires a newer version of PHP than my hosting company has installed. I asked what their upgrade schedule was, and they seemed confused about the word “schedule.” No problem, the PC I built a few years ago is underused and has an 80gb hard drive with nothing on it… PERFECT!

Format hard drive, install a LAMP stack, SSL cert, install OwnCloud, DONE! In less than an hour I was moving files out of the Dropbox and into the OwnCloud folder. Plugged the PC in downstairs in the laundry room – out of site, out of mind.

“So, what… you just leave your computer on 24/7? That’s not very green, Dom!”

Totally agree. So I built a Wake-On-Wifi solution. Wake-On-LAN has existed for a long time, but not all hardware supports it. And some that claim to support don’t actually work correctly. Even if it did work properly on my machine, I had no way to send the magic wake-up packet to the computer through the router.

Thankfully, I had another router which was looking for a purpose. Enter: the TP-Link 703n. As is, this little device can’t help me…

First step: replace the firmware with OpenWRT. That’s right, we’re putting Linux on it.

Second step: hijack some GPIO pins and tap into the power. There are two pins on the processor inside this thing which aren’t being used. With linux installed, I can control them. And by controlling them, I can control other things… like a relay.IMG_20130209_181712


Third step: wire it up to the relay!


Fourth step: wire it up to the power button on the PC


Final step: code! The final step is really a two-parter – code on the router to wake up the computer, and code on the computer to shutdown when idle.

The computer was easy. A cron job runs every 5 minutes which monitors network activity for the next 10 (yes, the overlap is intentional). If the computer sends and receives less than 1kb during that period, it sends a shutdown signal with a 2 minute warning.

The router pings the PC to see if it’s alive.

  • If it isn’t alive, the router borrows the PC’s static IP address so it can monitor for traffic. As soon as the router hears any traffic on port 443 or port 80, it activates the relay for 1 second, which simulates the power button being pressed. It also gives up the IP address and takes back its own.
  • If it is alive, the router pings the PC at regular intervals and does nothing while it continues receiving a response.

How well does it work?

So far, so good! The PC takes ~20 seconds to fire up, which is quick enough that requests don’t timeout while waiting. So I can snap a pic on my phone, it attempts the upload, the router hears the request and powers on the PC, the PC takes over the IP address and processes the request! Likewise, I can turn on the OwnCloud sync client on any of my computers, and 10 minutes after I turn it off, the computer shuts itself down. Over-engineered? Probably. A hack-job? Perhaps… but I am very pleased nonetheless!


By request, here’s the server code which is ran via cron job:



# Dominic Canare

shutdownDelay=2  # minutes to wait before shutdown
samplePeriod=300 # seconds to query network per sample
sampleCount=2    # number of samples

threshold=1      # kb threshold for idle status
iface=wlan0      # interface to watch

# get current net stats | look at the average for our iface || get total transfer | truncate to integer
usage=$(sar -n DEV $samplePeriod $sampleCount | grep "Average: *$iface" | tr -s " ")
tx=$(echo "$usage" | cut -d " " -f 5 | cut -d "." -f 1)
rx=$(echo "$usage" | cut -d " " -f 6 | cut -d "." -f 1)
echo "Usage is '$tx' + '$rx' vs '$threshold' $(date)" >> /tmp/usage.log
usage=$(($tx + $rx))

if [ "$usage" -lt "$threshold" ]; then
	cp /tmp/usage.log /root/usage.log
	/sbin/shutdown -hP +$shutdownDelay "System is idle. You have $shutdownDelay minutes to save your work." &> /tmp/test-shutdown-log
	killall shutdown

and the router code



# Dominic Canare





killEverything() {
	kill 0

trap killEverything SIGINT
trap killEverything SIGTERM

installDependencies() {
	opkg update
	# there isn't enough flash memory, but there's plenty of RAM
	# this will install tcpdump binaries to RAM
	opkg -d ram install tcpdump

setupGPIO() {
	# enable pin 29 on the processor for output
	# default it to 0 (low)
	echo "$GPIO_PIN" > /sys/class/gpio/export
	echo "out" > $GPIO_PATH/direction
	echo "0" > $GPIO_PATH/value

pressButton() {
		echo "1" > $GPIO_PATH/value
		sleep 1
		echo "0" > $GPIO_PATH/value

setIP() {
	# if the requested IP address is not currently set, set it and ping the router, so the router knows who we are
	currentIP=`ifconfig wlan0 | grep "inet addr" | tr ":" " " | awk '{ print $3 }'`
	if [ "$currentIP" != "$1" ]; then
		ifconfig wlan0 $1
		ping -W 1 -c 1 &>/dev/null &

checkForClient() {
	while [ 1 ];
		if [ $sleeping -eq 1 ]; then
			# send one PING to the server
			ping -c 1 $IP_HEARTBEAT
			if [ "$?" -eq 0 ]; then
				# the server is awake, we should be standing by
				# the server is asleep, we should hijack his IP
		sleep 10

waitForWakeUp() {
	echo "Waiting for wakeup call..." &> /tmp/status

	# listen for web traffic on the wireless interface
	$tcpdump -vv -c 1 -i wlan0 "dst $IP_SUBSCRIPTION and (dst port 80 or dst port 443)" > /tmp/tcpdump

	echo "POWER button press" &> /tmp/status
	date > /tmp/last-wakeup

	# wait a bit while the server starts up
	sleep 300

if [ ! -e "$tcpdump" ]; then
if [ ! -e "$GPIO_PATH" ]; then

checkForClient &
while [ 1 ];

Which is installed as a service via /etc/init.d/wake-me-up:

#!/bin/sh /etc/rc.common



start() {
	/root/ &

stop() {
	killall -9

Ten days in Tahoe

Lake Tahoe and the valley

Photos are on facebook.

I spent less than a week at home after returning from the Philippines. I had been planning a trip to Tahoe for few months prior, but it was postponed and then re-planned while I had some (precious) free time in the Philippines.

If you’ve never been to Tahoe, it is beautiful! And I hear it’s even better in the summer…

The first few days there were rocky (heh). I traveled with Jess B, and she has a car in Tahoe, but unfortunately, the battery was dead after sitting for so long. A kind neighbor gave us a jump-start, but the car died again while backing it out of the drive. What made it especially bad is that it died in a position which made it impossible to jump – so we had to push it out first… on ice. Yeah, I swapped out my flip flops for shoes on this one.

By the time we moved the car far enough, the neighbor couldn’t be found, and it was starting to get dark. A couple more doors later, a neighbor answers, but is leery of us strangers fumbling in the dark across the street. Eventually, he accepts that we aren’t stealing the car and gives us a jump. We make it to a gas station… and need another jump. First stop after that? New battery.

The first two nights were spent at a friend’s house in the guest room. I enjoyed the time there, and wished to stay longer, but we had to move on. Unfortunately, the original arrangements following those first two days fell through, basically at the last minute. We managed to find a room-share from a friend-of-a-friend, but they were out of town for at least another day. Thankfully, we only had to spend one night in a hotel, and it was relatively cheap (not bed-bugs-cheap, but reasonable). We spent the rest of the time occupying the basement of the home of some new friends.

I actually only went up the mountain for snowboarding twice – but I didn’t mind so much because it is so expensive! Fortunately, I was able to borrow the board, boots, and bindings – so I only had to pay for lift tickets… but that was enough (even with a discount)! Boarding was just as fun as I remembered, and I was just about as good as I remembered. I’ve now officially spent 4 days on a snowboard, so I think I’m about ready for the Winter X-Games!

I did have one bad fall during my time there. I can probably chalk it up to still being relatively new, but I don’t maneuver as fast as I’d like. We spent a lot of time going through trees, and it was a lot of fun. More than once, however, I had to force abrupt stops to avoid crashing into a tree. On my last day there, I was doing well carving around trees until I came to one which had broken at the trunk. I tried to stop, but not quite fast enough – took a hit straight to my lower back. I can only imagine how hilarious it probably was for the people in the lift above me. If nothing else, I learned that your lower back muscles are tensed when you sneeze – still hurts!

Being winter, we didn’t spend a lot of time at the lake, as there’s not much to do when it’s that cold. And without snow shoes, we couldn’t really go hiking (believe me, we tried. I learned what it means to ‘fencepost’). I definitely enjoyed my time there, and I’m looking forward to returning!

The Philippines 2012-2013

Crater Lake at Mt Pinatubo

Crater Lake at Mt Pinatubo

So, I’ll bet you’ve been wondering what I’ve been up to… There’s a bit to catch up on, but I’ll try to keep it short.

First things first – my vacation in the Philippines (pictures are on Facebook).

(confession: this took a while to write, and I’m not going to proofread it because I’m lazy. if you notice an error, make a comment – please and thanks!)

Traveling there

This was my second time traveling there, and once again I had an amazing time. Travel was a pain though… I waited to book my flights because I hoped to bring my dad. Unfortunately, he couldn’t come, and by the time it was settled, prices had doubled. I did a LOT of shopping, and finally determined the cheapest option.

  1. Booked through Delta one-way from Wichita -> Atlanta -> San Francisco
  2. Book through Orbitz two-way from San Fransisco -> Hong Kong -> Philippines
  3. Book through United (using reward miles) from San Fransisco -> Denver -> Wichita

Booking this way saved me about $1,500 – but here’s what happened. My first flight leaving Wichita was delayed 3 hours and I missed my connecting flight from ATL->SFO. I expected there might be SOME delay, so my flight leaving SFO wasn’t until noon the next morning and by some miracle, the agent was able to book me on an oversold flight the next morning. When I arrived in SFO, I had to run to the international terminal, get through TSA, run to my gate, and arrived just before they finished boarding the plane. Luuuuuucky!

Hong Kong

I had a 12-hour layover in Hong Kong, and there was some neat things to do in the airport, but my layover was overnight, so I didn’t get to enjoy any of it. Instead, I bought a bus ticket and checked out the shopping district downtown. Hong Kong was formerly a British Colony, every sign had (good) English – making it pretty easy to get around. There was a TON of shops and a LOT of people. After a few hours of meandering, I went back to the airport.

Arriving in the Philippines

Upon my arrival, I was informed that a piece of my luggage had been lost. It wasn’t anything vital, but it took them over an hour to complete the paperwork. When I finally left, I was greeted by my Tita Nene, my cousins (Valerie and Jil), and their boyfriends (Jessie and Jason). First thing we did? Went to the mall, changed some money, bought a SIM card, and ate!


The last time I was in the Philippines, we spent most of our time with my cousins Ron Ron and Che Che. But four years later, Che Che is married and has a baby while Ron Ron works in Manila, ~3 hours away. I didn’t get to spend as much time with either of them as I would have liked, but I was honored to be one of Marcus’s (Che Che’s son) godparents. There was a reception to celebrate Marcus (with Videoke, of course!).

Throughout the trip we visited with family and friends. Some of them I hadn’t seen since last time, and others I met for the first time, including my Ate Ay Ay.

EVERYBODY asked about my dad, naturally, as it was often how I was introduced (as Domi’s son). Dad, everybody misses you.

Eat Bulaga! (A Filipino variety show)

Eat Bulaga is a very popular variety show in the Philippines. A large group of people from Mabatang (the barangay where my dad grew up) were traveling to Manila to be in the audience. It’s a tight community which my Tita Nene is still connected with – so we tagged along. They chartered a bus for the group and we left very early in the morning.

When we arrived, we were informed of the dress code. Apparently, men weren’t allowed to wear open-toed shoes in the studio – so Jason bought socks so that he, Jesse, and I could look super-cool in our flip-flops.

Inside the studio, an entire section was allocated for our group and they made sure to put the Americans at the front. We were the first people in the studio, and it was still early. Several performers were still rehearsing and people were actively working on the stage still. An intern stopped a couple of times to chat with me, which I didn’t think much of at the time. As the audience filled in, the stage crew began teaching us various coordinated dance moves… Turns out the show is very interactive! They also had a couple of comedians to warm-up the crowd, and they seemed pretty excited to find some Americans who knew little to no Tagalog!

At one point, the intern returned with a friend and asked if I would be a karaoke judge. Of course, I said, “Yes!” So I followed them backstage to a couple more interns and a girl who was also supposed to be a karaoke judge. They asked if I could speak Tagalog (not yet…) and then asked me to sing for them. I had never seen the show before, and really didn’t know what to expect… but after turning down suggestions for Katy Perry and Lady Gaga, I sang some Bruno Mars… they giggled, and asked if they could take pictures with me. Ok, now I get it.

They took me to the makeup guy who covered my face and sent me on the way. The actual judging was no big deal. They gave me an iPad with scores to swipe through. I didn’t have to give any feedback on the singers – just hold up the iPad and smile for the camera. They did say my name on the air, which has led to a number of unsolicited Facebook friend requests.

The show has several hosts – and they were LOVING the white guys (Jesse and Jason). Jason competed in game – he did well, but was beat handily. Both of us were paid for our air time (although I think he got more than me!).


The island of Palawan is known as a big tourist draw – and it definitely felt like it. We flew there so that we could tour an underground river. Unfortunately, typhoon-like conditions prevented us from going on our originally scheduled day – but we made the most of it by touring various parts of Puerto Princesa, and our underground river tour was rescheduled for the following day… the same day we were supposed to fly back to Luzon. Despite the long drive and long lines, we managed the tour without missing our flight.

Oh, and a bat pooped on Jil! Classic.

Mt. Pinatubo and the Gift-giving Hike

This was probably my favorite part of the trip. We hooked up with a group (PinayKeyPoint) who organizes a hike to the crater lake at the top of Mt. Pinatubo and back down. To get there, we had to take a jeep through a (mostly) dried river valley. The ride was rough and dusty (ashy, actually), and felt like about an hour long. We made a couple of stops along the way to give toys to some of the Aeta children – which they were very happy to receive.

After the jeep ride, we started our 7km trek. Personally, I thought the trek was beautiful, but it was a bit long. We were happy to arrive at the top, and the lake was gorgeous. Had I brought a book, I could’ve easily spent the day there!

When we returned to the Jeeps, a large group of Aeta was waiting for us. All of the hikers had gifts – we brought soap, toys, and food. The Aeta were very grateful for everything we brought. We all agreed that if there was anything we could change about the trip, it would be to bring more for them.

Time to Myself

When I was planning on traveling with my father, I made sure he and I would have plenty of time there. However, when he couldn’t come, I failed to adjust my schedule, so I ended up staying a few days later than Val, Jil, Jesse, and Jason. I took one day just to rest, and it was nice. We had nearly non-stop activities since I arrived, so it was nice to have a little time to just relax. In fact, I took it easy for the rest of my trip. I visited Manila once more and gave myself a photo-jogging tour through Orani. I really enjoyed this, but the best night was Karaoke with my cousins and some new friends!

Karaoke in the Philippines is very different from karaoke in the United States. Let me summarize US Karaoke:

  • If you want to do Karaoke, you have to find a bar
  • Be sure to check which days they have karaoke, and that time it starts
  • Hungry? I hope you enjoy bar food…
  • On a slow night, you might get to sing a handful of songs. If it’s busy, you might get 2.

Karaoke is much more popular in the Philippines. So while you will find it at many bars, you’ll find it many other places too. We went to the Crowne Royal Hotel in Balanga. We snagged a room which had a couch, a table, a TV, and a Karaoke machine. The room wasn’t big, but it accommodated our group well enough – and since we were few (and some didn’t care to sing), I got to sing as much as I wanted! They even had full dinner and drink menus, and we happily indulged.

Really, the experience was so much better. Although, I do have to say that I had to go without some of my standard karaoke songs and I couldn’t get anyone to sing a duet with me. Besides that, wouldn’t change a thing!

Traveling Home

Traveling back home was much smoother than getting there. In fact, the only memorable incident was hearing the phrase “baby momma” as soon as I passed through immigration in San Fransisco.

When to go back?!

I’m eager to head back. I made some new friends that I’d like to see more of (although, it’d be nice if I could speak more Tagalog!), and I always enjoy seeing my family. Ron Ron graduates on March 26th, which is within a week of Easter, which I’ve wanted to experience in the Philippines since I was a kid. Hopefully this will work out, but I will need to assess my finances before I can decide.