Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Can the presence of an iPhone be detected Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
GadgetGuy
Super User
Super User
Avatar

Joined: June 01 2008
Location: United States
Online Status: Offline
Posts: 872
Posted: June 26 2013 at 13:53 | IP Logged Quote GadgetGuy

Smarty -

Thats good information. I have a rather clunky detection
method. I like yours a lot better.

I made the socket call as a formula within a Set Global
macro line. I then tested that global for null ("") or
not. But I like the positive negative number approach
better.

How did you arrive at that answer?

__________________
Ken B - Live every day like it's your last. Eventually, you'll get it right!
Back to Top View GadgetGuy's Profile Search for other posts by GadgetGuy
 
GadgetGuy
Super User
Super User
Avatar

Joined: June 01 2008
Location: United States
Online Status: Offline
Posts: 872
Posted: June 26 2013 at 13:58 | IP Logged Quote GadgetGuy

smarty wrote:
From the little testing I have done, it
appears that from a CMD PROMT (aka a dos window), the
"ping" command seems to accomplish the same task.

I can ping "sleeping" devices at home (my ipad and old
iphone) and they respond. When I ping the wife's or my
iphone (which we have with us at work), the ping does not
respond and times out.

I have yet to try this ping approach from within
PowerHome, but I would suspect it would work the same.


Interesting. That is the first approach I tried weeks
ago and I only got a response when the phone was awake
(eg, screen lit) or for about 30 seconds after. Then the
pings could not find the device.

Make sure your phone is really asleep. I use a
netscanner like "iNet" in the App store from my iPad to
make sure the phone is alive or not. When it is dead, I
never get ping responses but the socket SYN message
works.

Edited by GadgetGuy - June 26 2013 at 13:59


__________________
Ken B - Live every day like it's your last. Eventually, you'll get it right!
Back to Top View GadgetGuy's Profile Search for other posts by GadgetGuy
 
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 686
Posted: June 26 2013 at 16:05 | IP Logged Quote smarty

The I-phone and I-pad are indeed are asleep.

Wife has been, and is still at work, and I am out of the country (again). I am VNC-ing into my home PC and doing the pings from there, on my home network (no one is home or has been home for hours - cameras and security confirm this). In my years, I have not seen the iphones stay awake for more then a few minutes (depending upon your settings).

I am just up from a nap, reconnected and re-confirmed the situation. Pings are able to see sleeping iphone/pad.

FYI...I am using "ph_ping" command...the positive/negative scheme is part of the command feedback.

Thanks for your good ideas!!!

__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 686
Posted: June 26 2013 at 17:38 | IP Logged Quote smarty

More testing needed...

***Maybe because the two devices I checked were plugged in...they kept their wifi on??? Will verify upon my return...


Wife is now home...her phone is off/sleeping....my pings DO NOT see it (it is a 4s)....I can ping my sleeping 4, and ipad2.

Your "ph_sendsocketdata1 ( "ken-iphone.local", 62078, 6, "\x16" )" does see the sleeping iphone.....

Edited by smarty - June 26 2013 at 18:05


__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 
GadgetGuy
Super User
Super User
Avatar

Joined: June 01 2008
Location: United States
Online Status: Offline
Posts: 872
Posted: June 26 2013 at 18:59 | IP Logged Quote GadgetGuy

Not sure why you can ping phone when it is supposedly
asleep.

I just verified that my iPhone 5 and my iPad 2 are not
pingable unless they are awake.   

__________________
Ken B - Live every day like it's your last. Eventually, you'll get it right!
Back to Top View GadgetGuy's Profile Search for other posts by GadgetGuy
 
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 686
Posted: June 26 2013 at 19:38 | IP Logged Quote smarty

What about asleep but yet plugged in?

__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 
GadgetGuy
Super User
Super User
Avatar

Joined: June 01 2008
Location: United States
Online Status: Offline
Posts: 872
Posted: June 26 2013 at 19:55 | IP Logged Quote GadgetGuy

It doesn't matter if the phone is docked (Plugged in) or
not. Unless you have your AutoLock setting at "Never" the
phone will go to sleep in 1,2,3,4,or 5 minutes after your
last interaction with it, whatever you pick.

Once asleep it will not respond to pings. Only a SYN,SYN
ACK, ACK 3-way handshake transaction will make it respond.
I haven't really checked but even that I don't think wakes
up the phone unless more communications exchanges are made.

