Reply
Thread Tools
Posts: 27 | Thanked: 74 times | Joined on Nov 2009
#1
Alright, i think i speak for a lot of us that losing our phones would be disastrous. Either because you lose it, or it was stolen. Nobody wants to go through that.

I've made some strides in making sure that you can get it back.
It's important to note that aside from the first step, the rest can be done REMOTE. So if you really have lost your phone you can do all of the steps while it's still lost but responding.

This guide will also help if you've allready lost it but can still log in.

Required:
*a modicum of unix/linux knowledge, you'll need to know how to use SSH and edit files from the commandline
*ssh installed on the phone
*a remote server, ssh/ftp etc.

DISCLAIMER: Using the below could end in tears/flames/the end of the world! Also my code will most likely be ugly/tear inducing/vommitable so use at your own risk


The most important step is making sure you know what your phone's public IP is. Most mobile providers will randomize your IP on each connection but that's what this whole thing is about. If you know this, and you can still login, you have a shot at recovery.

To be able to find it, you could install a dynamic DNS client, or you can do the following:
Locate the /etc/network/if-up.d/00_disable_icmp_echo_reply and add the following in between the bottom echo and exit lines:

Code:
ifconfig gprs0|awk '/inet addr/ { print $2 }'|awk -F: '{ print $2 }' > /tmp/n900ip
The line below that you add a way to make sure the file is stored on the remote server. You can do this with SCP for example:

Code:
scp /tmp/n900ip [user]@[remote computer]:/[remote location]
Or use any other way to make sure this file is stored somewhere other than the phone, and accessible to you since it contains the public IP of your phone.
Adding these lines to this script will make sure it's activated every time your phone makes a gprs/3g connection, storing the ip offsite every time.

Check to make sure this works by disconnecting and reconnecting your connection on the phone and checking the file it uploaded to your server. After you do this try logging in to your phone with this IP using SSH. Did all that work? Great, rest easy for now.



IT'S GONE! I CAN'T FIND IT!


Alright, if everything went as planned you'll have your public ip. Try the SSH connection you tested and login.


IT WORKED! Now what?

First things first. If your phone is moving, it very probably isn't in your posession anymore.
Check the accelerometers to see if this is the case with:

Code:
watch cat /sys/class/i2c-adapter/i2c-3/3-001d/coord
If you see those numbers (x,y,z) vary, then skip straight to the GPS step.


Ok so it's not moving, it could be you just left it in a pocket or somewhere close.
Let's make it make a noise. If you have mplayer you could do a:

Code:
mplayer /home/user/MyDocs/[location with an MP3]
Or make it vibrate with:

Code:
dbus-send --print-reply --system --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.req_vibrator_pattern_activate string:PatternIncomingCall
and use:

Code:
dbus-send --print-reply --system --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.req_vibrator_pattern_deactivate string:PatternIncomingCall
to stop vibrating.


THIS IS STUPID, YOU'RE STUPID! I DON'T HEAR IT?


Well, here is where things get a bit more complicated. It could be that you left it at work, or maybe it's not actually in your possesion anymore...

Let's see what were up against.

Make a picture with the front cam:

Code:
gst-launch v4l2src device=/dev/video1 num-buffers=1 ! ffmpegcolorspace ! jpegenc ! filesink location=frontcam.jpg
and get the picture to your server (scp [user]@[n900 public ip]:/home/user/MyDocs/frontcam.png .). You can even start a simple webserver from the commandline with:

Code:
python -m SimpleHTTPServer 80
and go to http://[public ip] to get the frontcam.jpg or any other files from the location where you started the above.


You can also make it call you and listen in on what is going on the neigbourhood of your phone:

Code:
dbus-send --system --dest=com.nokia.csd.Call --type=method_call --print-reply /com/nokia/csd/call com.nokia.csd.Call.CreateWith string:"[YOUR PHONE NUMBER GOES HERE]" uint32:0

I DON'T HEAR OR SEE A THING!


Here's where we're going to try and read the gps.

First, install python-location (apt-get install python-location) on your phone and make a new file called gps.py and fill it with this (thanks to happy_n900_user!):

Code:
 import location
import gobject

def on_error(control, error, data):
    print "location error: %d... quitting" % error
    data.quit()

def on_changed(device, data):
    if not device:
        return
    if device.fix:
        if (device.fix[1] & location.GPS_DEVICE_LATLONG_SET) and (device.fix[1] & location.GPS_DEVICE_TIME_SET) and not (device.status & location.GPS_DEVICE_STATUS_NO_FIX):
            print "lat = %f, long = %f" % device.fix[4:6]
            data.stop()

def on_stop(control, data):
    print "quitting"
    data.quit()

def start_location(data):
    data.start()
    return False

