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: September 14 2014 at 19:53 | IP Logged Quote GadgetGuy

So very sorry for the delay in responding to the questions posted here. I had to replace my computer a few months ago and when I tried to reply to the questions herein, I discovered I had lost a lost of my project files.

Fortunately I had backups but it has taken me several weeks to recompile and track down the up-to-date documentation.

Hopefully these links will help.

For those interested in detecting their iPhone, download this much updated ZIP file which contains documentation, the source code, and the executable for use with a PowerHome call...

findMyiPhone-v2.6.0.zip

For those interested in detecting their smartphone (specifically this App was written and tested for the Galaxy S5 Android, but I expect it should work with other smartPhones in general), download this ZIP...

findMyDroid-v3.1.3.zip

Hopefully these work as well for you as they have for me.


PS - Darrin. Yes. this should work for an iPad also.


Edited by GadgetGuy - October 25 2014 at 10:18


__________________
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
 
gg102
Senior Member
Senior Member


Joined: January 29 2013
Location: United States
Online Status: Offline
Posts: 179
Posted: September 16 2014 at 18:13 | IP Logged Quote gg102

JAAAY,
Sorry for the long delay. I've traveling since March and finally getting ready to go home so things are hectic right now.

I'll hopefully answer your question here, but this might be a bit criptic. I hope you can follow. If you need more details, I can explain in more detail.