__________________
Ken B - Live every day like it's your last. Eventually, you'll get it right!
Back to Top View GadgetGuy's Profile Search for other posts by GadgetGuy
 
GadgetGuy
Super User
Super User
Avatar

Joined: June 01 2008
Location: United States
Online Status: Offline
Posts: 872
Posted: June 27 2013 at 11:03 | IP Logged Quote GadgetGuy

YES!!!! It is all working perfectly. PH now senses the presence of my iPhone and accordingly enables/disables my security camera motion detection, thus turning it off when I'm home and reducing the recorded clutter.

Unfortunately it is not possible to post images in this Forum any longer. The db format code is hard for newbees to read so will simulate the macro code.   

Code:

Cmmd      Formula
Formula    ph_setglobal_a("ISENSE",ph_se ndsocketdata1("192.168.1.92",62078,6,"\x16"))
GotoLabel if(pos("{ISENSE}","ERROR")=0,"HOME","AWAY")
Label       HOME
Formula    ph_run("C:\powerhome\jsonBI.e xe   login http://192.168.1.90:8080/json keb 00qazwsx; camconfig pause LivCam -1; camconfig pause ThtrCam -1")
EndMacro
Label       AWAY
Formula   ph_setglobal_a("ISENSE",ph_sendsock etdata1("192.168.1.92",62078,6,"\x16")) /*Try again if phone misses 1st attempt */
GotoLabel if(pos("{ISENSE}","ERROR")=0,"HOME","next")
Formula    ph_run("C:\powerhome\jsonBI.e xe login http://192.168.1.90:8080/json, keb, 00qazwsx; camconfig pause ThtrCam 0; camconfig pause LivCam 0")
EndMacro



Where:
jsonBI.exe is a json interface handler I created to Blue Iris camera monitor sw (the forum stuck a space in the ".exe" extension that shouldn't be there, but I can't eliminate it!)

It has also stuck some other spaces in so be aware (ie, "ph_sendsock etdata1")

I did two access attempts against the phone because I found that when it is asleep, sometimes it does not respond to the 1st query, but always seems to respond to the 2nd.

Anyone interested in the jsonBI VB code or executable, just let me know. It is still a work in progress as I add command support, so it may be fluid for a few more weeks.


__________________
Ken B - Live every day like it's your last. Eventually, you'll get it right!
Back to Top View GadgetGuy's Profile Search for other posts by GadgetGuy
 
GadgetGuy
Super User
Super User
Avatar

Joined: June 01 2008
Location: United States
Online Status: Offline
Posts: 872
Posted: June 29 2013 at 12:15 | IP Logged Quote GadgetGuy

Follow-on Post to above.

I've found that the above method does not seem to be
reliable and often yields inaccurate results. Not sure
if it is a timing issue with socket communications, or
what.

To get a better handle on the communications I have
written a socketCom executable that allows me more
control and seems to be much more reliable.

Before releasing it for general use, I want to get more
testing under my belt, and I also want to add the ability
to use the iPhone MAC address instead of it's IP address.

This way users won't have to worry about Router config
and the MAC address is unique to each device and easily
discovered in the iPhone Settings>General>About>Wi-Fi
Address field which gives the MAC, not the IP address.



__________________
Ken B - Live every day like it's your last. Eventually, you'll get it right!
Back to Top View GadgetGuy's Profile Search for other posts by GadgetGuy
 
krommetje
Super User
Super User
Avatar

Joined: December 29 2004
Location: Netherlands
Online Status: Offline
Posts: 695
Posted: July 02 2013 at 07:36 | IP Logged Quote krommetje

I have tried this with android phones. The android phones in my household can be actively pinged and they DO respond.
I have made DHCP-reservations in my router so they have fixed IP's... what I come up with I will post here...

To be continued
Back to Top View krommetje's Profile Search for other posts by krommetje Visit krommetje's Homepage
 
GadgetGuy
Super User
Super User
Avatar

Joined: June 01 2008
Location: United States
Online Status: Offline
Posts: 872
Posted: July 02 2013 at 16:35 | IP Logged Quote GadgetGuy

I am working on a major enhancement to my original
effort.

The new approach supports IP addressing access (fastest
and surest) to the iPhone, as well as MAC address access.

