Presence via Iphone


(Gary G) #1

I’ve read on here and several other web sites about people trying to determine the presence of people in a home via their iphones (or other such devices too). The problem is the smart phones are designed to turn off from the wifi to conserve battery life. So disappointing. But the other night it occurred to me that even when my phone is dark and in a standby mode, it still seems to get e-mail messages, text messages, etc. immediately. Now those could be coming from the cell phone network instead of the wifi. But I remembered that when I was overseas last year, I had my iPhone with me and set it to disable the cell network (so I didn’t get charged enormous sums of money) and yet I still got email and text messages fine.

So yesterday morning I did a port scan on my local network and discovered both iPhones in our house (mine and my wife’s) actively listening on port 62078. Found out later that is the “iTunes port”. So I wrote a little Perl script on my local Linux box to telnet (was easier than ping’ing for me) to that port with a timeout of 5 seconds. I’ve ran the script for about 38 hours now–so far it has reliably tracked when either of our phones come and go from the house. I gotta believe it isn’t that simple. Maybe that port number moves around a bit and it is just coincidence that I have two phones currently on that port?

Anyways, wanted to pass that along to see if others can replicate my success. As things go, I fully expect my script to stop reliably functioning as soon as I hit the Submit button below. By the way, here’s the snippet of Perl code, where $TIMEOUT_SECS = 5 and $PHONEIP{Gary} = my phone’s local IP address (which I’ve now made static via my UVerse router).

sub IsThisPersonHere { # ($name)
$found = 0;
open(IN,“timeout $TIMEOUT_SECS telnet $PHONEIP{$_[0]} 62078 |”);
while (chop($line = <IN>)) {
if ($line =~ /Connected/) {
$found++;
}
}
close(IN);
if ($found > 0) { return ‘Yes’; } else { return ‘No’; }
}


(Ben Edwards) #2

This is very cool. I will have the team here at SmartThings check it out.


(Kirsten27) #3

so can we use iphone as presence detector? will it open the garage when you come home or be delayed? (etc other problems)