First you need to set up your router to give your phone the same IP based on the MAC. (I'll assume you know how to do that.)

In PH, I launch a DOS batch file to ping my smartphone.
The pingppc batch file is:

ECHO Ping PPC
@ECHO OFF
cd\
REM USE YOUR IP for the next instruction
ping >c:\ping.txt 192.168.x.x -w 2500 -n 5
cd\
REM Show anyone watching:
type c:\ping.txt
REM Wait a couple seconds
ping >NUL 127.0.0.1 -n 3

Then I use the FILEMON plugin to PH. If the file (ping.txt) changed, it sets off a trigger. (You need to set up this trigger)

Now, in PH in the macro, I use:
..10 if (ph_fileexists( "c:\ping.txt" )=1,1,999) ; make sure the file exists and just didn;t get deleted.
..20 if (pos(ph_readfile("c:\ping.txt"),"TTL")>0,(not_home_jump), (home_jump)) ;put in your own jumps in.

What happens is this; you trigger the "pingppc.bat" BATCH file to run say once per minute. That app, will ping the phone 5 times and create/re-write the file c:\ping.txt. When the ping.txt file gets created/re-written that causes the FILEMON plugin to trigger your macro that decides if the phone is home or not based on the ping.txt information.

Now, yes, you can do this effectively within PH, BUT you'll quickly notice an issue. If you do the ping from within PH, then you'll find that PH will stop processing while the ping is waiting. I found that annoying. That's why I do this in a .BAT. Also, you need to do multiple pings, and that makes PH really wait. My way, the pings are happening in a separate thread, thus allowing PH to run uninterrupted until the file ping.txt gets changed.

So, yes, this requires some convoluted setups, but it runs smoothly and reliably.

your mileage may vary.

   

Edited by gg102 - September 16 2014 at 18:14
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 20 2014 at 15:00 | IP Logged Quote Jaaay

GG102,

Thanks for the update.. Yes, I have found that PH
Hangs for the pings, and multiple pings even longer.
I am trying to keep track of 2 phones.

I will give your method a shot!

Thanks again for the update.

J

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


Joined: January 29 2013
Location: United States
Online Status: Offline
Posts: 179
Posted: September 22 2014 at 16:03 | IP Logged Quote gg102

I also check for 2 phones. My house does different things based on which phone is home.

So, I make one pingppc.bat and the other pingppc2.bat. They basically do the same thing, just a different ping address, and they write to ping.txt and ping2.txt respectively. Then you need two timedevents to trigger the ping.bat(s), two triggers in the FILEMON plugin, and two macros to check if the phones are home.

I've been using this method for a few years now, and it's very reliable. The ONLY annoying thing is that the DOS boxes pop up every minute. To handle that, I run PH in a separate explorer using "DESKTOPS.EXE" from MS from the SYSINTERNALS suite. You can download it from here: http://technet.microsoft.com/en-us/sysinternals/bb842062.asp x (This includes a lot of useful (and potentially dangerous) utilities from MS.) I start PH in a second desktop so I don't see it pop up all the time.

If you want more options for the virtual desktop, you can investigate http://www.dexpot.de They have a more useful virtual desktop that you can start programs on a specified desktop and more neat stuff.

Back to Top View gg102's Profile Search for other posts by gg102
 
GadgetGuy
Super User
Super User
Avatar

Joined: June 01 2008
Location: United States
Online Status: Offline
Posts: 872
Posted: September 22 2014 at 16:39 | IP Logged Quote GadgetGuy

Guys, you might want to try my Find My[i/droid]Phone
utilities I posted about a few replies above. No messy
screens and a much more robust attempt at finding the
phones.

The new links I posted above should get you to the
latest SW releases for either phone type.   

The posts include documentation, source code, and
executables.



__________________
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: October 19 2014 at 11:06 | IP Logged Quote krommetje

I've got it working but the Trigger will not fire so I made a macro which does all in one and is called by PH every 5 minutes. The Phone used here are 2:

A Samsung Mega4 (Similar to a noteII but without HD screen)
A Samsung S4-Mini

update:
It also works now on a Samsung Tab2 10.1

update2: once in a while I get an error: Unable to find C:\ArpCache.txt

Edited by krommetje - October 19 2014 at 11:22
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: October 25 2014 at 10:23 | IP Logged Quote GadgetGuy

krommetje-

See new code to download posted at the beginning of this message thread.

The new Driod version is 3.1.3.

I had occasionally seen the same error you have been getting, but never often enough to debug it.

Given your more consistent issue, I figured this was not just a random error, so started looking and think I found it. My old code deleted the arp file and then immediately created a new one. If there was any I/O delays it may have been possible the file delete had not completed by the time a new creation was tried. I added a 1 second delay between these events. Hopefully that will find the problem. Let me know what you experience.


__________________
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
 
nick7920
Senior Member
Senior Member


Joined: March 04 2008
Location: United States
Online Status: Offline
Posts: 193
Posted: October 25 2014 at 13:02 | IP Logged Quote nick7920

May I also suggest that way creating file C:\ArpCache.txt . it
fails in windows 8 because of security permission.

so may be allow the another command line parameter for the
location of arpcache.txt or create file in the running
directory rather than fixed location or in c:\temp (normally
its in win 8 and allowed by default other version user can
create.)

Nick
Back to Top View nick7920's Profile Search for other posts by nick7920
 
britcowboy
Newbie
Newbie


Joined: February 03 2015
Online Status: Offline
Posts: 1
Posted: February 03 2015 at 19:27 | IP Logged Quote britcowboy

Hi Gadgetguy,

Thanks for the script, looks good. However I'm finding that the
socket call doesn't wake the iPhone the majority of the time, I'm
trying with my GF's iPhone 5c with wifisync on, and occasionally
the port will be open and it can connect, however more often than
not it will fail and so it falsely shows the iPhone as being offline.

This problem has been driving me made for weeks due to the
iPhones special behaviour. Any ideas? Annoyingly if I open iTunes I
find it will detect the phone over wifi in seconds.

(P.S I know that it's failing on the socket call as I've been
debugging in Visual Studio :))

Edited by britcowboy - February 03 2015 at 19:28
Back to Top View britcowboy's Profile Search for other posts by britcowboy
 
Resolute
Newbie
Newbie
Avatar

Joined: January 11 2016
Online Status: Offline
Posts: 26
Posted: June 21 2016 at 23:46 | IP Logged Quote Resolute

No need to run a separate instance of explorer, just spawn a command as a process (pass the command as a variable) using
this (VB):