loop = gobject.MainLoop()
control = location.GPSDControl.get_default()
device = location.GPSDevice()
control.set_properties(preferred_method=location.METHOD_USER_SELECTED,
                       preferred_interval=location.INTERVAL_DEFAULT)

control.connect("error-verbose", on_error, loop)
device.connect("changed", on_changed, control)
control.connect("gpsd-stopped", on_stop, loop)

gobject.idle_add(start_location, control)

loop.run()
Now save and run it with

Code:
python2.5 gps.py
If everything goes well you'll get a LAT LONG you can plug into google maps.
If it's out of GPS range, you'll have to kill it with CTRL+C.

Once you have that, GO GET YOUR PHONE BACK (but please be smart about it! )

All of this is not meant to be some all inclusive guide, it's meant to give you a shot if you ever do lose your phone.

I'll try and keep this post updated with new methods

Big thanks go to:
-Jebba for his great list of dbus commands
-happy_n900_user for getting the python script to actually spit out a GPS location
-everyone involved in making this phone as great as it is!

Last edited by synthaxx; 2010-03-13 at 23:43.
 

The Following 54 Users Say Thank You to synthaxx For This Useful Post:
TomJ's Avatar
Posts: 505 | Thanked: 665 times | Joined on Oct 2009
#2
I still like the option of setting up a daemon to check a file on a server you have access to for a trigger to send the front cam photo and lat/long to an email address or save it to a server. This means that if it is out of signal range of any network when you try to get hold of it, it can still get the info to you when it finds a network connection...
__________________
Want to know how to add public holidays to your device calendar? See the instructions wiki page.

Want to improve the location bar's search capabilities? there's a wiki page for that too...
 
Posts: 279 | Thanked: 34 times | Joined on Jan 2010 @ Belgrade, Serbia
#3
Very useful. Thanks.
 
Posts: 5,795 | Thanked: 3,151 times | Joined on Feb 2007 @ Agoura Hills Calif
#4
Useful and funny. I like that it helps with my most likely problem, that my N900 has fallen into an obscure corner of the rubble sometimes called my residence.
 
Posts: 38 | Thanked: 8 times | Joined on Jan 2010
#5
Nice ideas but totally useless if someone has stolen your phone and puts a different sim card in it
 
Posts: 27 | Thanked: 74 times | Joined on Nov 2009
#6
Originally Posted by lew247 View Post
Nice ideas but totally useless if someone has stolen your phone and puts a different sim card in it
He'd better have wiped the phone too, because if the sim card has a data connection, this script will still upload the current IP to your server.
 
zail's Avatar
Posts: 171 | Thanked: 59 times | Joined on Feb 2010 @ Bristol, uk
#7
That's a pretty cool thing to be able to do!

Does the phone need to have active internet connection for this to work or just be switched on?
 
Posts: 455 | Thanked: 278 times | Joined on Dec 2009 @ Oregon, USA
#8
This is a nice idea and all, but how do you expect to SSH to the device if it is connected to a GSM network only? In my experience, devices on cellular GSM data networks are NAT'd behind a firewall with hundreds of other devices, so unless they explicitly forward SSH to your device, there's no way you can connect to it..

I just connected my N900 to a GSM data network, viewed IP for gprs0 in ifconfig, and even visited 'whatismyip.org' to verify, and I was unable to SSH to the device, or even ping it.

Unfortunately, unless the device somehow 'knows' it is stolen and phones home, or the thief connects to a wifi network that explicitly allows SSH forwarding to the device, it's as good as gone.
 

The Following User Says Thank You to craftyguy For This Useful Post:
Posts: 82 | Thanked: 44 times | Joined on Feb 2010
#9
I am pretty sure you could also use dynamic dns to keep track of your IP, but I have never tried it before, so not sure how to set it up.
 
Posts: 27 | Thanked: 74 times | Joined on Nov 2009
#10
@craftyguy:

In testing this i was consistently able to setup a connection using the public IP, but this might not work for your provider.
Instead you could go the reverse port forwarding route.
This will require you have an ssh-able server on the other end, not to mention you'd still need some way to consistently reconnect. If someone has a version of autossh that runs on the phone that'd be ideal for this. The unknown however is how a permanent connection will affect the battery life.

As said, this is not meant to be a all inclusive guide, more of a list of pointers and commands that, should your phone be lost, can be used to track it down.

@benh_n900:
I've added this link to the above guide which has information on how to do that.
Personally I don't like to give it a DNS for fear of it getting hit too hard from outside sources. The only person who should have access to it is me. The method in the guide ensures that.

Last edited by synthaxx; 2010-03-14 at 00:03.
 

The Following 2 Users Say Thank You to synthaxx For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 13:18.