Mar 022013

As a result of some discussion on the Raspberry Pi forums, I decided to make my Pi into a dock of sorts for my HTC Desire.

Rather than using WiFi to connect to the Pi, I ended up using USB so that it doesn’t have to rely on anything external.

First thing I had to do was add this line into /etc/network/interfaces

iface usb0 inet dhcp

This let my HTC Desire assign an IP address to the Pi when I activated USB Tethering.
Second thing was to activate USB tethering itself after I plugged the phone into the USB Dock that I had.
Once the phone was plugged in, and USB tethering activated, the phone got an IP address on the usb0 interface.
Running ifconfig usb0 gave me this –

usb0 Link encap:Ethernet HWaddr ee:21:82:8b:eb:d1
inet addr: Bcast: Mask:
RX packets:616 errors:0 dropped:1 overruns:0 frame:0
TX packets:422 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:220596 (215.4 KiB) TX bytes:58184 (56.8 KiB)

As you can see, it has the IP address of which has been assigned by the Desire.
I have installed a VNC server on the HTC Desire which allowed me to access the screen of the Desire, and also allows me to use my keyboard to do typing on the Desire.

The VNC server I used was called Droid VNC Server. Unfortunately it needs a rooted phone, but I had already rooted my Desire so it was no problem for me.
Once the VNC server was started, I used tightvncviewer on my Pi to access the VNC server on the Desire, and as you can see in the picture above, it’s very viewable.
Responsiveness leaves a bit to be desired, but it’s usable enough as long as you’re not playing games.

Mar 012013

One of my headless wireless devices have been freezing lately, and since it’s in a somewhat isolated location, I have no idea when it freezes.
So I wrote up a quick script to check to see whether it’s up and I’m running it every hour so that it alerts me when it goes down. It will also alert me once it comes back up, in case it comes back up by itself !

The script will also save the last state that the device was in so that it will only email me once when the device goes down.


if [[ -z $1 ]]; then
echo Usage: ./ \
if [ ! -f /tmp/$1.status ]; then
touch /tmp/$1.status

oldstatus=`cat /tmp/$1.status`
reply=`ping -c 1 $ip | grep 64\ bytes | wc -l`
echo $reply > /tmp/$1.status

if [[ $oldstatus -ne $reply ]]; then
if [[ $reply -eq 1 ]]; then
echo $1 is online | mail -s "Node is online" $email
echo $1 is offline | mail -s "Node is offline" $email