Smartphone Radar - Smartphone presence detection (Locked)

Smartphone presence detection.
User avatar
berkinet
Posts: 3441
Joined: Tue Nov 18, 2008 2:08 pm
Location: Berkeley, CA, USA & Mougins, France

Re: Smartphone Radar - Smartphone presence detection (Update

Post by berkinet »

kpfriedberg wrote:... I have Apple routers (and all iPhones/iPod Touches), has anyone had any success with getting this to consistently work...
This app works GREAT, and is worth the few steps below to get working...

I just installed the plugin and had the same question. The answer was discussed earlier in this thread, but here it is in a nutshell for Lion(10.7.2):

Set syslogd to accept messaging from other hosts (this differs on Lion - see http://hints.macworld.com/article.php?s ... 4103552640 but make sure you read the last comment before you start).

Then, (as root, or using sudo) edit /etc/syslog.conf and change
local0.* /var/log/appfirewall.log
to
local0.* @127.0.0.1:1514

(Of course, if you use the app firewall and want to see its log, you may not want to do this). In my case,
/var/log/appfirewall.log didn't even exist. Once you make this change, all app firewall, and any local0, messages will go to Smartphone Radar.)

Finally, do these 2 commands:
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.syslogd.plist
sudo launchctl load /System/Library/LaunchDaemons/com.apple.syslogd.plist
bluenoise
Posts: 143
Joined: Sat Aug 23, 2008 3:21 pm

Re: Smartphone Radar - Smartphone presence detection (Update

Post by bluenoise »

berkinet wrote:
kpfriedberg wrote:... I have Apple routers (and all iPhones/iPod Touches), has anyone had any success with getting this to consistently work...
This app works GREAT, and is worth the few steps below to get working...

I just installed the plugin and had the same question. The answer was discussed earlier in this thread, but here it is in a nutshell for Lion(10.7.2):

Set syslogd to accept messaging from other hosts (this differs on Lion - see http://hints.macworld.com/article.php?s ... 4103552640 but make sure you read the last comment before you start).

Then, (as root, or using sudo) edit /etc/syslog.conf and change
local0.* /var/log/appfirewall.log
to
local0.* @127.0.0.1:1514

(Of course, if you use the app firewall and want to see its log, you may not want to do this). In my case,
/var/log/appfirewall.log didn't even exist. Once you make this change, all app firewall, and any local0, messages will go to Smartphone Radar.)

Finally, do these 2 commands:
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.syslogd.plist
sudo launchctl load /System/Library/LaunchDaemons/com.apple.syslogd.plist
Is it working well for you with an Airport Base Station? I did everything you've described and it did not work for me on an ABS. Luckily, the SNMP method described several posts back does work reliably and it allowed me to roll back the changes I had made to the syslog.conf.
User avatar
berkinet
Posts: 3441
Joined: Tue Nov 18, 2008 2:08 pm
Location: Berkeley, CA, USA & Mougins, France

Re: Smartphone Radar - Smartphone presence detection (Update

Post by berkinet »

bluenose wrote:...Is it working well for you with an Airport Base Station? I did everything you've described and it did not work for me on an ABS. Luckily, the SNMP method described several posts back does work reliably and it allowed me to roll back the changes I had made to the syslog.conf.
So far, so good. As noted, I am on Lion. I have several Airport Extremes and one flakey gray UFO. It works on the Extremes, but I haven't tested the UFO.

BTW, iPhone4S
kpfriedberg

Re: Smartphone Radar - Smartphone presence detection (Update

Post by kpfriedberg »

berkinet wrote:
bluenose wrote:...Is it working well for you with an Airport Base Station? I did everything you've described and it did not work for me on an ABS. Luckily, the SNMP method described several posts back does work reliably and it allowed me to roll back the changes I had made to the syslog.conf.
So far, so good. As noted, I am on Lion. I have several Airport Extremes and one flakey gray UFO. It works on the Extremes, but I haven't tested the UFO.

BTW, iPhone4S
I'll give it a shot and report back....thanks!
bluenoise
Posts: 143
Joined: Sat Aug 23, 2008 3:21 pm

Re: Smartphone Radar - Smartphone presence detection (Update

Post by bluenoise »

berkinet wrote:
bluenose wrote:...Is it working well for you with an Airport Base Station? I did everything you've described and it did not work for me on an ABS. Luckily, the SNMP method described several posts back does work reliably and it allowed me to roll back the changes I had made to the syslog.conf.
So far, so good. As noted, I am on Lion. I have several Airport Extremes and one flakey gray UFO. It works on the Extremes, but I haven't tested the UFO.

BTW, iPhone4S
I'm running Lion, also, but my iPhones are the iPhone 4 models. I don't know if that makes a difference. Mine get tagged as being away shortly after going to sleep, using the plugin.
User avatar
berkinet
Posts: 3441
Joined: Tue Nov 18, 2008 2:08 pm
Location: Berkeley, CA, USA & Mougins, France

Re: Smartphone Radar - Smartphone presence detection (Update

Post by berkinet »

bluenose wrote:...I'm running Lion, also, but my iPhones are the iPhone 4 models. I don't know if that makes a difference. Mine get tagged as being away shortly after going to sleep, using the plugin.
Looking at the code I think I see the problem.

CAVEAT: This thread has been around for a while, and I just installed the plugin - this all may have been discussed before.

There are really two timeout situations:
1) After a Disassociate message, how long to wait for an Associate message (I.e. stepped outside, roamed between hubs, etc.
2) How long to wait for a Dissociate message before assuming the phone left with out leaving a trace.

However, in the plugin, one timer, lastSeen serves both purposes. So, If I set lastTime to 1 minute to quickly figure out when I leave, it will also assume I have left if my phone does nothing for a minute.
User avatar
travisc
Posts: 346
Joined: Tue Sep 07, 2010 7:24 am
Location: Toronto, Canada
Contact:

Re: Smartphone Radar - Smartphone presence detection (Update

Post by travisc »

@ berkinet

These associated / disassociated log entries are unique to Apple routers. Most other routers with syslog abilities will log ALL network activity. In those cases the lastSeen variable is set to 0 any time the phone accesses the network at all, it works very well. With Apple's routers there is only a log entry when the phone associates/disassociates with the station. Also when an iPhone is on charge it doesn't associate/disassociate anymore so there are no more log messages.

I don't think using this plugin in its current form is reliable with Apple routers. I'd recommend trying the script posted a few days back. A few other users are having luck with that. If it works reliably for everyone I can incorporate it into the plugin so that method can be used if the user has an Airport router. This method will also eliminate the need to do any syslog mods.

Let me know how you make out with it.

Travis
sandconformgorgecloud
Posts: 85
Joined: Fri Jun 22, 2007 7:26 am

Re: Smartphone Radar - Smartphone presence detection (Update

Post by sandconformgorgecloud »

Don't know if it help anyone but, as I own iPhone and AirPort Extreme...

Last year I saw a script using association in the syslog for iPhone, but as it was not so easy to check the leave, I worked on another solution, that is working fine for me, but I leave alone :)

I use an AppleScript that loops with a ping command, to check if the phone is here or not.
I use 3 scripts, on for when the phone is back (so it pings until success), one when the phone is here and I'll leave or shutdown the phone (1 script for away and one for sleep but it could be the same).

The command for the phone detection is "ping -s 1 -i 11 -o 192.168.xx.xx"

Maybe it should help to work with a ping instead of the router log for iPhones, it worked fine since iOS 3 until iOS 5.0.1, no problem at all.
snowjay
Posts: 274
Joined: Wed Aug 09, 2006 10:07 am

Re: Smartphone Radar - Smartphone presence detection (Update

Post by snowjay »

I've been doing some testing with the snmp script and wifi monitoring via ping. The snmp is running every minute and I just have a console window doing a continuous ping to my iPhone so I could monitor it's behavior easily.

When the phone is cradled and charging wifi is connect all the time and will respond to pings 100% and of course stays associated with the Airport/Time Capsule.

When it sleeps the wifi radio turns on and off about every 5 minutes and reconnects briefly for 15-30 secs where it will respond to pings and this allows it to stay associated with the Airport/Time Capsule.

If it goes longer than ~5 minutes then the Airport/Time Capsule disassociates it.

Turning on Airplane Mode or turning off WiFi will force it to disassociate immediately.


To test when it disassociates when I am out of the house I made a little script that will email me a text message. I did preliminary testing just by putting the phone in my safe. :wink:

I have an iPhone 4S so it may be different with other models.
Jason
sandconformgorgecloud
Posts: 85
Joined: Fri Jun 22, 2007 7:26 am

Re: Smartphone Radar - Smartphone presence detection (Update

Post by sandconformgorgecloud »

In my case I have to admit that I manually say "Sleep" or "Leave" and then it launch the script to check when my phone does not respond anymore. But of course that can be not the best way is more than 1 person.
User avatar
travisc
Posts: 346
Joined: Tue Sep 07, 2010 7:24 am
Location: Toronto, Canada
Contact:

Re: Smartphone Radar - Smartphone presence detection (Update

Post by travisc »

@snowjay

Oh brilliant! This information is exactly what we need. So when you say this ...
snowjay wrote:To test when it disassociates when I am out of the house I made a little script that will email me a text message. I did preliminary testing just by putting the phone in my safe.
I'm assuming it took at most about 5 minutes to get a message after you left the house? Could be less depending on where in the iPhone's 5 minute check cycle you left.

Did you have any 3rd party apps running like Skype or some other app that would possibly be making the phone connect every 5 minutes? Email can only be checked every 15, I wonder what it needs to do every 5. Is your email account exchange based? Or maybe it's activity related to Apple's push notifications service which all phones would do.

Either way, we know how the base station behaves now which is the most important thing. We can work around the fact that some phones may connect at different intervals.

Thanks snowjay, great info!
snowjay
Posts: 274
Joined: Wed Aug 09, 2006 10:07 am

Re: Smartphone Radar - Smartphone presence detection (Update

Post by snowjay »

travisc wrote:@snowjay

Oh brilliant! This information is exactly what we need. So when you say this ...
snowjay wrote:To test when it disassociates when I am out of the house I made a little script that will email me a text message. I did preliminary testing just by putting the phone in my safe.
I'm assuming it took at most about 5 minutes to get a message after you left the house? Could be less depending on where in the iPhone's 5 minute check cycle you left.
In the case of last night I got in the car at 6:36PM and left the driveway and I got the text at 6:42PM. If you didn't have it cradled and it was just sleeping, it is possible it could get marked away quicker. Mine is cradled/charging usually so I remove it from the cradle, put it in my pocket and leave the house. So it can be a little longer as well depending if it checks or you use the phone right before you leave and how strong your wifi signal is.
Did you have any 3rd party apps running like Skype or some other app that would possibly be making the phone connect every 5 minutes? Email can only be checked every 15, I wonder what it needs to do every 5. Is your email account exchange based? Or maybe it's activity related to Apple's push notifications service which all phones would do.
I don't have any 3rd party stuff running, but do have a work and gmail exchange accounts, along with iCloud and Yahoo mail set to push. So it could be one of those forcing the wifi activity. I had my iPhone off the cradle for over an hour last night and it never got disassociated/marked as away.
Either way, we know how the base station behaves now which is the most important thing. We can work around the fact that some phones may connect at different intervals.

Thanks snowjay, great info!
I'll be doing some more coming and going today so I'll be testing some more. Let me know if there is anything specific you want me to test.

Oh and as a quick a dirty way to send myself a text message I just send an email, using <phonenumber>@txt.att.net for an AT&T phone. Verizon is @vtext.com. I have a trigger set up to send an email via Applescript when the variable changes. I also log activity to the Indigo log just incase the email/text delivery gets delayed.

Code: Select all

if the value of variable "iPhone4SHome" is equal to "true" then
	set var_emailState to "Home" as text
else
	set var_emailState to "Away" as text
end if

set newline to ASCII character 10 -- I always do this because I don't like actual newlines in strings

set emailAddress to "<phonenumber>@txt.att.net"
set emailSubject to "iPhone State Change"
set emailBody to "iPhone is " & var_emailState

send email to emailAddress with subject emailSubject with body emailBody
Jason
bluenoise
Posts: 143
Joined: Sat Aug 23, 2008 3:21 pm

Re: Smartphone Radar - Smartphone presence detection (Update

Post by bluenoise »

I tried the ping method before with our iPhone 4 phones, but found that they stopped responding to the pings within seconds of going to sleep.
snowjay
Posts: 274
Joined: Wed Aug 09, 2006 10:07 am

Re: Smartphone Radar - Smartphone presence detection (Update

Post by snowjay »

bluenoise wrote:I tried the ping method before with our iPhone 4 phones, but found that they stopped responding to the pings within seconds of going to sleep.
That is correct. My 4S will turn on wifi every few minutes and pings will respond again for a short time, then back to sleep it goes. This behavior is what keeps it associated with the Airport which you can poll via snmp. Hopefully turning the radio off/on/off is consistent across platforms.
Jason
User avatar
travisc
Posts: 346
Joined: Tue Sep 07, 2010 7:24 am
Location: Toronto, Canada
Contact:

Re: Smartphone Radar - Smartphone presence detection (Update

Post by travisc »

Hi snowjay,

Any false aways since you set that up? If it's still working nice I might try rolling that code into the plugin in the next day or so.

Thanks!
Locked

Return to “Smartphone Radar”