The later has a problem I am struggling to get around in
that I have to use the windows arp cache table to reverse
lookup the phone's IP address given its MAC, and the arp
cache may have no entry for the phone if the phone hasn't
been active for 15 minutes, or so.

In that case it appears that the phone is absent which is
a wrong answer.

I'm struggling to force the arp to refresh by doing a ARP
BROADCAST "Who has", but have not discovered how to send
that raw socket message to the network. I know exactly
what to send, if I can just discover how to.

I've been to a dozen sw forums over the last week and no
one seems to be able to give me an answer, but I'm sure
it's possible.

Just need to figure out how!   

PS- if anyone has a thought how to do this, PLEASE share
it!

__________________
Ken B - Live every day like it's your last. Eventually, you'll get it right!
Back to Top View GadgetGuy's Profile Search for other posts by GadgetGuy
 
GadgetGuy
Super User
Super User
Avatar

Joined: June 01 2008
Location: United States
Online Status: Offline
Posts: 872
Posted: July 10 2013 at 07:51 | IP Logged Quote GadgetGuy

At this time (July 10, 2013) my findMyPhone routine appears to be working perfectly to determine if my iPhone is in the house or gone.

For several days I have been correctly setting my HOME/AWAY flag that controls night time lighting settings, as well as enabling/disabling motion sensing on my security cameras.

Once a week of no hang-ups or found bugs I will get everything posted.


__________________
Ken B - Live every day like it's your last. Eventually, you'll get it right!
Back to Top View GadgetGuy's Profile Search for other posts by GadgetGuy
 
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 686
Posted: July 26 2013 at 06:42 | IP Logged Quote smarty

How is this going?

I could use it for many different things....

__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 
GadgetGuy
Super User
Super User
Avatar

Joined: June 01 2008
Location: United States
Online Status: Offline
Posts: 872
Posted: July 26 2013 at 07:18 | IP Logged Quote GadgetGuy

Smarty-

See the my first post in this thread! I edited it to
put the download link at the beginning, as I was
afraid that folks might miss it if I posted it here at
the end.

Since you have been following this thread, it was easy
to miss.   

For others here is a brief repeat of what is at
beginning of this thread . . .

I have developed code to reliably detect an iPhone (a
non-trivial feat as the iPhone is a very different
device) on your local LAN is now available here . . .

home.com/download/ken/findMyPhone-
v2.6.0.zip">findMyPhone-v2.6.0.zip file


The ZIP file contains the raw VB .Net 4.5 code, a
Windows executable, and a User Guide with instructions
on how to integrate into PowerHome.