Sub Execute(Command)
     Const HIDDEN_WINDOW = 0
     strComputer = "."
     Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
     Set objStartup = objWMIService.Get("Win32_ProcessStartup")
     Set objConfig = objStartup.SpawnInstance_
     objConfig.ShowWindow = HIDDEN_WINDOW
     Set objProcess = GetObject("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
     objProcess.Create Command, null, objConfig, intProcessID
End Sub

Since it runs as a process, no flashing windows.
Back to Top View Resolute's Profile Search for other posts by Resolute
 
SandieRevel
Newbie
Newbie


Joined: May 22 2018
Online Status: Offline
Posts: 4
Posted: May 22 2018 at 15:24 | IP Logged Quote SandieRevel

This is really a nice utility to determine if we are
home or away. But when I try to implement the code
snippet provided by Resolute in the last post, my
system just crashes. I've tried many times with the
same result. I don't think that there is any problem
with the code, but I can't find the problem.

Edited by TonyNo - June 11 2018 at 07:22
Back to Top View SandieRevel's Profile Search for other posts by SandieRevel
 
SandieRevel
Newbie
Newbie


Joined: May 22 2018
Online Status: Offline
Posts: 4
Posted: June 10 2018 at 22:15 | IP Logged Quote SandieRevel

Resolut wrote:

This is really a nice utility to determine if we are
home or away. But if you want to which you should when I
try to implement the
code snippet provided by Resolute in the last post, my
system just crashes. I've tried many times with the
same result. I don't think that there is any problem
with the code, but I can't find the problem.
No need to run a separate instance of explorer, just
spawn a command as a process (pass the command as a
variable) using
this (VB):

Sub Execute(Command)
     Const HIDDEN_WINDOW = 0
     strComputer = "."
     Set objWMIService = GetObject("winmgmts:\\" &
strComputer & "\root\cimv2")
     Set objStartup =
objWMIService.Get("Win32_ProcessStartup")
     Set objConfig = objStartup.SpawnInstance_
     objConfig.ShowWindow = HIDDEN_WINDOW
     Set objProcess = GetObject("winmgmts:\\" &
strComputer & "\root\cimv2:Win32_Process")
     objProcess.Create Command, null, objConfig,
intProcessID
End Sub

Since it runs as a process, no flashing windows.


I was finally able to run the script. Thank for taking
your time writing the script for people like me who
need help whenever they are stuck.

Edited by dhoward - August 29 2018 at 16:27
Back to Top View SandieRevel's Profile Search for other posts by SandieRevel
 
SandieRevel
Newbie
Newbie


Joined: May 22 2018
Online Status: Offline
Posts: 4
Posted: August 29 2018 at 08:53 | IP Logged Quote SandieRevel


I may need to attempt the switch approach. I've had my
telephone in Airplane mode throughout the previous 24
hours yet with wi-fi re- empowered to check whether it
gets alarms, or email.
Back to Top View SandieRevel's Profile Search for other posts by SandieRevel
 
gg102
Senior Member
Senior Member


Joined: January 29 2013
Location: United States
Online Status: Offline
Posts: 179
Posted: November 08 2018 at 17:30 | IP Logged Quote gg102

Hi guys,

MY experience is that Android turns off the WiFi after a while, even if you set it to NOT turn off. I have a Samsung Note4.
I love it, it's older but I can replace my battery.    If my screen auto-sleeps, the WiFi will respond for about an hour
and then it stops responding. If I turn the screen on, then off, the WiFi will respond for about another hour. So, to
solve this problem I use an android app "AutomateIt" to turn on the screen every 45 minutes and it timesout about 1 minute
later. So, yes, every 45 minutes my phone turns on for 1 minute but it's at the lock screen so who cares...

When using "AutomateIt", you'll have to add a plugin to "AutomateIt" to "turn the screen on", and add a "rule" to turn the
screen on after xx-minutes.

This way, the WiFi is always on and can always and reliably be ping'ed. I have tried other keep-WiFi-on apps, but my
experience is that they don't work.

This does not seem to eat any more battery.



https://play.google.com/store/apps/details?id=AutomateIt.mai nPackage



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


Joined: January 29 2013
Location: United States
Online Status: Offline
Posts: 179
Posted: December 13 2018 at 12:13 | IP Logged Quote gg102





Happy to help.

Edited by gg102 - December 13 2018 at 12:15
Back to Top View gg102's Profile Search for other posts by gg102
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

<< Prev Page of 3
  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