[See also the initial edited post for some "how do you
use this" comments.]   


Edited by GadgetGuy - September 14 2014 at 19:22


__________________
Ken B - Live every day like it's your last. Eventually, you'll get it right!
Back to Top View GadgetGuy's Profile Search for other posts by GadgetGuy
 
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 686
Posted: July 28 2013 at 11:44 | IP Logged Quote smarty

Ken,
I believe I have this working correctly, thank you.

I wanted to "pick your brain"... If I were to track 2 Iphones (the wife and mine)...what might you change up?

I think I would just duplicate the _SND and _RCV files for the other phone, but I am thinking the single file monitor plugin could be set up to monitor both files (wife's/mine), and have two triggers...but with different options for the different file changes. Is there anything else you might do?

__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 
GadgetGuy
Super User
Super User
Avatar

Joined: June 01 2008
Location: United States
Online Status: Offline
Posts: 872
Posted: July 28 2013 at 15:47 | IP Logged Quote GadgetGuy

Smarty -

Congratulations! I'm really happy to know it worked for
someone else too.   

You will clearly need two Sends to check for the
different phones.

The filemonitor can be set up with different trigger
keys, as you have noticed. I would set up the
phfilemon.ini file with two files to monitor. One for
your phone and one for your wife's. When a Trigger
occurs, have the triggered macro check the contents of
[TEMP10] which contains the file name that caused the
trigger. This way you can determine which phone caused
the event.

It would be interesting if you posted what you did with
two phones. It is one way to correctly arm your security
system, for instance, but in my case my wife often
forgets to take her phone with her, so I just focused on
my phone and only control night lighting and camera
triggering (which results in motion detection when I am
gone and she is home, but that is not a big deal to have
happen).

Keep us advised.   

__________________
Ken B - Live every day like it's your last. Eventually, you'll get it right!
Back to Top View GadgetGuy's Profile Search for other posts by GadgetGuy
 
GadgetGuy
Super User
Super User
Avatar

Joined: June 01 2008
Location: United States
Online Status: Offline
Posts: 872
Posted: September 01 2013 at 11:06 | IP Logged Quote GadgetGuy

smarty wrote:
From the little testing I have done, it appears that from a CMD PROMT (aka a dos window), the "ping" command seems to accomplish the same task.

I can ping "sleeping" devices at home (my ipad and old iphone) and they respond. When I ping the wife's or my iphone (which we have with us at work), the ping does not respond and times out.

I have yet to try this ping approach from within PowerHome, but I would suspect it would work the same.


Interesting as I have attempted this multiple times and ALWAYS get back a ping failure. The DOS Cmmd window shows a return message of "Destination host unreachable."

__________________
Ken B - Live every day like it's your last. Eventually, you'll get it right!
Back to Top View GadgetGuy's Profile Search for other posts by GadgetGuy
 
Oguime
Newbie
Newbie


Joined: July 03 2014
Online Status: Offline
Posts: 1
Posted: July 03 2014 at 20:52 | IP Logged Quote Oguime

GadgetGuy wrote:
Smarty-

See the my first post in this thread! I edited it to put
the download link at the beginning, as I was afraid that
folks might miss it if I posted it here at the end.

Since you have been following this thread, it was easy to
miss.   

For others here is a brief repeat of what is at beginning
of this thread . . .

I have developed code to reliably detect an iPhone (a non-
trivial feat as the iPhone is a very different device) on
your local LAN is now available here . . .

v2.3.3.zip">findMyPhone-v2.3.3.zip file

The ZIP file contains the raw VB .Net 4.5 code, a Windows
executable, and a User Guide with instructions on how to
integrate into PowerHome.

[See also the initial edited post for some "how do you use
this" comments.]   


Hi GadgetGuy,

The ZIP file seems to be unavailable.

Is there any other source for download?

Thanks!
Back to Top View Oguime's Profile Search for other posts by Oguime
 
gg102
Senior Member
Senior Member


Joined: January 29 2013
Location: United States
Online Status: Online
Posts: 179
Posted: July 04 2014 at 00:13 | IP Logged Quote gg102

I ping my Android to determine if I'm home. I have my Android WiFi set to "always on" (or whatever the setting is) and it doesn't use much battery. What I have noticed is that it's usually slow to respond to the first ping, so I do multiple pings to make sure I'm home or not home. I ping once per minute so PH can determine if I've changed from home-to-away or away-to-home.

Now with ver 2.15 there's a new ph_ping1() which Dave put in at my request. This new ping1 allows to have a longer timeout. This is important because the original ph_ping() function would usually NOT find my Android because it would timeout before my smartphone would respond.

Another thing is that smartphones sometimes do not respond at all. So you have to do multiple pings JIC.

Another thing you need to do is setup your WiFi so that you always have the same IP address otherwise, if you DHCP, you'll not have a predictable address. OR you can set an address based of the MAC address or your phone. You need to do this. (FYI, if you set a hard IP, you probably won't be able to use public WiFi. For me, that's OK.)

I use this all the time, and I find it totally reliable.
just remember to do multiple pings. One is NOT sufficient.

I don't know anything about IOS or its options. Maybe you can find similar options.

Back to Top View gg102's Profile Search for other posts by gg102
 
Jaaay
Newbie
Newbie


Joined: July 01 2012
Online Status: Offline
Posts: 24
Posted: September 07 2014 at 11:33 | IP Logged Quote Jaaay

GG102,

Can I ask what TTL and timeout you use on for your
setup?

I was also curious how you handled the multiple ping
test to ensure the phone is around?

In the past I had this setup with Bluetooth and some
Prox software that would tell PH if my cell was within
range.. It worked really well, but the range is not as
good as wifi.

I am a kind of excited to try out your new way of
getting it to work over wifi. Those older Andriods
just didn't have the Wifi "always on" option like they
do now.

Thanks,
J
Back to Top View Jaaay's Profile Search for other posts by Jaaay
 

<< Prev Page of 3 Next >>
  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum